From 50e0a2c2a81731303deb9b6c75e62e996ad87093 Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Thu, 24 Oct 2013 10:12:31 +0200 Subject: [PATCH] Added boolean to deactivate legend rule. --- Mage/src/mage/game/GameImpl.java | 3 ++- Mage/src/mage/game/GameState.java | 18 +++++++++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/Mage/src/mage/game/GameImpl.java b/Mage/src/mage/game/GameImpl.java index 9fbb464a92..2e9a74b8f1 100644 --- a/Mage/src/mage/game/GameImpl.java +++ b/Mage/src/mage/game/GameImpl.java @@ -1327,7 +1327,7 @@ public abstract class GameImpl> implements Game, Serializa } } } - if (filterLegendary.match(perm, this)) { + if (this.getState().isLegendaryRuleActive() && filterLegendary.match(perm, this)) { legendary.add(perm); } if (filterEquipment.match(perm, this)) { @@ -1415,6 +1415,7 @@ public abstract class GameImpl> implements Game, Serializa // If a player controls two or more legendary permanents with the same name, that player // chooses one of them, and the rest are put into their owners' graveyards. // This is called the "legend rule." + if (legendary.size() > 1) { //don't bother checking if less than 2 legends in play for (Permanent legend: legendary) { FilterPermanent filterLegendName = new FilterPermanent(); diff --git a/Mage/src/mage/game/GameState.java b/Mage/src/mage/game/GameState.java index 3f64f41315..31439744dc 100644 --- a/Mage/src/mage/game/GameState.java +++ b/Mage/src/mage/game/GameState.java @@ -98,6 +98,7 @@ public class GameState implements Serializable, Copyable { private Battlefield battlefield; private int turnNum = 1; private boolean extraTurn = false; + private boolean legendaryRuleActive = true; private boolean gameOver; private boolean paused; private ContinuousEffects effects; @@ -144,6 +145,7 @@ public class GameState implements Serializable, Copyable { this.battlefield = state.battlefield.copy(); this.turnNum = state.turnNum; this.extraTurn = state.extraTurn; + this.legendaryRuleActive = state.legendaryRuleActive; this.gameOver = state.gameOver; this.effects = state.effects.copy(); for (TriggeredAbility trigger: state.triggered) { @@ -385,7 +387,7 @@ public class GameState implements Serializable, Copyable { } battlefield.reset(game); combat.reset(); - resetOtherAbilities(); + this.reset(); effects.apply(game); battlefield.fireControlChangeEvents(game); } @@ -621,6 +623,11 @@ public class GameState implements Serializable, Copyable { } } + private void reset() { + this.setLegendaryRuleActive(true); + this.resetOtherAbilities(); + } + public void clear() { battlefield.clear(); effects.clear(); @@ -634,6 +641,7 @@ public class GameState implements Serializable, Copyable { lookedAt.clear(); turnNum = 0; extraTurn = false; + legendaryRuleActive = true; gameOver = false; specialActions.clear(); otherAbilities.clear(); @@ -656,4 +664,12 @@ public class GameState implements Serializable, Copyable { return this.paused; } + public boolean isLegendaryRuleActive() { + return legendaryRuleActive; + } + + public void setLegendaryRuleActive(boolean legendaryRuleActive) { + this.legendaryRuleActive = legendaryRuleActive; + } + }