use of mage.abilities.costs.Cost in project mage by magefree.
the class FalkenrathAristocratEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
for (Cost cost : source.getCosts()) {
if (cost instanceof SacrificeTargetCost) {
Permanent sacrificedCreature = ((SacrificeTargetCost) cost).getPermanents().get(0);
Permanent sourceCreature = game.getPermanent(source.getSourceId());
if (sacrificedCreature.hasSubtype(SubType.HUMAN, game) && sourceCreature != null) {
sourceCreature.addCounters(CounterType.P1P1.createInstance(), source.getControllerId(), source, game);
break;
}
}
}
return true;
}
use of mage.abilities.costs.Cost in project mage by magefree.
the class FoodChainManaEffect method produceMana.
@Override
public Mana produceMana(Game game, Ability source) {
Mana mana = new Mana();
if (game == null) {
return mana;
}
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
int manaCostExiled = 0;
for (Cost cost : source.getCosts()) {
if (cost.isPaid() && cost instanceof ExileTargetCost) {
for (Card card : ((ExileTargetCost) cost).getPermanents()) {
manaCostExiled += card.getManaValue();
}
}
}
ChoiceColor choice = new ChoiceColor();
if (!controller.choose(Outcome.PutManaInPool, choice, game)) {
return mana;
}
Mana chosen = choice.getMana(manaCostExiled + 1);
return manaBuilder.setMana(chosen, source, game).build();
}
return mana;
}
use of mage.abilities.costs.Cost in project mage by magefree.
the class SacrificedWasCondition method apply.
@Override
public boolean apply(Game game, Ability source) {
for (Cost cost : source.getCosts()) {
if (cost instanceof SacrificeTargetCost) {
UUID targetId = cost.getTargets().getFirstTarget();
Permanent permanent = game.getPermanentOrLKIBattlefield(targetId);
if (filter.match(permanent, game)) {
return true;
}
}
}
return false;
}
use of mage.abilities.costs.Cost in project mage by magefree.
the class MudslideEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(targetPointer.getFirst(game, source));
Permanent sourcePermanent = game.getPermanent(source.getSourceId());
if (player != null && sourcePermanent != null) {
int countBattlefield = game.getBattlefield().getAllActivePermanents(filter, game.getActivePlayerId(), game).size();
while (player.canRespond() && countBattlefield > 0 && player.chooseUse(Outcome.Benefit, "Pay {2} and untap a tapped creature without flying under your control?", source, game)) {
Target tappedCreatureTarget = new TargetControlledCreaturePermanent(1, 1, filter, true);
if (player.choose(Outcome.Untap, tappedCreatureTarget, source.getSourceId(), game)) {
Cost cost = ManaUtil.createManaCost(2, false);
Permanent tappedCreature = game.getPermanent(tappedCreatureTarget.getFirstTarget());
if (tappedCreature != null && cost.pay(source, game, source, player.getId(), false)) {
tappedCreature.untap(game);
} else {
break;
}
} else {
break;
}
countBattlefield = game.getBattlefield().getAllActivePermanents(filter, game.getActivePlayerId(), game).size();
}
return true;
}
return false;
}
use of mage.abilities.costs.Cost in project mage by magefree.
the class MtendaLionEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(game.getCombat().getDefendingPlayerId(source.getSourceId(), game));
if (player == null) {
return false;
}
Cost cost = new ManaCostsImpl("{U}");
if (!player.chooseUse(outcome, "Pay {U} to prevent damage?", source, game) || !cost.pay(source, game, source, player.getId(), false)) {
return false;
}
game.addEffect(new PreventCombatDamageBySourceEffect(Duration.EndOfTurn), source);
return true;
}
Aggregations