public Card getCharacteristics(Game game) { Spell spell = game.getSpell(this.getId()); if (spell != null) { return spell; } return game.getCard(this.getSourceId()); }
/** * As we have ability in the stack, we need to update optional costs in * original card. This information will be used later by effects, e.g. to * determine whether card was kicked or not. E.g. Desolation Angel */ private void updateOptionalCosts(int index) { spellCards.get(index).getAbilities().get(spellAbilities.get(index).getId()).ifPresent(abilityOrig -> { for (Object object : spellAbilities.get(index).getOptionalCosts()) { Cost cost = (Cost) object; for (Cost costOrig : abilityOrig.getOptionalCosts()) { if (cost.getId().equals(costOrig.getId())) { if (cost.isPaid()) { costOrig.setPaid(); } else { costOrig.clearPaid(); } break; } } } }); }
@Override public boolean applies(GameEvent event, Ability source, Game game) { if (event.getType() == EventType.COUNTER) { Card card = game.getCard(source.getSourceId()); if (card != null) { UUID spellId = card.getSpellAbility().getId(); if (event.getTargetId().equals(spellId)) { if (condition.apply(game, source)) { return true; } } } } return false; }
@Override public boolean checkTrigger(GameEvent event, Game game) { //Intervening if must be checked Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(getSourceId()); DragonOnTheBattlefieldWhileSpellWasCastWatcher watcher = game.getState().getWatcher(DragonOnTheBattlefieldWhileSpellWasCastWatcher.class); return event.getTargetId().equals(getSourceId()) && watcher != null && watcher.castWithConditionTrue(sourcePermanent.getSpellAbility().getId()); }
@Override public boolean apply(Game game, Ability source) { Permanent sourcePermanent = game.getPermanentEntering(source.getSourceId()); if (sourcePermanent != null) { DragonOnTheBattlefieldWhileSpellWasCastWatcher watcher = game.getState().getWatcher(DragonOnTheBattlefieldWhileSpellWasCastWatcher.class); return (watcher != null && watcher.castWithConditionTrue(sourcePermanent.getSpellAbility().getId())); } return false; } }
public Spell(Card card, SpellAbility ability, UUID controllerId, Zone fromZone) { this.card = card; this.color = card.getColor(null).copy(); this.frameColor = card.getFrameColor(null).copy(); this.frameStyle = card.getFrameStyle(); id = ability.getId(); this.ability = ability; this.ability.setControllerId(controllerId); if (ability.getSpellAbilityType() == SpellAbilityType.SPLIT_FUSED) { spellCards.add(((SplitCard) card).getLeftHalfCard()); spellAbilities.add(((SplitCard) card).getLeftHalfCard().getSpellAbility().copy()); spellCards.add(((SplitCard) card).getRightHalfCard()); spellAbilities.add(((SplitCard) card).getRightHalfCard().getSpellAbility().copy()); } else { spellCards.add(card); spellAbilities.add(ability); } this.controllerId = controllerId; this.fromZone = fromZone; this.countered = false; }
useable.put(((SplitCard) object).getLeftHalfCard().getSpellAbility().getId(), ((SplitCard) object).getLeftHalfCard().getSpellAbility()); useable.put(((SplitCard) object).getRightHalfCard().getSpellAbility().getId(), ((SplitCard) object).getRightHalfCard().getSpellAbility()); if (zone == Zone.GRAVEYARD) { if (((SplitCard) object).getRightHalfCard().getSpellAbility().canChooseTarget(game)) { useable.put(((SplitCard) object).getRightHalfCard().getSpellAbility().getId(), ((SplitCard) object).getRightHalfCard().getSpellAbility()); useable.put(((SplitCard) object).getLeftHalfCard().getSpellAbility().getId(), ((SplitCard) object).getLeftHalfCard().getSpellAbility());
@Override public boolean cast(Game game, Zone fromZone, SpellAbility ability, UUID controllerId) { Card mainCard = getMainCard(); ZoneChangeEvent event = new ZoneChangeEvent(mainCard.getId(), ability.getId(), controllerId, fromZone, Zone.STACK); ZoneChangeInfo.Stack info = new ZoneChangeInfo.Stack(event, new Spell(this, ability.getSpellAbilityToResolve(game), controllerId, event.getFromZone())); return ZonesHandler.cast(info, game); }
@Override public boolean apply(Game game, Ability source) { //Intervening if is checked again on resolution Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(source.getSourceId()); if (sourcePermanent != null) { DragonOnTheBattlefieldWhileSpellWasCastWatcher watcher = game.getState().getWatcher(DragonOnTheBattlefieldWhileSpellWasCastWatcher.class); if (watcher != null && watcher.castWithConditionTrue(sourcePermanent.getSpellAbility().getId())) { controller.drawCards(1, game); return true; } } } return false; } }
if (!game.replaceEvent(GameEvent.getEvent(GameEvent.EventType.CAST_SPELL, ability.getId(), ability.getSourceId(), playerId, permittingObject), ability)) { int bookmark = game.bookmarkState(); Zone fromZone = game.getState().getZone(card.getMainCard().getId()); card.cast(game, fromZone, ability, playerId); Spell spell = game.getStack().getSpell(ability.getId()); if (spell == null) { logger.error("Got no spell from stack. ability: " + ability.getRule()); GameEvent event = GameEvent.getEvent(GameEvent.EventType.CAST_SPELL, spell.getSpellAbility().getId(), spell.getSpellAbility().getSourceId(), playerId, permittingObject); game.fireEvent(event); if (spell.activate(game, noMana)) { event = GameEvent.getEvent(GameEvent.EventType.SPELL_CAST, spell.getSpellAbility().getId(), spell.getSpellAbility().getSourceId(), playerId, permittingObject); event.setZone(fromZone); game.fireEvent(event);
if (offer != null) { UUID activationId = UUID.randomUUID(); OfferingCostReductionEffect effect = new OfferingCostReductionEffect(spellToCast.getSpellAbility().getId(), new MageObjectReference(offer, game), activationId); game.addEffect(effect, source); game.getState().setValue("offering_ok_" + card.getId(), true);
GameEvent.getEvent(GameEvent.EventType.CAST_SPELL, this.getId(), this.getSourceId(), playerId), this, game, true)) { return ActivationStatus.getFalse();
StackObject stackObject; if (getSpellAbility() != null) { stackObject = game.getStack().getSpell(getSpellAbility().getId()); } else { stackObject = game.getStack().getSpell(this.getId());