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;
}
Aggregations