use of mage.abilities.costs.common.PayLifeCost in project mage by magefree.
the class ChangeLandAttachedEffect method apply.
@Override
public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) {
Permanent enchantment = game.getPermanent(source.getSourceId());
if (enchantment == null) {
return false;
}
Permanent permanent = game.getPermanent(enchantment.getAttachedTo());
if (permanent == null) {
return true;
}
switch(layer) {
case TypeChangingEffects_4:
permanent.removeAllSubTypes(game, SubTypeSet.NonBasicLandType);
break;
case AbilityAddingRemovingEffects_6:
permanent.removeAllAbilities(source.getSourceId(), game);
permanent.addAbility(new ColorlessManaAbility(), source.getSourceId(), game);
Ability ability = new AnyColorManaAbility();
ability.addCost(new PayLifeCost(1));
permanent.addAbility(ability, source.getSourceId(), game);
break;
}
return true;
}
use of mage.abilities.costs.common.PayLifeCost in project mage by magefree.
the class MaskOfGriselbrandEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Permanent permanent = (Permanent) getValue("attachedTo");
if (controller == null || permanent == null) {
return false;
}
int xValue = permanent.getPower().getValue();
Cost cost = new PayLifeCost(xValue);
if (cost.canPay(source, source, source.getControllerId(), game) && controller.chooseUse(outcome, "Pay " + xValue + " life? If you do, draw " + xValue + " cards.", source, game) && cost.pay(source, game, source, source.getControllerId(), false)) {
controller.drawCards(xValue, source, game);
}
return true;
}
use of mage.abilities.costs.common.PayLifeCost in project mage by magefree.
the class SwordPointDiplomacyEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = game.getObject(source.getSourceId());
if (controller == null || sourceObject == null) {
return false;
}
int amount = Math.min(controller.getLibrary().size(), 3);
CardsImpl cards = new CardsImpl();
cards.addAll(controller.getLibrary().getTopCards(game, amount));
controller.revealCards(sourceObject.getIdName(), cards, game);
Set<Card> cardsList = cards.getCards(game);
Cards cardsToHand = new CardsImpl();
for (Card card : cardsList) {
boolean keepIt = true;
Cost cost = new PayLifeCost(3);
for (UUID oppId : game.getOpponents(controller.getId())) {
Player opponent = game.getPlayer(oppId);
if (opponent != null && cost.canPay(source, source, opponent.getId(), game) && opponent.chooseUse(Outcome.Neutral, "Pay 3 life to prevent " + controller.getLogName() + " from getting " + card.getLogName() + "?", source, game) && cost.pay(source, game, source, opponent.getId(), true)) {
keepIt = false;
}
}
if (keepIt) {
cardsToHand.add(card);
cards.remove(card);
}
}
controller.moveCards(cardsToHand, Zone.HAND, source, game);
controller.moveCards(cards, Zone.EXILED, source, game);
return true;
}
use of mage.abilities.costs.common.PayLifeCost in project mage by magefree.
the class MadnessCastEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Card card = game.getCard(source.getSourceId());
if (card == null) {
return false;
}
Player owner = game.getPlayer(card.getOwnerId());
if (owner == null) {
return false;
}
// Replace with the new cost
SpellAbility castByMadness = card.getSpellAbility().copy();
ManaCosts<ManaCost> costRef = castByMadness.getManaCostsToPay();
castByMadness.setSpellAbilityType(SpellAbilityType.BASE_ALTERNATE);
castByMadness.setSpellAbilityCastMode(SpellAbilityCastMode.MADNESS);
castByMadness.getCosts().clear();
castByMadness.addCost(new PayLifeCost(this.lifeCost));
costRef.clear();
costRef.add(madnessCost);
return owner.cast(castByMadness, game, false, new ApprovingObject(source, game));
}
use of mage.abilities.costs.common.PayLifeCost in project mage by magefree.
the class BloodClockEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(targetPointer.getFirst(game, source));
if (player == null) {
return false;
}
PayLifeCost cost = new PayLifeCost(2);
if (cost.canPay(source, source, player.getId(), game) && player.chooseUse(Outcome.Neutral, "Pay 2 life? If you don't, " + "return a permanent you control to its owner's hand.", source, game) && cost.pay(source, game, source, player.getId(), true)) {
return true;
}
Target target = new TargetControlledPermanent();
target.setNotTarget(true);
if (!target.canChoose(source.getSourceId(), player.getId(), game) || !player.chooseTarget(outcome, target, source, game)) {
return false;
}
Permanent permanent = game.getPermanent(target.getFirstTarget());
if (permanent == null) {
return false;
}
return player.moveCards(permanent, Zone.HAND, source, game);
}
Aggregations