* Chorus of the Conclave - Fixed that the addional counters were sometimes also added to the cast creature if the costs were paid for another instance of the spell (e.g. Guile).

This commit is contained in:
LevelX2 2015-10-07 00:15:26 +02:00
parent af61e8b43b
commit b4061b2f4a
2 changed files with 26 additions and 24 deletions

View file

@ -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<UUID, Integer> spellX;
Map<String, Integer> spellX;
if (object != null && object instanceof Map) {
spellX = (Map<UUID, Integer>) object;
spellX = (Map<String, Integer>) 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<UUID, Integer> spellX = (Map<UUID, Integer>) game.getState().getValue("spellX" + source.getSourceId());
return spellX != null && spellX.containsKey(event.getSourceId());
Map<String, Integer> spellX = (Map<String, Integer>) 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<UUID, Integer> spellX = (Map<UUID, Integer>) game.getState().getValue("spellX" + source.getSourceId());
Map<String, Integer> spellX = (Map<String, Integer>) 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;
}

View file

@ -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());
}