diff --git a/Mage.Sets/src/mage/sets/mirrodinbesieged/PhyrexianVatmother.java b/Mage.Sets/src/mage/sets/mirrodinbesieged/PhyrexianVatmother.java index 34ba1d4768..edd6de6de5 100644 --- a/Mage.Sets/src/mage/sets/mirrodinbesieged/PhyrexianVatmother.java +++ b/Mage.Sets/src/mage/sets/mirrodinbesieged/PhyrexianVatmother.java @@ -92,7 +92,7 @@ class PoisonControllerEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player player = game.getPlayer(source.getControllerId()); if (player != null) { - player.getCounters().addCounter(CounterType.POISON.createInstance()); + player.addCounters(CounterType.POISON.createInstance(), game); return true; } return false; diff --git a/Mage.Sets/src/mage/sets/mirrodinbesieged/PistusStrike.java b/Mage.Sets/src/mage/sets/mirrodinbesieged/PistusStrike.java index 57d84f71d9..5fc268a331 100644 --- a/Mage.Sets/src/mage/sets/mirrodinbesieged/PistusStrike.java +++ b/Mage.Sets/src/mage/sets/mirrodinbesieged/PistusStrike.java @@ -102,7 +102,7 @@ class PoisonControllerTargetCreatureEffect extends OneShotEffect { for (UUID playerId : game.getPlayerList()) { Player player = game.getPlayer(playerId); if (player != null) { - player.getCounters().addCounter(CounterType.POISON.createInstance()); + player.addCounters(CounterType.POISON.createInstance(), game); } } return true; diff --git a/Mage/src/mage/abilities/effects/common/AddPoisonCounterTargetEffect.java b/Mage/src/mage/abilities/effects/common/AddPoisonCounterTargetEffect.java index 447e62e410..56c5de4ec6 100644 --- a/Mage/src/mage/abilities/effects/common/AddPoisonCounterTargetEffect.java +++ b/Mage/src/mage/abilities/effects/common/AddPoisonCounterTargetEffect.java @@ -66,7 +66,7 @@ public class AddPoisonCounterTargetEffect extends OneShotEffect { if (player.getCounters().size() > 0) { if (player.getCounters().size() == 1) { for (Counter counter : player.getCounters().values()) { - player.getCounters().addCounter(counter.getName(), 1); + Counter newCounter = new Counter(counter.getName(), 1); + player.addCounters(newCounter, game); } } else { Choice choice = new ChoiceImpl(true); @@ -118,7 +119,8 @@ public class ProliferateEffect extends OneShotEffect { controller.choose(Outcome.Benefit, choice, game); for (Counter counter : player.getCounters().values()) { if (counter.getName().equals(choice.getChoice())) { - player.getCounters().addCounter(counter.getName(), 1); + Counter newCounter = new Counter(counter.getName(), 1); + player.addCounters(newCounter, game); break; } } diff --git a/Mage/src/mage/game/events/GameEvent.java b/Mage/src/mage/game/events/GameEvent.java index 404b298f7d..df3e96e6a5 100644 --- a/Mage/src/mage/game/events/GameEvent.java +++ b/Mage/src/mage/game/events/GameEvent.java @@ -149,7 +149,14 @@ public class GameEvent { return new GameEvent(type, targetId, null, playerId); } - public EventType getType() { + public static GameEvent getEvent(EventType type, UUID targetId, UUID playerId, String data, int amount) { + GameEvent event = getEvent(type, targetId,playerId); + event.setAmount(amount); + event.setData(data); + return event; + } + + public EventType getType() { return type; } diff --git a/Mage/src/mage/game/permanent/PermanentImpl.java b/Mage/src/mage/game/permanent/PermanentImpl.java index 0e4a4284ed..2e8d3ebb5c 100644 --- a/Mage/src/mage/game/permanent/PermanentImpl.java +++ b/Mage/src/mage/game/permanent/PermanentImpl.java @@ -177,17 +177,18 @@ public abstract class PermanentImpl> extends CardImpl @Override public void addCounters(String name, int amount, Game game) { - if (!game.replaceEvent(GameEvent.getEvent(GameEvent.EventType.ADD_COUNTER, objectId, controllerId))) { + GameEvent event = GameEvent.getEvent(GameEvent.EventType.ADD_COUNTER, objectId, controllerId, name, amount); + if (!game.replaceEvent(event)) { counters.addCounter(name, amount); - game.fireEvent(GameEvent.getEvent(EventType.COUNTER_ADDED, objectId, controllerId)); + game.fireEvent(GameEvent.getEvent(EventType.COUNTER_ADDED, objectId, controllerId, name, amount)); } } @Override public void addCounters(Counter counter, Game game) { - if (!game.replaceEvent(GameEvent.getEvent(GameEvent.EventType.ADD_COUNTER, objectId, controllerId))) { + if (!game.replaceEvent(GameEvent.getEvent(GameEvent.EventType.ADD_COUNTER, objectId, controllerId, counter.getName(), counter.getCount()))) { counters.addCounter(counter); - game.fireEvent(GameEvent.getEvent(EventType.COUNTER_ADDED, objectId, controllerId)); + game.fireEvent(GameEvent.getEvent(EventType.COUNTER_ADDED, objectId, controllerId, counter.getName(), counter.getCount())); } } diff --git a/Mage/src/mage/players/Player.java b/Mage/src/mage/players/Player.java index 89ef0470d0..2364d14573 100644 --- a/Mage/src/mage/players/Player.java +++ b/Mage/src/mage/players/Player.java @@ -53,6 +53,7 @@ import mage.cards.Card; import mage.cards.Cards; import mage.cards.decks.Deck; import mage.choices.Choice; +import mage.counters.Counter; import mage.counters.Counters; import mage.filter.FilterAbility; import mage.game.events.GameEvent; @@ -67,7 +68,6 @@ import mage.target.TargetAmount; import mage.target.TargetCard; import mage.target.common.TargetCardInLibrary; import mage.util.Copyable; -import org.w3c.dom.UserDataHandler; /** * @@ -238,4 +238,6 @@ public interface Player extends MageItem, Copyable { public List getPlayable(Game game, FilterAbility filter, ManaOptions available, boolean hidden); public List getPlayableOptions(Ability ability, Game game); + public void addCounters(Counter counter, Game game); + } diff --git a/Mage/src/mage/players/PlayerImpl.java b/Mage/src/mage/players/PlayerImpl.java index 72629aaa60..c2aa16b316 100644 --- a/Mage/src/mage/players/PlayerImpl.java +++ b/Mage/src/mage/players/PlayerImpl.java @@ -55,6 +55,7 @@ import mage.cards.Card; import mage.cards.Cards; import mage.cards.CardsImpl; import mage.cards.decks.Deck; +import mage.counters.Counter; import mage.counters.CounterType; import mage.counters.Counters; import mage.filter.FilterAbility; @@ -65,6 +66,7 @@ import mage.game.events.DamagePlayerEvent; import mage.game.events.DamagedPlayerEvent; import mage.game.permanent.Permanent; import mage.game.events.GameEvent; +import mage.game.events.GameEvent.EventType; import mage.game.stack.StackAbility; import mage.players.net.UserData; import mage.target.common.TargetCardInLibrary; @@ -758,7 +760,7 @@ public abstract class PlayerImpl> implements Player, Ser if (actualDamage > 0) { Permanent source = game.getPermanent(sourceId); if (source != null && (source.getAbilities().containsKey(InfectAbility.getInstance().getId()))) { - getCounters().addCounter(CounterType.POISON.createInstance(actualDamage)); + addCounters(CounterType.POISON.createInstance(actualDamage), game); } else { // fixed: damage dealt should not be equal to life lost // actualDamage = this.loseLife(actualDamage, game); @@ -776,7 +778,15 @@ public abstract class PlayerImpl> implements Player, Ser return 0; } - protected boolean canDamage(MageObject source) { + @Override + public void addCounters(Counter counter, Game game) { + if (!game.replaceEvent(GameEvent.getEvent(GameEvent.EventType.ADD_COUNTER, playerId, playerId, counter.getName(), counter.getCount()))) { + counters.addCounter(counter); + game.fireEvent(GameEvent.getEvent(EventType.COUNTER_ADDED, playerId, playerId, counter.getName(), counter.getCount())); + } + } + + protected boolean canDamage(MageObject source) { for (ProtectionAbility ability: abilities.getProtectionAbilities()) { if (!ability.canTarget(source)) return false;