use of mage.abilities.costs.common.PayLifeCost in project mage by magefree.
the class AthreosDiesCreatureTriggeredAbility method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller == null) {
return false;
}
UUID creatureId = (UUID) this.getValue("creatureId");
Card creature = game.getCard(creatureId);
if (creature == null) {
return true;
}
Player opponent = game.getPlayer(source.getFirstTarget());
boolean paid = false;
if (opponent != null) {
Cost cost = new PayLifeCost(3);
if (cost.canPay(source, source, opponent.getId(), game) && opponent.chooseUse(outcome, "Pay 3 life to prevent that " + creature.getLogName() + " returns to " + controller.getLogName() + "'s hand?", source, game) && cost.pay(source, game, source, opponent.getId(), false, null)) {
paid = true;
}
}
if ((opponent != null && paid) || game.getState().getZone(creature.getId()) != Zone.GRAVEYARD) {
return true;
}
controller.moveCards(creature, Zone.HAND, source, game);
return true;
}
use of mage.abilities.costs.common.PayLifeCost in project mage by magefree.
the class PhyrexianProcessorCreateTokenEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Permanent permanent = game.getPermanentEntering(source.getSourceId());
if (controller == null || permanent == null) {
return false;
}
int payAmount = controller.getAmount(0, controller.getLife(), "Pay any amount of life", game);
Cost cost = new PayLifeCost(payAmount);
if (!cost.pay(source, game, source, source.getControllerId(), true)) {
return false;
}
Card sourceCard = game.getCard(source.getSourceId());
game.informPlayers((sourceCard != null ? sourceCard.getName() : "") + ": " + controller.getLogName() + " pays " + payAmount + " life.");
String key = CardUtil.getCardZoneString("lifePaid", source.getSourceId(), game);
game.getState().setValue(key, payAmount);
permanent.addInfo("life paid", CardUtil.addToolTipMarkTags("Life paid: " + payAmount), game);
return true;
}
use of mage.abilities.costs.common.PayLifeCost in project mage by magefree.
the class TivashGloomSummonerEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
PlayerGainedLifeWatcher watcher = game.getState().getWatcher(PlayerGainedLifeWatcher.class);
if (player == null || watcher == null) {
return false;
}
int lifeGained = watcher.getLifeGained(source.getControllerId());
Cost cost = new PayLifeCost(lifeGained);
if (!cost.canPay(source, source, source.getControllerId(), game) || !player.chooseUse(Outcome.PutCreatureInPlay, "Pay " + lifeGained + " life?", source, game) || !cost.pay(source, game, source, source.getControllerId(), true)) {
return false;
}
new DemonFlyingToken(lifeGained).putOntoBattlefield(1, game, source, source.getControllerId());
return true;
}
use of mage.abilities.costs.common.PayLifeCost in project mage by magefree.
the class TymnaTheWeaverWatcher method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
TymnaTheWeaverWatcher watcher = game.getState().getWatcher(TymnaTheWeaverWatcher.class);
if (watcher != null) {
int cardsToDraw = watcher.opponentsThatGotCombatDamage(source.getControllerId(), game);
Cost cost = new PayLifeCost(cardsToDraw);
if (cost.canPay(source, source, source.getControllerId(), game) && cost.pay(source, game, source, source.getControllerId(), false)) {
controller.drawCards(cardsToDraw, source, game);
}
return true;
}
}
return false;
}
use of mage.abilities.costs.common.PayLifeCost in project mage by magefree.
the class BolassCitadelPlayTheTopCardEffect method applies.
@Override
public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) {
// current card's part
Card cardToCheck = game.getCard(objectId);
if (cardToCheck == null) {
return false;
}
// must be you
if (!affectedControllerId.equals(source.getControllerId())) {
return false;
}
// must be your card
Player player = game.getPlayer(cardToCheck.getOwnerId());
if (player == null || !player.getId().equals(affectedControllerId)) {
return false;
}
// must be from your library
Card topCard = player.getLibrary().getFromTop(game);
if (topCard == null || !topCard.getId().equals(cardToCheck.getMainCard().getId())) {
return false;
}
// allows to play/cast with alternative life cost
if (!cardToCheck.isLand(game)) {
PayLifeCost lifeCost = new PayLifeCost(cardToCheck.getSpellAbility().getManaCosts().manaValue());
Costs newCosts = new CostsImpl();
newCosts.add(lifeCost);
newCosts.addAll(cardToCheck.getSpellAbility().getCosts());
player.setCastSourceIdWithAlternateMana(cardToCheck.getId(), null, newCosts);
}
return true;
}
Aggregations