Search in sources :

Example 1 with SpellCostReductionSourceEffect

use of mage.abilities.effects.common.cost.SpellCostReductionSourceEffect in project mage by magefree.

the class GodEternalKefnetDrawCardReplacementEffect method replaceEvent.

@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
    // reveal top card and drawn (return false to continue default draw)
    Permanent god = game.getPermanent(source.getSourceId());
    Player you = game.getPlayer(source.getControllerId());
    if (god == null && you == null) {
        return false;
    }
    Card topCard = you.getLibrary().getFromTop(game);
    if (topCard == null) {
        return false;
    }
    // reveal
    you.setTopCardRevealed(true);
    // cast copy
    if (topCard.isInstantOrSorcery(game) && you.chooseUse(outcome, "Copy " + topCard.getName() + " and cast it for {2} less?", source, game)) {
        Card blueprint = topCard.copy();
        if (blueprint instanceof SplitCard) {
            ((SplitCard) blueprint).getLeftHalfCard().addAbility(new SimpleStaticAbility(Zone.ALL, new SpellCostReductionSourceEffect(2)));
            ((SplitCard) blueprint).getRightHalfCard().addAbility(new SimpleStaticAbility(Zone.ALL, new SpellCostReductionSourceEffect(2)));
        } else if (blueprint instanceof ModalDoubleFacesCard) {
            ((ModalDoubleFacesCard) blueprint).getLeftHalfCard().addAbility(new SimpleStaticAbility(Zone.ALL, new SpellCostReductionSourceEffect(2)));
            ((ModalDoubleFacesCard) blueprint).getRightHalfCard().addAbility(new SimpleStaticAbility(Zone.ALL, new SpellCostReductionSourceEffect(2)));
        } else {
            blueprint.addAbility(new SimpleStaticAbility(Zone.ALL, new SpellCostReductionSourceEffect(2)));
        }
        Card copiedCard = game.copyCard(blueprint, source, source.getControllerId());
        // The copy is created in and cast from your hand. (2019-05-03)
        you.moveCardToHandWithInfo(copiedCard, source, game, true);
        game.getState().setValue("PlayFromNotOwnHandZone" + copiedCard.getId(), Boolean.TRUE);
        you.cast(you.chooseAbilityForCast(copiedCard, game, false), game, false, new ApprovingObject(source, game));
        game.getState().setValue("PlayFromNotOwnHandZone" + copiedCard.getId(), null);
    }
    // draw (return false for default draw)
    return false;
}
Also used : Player(mage.players.Player) ApprovingObject(mage.ApprovingObject) Permanent(mage.game.permanent.Permanent) SpellCostReductionSourceEffect(mage.abilities.effects.common.cost.SpellCostReductionSourceEffect) SimpleStaticAbility(mage.abilities.common.SimpleStaticAbility)

Aggregations

ApprovingObject (mage.ApprovingObject)1 SimpleStaticAbility (mage.abilities.common.SimpleStaticAbility)1 SpellCostReductionSourceEffect (mage.abilities.effects.common.cost.SpellCostReductionSourceEffect)1 Permanent (mage.game.permanent.Permanent)1 Player (mage.players.Player)1