@Override public boolean apply(MageObject input, Game game) { Abilities<Ability> abilities = input.getAbilities(); for (int i = 0; i < abilities.size(); i++) { if (abilities.get(i) instanceof EmbalmAbility) { return true; } if (abilities.get(i) instanceof EternalizeAbility) { return true; } } return false; }
@Override public boolean apply(MageObject input, Game game) { Abilities<Ability> abilities = input.getAbilities(); for (int i = 0; i < abilities.size(); i++) { if (abilities.get(i) instanceof EnchantAbility) { String enchantText = abilities.get(i).getRule(); if (enchantText.contentEquals("Enchant creature")) { return true; } } } return false; }
@Override public boolean apply(MageObject input, Game game) { Abilities<Ability> abilities = input.getAbilities(); for (int i = 0; i < abilities.size(); i++) { if (abilities.get(i) instanceof EnchantAbility) { String enchantText = abilities.get(i).getRule(); if (enchantText.contentEquals("Enchant creature")) { return true; } } } return false; }
@Override public Optional<Ability> getAbility(UUID abilityId, UUID sourceId) { MageObject object = getObject(sourceId); if (object != null) { return object.getAbilities().get(abilityId); } return Optional.empty(); }
@Override public String getTargetDescription(Targets targets, Game game) { return getAbilities().get(0).getTargetDescription(targets, game); }
@Override public boolean applies(GameEvent event, Ability source, Game game) { MageObject object = game.getObject(event.getSourceId()); if (object instanceof Permanent && filter.match((Permanent)object, game)) { Optional<Ability> ability = object.getAbilities().get(event.getTargetId()); if (ability.isPresent() && !(ability.get() instanceof ActivatedManaAbilityImpl)) { return true; } } return false; }
public static SpellAbility getSpellAbilityFromEvent(GameEvent event, Game game) { if (event.getType() != GameEvent.EventType.CAST_SPELL) { return null; } Card card = game.getCard(event.getSourceId()); if (card != null) { Optional<Ability> ability = card.getAbilities(game).get(event.getTargetId()); if (ability.isPresent() && ability.get() instanceof SpellAbility) { return (SpellAbility) ability.get(); } return card.getSpellAbility(); } return null; }
/** * 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 apply(Game game, Ability source) { CreateTokenEffect effect = new CreateTokenEffect(new MaskToken()); effect.apply(game, source); for (UUID tokenId : effect.getLastAddedTokenIds()) { Permanent token = game.getPermanent(tokenId); if (token == null) { continue; } token.getAbilities().get(0).getTargets().get(0).add(source.getFirstTarget(), game); token.getAbilities().get(0).getEffects().get(0).apply(game, token.getAbilities().get(0)); // token.attachTo(source.getFirstTarget(), game); } return true; } }
case 4: // CHANDRA FLAMECALLER 1 sb.append("Create two 3/1 red Elemental creature tokens with haste. Exile them at the beginning of the next end step."); effects.add(new mage.cards.c.ChandraFlamecaller(controller.getId(), setInfo).getAbilities().get(2).getEffects().get(0)); break; case 5: // ELSPETH SUNS CHAMPION 1 case 8: // GIDEON JURA 1 sb.append("During target opponent’s next turn, creatures that player controls attack Urza if able."); effects.add(new mage.cards.g.GideonJura(controller.getId(), setInfo).getAbilities().get(2).getEffects().get(0)); target = new TargetOpponent(); break; case 10: // JACE ARCHITECT OF THOUGHT 1 sb.append("Until your next turn, whenever a creature an opponent controls attacks, it gets -1/-0 until end of turn."); effects.add(new mage.cards.j.JaceArchitectOfThought(controller.getId(), setInfo).getAbilities().get(2).getEffects().get(0)); break; case 11: // KARN LIBERATED 1 case 12: // NISSA SAGE ANIMIST 1 sb.append("Reveal the top card of your library. If it’s a land card, put it onto the battlefield. Otherwise, put it into your hand."); effects.add(new mage.cards.n.NissaSageAnimist(controller.getId(), setInfo).getAbilities().get(2).getEffects().get(0)); break; case 13: // NISSA WORLDWAKER 1 sb.append("Target land you control becomes a 4/4 Elemental creature with trample. It’s still a land."); effects.add(new mage.cards.n.NissaWorldwaker(controller.getId(), setInfo).getAbilities().get(2).getEffects().get(0)); target = new TargetPermanent(new FilterControlledLandPermanent()); break; case 14: // SARKHAN UNBROKEN 1 sb.append("Draw a card, then add one mana of any color to your mana pool.");
if (spellAbility == null) { if (!perm.getAbilities().isEmpty()) { spellAbility = perm.getAbilities().get(0); // Can happen for created tokens (e.g. Estrid, the Masked)