use of mage.abilities.costs.common.PayLifeCost in project mage by magefree.
the class EssenceVortexEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(source.getFirstTarget());
if (permanent == null) {
return false;
}
Cost cost = new PayLifeCost(permanent.getToughness().getValue());
if (cost.pay(source, game, source, permanent.getControllerId(), true)) {
return true;
}
return permanent.destroy(source, game, true);
}
use of mage.abilities.costs.common.PayLifeCost in project mage by magefree.
the class ForceChokeEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
StackObject stackObject = (StackObject) game.getObject(getTargetPointer().getFirst(game, source));
Player objectController = game.getPlayer(stackObject.getControllerId());
if (player != null) {
Cost cost = new PayLifeCost(stackObject.getManaValue());
if (cost.canPay(source, source, objectController.getId(), game) && objectController.chooseUse(Outcome.LoseLife, "Pay " + stackObject.getManaValue() + " life?", source, game) && cost.pay(source, game, source, objectController.getId(), false, null)) {
objectController.moveCards((Card) stackObject, Zone.HAND, source, game);
} else {
game.getStack().counter(stackObject.getId(), source, game);
}
return true;
}
return false;
}
use of mage.abilities.costs.common.PayLifeCost in project mage by magefree.
the class PrinceOfThrallsEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Card card = game.getCard(targetPointer.getFirst(game, source));
Permanent permanent = (Permanent) game.getLastKnownInformation(targetPointer.getFirst(game, source), Zone.BATTLEFIELD);
if (controller != null && card != null && permanent != null) {
Player opponent = game.getPlayer(permanent.getControllerId());
if (opponent != null) {
PayLifeCost cost = new PayLifeCost(3);
if (opponent.chooseUse(Outcome.Neutral, cost.getText() + " or " + card.getLogName() + " comes back into the battlefield under opponents control", source, game)) {
cost.clearPaid();
if (cost.pay(source, game, source, opponent.getId(), true, null)) {
return true;
}
}
controller.moveCards(card, Zone.BATTLEFIELD, source, game);
}
return true;
}
return false;
}
use of mage.abilities.costs.common.PayLifeCost in project mage by magefree.
the class AbilityImpl method handlePhyrexianManaCosts.
/**
* 601.2b If a cost that will be paid as the spell is being cast includes
* Phyrexian mana symbols, the player announces whether they intend to pay 2
* life or the corresponding colored mana cost for each of those symbols.
*/
private void handlePhyrexianManaCosts(Game game, Player controller) {
Iterator<ManaCost> costIterator = manaCostsToPay.iterator();
while (costIterator.hasNext()) {
ManaCost cost = costIterator.next();
if (!cost.isPhyrexian()) {
continue;
}
PayLifeCost payLifeCost = new PayLifeCost(2);
if (payLifeCost.canPay(this, this, controller.getId(), game) && controller.chooseUse(Outcome.LoseLife, "Pay 2 life instead of " + cost.getText().replace("/P", "") + '?', this, game)) {
costIterator.remove();
costs.add(payLifeCost);
manaCostsToPay.incrPhyrexianPaid();
}
}
}
use of mage.abilities.costs.common.PayLifeCost in project mage by magefree.
the class GiantAlbatrossEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(source.getSourceId());
if (sourcePermanent != null && controller != null) {
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
Player player = game.getPlayer(playerId);
if (player != null) {
List<Permanent> creatures = game.getBattlefield().getAllActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, playerId, game);
Cost cost = new PayLifeCost(2);
for (Permanent creature : creatures) {
if (sourcePermanent.getDealtDamageByThisTurn().contains(new MageObjectReference(creature.getId(), game))) {
final StringBuilder sb = new StringBuilder("Pay 2 life? (Otherwise ").append(creature.getName()).append(" will be destroyed)");
if (cost.canPay(source, source, creature.getControllerId(), game) && player.chooseUse(Outcome.Benefit, sb.toString(), source, game)) {
cost.pay(source, game, source, creature.getControllerId(), true, null);
}
if (!cost.isPaid()) {
creature.destroy(source, game, true);
}
}
}
}
}
}
return false;
}
Aggregations