public SpellAbility getSpellAbility(Card card) { if (spellAbilityIndex > 0) { throw new IndexOutOfBoundsException("SpellAbility index " + spellAbilityIndex + " is out of bounds."); } return card.getSpellAbility(); }
@Override public boolean apply(Card input, Game game) { for (Target target : input.getSpellAbility().getTargets()) { if (target.canTarget(toBeCheckedPermanentId, input.getSpellAbility(), game)) { return true; } } return false; }
public TargetAddressIterator(Card card) { this.lastSpellAbilityIndex = 0; this.spellAbilityIterator = null; this.modes = card.getSpellAbility().getModes(); this.modeIterator = this.modes.getSelectedModes().iterator(); calcNext(); }
public static boolean cardCanBePlayedNow(Card card, UUID playerId, Game game) { if (card.isLand()) { return game.canPlaySorcery(playerId) && game.getPlayer(playerId).canPlayLand(); } else { return card.getSpellAbility() != null && card.getSpellAbility().spellCanBeActivatedRegularlyNow(playerId, game); } }
private void addMadnessToCard(Game game, Card card, Map<UUID, MadnessAbility> usedMadnessAbilities) { MadnessAbility ability = madnessAbilities.get(card.getId()); if (ability == null) { ability = new MadnessAbility(card, card.getSpellAbility().getManaCosts()); } game.getState().addOtherAbility(card, ability, false); usedMadnessAbilities.put(card.getId(), ability); } }
public PayMoreToCastAsThoughtItHadFlashAbility(Card card, ManaCosts<ManaCost> costsToAdd) { super(card.getSpellAbility().getManaCosts().copy(), card.getName() + " as though it had flash", Zone.HAND, SpellAbilityType.BASE_ALTERNATE); this.costsToAdd = costsToAdd; this.timing = TimingRule.INSTANT; this.ruleAtTheTop = true; CardUtil.increaseCost(this, costsToAdd); }
public EmergeAbility(Card card, ManaCosts<ManaCost> emergeCost) { super(emergeCost, card.getName() + " with emerge", Zone.HAND, SpellAbilityType.BASE_ALTERNATE); this.getCosts().addAll(card.getSpellAbility().getCosts().copy()); this.getEffects().addAll(card.getSpellAbility().getEffects().copy()); this.getTargets().addAll(card.getSpellAbility().getTargets().copy()); this.timing = card.getSpellAbility().getTiming(); this.setRuleAtTheTop(true); this.emergeCost = emergeCost.copy(); }
@Override public boolean apply(Card input, Game game) { SpellAbility ability = input.getSpellAbility().copy(); ability.setControllerId(controllerId); input.adjustTargets(ability, game); return ability.canChooseTarget(game); }
public SpectacleAbility(Card card, ManaCost spectacleCosts) { super(spectacleCosts, card.getName() + " with spectacle", Zone.HAND, SpellAbilityType.BASE_ALTERNATE); this.getCosts().addAll(card.getSpellAbility().getCosts().copy()); this.getEffects().addAll(card.getSpellAbility().getEffects().copy()); this.getTargets().addAll(card.getSpellAbility().getTargets().copy()); this.spellAbilityType = SpellAbilityType.BASE_ALTERNATE; this.timing = card.getSpellAbility().getTiming(); this.setRuleAtTheTop(true); this.rule = "Spectacle " + spectacleCosts.getText() + " <i>(You may cast this spell for its spectacle cost rather than its mana cost if an opponent lost life this turn.)</i>"; }
public SurgeAbility(Card card, String surgeCosts) { super(new ManaCostsImpl<>(surgeCosts), card.getName() + " with surge", Zone.HAND, SpellAbilityType.BASE_ALTERNATE); this.getCosts().addAll(card.getSpellAbility().getCosts().copy()); this.getEffects().addAll(card.getSpellAbility().getEffects().copy()); this.getTargets().addAll(card.getSpellAbility().getTargets().copy()); this.spellAbilityType = SpellAbilityType.BASE_ALTERNATE; this.timing = card.getSpellAbility().getTiming(); this.setRuleAtTheTop(true); this.rule = "Surge " + surgeCosts + " <i>(You may cast this spell for its surge cost if you or a teammate has cast another spell this turn.)</i>"; }
@Override public boolean apply(Card input, Game game) { final Permanent permanent = game.getPermanentOrLKIBattlefield(toBeCheckedLKIPermanentId); Filter filter; for (Target target : input.getSpellAbility().getTargets()) { filter = target.getFilter(); if (filter.match(permanent, game)) { return true; } } return false; }
@Override public boolean lookAtFaceDownCard(Card card, Game game ) { if (null != game.getContinuousEffects().asThough(card.getId(), AsThoughEffectType.LOOK_AT_FACE_DOWN, card.getSpellAbility(), this.getId(), game)) { if (chooseUse(Outcome.Benefit, "Look at that card?", null, game)) { Cards cards = new CardsImpl(card); this.lookAtCards(getName() + " - " + sdf.format(System.currentTimeMillis()), cards, game); return true; } } return false; }
public JumpStartAbility(Card card) { super(card.getManaCost(), card.getName() + " with jump-start", Zone.GRAVEYARD, SpellAbilityType.BASE_ALTERNATE); this.getCosts().addAll(card.getSpellAbility().getCosts().copy()); Cost cost = new DiscardTargetCost(new TargetCardInHand()); cost.setText(""); this.addCost(cost); this.getEffects().addAll(card.getSpellAbility().getEffects().copy()); this.getTargets().addAll(card.getSpellAbility().getTargets().copy()); this.spellAbilityType = SpellAbilityType.BASE_ALTERNATE; this.timing = card.getSpellAbility().getTiming(); }
public RetraceAbility(Card card) { super(card.getManaCost(), card.getName() + " with retrace", Zone.GRAVEYARD, SpellAbilityType.BASE_ALTERNATE); this.getCosts().addAll(card.getSpellAbility().getCosts().copy()); Cost cost = new DiscardTargetCost(new TargetCardInHand(new FilterLandCard())); cost.setText(""); this.addCost(cost); this.getEffects().addAll(card.getSpellAbility().getEffects().copy()); this.getTargets().addAll(card.getSpellAbility().getTargets().copy()); this.spellAbilityType = SpellAbilityType.BASE_ALTERNATE; this.timing = card.getSpellAbility().getTiming(); }
public CastCommanderAbility(Card card) { super(card.getManaCost(), card.getName(), Zone.COMMAND, SpellAbilityType.BASE); this.costs = card.getSpellAbility().getCosts().copy(); this.timing = TimingRule.SORCERY; this.usesStack = true; this.controllerId = card.getOwnerId(); this.sourceId = card.getId(); }
@Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); Card target = (Card) game.getObject(source.getFirstTarget()); if (controller != null && target != null) { return controller.cast(target.getSpellAbility(), game, true, new MageObjectReference(source.getSourceObject(game), game)); } return false; }
@Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); Card card = game.getCard(source.getFirstTarget()); if (controller == null || card == null) { return false; } controller.cast(card.getSpellAbility(), game, true, new MageObjectReference(source.getSourceObject(game), game)); game.addEffect(new WrexialReplacementEffect(card.getId()), source); return true; } }
@Override public boolean apply(Game game, Ability source) { Card card = game.getCard(getTargetPointer().getFirst(game, source)); if (card != null) { Player player = game.getPlayer(source.getControllerId()); if (player != null && player.chooseUse(Outcome.Benefit, "Cast " + card.getName() + " without paying cost?", source, game)) { player.cast(card.getSpellAbility(), game, true, new MageObjectReference(source.getSourceObject(game), game)); } } return false; } }
public SupportEffect(Card card, int amount, boolean otherPermanent) { super(CounterType.P1P1.createInstance(0), new StaticValue(1)); this.amountSupportTargets = new StaticValue(amount); this.otherPermanent = otherPermanent; if (card.isInstant() || card.isSorcery()) { card.getSpellAbility().addTarget(new TargetCreaturePermanent(0, amount, new FilterCreaturePermanent("target creatures"), false)); } staticText = setText(); }
@Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { Card card = game.getCard(getTargetPointer().getFirst(game, source)); if (card != null) { controller.cast(card.getSpellAbility(), game, false, new MageObjectReference(source.getSourceObject(game), game)); game.addEffect(new ToshiroUmezawaReplacementEffect(card.getId()), source); } } return false; } }