@Override public boolean apply(Game game, Ability source, Ability abilityToModify) { SpellAbility spellAbility = (SpellAbility) abilityToModify; for (Cost cost : spellAbility.getCosts()) { if (cost instanceof SacrificeXTargetCost) { int reduction = ((SacrificeXTargetCost) cost).getAmount(); CardUtil.adjustCost(spellAbility, reduction * 2); break; } } return true; }
@Override public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) { if (affectedControllerId.equals(source.getControllerId()) && getTargetPointer().getTargets(game, source).contains(objectId)) { Card card = game.getCard(objectId); if (card != null && !card.isLand() && card.getSpellAbility().getCosts() != null) { Player player = game.getPlayer(affectedControllerId); if (player != null) { player.setCastSourceIdWithAlternateMana(objectId, null, card.getSpellAbility().getCosts()); } } return true; } return false; } }
@Override public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) { if (objectId.equals(getTargetPointer().getFirst(game, source)) && affectedControllerId.equals(source.getControllerId())) { Card card = game.getCard(objectId); if (card != null) { Player player = game.getPlayer(affectedControllerId); if (player != null) { player.setCastSourceIdWithAlternateMana(objectId, null, card.getSpellAbility().getCosts()); return true; } } } return false; } }
@Override public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) { if (objectId != null && objectId.equals(getTargetPointer().getFirst(game, source))) { if (affectedControllerId.equals(source.getControllerId())) { Card card = game.getCard(objectId); if (card != null && game.getState().getZone(objectId) == Zone.EXILED) { if (!card.isLand() && card.getSpellAbility().getCosts() != null) { Player player = game.getPlayer(affectedControllerId); if (player != null) { player.setCastSourceIdWithAlternateMana(objectId, null, card.getSpellAbility().getCosts()); } } return true; } } } return false; } }
@Override public boolean applies(UUID sourceId, Ability source, UUID affectedControllerId, Game game) { if (sourceId != null && sourceId.equals(getTargetPointer().getFirst(game, source)) && affectedControllerId.equals(source.getControllerId())) { Card card = game.getCard(sourceId); if (card != null && game.getState().getZone(sourceId) == Zone.EXILED) { Player player = game.getPlayer(affectedControllerId); if (player != null) { player.setCastSourceIdWithAlternateMana(sourceId, null, card.getSpellAbility().getCosts()); return true; } } } return false; } }
@Override public boolean applies(UUID sourceId, Ability source, UUID affectedControllerId, Game game) { if (sourceId != null && sourceId.equals(getTargetPointer().getFirst(game, source)) && affectedControllerId.equals(source.getControllerId())) { Card card = game.getCard(sourceId); if (card != null && game.getState().getZone(sourceId) == Zone.EXILED) { Player player = game.getPlayer(affectedControllerId); if(player != null) { player.setCastSourceIdWithAlternateMana(sourceId, null, card.getSpellAbility().getCosts()); return true; } } } return false; } }
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 applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) { UUID ownerId = game.getOwnerId(objectId); if (objectId.equals(getTargetPointer().getFirst(game, source))) { if (affectedControllerId.equals(ownerId)) { Card card = game.getCard(objectId); Player player = game.getPlayer(ownerId); if (player != null && card != null) { player.setCastSourceIdWithAlternateMana(objectId, null, card.getSpellAbility().getCosts()); return true; } } } else { if (((FixedTarget) getTargetPointer()).getTarget().equals(objectId)) { // object has moved zone so effect can be discarted this.discard(); } } return false; } }
@Override public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) { if (targetPointer.getTargets(game, source).contains(objectId) && game.getState().getZone(objectId) == Zone.EXILED) { Player player = game.getPlayer(source.getControllerId()); Card card = game.getCard(objectId); if (player != null && card != null) { player.setCastSourceIdWithAlternateMana(objectId, null, card.getSpellAbility().getCosts()); return true; } } return false; } }
@Override public boolean applies(UUID sourceId, Ability source, UUID affectedControllerId, Game game) { if (!cardTypeHandler.atLeastOneAvailable(cardType)){ return false; } if (sourceId != null && sourceId.equals(getTargetPointer().getFirst(game, source)) && affectedControllerId.equals(source.getControllerId())) { Card card = game.getCard(sourceId); if (card != null && game.getState().getZone(sourceId) == Zone.EXILED) { Player player = game.getPlayer(affectedControllerId); Costs costs = card.getSpellAbility().getCosts().copy(); costs.add(new ConsumeCardTypeCost(cardType, cardTypeHandler)); player.setCastSourceIdWithAlternateMana(sourceId, null, costs); return true; } } return false; } }
@Override public void watch(GameEvent event, Game game) { if (event.getType() == GameEvent.EventType.SPELL_CAST) { // targetId is the unique ID of the spell Spell spell = game.getState().getStack().getSpell(event.getTargetId()); // revealed a Dragon card or controlled a Dragon as you cast the spell if (spell != null) { boolean revealedOrOnBattlefield = false; for (Cost cost : spell.getSpellAbility().getCosts()) { if (cost instanceof RevealTargetFromHandCost) { revealedOrOnBattlefield = ((RevealTargetFromHandCost) cost).getNumberRevealedCards() > 0; break; } } if (!revealedOrOnBattlefield) { revealedOrOnBattlefield = game.getBattlefield().countAll(filter, spell.getControllerId(), game) > 0; } if (revealedOrOnBattlefield){ castWithDragonOnTheBattlefield.add(spell.getId()); } } } }
@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; }
@Override public boolean apply(Game game, Ability source) { boolean applies = false; Spell spell = game.getStack().getSpell(source.getSourceId()); if (spell != null && spell.getSpellAbility() != null) { for (Cost cost : spell.getSpellAbility().getCosts()) { if (cost instanceof RevealTargetFromHandCost) { applies = !cost.getTargets().isEmpty(); break; } } } if (!applies) { applies = game.getBattlefield().countAll(filter, source.getControllerId(), game) > 0; } return applies; } }
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(); }
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>"; }
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 AwakenAbility(Card card, int awakenValue, String awakenCosts) { super(new ManaCostsImpl<>(awakenCosts), card.getName() + " with awaken", 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.addTarget(new TargetControlledPermanent(new FilterControlledLandPermanent(filterMessage))); this.addEffect(new AwakenEffect()); this.awakenValue = awakenValue; rule = "Awaken " + awakenValue + "—" + awakenCosts + " <i>(If you cast this spell for " + awakenCosts + ", also put " + CardUtil.numberToText(awakenValue, "a") + " +1/+1 counters on target land you control and it becomes a 0/0 Elemental creature with haste. It's still a land.)</i>"; }