use of mage.abilities.costs.mana.ManaCostsImpl in project mage by magefree.
the class HellkiteChargerEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player != null) {
ManaCosts cost = new ManaCostsImpl("{5}{R}{R}");
if (player.chooseUse(Outcome.Damage, "Pay " + cost.getText() + '?', source, game)) {
cost.clearPaid();
if (cost.pay(source, game, source, source.getControllerId(), false, null)) {
new UntapAllControllerEffect(new FilterAttackingCreature(), "").apply(game, source);
game.getState().getTurnMods().add(new TurnMod(source.getControllerId(), TurnPhase.COMBAT, null, false));
return true;
}
}
}
return false;
}
use of mage.abilities.costs.mana.ManaCostsImpl in project mage by magefree.
the class PuppetMasterEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Permanent permanent = (Permanent) getValue("attachedTo");
if (controller == null || permanent == null) {
return false;
}
Card card = permanent.getMainCard();
if (card == null || card.getZoneChangeCounter(game) != permanent.getZoneChangeCounter(game) + 1) {
return false;
}
controller.moveCards(card, Zone.HAND, source, game);
if (game.getState().getZone(card.getId()) != Zone.HAND) {
return false;
}
card = game.getCard(source.getSourceId());
if (card == null || card.getZoneChangeCounter(game) != source.getSourceObjectZoneChangeCounter() + 1) {
return false;
}
Cost cost = new ManaCostsImpl("{U}{U}{U}");
if (!controller.chooseUse(Outcome.Neutral, "Pay " + cost.getText() + " to return " + card.getLogName() + " to its owner's hand?", source, game) || !cost.pay(source, game, source, controller.getId(), false, null)) {
return true;
}
controller.moveCards(card, Zone.HAND, source, game);
return true;
}
use of mage.abilities.costs.mana.ManaCostsImpl in project mage by magefree.
the class SedrisTheTraitorKingEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
for (UUID cardId : controller.getGraveyard()) {
Card card = game.getCard(cardId);
if (card != null && card.isCreature(game)) {
UnearthAbility ability = new UnearthAbility(new ManaCostsImpl("{2}{B}"));
ability.setSourceId(cardId);
ability.setControllerId(card.getOwnerId());
game.getState().addOtherAbility(card, ability);
}
}
return true;
}
return false;
}
use of mage.abilities.costs.mana.ManaCostsImpl in project mage by magefree.
the class SeizuresEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
// In the case that the enchantment is blinked
Permanent enchantment = (Permanent) game.getLastKnownInformation(source.getSourceId(), Zone.BATTLEFIELD);
if (enchantment == null) {
// It was not blinked, use the standard method
enchantment = game.getPermanentOrLKIBattlefield(source.getSourceId());
}
if (enchantment == null) {
return false;
}
Permanent enchanted = game.getPermanentOrLKIBattlefield(enchantment.getAttachedTo());
if (enchanted == null) {
return false;
}
Player player = game.getPlayer(enchanted.getControllerId());
if (player != null) {
Cost cost = new ManaCostsImpl("{3}");
if (cost.canPay(source, source, player.getId(), game) && player.chooseUse(Outcome.Benefit, "Pay " + cost.getText() + " to avoid damage?", source, game)) {
cost.clearPaid();
if (cost.pay(source, game, source, player.getId(), false, null)) {
return true;
}
}
player.damage(3, source.getSourceId(), source, game);
return true;
}
return false;
}
use of mage.abilities.costs.mana.ManaCostsImpl in project mage by magefree.
the class ThievingAmalgamLifeLossEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Player active = game.getPlayer(game.getActivePlayerId());
if (controller == null || active == null) {
return false;
}
Ability newSource = source.copy();
newSource.setWorksFaceDown(true);
Set<Card> cards = active.getLibrary().getTopCards(game, 1);
cards.stream().forEach(card -> {
ManaCosts manaCosts = null;
if (card.isCreature(game)) {
manaCosts = card.getSpellAbility() != null ? card.getSpellAbility().getManaCosts() : null;
if (manaCosts == null) {
manaCosts = new ManaCostsImpl("{0}");
}
}
MageObjectReference objectReference = new MageObjectReference(card.getId(), card.getZoneChangeCounter(game) + 1, game);
game.addEffect(new BecomesFaceDownCreatureEffect(manaCosts, objectReference, Duration.Custom, BecomesFaceDownCreatureEffect.FaceDownType.MANIFESTED), newSource);
});
controller.moveCards(cards, Zone.BATTLEFIELD, source, game, false, true, false, null);
cards.stream().map(Card::getId).map(game::getPermanent).filter(permanent -> permanent != null).forEach(permanent -> permanent.setManifested(true));
return true;
}
Aggregations