diff --git a/Mage.Sets/src/mage/sets/commander/ChorusOfTheConclave.java b/Mage.Sets/src/mage/sets/commander/ChorusOfTheConclave.java index 7454b49566..8377498150 100644 --- a/Mage.Sets/src/mage/sets/commander/ChorusOfTheConclave.java +++ b/Mage.Sets/src/mage/sets/commander/ChorusOfTheConclave.java @@ -48,7 +48,6 @@ import mage.counters.CounterType; import mage.game.Game; import mage.game.events.GameEvent; import mage.game.permanent.Permanent; -import mage.game.stack.Spell; import mage.players.Player; /** @@ -116,13 +115,13 @@ class ChorusOfTheConclaveReplacementEffect extends ReplacementEffectImpl { xCost += playerPaysXGenericMana(you, source, game); // save the x value to be available for ETB replacement effect Object object = game.getState().getValue("spellX" + source.getSourceId()); - Map spellX; + Map spellX; if (object != null && object instanceof Map) { - spellX = (Map) object; + spellX = (Map) object; } else { spellX = new HashMap<>(); } - spellX.put(event.getSourceId(), xCost); + spellX.put(event.getSourceId().toString() + game.getState().getZoneChangeCounter(event.getSourceId()), xCost); game.getState().setValue("spellX" + source.getSourceId(), spellX); } } @@ -157,7 +156,7 @@ class ChorusOfTheConclaveReplacementEffect extends ReplacementEffectImpl { payed = true; } } - game.informPlayers(new StringBuilder(player.getLogName()).append(" pays {").append(xValue).append("}.").toString()); + game.informPlayers(player.getLogName() + " pays {" + xValue + "}"); return xValue; } @@ -191,22 +190,23 @@ class ChorusOfTheConclaveReplacementEffect2 extends ReplacementEffectImpl { @Override public boolean applies(GameEvent event, Ability source, Game game) { - Map spellX = (Map) game.getState().getValue("spellX" + source.getSourceId()); - return spellX != null && spellX.containsKey(event.getSourceId()); + Map spellX = (Map) game.getState().getValue("spellX" + source.getSourceId()); + return spellX != null && event.getSourceId() != null && spellX.containsKey(event.getSourceId().toString() + (game.getState().getZoneChangeCounter(event.getSourceId()) - 2)); } @Override public boolean replaceEvent(GameEvent event, Ability source, Game game) { Permanent creature = game.getPermanent(event.getSourceId()); - Map spellX = (Map) game.getState().getValue("spellX" + source.getSourceId()); + Map spellX = (Map) game.getState().getValue("spellX" + source.getSourceId()); MageObject sourceObject = source.getSourceObject(game); if (sourceObject != null && creature != null && spellX != null) { - int xValue = spellX.get(event.getSourceId()); + String key = event.getSourceId().toString() + (game.getState().getZoneChangeCounter(event.getSourceId()) - 2); + int xValue = spellX.get(key); if (xValue > 0) { creature.addCounters(CounterType.P1P1.createInstance(xValue), game); - game.informPlayers(sourceObject.getName() +": Added " + xValue +" +1/+1 counter" + (xValue > 1 ? "s":"") + "on " + creature.getName()); + game.informPlayers(sourceObject.getLogName() + ": " + creature.getLogName() + " enters the battlefield with " + xValue + " +1/+1 counter" + (xValue > 1 ? "s" : "") + " on it"); } - spellX.remove(event.getSourceId()); + spellX.remove(key); } return false; } diff --git a/Mage.Sets/src/mage/sets/lorwyn/Guile.java b/Mage.Sets/src/mage/sets/lorwyn/Guile.java index 4e9977188f..a945a8c5c5 100644 --- a/Mage.Sets/src/mage/sets/lorwyn/Guile.java +++ b/Mage.Sets/src/mage/sets/lorwyn/Guile.java @@ -65,10 +65,10 @@ public class Guile extends CardImpl { // Guile can't be blocked except by three or more creatures. this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new CantBeBlockedByOneEffect(3))); - + // If a spell or ability you control would counter a spell, instead exile that spell and you may play that card without paying its mana cost. this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new GuileReplacementEffect())); - + // When Guile is put into a graveyard from anywhere, shuffle it into its owner's library. this.addAbility(new PutIntoGraveFromAnywhereSourceTriggeredAbility(new ShuffleIntoLibrarySourceEffect())); } @@ -107,28 +107,30 @@ class GuileReplacementEffect extends ReplacementEffectImpl { @Override public boolean replaceEvent(GameEvent event, Ability source, Game game) { Spell spell = game.getStack().getSpell(event.getTargetId()); - Player guileController = game.getPlayer(source.getControllerId()); - if (spell != null && guileController != null) { - Card spellCard = spell.getCard(); - guileController.moveCardToExileWithInfo(spellCard, null, "", source.getSourceId(), game, Zone.STACK, true); - if (guileController.chooseUse(Outcome.PlayForFree, "Cast that card for free?", source, game)) { - guileController.cast(spellCard.getSpellAbility(), game, true); + Player controller = game.getPlayer(source.getControllerId()); + if (spell != null && controller != null) { + controller.moveCards(spell, null, Zone.EXILED, source, game); + if (!spell.isCopy()) { + Card spellCard = spell.getCard(); + if (spellCard != null && controller.chooseUse(Outcome.PlayForFree, "Cast " + spellCard.getIdName() + " for free?", source, game)) { + controller.cast(spellCard.getSpellAbility(), game, true); + } + return true; } - return true; } return false; } - - @Override + + @Override public boolean checksEventType(GameEvent event, Game game) { return event.getType() == EventType.COUNTER; } - + @Override public boolean applies(GameEvent event, Ability source, Game game) { Spell counteredSpell = game.getStack().getSpell(event.getTargetId()); StackObject counteringObject = game.getStack().getStackObject(event.getSourceId()); - return counteredSpell != null + return counteredSpell != null && counteringObject != null && counteringObject.getControllerId().equals(source.getControllerId()); }