@Override public EnumSet<CardType> getCardType() { if (faceDown) { EnumSet<CardType> cardTypes = EnumSet.noneOf(CardType.class); cardTypes.add(CardType.CREATURE); return cardTypes; } if (this.getSpellAbility() instanceof BestowAbility) { EnumSet<CardType> cardTypes = EnumSet.noneOf(CardType.class); cardTypes.addAll(card.getCardType()); cardTypes.remove(CardType.CREATURE); return cardTypes; } return card.getCardType(); }
@Override public boolean apply(Game game, Ability source) { MageObject madnessSpell = game.getLastKnownInformation(source.getSourceId(), Zone.STACK, source.getSourceObjectZoneChangeCounter() - 1); if (madnessSpell instanceof Spell) { if (((Spell) madnessSpell).getSpellAbility() != null) { return ((Spell) madnessSpell).getSpellAbility().getSpellAbilityCastMode() == SpellAbilityCastMode.MADNESS; } } return false; }
public String getSpellCastText(Game game) { for (Ability spellAbility : getAbilities()) { if (spellAbility instanceof MorphAbility && ((AlternativeSourceCosts) spellAbility).isActivated(getSpellAbility(), game)) { return "a card face down"; } } return GameLog.replaceNameByColoredName(card, getSpellAbility().toString()); }
@Override public boolean checkTrigger(GameEvent event, Game game) { if (event.getSourceId().equals(this.getSourceId())) { MageObject spellObject = game.getObject(sourceId); if ((spellObject instanceof Spell)) { Spell spell = (Spell) spellObject; if (spell.getSpellAbility() != null) { for (Effect effect : getEffects()) { effect.setValue(SOURCE_CAST_SPELL_ABILITY, spell.getSpellAbility()); } } } return true; } return false; }
@Override public boolean checkTrigger(GameEvent event, Game game) { if (super.checkTrigger(event, game)) { Spell spell = game.getStack().getSpell(event.getSourceId()); return spell != null && spell.getSpellAbility() instanceof EmergeAbility; } return false; }
@Override public boolean apply(Game game, Ability source) { Spell spell = (Spell) game.getStack().getStackObject(source.getSourceId()); if (spell != null) { return (xValue.calculate(game, spell.getSpellAbility(), null) >= limit); } return false; } }
@Override public SubTypeList getSubtype(Game game) { if (this.getSpellAbility() instanceof BestowAbility) { SubTypeList subtypes = card.getSubtype(game); if (!subtypes.contains(SubType.AURA)) { // do it only once subtypes.add(SubType.AURA); } return subtypes; } return card.getSubtype(game); }
@Override public boolean apply(Game game, Ability source) { Spell spell = game.getStack().getSpell(this.getTargetPointer().getFirst(game, source)); if (spell != null) { int numTargets = 0; for (Target target : spell.getSpellAbility().getTargets()) { numTargets += target.getTargets().size(); } if (numTargets == 1 && spell.getSpellAbility().getTargets().getFirstTarget().equals(source.getSourceId())) { spell.chooseNewTargets(game, source.getControllerId(), true, false, null); } return true; } return false; } }
@Override public boolean hasSubtype(SubType subtype, Game game) { if (this.getSpellAbility() instanceof BestowAbility) { // workaround for Bestow (don't like it) SubTypeList subtypes = card.getSubtype(game); if (!subtypes.contains(SubType.AURA)) { // do it only once subtypes.add(SubType.AURA); } if (subtypes.contains(subtype)) { return true; } } return card.hasSubtype(subtype, game); }
@Override public boolean apply(Game game, Ability source) { Spell targetSpell = game.getStack().getSpell(source.getFirstTarget()); if(targetSpell != null && KickedCondition.instance.apply(game, targetSpell.getSpellAbility())) { return super.apply(game, source); } return false; }
@Override public boolean checkTrigger(GameEvent event, Game game) { Spell spell = game.getStack().getSpell(event.getTargetId()); if (spell != null && spell.isControlledBy(controllerId)) { for (Ability ability : spell.getAbilities()) { if (ability instanceof KickerAbility && ((KickerAbility) ability).getKickedCounter(game, spell.getSpellAbility()) > 0) { return true; } } } return false; }
@Override public void watch(GameEvent event, Game game) { // Watcher saves all casts becaus of possible Clone cards that copy Jeleva if (event.getType() == GameEvent.EventType.SPELL_CAST) { if (!game.getStack().isEmpty()) { for (StackObject stackObject : game.getStack()) { if (stackObject instanceof Spell) { Spell spell = (Spell) stackObject; manaSpendToCast.putIfAbsent(spell.getSourceId().toString() + spell.getCard().getZoneChangeCounter(game), spell.getSpellAbility().getManaCostsToPay().convertedManaCost()); } } } } }
@Override public boolean checkTrigger(GameEvent event, Game game) { Spell spell = game.getStack().getSpell(event.getTargetId()); if (spell != null && spell.isControlledBy(controllerId)) { for (Ability ability : spell.getAbilities()) { if (ability instanceof KickerAbility && ((KickerAbility) ability).getKickedCounter(game, spell.getSpellAbility()) > 0) { return true; } } } return false; }
@Override public boolean apply(MageObject input, Game game) { String name = input.getName(); if (input instanceof SplitCard) { return hasTwoWords(((SplitCard)input).getLeftHalfCard().getName()) || hasTwoWords(((SplitCard)input).getRightHalfCard().getName()); } else if (input instanceof Spell && ((Spell) input).getSpellAbility().getSpellAbilityType() == SpellAbilityType.SPLIT_FUSED){ SplitCard card = (SplitCard) ((Spell)input).getCard(); return hasTwoWords(card.getLeftHalfCard().getName()) || hasTwoWords(card.getRightHalfCard().getName()); } else { if (name.contains(" // ")) { String leftName = name.substring(0, name.indexOf(" // ")); String rightName = name.substring(name.indexOf(" // ") + 4, name.length()); return hasTwoWords(leftName) || hasTwoWords(rightName); } else { return hasTwoWords(name); } } }
@Override public void watch(GameEvent event, Game game) { if (event.getType() == GameEvent.EventType.SPELL_CAST && event.getZone() == Zone.HAND) { Spell spell = (Spell) game.getObject(event.getTargetId()); if (spell != null && this.getSourceId().equals(spell.getSourceId())) { payment = spell.getSpellAbility().getManaCostsToPay().getPayment(); } } if (event.getType() == GameEvent.EventType.ZONE_CHANGE && this.getSourceId().equals(event.getSourceId())) { if (((ZoneChangeEvent) event).getFromZone() == Zone.BATTLEFIELD) { payment = null; } } }
@Override public boolean apply(Game game, Ability source) { Spell spell = game.getStack().getSpell(source.getFirstTarget()); Player controller = game.getPlayer(source.getControllerId()); if (spell != null && controller != null) { spell.getSpellAbility().getTargets().clear(); TargetPlayer targetPlayer = new TargetPlayer(); if (controller.choose(Outcome.Neutral, targetPlayer, source.getSourceId(), game)) { spell.getSpellAbility().addTarget(targetPlayer); game.informPlayers("The target of the spell was changed to " + targetPlayer.getTargetedName(game)); return true; } } return false; } }
@Override public int calculate(Game game, Ability source, Effect effect) { Spell spell = game.getStack().getSpell(source.getSourceId()); if (spell == null) { MageObject mageObject = game.getLastKnownInformation(source.getSourceId(), Zone.STACK); if (mageObject instanceof Spell) { spell = (Spell) mageObject; } } if (spell != null) { // NOT the cmc of the spell on the stack return spell.getSpellAbility().getManaCostsToPay().convertedManaCost(); } return 0; }
@Override public Set<UUID> possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) { Spell spell = game.getStack().getSpell(sourceId); if (spell != null) { Permanent firstTarget = getPermanentFromFirstTarget(spell.getSpellAbility(), game); if (firstTarget != null) { int power = firstTarget.getPower().getValue(); // overwrite the filter with the power predicate filter = new FilterCreaturePermanent("creature with power less than " + power); filter.add(new PowerPredicate(ComparisonType.FEWER_THAN, power)); } } return super.possibleTargets(sourceId, sourceControllerId, game); }
@Override public boolean checkTrigger(GameEvent event, Game game) { Spell spell = game.getStack().getSpell(event.getTargetId()); if (spell != null && spell.isControlledBy(controllerId)) { int damageAmount = 0; for (Ability ability: spell.getAbilities()) { if (ability instanceof KickerAbility) { damageAmount += ((KickerAbility) ability).getKickedCounter(game, spell.getSpellAbility()); } } if (damageAmount > 0) { this.getEffects().get(0).setValue("damageAmount", damageAmount); return true; } } return false; }
@Override public boolean apply(Game game, Ability source, Ability abilityToModify) { Player controller = game.getPlayer(source.getControllerId()); Card spliceCard = game.getCard(source.getSourceId()); if (spliceCard != null && controller != null) { Spell spell = game.getStack().getSpell(abilityToModify.getId()); if (spell != null) { SpellAbility splicedAbility = spliceCard.getSpellAbility().copy(); splicedAbility.setSpellAbilityType(SpellAbilityType.SPLICE); splicedAbility.setSourceId(abilityToModify.getSourceId()); spell.addSpellAbility(splicedAbility); for (Iterator it = ((SpliceOntoArcaneAbility) source).getSpliceCosts().iterator(); it.hasNext();) { spell.getSpellAbility().getCosts().add(((Cost) it.next()).copy()); } } return true; } return false; }