use of mage.abilities.costs.mana.ManaCostsImpl in project mage by magefree.
the class DemonicEmbracePlayEffect method applies.
@Override
public boolean applies(UUID sourceId, Ability source, UUID affectedControllerId, Game game) {
if (sourceId.equals(source.getSourceId()) && source.isControlledBy(affectedControllerId)) {
if (game.getState().getZone(source.getSourceId()) == Zone.GRAVEYARD) {
Player player = game.getPlayer(affectedControllerId);
if (player != null) {
Costs<Cost> costs = new CostsImpl<>();
costs.add(new PayLifeCost(3));
costs.add(new DiscardCardCost());
player.setCastSourceIdWithAlternateMana(sourceId, new ManaCostsImpl<>("{1}{B}{B}"), costs);
return true;
}
}
}
return false;
}
use of mage.abilities.costs.mana.ManaCostsImpl in project mage by magefree.
the class DelayingShieldUpkeepEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Permanent permanent = game.getPermanent(source.getSourceId());
if (controller != null && permanent != null) {
int numCounters = permanent.getCounters(game).getCount(CounterType.DELAY);
permanent.removeCounters(CounterType.DELAY.createInstance(numCounters), source, game);
for (int i = numCounters; i > 0; i--) {
if (controller.chooseUse(Outcome.Benefit, "Pay {1}{W}? (" + i + " counters left to pay)", source, game)) {
Cost cost = new ManaCostsImpl<>("{1}{W}");
if (cost.pay(source, game, source, source.getControllerId(), false, null)) {
continue;
}
}
new LoseLifeSourceControllerEffect(1).apply(game, source);
}
return true;
}
return false;
}
use of mage.abilities.costs.mana.ManaCostsImpl in project mage by magefree.
the class ChandrasRegulatorEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
ManaCostsImpl cost = new ManaCostsImpl("{1}");
if (player == null) {
return false;
}
if (!cost.canPay(source, source, player.getId(), game) || !player.chooseUse(Outcome.Benefit, "Pay " + cost.getText() + "? If you do, copy that ability. You may choose new targets for the copy.", source, game)) {
return true;
}
if (!cost.pay(source, game, source, source.getControllerId(), false, null)) {
return true;
}
StackAbility ability = (StackAbility) getValue("stackAbility");
Player controller = game.getPlayer(source.getControllerId());
Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(source.getSourceId());
if (ability == null || controller == null || sourcePermanent == null) {
return false;
}
ability.createCopyOnStack(game, source, source.getControllerId(), true);
return true;
}
use of mage.abilities.costs.mana.ManaCostsImpl in project mage by magefree.
the class CowedByWisdomayCostToAttackBlockEffect method getManaCostToPay.
@Override
public ManaCosts getManaCostToPay(GameEvent event, Ability source, Game game) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null && !controller.getHand().isEmpty()) {
ManaCosts manaCosts = new ManaCostsImpl();
manaCosts.add(new GenericManaCost(controller.getHand().size()));
return manaCosts;
}
return null;
}
use of mage.abilities.costs.mana.ManaCostsImpl in project mage by magefree.
the class CycloneEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
Permanent permanent = game.getPermanent(source.getSourceId());
int total = permanent.getCounters(game).getCount(CounterType.WIND);
StringBuilder greens = new StringBuilder(total);
for (int i = 0; i < total; i++) {
greens.append("{G}");
}
if (this.choice(game, source, player, new ManaCostsImpl(greens.toString()))) {
DamageEverythingEffect dmg = new DamageEverythingEffect(total);
dmg.apply(game, source);
} else {
permanent.sacrifice(source, game);
}
return true;
}
Aggregations