From 89d185049325f626391be041a3dea849eaf1bdbb Mon Sep 17 00:00:00 2001 From: BetaSteward Date: Wed, 14 Sep 2011 23:09:09 -0400 Subject: [PATCH] created mana added event --- .../sets/newphyrexia/VorinclexVoiceOfHunger.java | 12 ++++++------ .../effects/common/AddManaOfAnyColorEffect.java | 10 +++++----- .../abilities/effects/common/BasicManaEffect.java | 3 ++- .../abilities/effects/common/DynamicManaEffect.java | 2 +- Mage/src/mage/game/events/GameEvent.java | 1 + Mage/src/mage/players/ManaPool.java | 6 +++++- 6 files changed, 20 insertions(+), 14 deletions(-) diff --git a/Mage.Sets/src/mage/sets/newphyrexia/VorinclexVoiceOfHunger.java b/Mage.Sets/src/mage/sets/newphyrexia/VorinclexVoiceOfHunger.java index 3278dd37118..f80483cab89 100644 --- a/Mage.Sets/src/mage/sets/newphyrexia/VorinclexVoiceOfHunger.java +++ b/Mage.Sets/src/mage/sets/newphyrexia/VorinclexVoiceOfHunger.java @@ -165,27 +165,27 @@ class VorinclexEffect extends ManaEffect { else player.choose(outcome, choice, game); if (choice.getChoice().equals("Black")) { - player.getManaPool().changeMana(Mana.BlackMana); + player.getManaPool().changeMana(Mana.BlackMana, game, source); return true; } else if (choice.getChoice().equals("Blue")) { - player.getManaPool().changeMana(Mana.BlueMana); + player.getManaPool().changeMana(Mana.BlueMana, game, source); return true; } else if (choice.getChoice().equals("Red")) { - player.getManaPool().changeMana(Mana.RedMana); + player.getManaPool().changeMana(Mana.RedMana, game, source); return true; } else if (choice.getChoice().equals("Green")) { - player.getManaPool().changeMana(Mana.GreenMana); + player.getManaPool().changeMana(Mana.GreenMana, game, source); return true; } else if (choice.getChoice().equals("White")) { - player.getManaPool().changeMana(Mana.WhiteMana); + player.getManaPool().changeMana(Mana.WhiteMana, game, source); return true; } else if (choice.getChoice().equals("Colorless")) { - player.getManaPool().changeMana(Mana.ColorlessMana); + player.getManaPool().changeMana(Mana.ColorlessMana, game, source); return true; } } diff --git a/Mage/src/mage/abilities/effects/common/AddManaOfAnyColorEffect.java b/Mage/src/mage/abilities/effects/common/AddManaOfAnyColorEffect.java index ef5b0446e5f..441ddb54211 100644 --- a/Mage/src/mage/abilities/effects/common/AddManaOfAnyColorEffect.java +++ b/Mage/src/mage/abilities/effects/common/AddManaOfAnyColorEffect.java @@ -59,23 +59,23 @@ public class AddManaOfAnyColorEffect extends ManaEffect ChoiceColor choice = (ChoiceColor) source.getChoices().get(0); Player player = game.getPlayer(source.getControllerId()); if (choice.getColor().isBlack()) { - player.getManaPool().changeMana(Mana.BlackMana); + player.getManaPool().changeMana(Mana.BlackMana, game, source); return true; } else if (choice.getColor().isBlue()) { - player.getManaPool().changeMana(Mana.BlueMana); + player.getManaPool().changeMana(Mana.BlueMana, game, source); return true; } else if (choice.getColor().isRed()) { - player.getManaPool().changeMana(Mana.RedMana); + player.getManaPool().changeMana(Mana.RedMana, game, source); return true; } else if (choice.getColor().isGreen()) { - player.getManaPool().changeMana(Mana.GreenMana); + player.getManaPool().changeMana(Mana.GreenMana, game, source); return true; } else if (choice.getColor().isWhite()) { - player.getManaPool().changeMana(Mana.WhiteMana); + player.getManaPool().changeMana(Mana.WhiteMana, game, source); return true; } return false; diff --git a/Mage/src/mage/abilities/effects/common/BasicManaEffect.java b/Mage/src/mage/abilities/effects/common/BasicManaEffect.java index caf329885c0..4e977af95ee 100644 --- a/Mage/src/mage/abilities/effects/common/BasicManaEffect.java +++ b/Mage/src/mage/abilities/effects/common/BasicManaEffect.java @@ -4,6 +4,7 @@ import mage.ConditionalMana; import mage.Mana; import mage.abilities.Ability; import mage.game.Game; +import mage.game.events.GameEvent; public class BasicManaEffect extends ManaEffect { protected Mana mana; @@ -32,7 +33,7 @@ public class BasicManaEffect extends ManaEffect { @Override public boolean apply(Game game, Ability source) { - game.getPlayer(source.getControllerId()).getManaPool().changeMana(mana); + game.getPlayer(source.getControllerId()).getManaPool().changeMana(mana, game, source); return true; } diff --git a/Mage/src/mage/abilities/effects/common/DynamicManaEffect.java b/Mage/src/mage/abilities/effects/common/DynamicManaEffect.java index 6c35294f109..96ffaa0ddfc 100644 --- a/Mage/src/mage/abilities/effects/common/DynamicManaEffect.java +++ b/Mage/src/mage/abilities/effects/common/DynamicManaEffect.java @@ -63,7 +63,7 @@ public class DynamicManaEffect extends BasicManaEffect { @Override public boolean apply(Game game, Ability source) { computeMana(game, source); - game.getPlayer(source.getControllerId()).getManaPool().changeMana(computedMana); + game.getPlayer(source.getControllerId()).getManaPool().changeMana(computedMana, game, source); return true; } diff --git a/Mage/src/mage/game/events/GameEvent.java b/Mage/src/mage/game/events/GameEvent.java index df3e96e6a5e..a6ffb2ce5ea 100644 --- a/Mage/src/mage/game/events/GameEvent.java +++ b/Mage/src/mage/game/events/GameEvent.java @@ -87,6 +87,7 @@ public class GameEvent { PLAY_LAND, LAND_PLAYED, CAST_SPELL, SPELL_CAST, ACTIVATE_ABILITY, ACTIVATED_ABILITY, + MANA_ADDED, LOSES, LOST, WINS, TARGET, TARGETED, COUNTER, COUNTERED, diff --git a/Mage/src/mage/players/ManaPool.java b/Mage/src/mage/players/ManaPool.java index 94388cfb693..e777d9c649a 100644 --- a/Mage/src/mage/players/ManaPool.java +++ b/Mage/src/mage/players/ManaPool.java @@ -39,6 +39,7 @@ import mage.abilities.Ability; import mage.filter.Filter; import mage.filter.FilterMana; import mage.game.Game; +import mage.game.events.GameEvent; /** * @@ -393,7 +394,7 @@ public class ManaPool implements Serializable { return mana; } - public void changeMana(Mana mana) { + public void changeMana(Mana mana, Game game, Ability source) { if (mana instanceof ConditionalMana) { this.conditionalMana.add((ConditionalMana)mana); } else { @@ -403,6 +404,9 @@ public class ManaPool implements Serializable { this.red += mana.getRed(); this.green += mana.getGreen(); this.colorless += mana.getColorless(); + GameEvent event = GameEvent.getEvent(GameEvent.EventType.MANA_ADDED, source.getSourceId(), source.getId(), source.getControllerId()); + event.setData(mana.toString()); + game.fireEvent(event); } }