Search in sources :

Example 26 with PayLifeCost

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;
}
Also used : SimpleStaticAbility(mage.abilities.common.SimpleStaticAbility) EntersBattlefieldTriggeredAbility(mage.abilities.common.EntersBattlefieldTriggeredAbility) EnchantAbility(mage.abilities.keyword.EnchantAbility) AnyColorManaAbility(mage.abilities.mana.AnyColorManaAbility) ColorlessManaAbility(mage.abilities.mana.ColorlessManaAbility) Ability(mage.abilities.Ability) TargetLandPermanent(mage.target.common.TargetLandPermanent) Permanent(mage.game.permanent.Permanent) TargetPermanent(mage.target.TargetPermanent) AnyColorManaAbility(mage.abilities.mana.AnyColorManaAbility) ColorlessManaAbility(mage.abilities.mana.ColorlessManaAbility) PayLifeCost(mage.abilities.costs.common.PayLifeCost)

Example 27 with PayLifeCost

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;
}
Also used : Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) PayLifeCost(mage.abilities.costs.common.PayLifeCost) PayLifeCost(mage.abilities.costs.common.PayLifeCost) Cost(mage.abilities.costs.Cost)

Example 28 with PayLifeCost

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;
}
Also used : Player(mage.players.Player) MageObject(mage.MageObject) PayLifeCost(mage.abilities.costs.common.PayLifeCost) UUID(java.util.UUID) PayLifeCost(mage.abilities.costs.common.PayLifeCost) Cost(mage.abilities.costs.Cost) CardsImpl(mage.cards.CardsImpl) Cards(mage.cards.Cards) Card(mage.cards.Card)

Example 29 with PayLifeCost

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));
}
Also used : Player(mage.players.Player) ApprovingObject(mage.ApprovingObject) ManaCost(mage.abilities.costs.mana.ManaCost) PayLifeCost(mage.abilities.costs.common.PayLifeCost) Card(mage.cards.Card)

Example 30 with PayLifeCost

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);
}
Also used : TargetControlledPermanent(mage.target.common.TargetControlledPermanent) Player(mage.players.Player) Target(mage.target.Target) Permanent(mage.game.permanent.Permanent) TargetControlledPermanent(mage.target.common.TargetControlledPermanent) PayLifeCost(mage.abilities.costs.common.PayLifeCost)

Aggregations

PayLifeCost (mage.abilities.costs.common.PayLifeCost)33 Player (mage.players.Player)26 Cost (mage.abilities.costs.Cost)17 Card (mage.cards.Card)12 Permanent (mage.game.permanent.Permanent)12 UUID (java.util.UUID)6 MageObject (mage.MageObject)6 CostsImpl (mage.abilities.costs.CostsImpl)3 CardsImpl (mage.cards.CardsImpl)3 FixedTarget (mage.target.targetpointer.FixedTarget)3 Ability (mage.abilities.Ability)2 EntersBattlefieldTriggeredAbility (mage.abilities.common.EntersBattlefieldTriggeredAbility)2 SimpleStaticAbility (mage.abilities.common.SimpleStaticAbility)2 SacrificeTargetCost (mage.abilities.costs.common.SacrificeTargetCost)2 ManaCost (mage.abilities.costs.mana.ManaCost)2 ManaCostsImpl (mage.abilities.costs.mana.ManaCostsImpl)2 SetPowerToughnessSourceEffect (mage.abilities.effects.common.continuous.SetPowerToughnessSourceEffect)2 Cards (mage.cards.Cards)2 ApprovingObject (mage.ApprovingObject)1 MageObjectReference (mage.MageObjectReference)1