use of mage.abilities.costs.mana.ManaCostsImpl in project mage by magefree.
the class VigilForTheLostEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
ManaCostsImpl cost = new ManaCostsImpl("{X}");
cost.clearPaid();
if (cost.payOrRollback(source, game, source, source.getControllerId())) {
Player player = game.getPlayer(source.getControllerId());
if (player != null) {
player.gainLife(cost.getX(), game, source);
return true;
}
}
return false;
}
use of mage.abilities.costs.mana.ManaCostsImpl in project mage by magefree.
the class CustomTestCard method addCustomEffect_TargetDamage.
/**
* Add target damage ability that can be called by text: "target damage xxx"
*
* @param controller
* @param damageAmount
*/
protected void addCustomEffect_TargetDamage(TestPlayer controller, int damageAmount) {
Ability ability = new SimpleActivatedAbility(new DamageTargetEffect(damageAmount).setText("target damage " + damageAmount), new ManaCostsImpl(""));
ability.addTarget(new TargetAnyTarget());
addCustomCardWithAbility("target damage " + damageAmount + " for " + controller.getName(), controller, ability);
}
use of mage.abilities.costs.mana.ManaCostsImpl in project mage by magefree.
the class ElectropotenceEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
UUID creatureId = (UUID) getValue("damageSource");
Permanent creature = game.getPermanentOrLKIBattlefield(creatureId);
Player controller = game.getPlayer(source.getControllerId());
if (creature != null && controller != null) {
if (controller.chooseUse(Outcome.Damage, "Pay {2}{R} to do the damage?", source, game)) {
// if (controller.chooseUse(Outcome.Damage, "Pay {2}{R}? If you do, " + creature.getName() + " deals damage equal to its power to any target.", game)) {
ManaCosts manaCosts = new ManaCostsImpl("{2}{R}");
if (manaCosts.pay(source, game, source, controller.getId(), false, null)) {
int amount = creature.getPower().getValue();
UUID target = source.getTargets().getFirstTarget();
Permanent targetCreature = game.getPermanent(target);
if (targetCreature != null) {
targetCreature.damage(amount, creature.getId(), source, game, false, true);
} else {
Player player = game.getPlayer(target);
if (player != null) {
player.damage(amount, creature.getId(), source, game);
}
}
}
}
return true;
}
return false;
}
use of mage.abilities.costs.mana.ManaCostsImpl in project mage by magefree.
the class ForgottenLoreEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player you = game.getPlayer(source.getControllerId());
Player opponent = game.getPlayer(targetPointer.getFirst(game, source));
if (you != null && opponent != null) {
FilterCard filter = new FilterCard();
filter.add(new OwnerIdPredicate(you.getId()));
Cost cost = new ManaCostsImpl("{G}");
TargetCardInGraveyard chosenCard;
Card card = null;
boolean done = false;
do {
chosenCard = new TargetCardInGraveyard(filter);
chosenCard.setNotTarget(true);
if (chosenCard.canChoose(source.getSourceId(), opponent.getId(), game)) {
opponent.chooseTarget(Outcome.ReturnToHand, chosenCard, source, game);
card = game.getCard(chosenCard.getFirstTarget());
if (card != null) {
filter.add(Predicates.not(new CardIdPredicate(card.getId())));
game.informPlayers("Forgotten Lore: " + opponent.getLogName() + " has chosen " + card.getLogName());
}
} else {
done = true;
}
if (!done) {
if (cost.canPay(source, source, you.getId(), game) && you.chooseUse(Outcome.Benefit, "Pay {G} to choose a different card ?", source, game)) {
cost.clearPaid();
if (!cost.pay(source, game, source, you.getId(), false, null)) {
done = true;
}
} else {
done = true;
}
}
} while (!done);
if (card != null) {
Cards cardsToHand = new CardsImpl();
cardsToHand.add(card);
you.moveCards(cardsToHand, Zone.HAND, source, game);
}
return true;
}
return false;
}
use of mage.abilities.costs.mana.ManaCostsImpl in project mage by magefree.
the class JeskaiInfiltratorEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Set<Card> cardsToManifest = new HashSet<>();
cardsToManifest.add(source.getSourcePermanentIfItStillExists(game));
cardsToManifest.add(controller.getLibrary().getFromTop(game));
UUID exileId = UUID.randomUUID();
controller.moveCardsToExile(cardsToManifest, source, game, false, exileId, "");
ExileZone exileZone = game.getExile().getExileZone(exileId);
for (Card card : exileZone.getCards(game)) {
card.setFaceDown(true, game);
}
// removes Jeskai Infiltrator from Battlefield, so Jeskai Infiltrator returns as a fresh permanent to the battlefield with new position
game.fireUpdatePlayersEvent();
Ability newSource = source.copy();
newSource.setWorksFaceDown(true);
// the Set will mimic the Shuffling
exileZone.getCards(game).forEach(card -> {
ManaCosts manaCosts = null;
if (card.isCreature(game)) {
manaCosts = card.getSpellAbility().getManaCosts();
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, FaceDownType.MANIFESTED), newSource);
});
controller.moveCards(exileZone.getCards(game), Zone.BATTLEFIELD, source, game, false, true, false, null);
return true;
}
return false;
}
Aggregations