From 309ebc7ee3ff8091133d496d8734ab337f79b632 Mon Sep 17 00:00:00 2001 From: magenoxx Date: Wed, 29 Aug 2012 22:44:48 +0400 Subject: [PATCH] Fixed Rebound for multi keywords. Added Player.#getSideboard method --- Mage/src/mage/abilities/keyword/ReboundAbility.java | 12 +++++++++++- Mage/src/mage/players/Player.java | 1 + Mage/src/mage/players/PlayerImpl.java | 12 ++++++++++++ 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/Mage/src/mage/abilities/keyword/ReboundAbility.java b/Mage/src/mage/abilities/keyword/ReboundAbility.java index d89d1c2819f..c43f140a4b6 100644 --- a/Mage/src/mage/abilities/keyword/ReboundAbility.java +++ b/Mage/src/mage/abilities/keyword/ReboundAbility.java @@ -37,6 +37,7 @@ import mage.abilities.DelayedTriggeredAbility; import mage.abilities.SpellAbility; import mage.abilities.TriggeredAbilityImpl; import mage.abilities.condition.common.MyTurnCondition; +import mage.abilities.effects.Effect; import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.ReplacementEffectImpl; import mage.cards.Card; @@ -105,7 +106,16 @@ public class ReboundAbility extends TriggeredAbilityImpl { if (event.getType() == EventType.SPELL_CAST && this.installReboundEffect) { Spell spell = game.getStack().getSpell(event.getTargetId()); if (spell != null && spell.getSourceId().equals(this.getSourceId())) { - spell.getSpellAbility().addEffect(new ReboundEffect()); + Effect reboundEffect = new ReboundEffect(); + boolean found = false; + for (Effect effect : spell.getSpellAbility().getEffects()) + if (effect instanceof ReboundEffect) { + found = true; + break; + } + if (!found) { + spell.getSpellAbility().addEffect(reboundEffect); + } this.installReboundEffect = false; } } diff --git a/Mage/src/mage/players/Player.java b/Mage/src/mage/players/Player.java index d1f39fcb814..4ceeda99bc4 100644 --- a/Mage/src/mage/players/Player.java +++ b/Mage/src/mage/players/Player.java @@ -71,6 +71,7 @@ public interface Player extends MageItem, Copyable { public String getName(); public RangeOfInfluence getRange(); public Library getLibrary(); + public Cards getSideboard(); public Cards getGraveyard(); public Abilities getAbilities(); public void addAbility(Ability ability); diff --git a/Mage/src/mage/players/PlayerImpl.java b/Mage/src/mage/players/PlayerImpl.java index 409e0286389..8b166504ae7 100644 --- a/Mage/src/mage/players/PlayerImpl.java +++ b/Mage/src/mage/players/PlayerImpl.java @@ -87,6 +87,7 @@ public abstract class PlayerImpl> implements Player, Ser protected boolean wins; protected boolean loses; protected Library library; + protected Cards sideboard; protected Cards hand; protected Cards graveyard; protected Abilities abilities; @@ -134,6 +135,7 @@ public abstract class PlayerImpl> implements Player, Ser counters = new Counters(); manaPool = new ManaPool(); library = new Library(playerId); + sideboard = new CardsImpl(Zone.OUTSIDE); } protected PlayerImpl(UUID id) { @@ -149,6 +151,7 @@ public abstract class PlayerImpl> implements Player, Ser this.wins = player.wins; this.loses = player.loses; this.library = player.library.copy(); + this.sideboard = player.sideboard.copy(); this.hand = player.hand.copy(); this.graveyard = player.graveyard.copy(); this.abilities = player.abilities.copy(); @@ -176,6 +179,10 @@ public abstract class PlayerImpl> implements Player, Ser public void useDeck(Deck deck, Game game) { library.clear(); library.addAll(deck.getCards(), game); + sideboard.clear(); + for (Card card : deck.getSideboard()) { + sideboard.add(card); + } } @Override @@ -796,6 +803,11 @@ public abstract class PlayerImpl> implements Player, Ser return library; } + @Override + public Cards getSideboard() { + return sideboard; + } + @Override public int getLife() { return life;