use of mage.ApprovingObject in project mage by magefree.
the class EfreetFlamepainterEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
UUID targetId = source.getFirstTarget();
if (targetId != null) {
Card card = game.getCard(targetId);
if (card != null && controller.chooseUse(outcome, "Cast " + card.getName() + " without paying its mana cost?", source, game)) {
game.addEffect(new ExileCardEnteringGraveyardReplacementEffect(card.getId()), source);
game.getState().setValue("PlayFromNotOwnHandZone" + card.getId(), Boolean.TRUE);
controller.cast(controller.chooseAbilityForCast(card, game, true), game, true, new ApprovingObject(source, game));
game.getState().setValue("PlayFromNotOwnHandZone" + card.getId(), null);
}
}
return true;
}
use of mage.ApprovingObject in project mage by magefree.
the class EyeOfTheStormEffect1 method apply.
@Override
public boolean apply(Game game, Ability source) {
Spell spell = game.getStack().getSpell(targetPointer.getFirst(game, source));
// spell was exiled already by another effect, for example NivMagus Elemental
boolean noLongerOnStack = false;
if (spell == null) {
spell = ((Spell) game.getLastKnownInformation(targetPointer.getFirst(game, source), Zone.STACK));
noLongerOnStack = true;
}
Permanent eyeOfTheStorm = game.getPermanentOrLKIBattlefield(source.getSourceId());
if (spell != null && eyeOfTheStorm != null) {
Player spellController = game.getPlayer(spell.getControllerId());
Card card = spell.getCard();
if (spellController == null || card == null || !StaticFilters.FILTER_SPELL_AN_INSTANT_OR_SORCERY.match(spell, game)) {
return false;
}
if (!noLongerOnStack) {
// the spell is still on the stack, so exile it
UUID exileZoneId = CardUtil.getExileZoneId(game, source.getSourceId(), eyeOfTheStorm.getZoneChangeCounter(game));
spellController.moveCardsToExile(spell, source, game, true, exileZoneId, eyeOfTheStorm.getIdName());
}
// technically, using the imprint functionality here is not correct.
eyeOfTheStorm.imprint(card.getId(), game);
if (eyeOfTheStorm.getImprinted() != null && !eyeOfTheStorm.getImprinted().isEmpty()) {
CardsImpl copiedCards = new CardsImpl();
for (UUID uuid : eyeOfTheStorm.getImprinted()) {
// Check if owner of card is still in game
card = game.getCard(uuid);
if (card != null && game.getPlayer(card.getOwnerId()) != null) {
if (card instanceof SplitCard) {
copiedCards.add(((SplitCard) card).getLeftHalfCard());
copiedCards.add(((SplitCard) card).getRightHalfCard());
} else if (card instanceof ModalDoubleFacesCard) {
copiedCards.add(((ModalDoubleFacesCard) card).getLeftHalfCard());
copiedCards.add(((ModalDoubleFacesCard) card).getRightHalfCard());
} else {
copiedCards.add(card);
}
}
}
boolean continueCasting = true;
while (spellController.canRespond() && continueCasting) {
continueCasting = copiedCards.size() > 1 && spellController.chooseUse(outcome, "Cast one of the copied cards without paying its mana cost?", source, game);
Card cardToCopy;
if (copiedCards.size() == 1) {
cardToCopy = copiedCards.getCards(game).iterator().next();
} else {
TargetCard target = new TargetCard(1, Zone.EXILED, new FilterCard("card to copy"));
spellController.choose(Outcome.Copy, copiedCards, target, game);
cardToCopy = copiedCards.get(target.getFirstTarget(), game);
copiedCards.remove(cardToCopy);
}
if (cardToCopy != null) {
Card copy = game.copyCard(cardToCopy, source, source.getControllerId());
if (spellController.chooseUse(outcome, "Cast " + copy.getIdName() + " without paying mana cost?", source, game)) {
game.getState().setValue("PlayFromNotOwnHandZone" + copy.getId(), Boolean.TRUE);
spellController.cast(spellController.chooseAbilityForCast(copy, game, true), game, true, new ApprovingObject(source, game));
game.getState().setValue("PlayFromNotOwnHandZone" + copy.getId(), null);
}
}
}
return true;
}
}
return false;
}
use of mage.ApprovingObject in project mage by magefree.
the class FinaleOfPromiseReplacementEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller == null) {
return false;
}
// split card can be targeted two time -- but can cast only one
List<UUID> cardsToCast = new ArrayList<>();
for (Target target : source.getTargets()) {
for (UUID id : target.getTargets()) {
if (id != null && !cardsToCast.contains(id)) {
cardsToCast.add(id);
}
}
}
// ask to cast order
if (!cardsToCast.isEmpty()) {
String cardsOrder = cardsToCast.stream().map(game::getCard).filter(Objects::nonNull).map(Card::getName).collect(Collectors.joining(" -> "));
if (!controller.chooseUse(Outcome.Detriment, "Cast cards by choose order: " + cardsOrder + "?", "Finale of Promise", "Use that order", "Reverse", source, game)) {
Collections.reverse(cardsToCast);
}
}
// free cast + replace effect
for (UUID id : cardsToCast) {
Card card = game.getCard(id);
if (card != null) {
game.getState().setValue("PlayFromNotOwnHandZone" + card.getId(), Boolean.TRUE);
controller.cast(controller.chooseAbilityForCast(card, game, true), game, true, new ApprovingObject(source, game));
game.getState().setValue("PlayFromNotOwnHandZone" + card.getId(), null);
ContinuousEffect effect = new FinaleOfPromiseReplacementEffect();
effect.setTargetPointer(new FixedTarget(card.getId(), game.getState().getZoneChangeCounter(card.getId())));
game.addEffect(effect, source);
}
}
// If X is 10 or more, copy each of those spells twice. You may choose new targets for the copies
int xValue = ManacostVariableValue.REGULAR.calculate(game, source, null);
if (xValue >= 10) {
for (UUID id : cardsToCast) {
Card card = game.getCard(id);
if (card != null) {
Spell spell = game.getStack().getSpell(card.getId());
if (spell != null) {
spell.createCopyOnStack(game, source, controller.getId(), true, 2);
}
}
}
}
return true;
}
use of mage.ApprovingObject 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;
}
use of mage.ApprovingObject in project mage by magefree.
the class IsochronScepterCopyEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Permanent scepter = game.getPermanentOrLKIBattlefield(source.getSourceId());
if (scepter != null && scepter.getImprinted() != null && !scepter.getImprinted().isEmpty()) {
Card imprintedInstant = game.getCard(scepter.getImprinted().get(0));
if (imprintedInstant != null && game.getState().getZone(imprintedInstant.getId()) == Zone.EXILED) {
if (controller.chooseUse(outcome, "Create a copy of " + imprintedInstant.getName() + '?', source, game)) {
Card copiedCard = game.copyCard(imprintedInstant, source, source.getControllerId());
if (copiedCard != null) {
game.getExile().add(source.getSourceId(), "", copiedCard);
game.getState().setZone(copiedCard.getId(), Zone.EXILED);
if (controller.chooseUse(outcome, "Cast the copied card without paying mana cost?", source, game)) {
if (copiedCard.getSpellAbility() != null) {
game.getState().setValue("PlayFromNotOwnHandZone" + copiedCard.getId(), Boolean.TRUE);
controller.cast(controller.chooseAbilityForCast(copiedCard, game, true), game, true, new ApprovingObject(source, game));
game.getState().setValue("PlayFromNotOwnHandZone" + copiedCard.getId(), null);
} else {
Logger.getLogger(IsochronScepterCopyEffect.class).error("Isochron Scepter: " + "spell ability == null " + copiedCard.getName());
}
}
}
}
}
}
return true;
}
return false;
}
Aggregations