@Override public boolean checkTrigger(GameEvent event, Game game) { Spell spell = game.getStack().getSpell(event.getTargetId()); if (spell != null && !spell.isCopy() && spell.getCard() != null && !spell.getCard().isCopy() && (spell.isInstant() || spell.isSorcery())) { for (Effect effect : this.getEffects()) { effect.setTargetPointer(new FixedTarget(event.getTargetId())); } return true; } return false; }
public Spell copySpell(UUID newController) { Spell copy = new Spell(this.card, this.ability.copySpell(), this.controllerId, this.fromZone); boolean firstDone = false; for (SpellAbility spellAbility : this.getSpellAbilities()) { if (!firstDone) { firstDone = true; continue; } SpellAbility newAbility = spellAbility.copy(); // e.g. spliced spell newAbility.newId(); copy.addSpellAbility(newAbility); } copy.setCopy(true, this); copy.setControllerId(newController); return copy; }
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 resolve(Game game) { boolean result; Player controller = game.getPlayer(getControllerId()); if (controller == null) { return false; if (commandedBy != null && !commandedBy.equals(getControllerId())) { Player turnController = game.getPlayer(commandedBy); if (turnController != null) { if (this.isInstant() || this.isSorcery()) { int index = 0; result = false; if (hasTargets(spellAbility, game)) { notTargeted = false; legalParts |= spellAbilityHasLegalParts(spellAbility, game); if (spellAbilityHasLegalParts(spellAbility, game)) { for (UUID modeId : spellAbility.getModes().getSelectedModes()) { spellAbility.getModes().setActiveMode(modeId); if (spellAbility.getTargets().stillLegal(spellAbility, game)) { if (spellAbility.getSpellAbilityType() != SpellAbilityType.SPLICE) { updateOptionalCosts(index); if (!isCopy()) { controller.moveCards(card, Zone.GRAVEYARD, ability, game); game.informPlayers(getName() + " has been fizzled.");
for (Ability ability : spell.getSpellAbilities()) { for (UUID modeId : ability.getModes().getSelectedModes()) { Mode mode = ability.getModes().get(modeId); Spell copy = spell.copySpell(source.getControllerId()); game.getStack().push(copy); setTarget: for (UUID modeId : copy.getSpellAbility().getModes().getSelectedModes()) { Mode mode = copy.getSpellAbility().getModes().get(modeId); for (Target target : mode.getTargets()) { if (target.getClass().equals(usedTarget.getClass())) { target.addTarget(creature.getId(), copy.getSpellAbility(), game, false); break setTarget; game.fireEvent(new GameEvent(GameEvent.EventType.COPIED_STACKOBJECT, copy.getId(), spell.getId(), source.getControllerId())); String activateMessage = copy.getActivatedMessage(game); if (activateMessage.startsWith(" casts ")) { activateMessage = activateMessage.substring(6);
@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(Game game, Ability source) { Spell spell = game.getStack().getSpell(getTargetPointer().getFirst(game, source)); if (spell != null) { Player controller = game.getPlayer(spell.getControllerId()); if (controller != null) { int count = 0; String name = spell.getName(); FilterCard filterCardName = new FilterCard(); filterCardName.add(new NamePredicate(name)); for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { Player player = game.getPlayer(playerId); if (player != null) { count += player.getGraveyard().count(filterCardName, game); } } if (count > 0) { new SquirrelToken().putOntoBattlefield(count, game, source.getSourceId(), spell.getControllerId()); } return true; } } return false; } }
@Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); Spell targetSpell = game.getStack().getSpell(source.getFirstTarget()); if (targetSpell != null) { Player controllerOfTargetedSpell = game.getPlayer(targetSpell.getControllerId()); if (controller != null && controllerOfTargetedSpell != null) { int numToDiscard = controller.getAmount(0, controller.getHand().size(), "How many cards do you want to discard?", game); Cards discardedCards = controller.discard(numToDiscard, false, source, game); int actualNumberDiscarded = discardedCards.size(); GenericManaCost cost = new GenericManaCost(actualNumberDiscarded * 3); if (controllerOfTargetedSpell.chooseUse(Outcome.AIDontUseIt, "Do you want to pay " + cost.convertedManaCost() + " to prevent " + targetSpell.getName() + " from gettting countered?", source, game) && cost.pay(source, game, source.getSourceId(), controllerOfTargetedSpell.getId(), false)) { return true; } else { targetSpell.counter(source.getSourceId(), game); return true; } } } return false; } }
String castText = spell.getSpellCastText(game); sb.append((castText.startsWith("Cast ") ? castText.substring(5) : castText)); if (spell.getFromZone() == Zone.GRAVEYARD) { sb.append(" from graveyard"); sb.append("unknown"); if (object instanceof Spell && ((Spell) object).getSpellAbilities().size() > 1) { if (((Spell) object).getSpellAbility().getSpellAbilityType() == SpellAbilityType.SPLIT_FUSED) { Spell spell = (Spell) object; int i = 0; for (SpellAbility spellAbility : spell.getSpellAbilities()) { i++; String half; Spell spell = (Spell) object; int i = 0; for (SpellAbility spellAbility : spell.getSpellAbilities()) { i++; if (i > 1) { } else if (object instanceof Spell && ((Spell) object).getSpellAbility().getModes().size() > 1) { Modes spellModes = ((Spell) object).getSpellAbility().getModes(); for (UUID selectedModeId : spellModes.getSelectedModes()) { Mode selectedMode = spellModes.get(selectedModeId);
@Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller == null) { return false; } Spell spell = game.getStack().getSpell(getTargetPointer().getFirst(game, source)); if (spell != null) { game.getStack().counter(spell.getId(), source.getSourceId(), game); if (SpellMasteryCondition.instance.apply(game, source) && controller.chooseUse(Outcome.PlayForFree, "Copy " + spell.getName() + " (you may choose new targets for the copy)?", source, game)) { StackObject newStackObject = spell.createCopyOnStack(game, source, source.getControllerId(), true); if (newStackObject instanceof Spell) { String activateMessage = ((Spell) newStackObject).getActivatedMessage(game); if (activateMessage.startsWith(" casts ")) { activateMessage = activateMessage.substring(6); } game.informPlayers(controller.getLogName() + activateMessage); } } return true; } return false; } }
@Override public boolean apply(Game game, Ability source) { Spell spell = game.getStack().getSpell(targetPointer.getFirst(game, source)); Player controller = game.getPlayer(source.getControllerId()); if (spell != null && controller != null) { Player spellCaster = game.getPlayer(spell.getControllerId()); // controller gets controll of spell spell.setControllerId(controller.getId()); // and chooses new targets spell.chooseNewTargets(game, controller.getId()); game.informPlayers(controller.getLogName() + " got control of " + spell.getName() + " spell."); // and spell controller get control of Perplexing Chimera if (spellCaster != null) { ContinuousEffect effect = new PerplexingChimeraControlEffect(); effect.setTargetPointer(new FixedTarget(spellCaster.getId())); game.addEffect(effect, source); } } return false; } }
@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(); }
rotate = (((SplitCard) card).getSpellAbility().getSpellAbilityType()) != SpellAbilityType.SPLIT_AFTERMATH; } else if (card instanceof Spell) { switch (((Spell) card).getSpellAbility().getSpellAbilityType()) { case SPLIT_FUSED: splitCard = (SplitCard) ((Spell) card).getCard(); rotate = true; break; case SPLIT_AFTERMATH: splitCard = (SplitCard) ((Spell) card).getCard(); rotate = false; break; this.mageObjectType = MageObjectType.SPELL; Spell spell = (Spell) card; for (SpellAbility spellAbility : spell.getSpellAbilities()) { for (UUID modeId : spellAbility.getModes().getSelectedModes()) { Mode mode = spellAbility.getModes().get(modeId); SpellAbilityType ty = spell.getSpellAbility().getSpellAbilityType(); if (ty == SpellAbilityType.SPLIT_RIGHT || ty == SpellAbilityType.SPLIT_LEFT || ty == SpellAbilityType.SPLIT_FUSED) { } else if (spell.getCard() != null) { SplitCard wholeCard = ((SplitCardHalf) spell.getCard()).getParentCard(); Abilities<Ability> aftermathHalfAbilities = wholeCard.getRightHalfCard().getAbilities(); if (aftermathHalfAbilities.stream().anyMatch(ability -> ability instanceof AftermathAbility)) { if (spell.getSpellAbility().isModal()) { for (UUID modeId : spell.getSpellAbility().getModes().getSelectedModes()) { Mode mode = spell.getSpellAbility().getModes().get(modeId);
@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 void watch(GameEvent event, Game game) { if (condition == true) { //no need to check - condition has already occured return; } if (event.getType() == EventType.SPELL_CAST && controllerId.equals(event.getPlayerId())) { Spell spell = game.getStack().getSpell(event.getTargetId()); if (spell.getCard().getName().equals("Peer Through Depths")) { castPeerThroughDepths = true; } else if (spell.getCard().getName().equals("Reach Through Mists")) { castReachThroughMists = true; } condition = castPeerThroughDepths && castReachThroughMists; } }
@Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); Spell spell = game.getStack().getSpell(targetPointer.getFirst(game, source)); if (spell != null && controller != null) { Spell copy = spell.copySpell(source.getControllerId()); copy.getColor(game).setRed(true); game.getStack().push(copy); copy.chooseNewTargets(game, controller.getId()); game.fireEvent(new GameEvent(GameEvent.EventType.COPIED_STACKOBJECT, copy.getId(), spell.getId(), source.getControllerId())); return true; } return false; }
@Override public boolean apply(Game game, Ability source) { MageObjectReference spellRef = (MageObjectReference) this.getValue("GravestormSpellRef"); if (spellRef != null) { GravestormWatcher watcher = game.getState().getWatcher(GravestormWatcher.class); if(watcher != null) { int gravestormCount = watcher.getGravestormCount(); if (gravestormCount > 0) { Spell spell = (Spell) this.getValue("GravestormSpell"); if (spell != null) { if (!game.isSimulation()) { game.informPlayers("Gravestorm: " + spell.getName() + " will be copied " + gravestormCount + " time" + (gravestormCount > 1 ? "s" : "")); } for (int i = 0; i < gravestormCount; i++) { spell.createCopyOnStack(game, source, source.getControllerId(), true); } } } return true; } } return false; }
@Override public boolean apply(Game game, Ability source) { Spell spell = game.getStack().getSpell(targetPointer.getFirst(game, source)); if (spell != null) { StackObject newStackObject = spell.createCopyOnStack(game, source, spell.getControllerId(), true); Player player = game.getPlayer(spell.getControllerId()); if (player != null && newStackObject instanceof Spell) { String activateMessage = ((Spell) newStackObject).getActivatedMessage(game); if (activateMessage.startsWith(" casts ")) { activateMessage = activateMessage.substring(6); } game.informPlayers(player.getLogName() + " copies " + activateMessage); } return true; } return false; }
Spell copy = spell.copySpell(source.getControllerId()); modifyCopy(copy, game, source); Target sampleTarget = targetsToBeChanged.iterator().next().getTarget(copy); copy = spell.copySpell(source.getControllerId()); try { modifyCopy(copy, (T) obj, game, source); targetInstance.add(objId, game); if (!playerTargetCopyMap.containsKey(copy.getControllerId())) { playerTargetCopyMap.put(copy.getControllerId(), new HashMap<>()); playerTargetCopyMap.get(copy.getControllerId()).put(objId, copy); target.setMinNumberOfTargets(0); target.setMaxNumberOfTargets(1); target.setTargetName(filter.getMessage() + " that " + spell.getLogName() + " could target (" + targetCopyMap.size() + " remaining)"); && target.canChoose(spell.getId(), player.getId(), game)) { player.choose(Outcome.Neutral, target, spell.getId(), game);