From 4ac54673ee29a36929ee689308b8927643a2cffd Mon Sep 17 00:00:00 2001 From: Viserion Date: Sat, 14 May 2011 14:23:55 -0500 Subject: [PATCH] Beginning Command Zone / Emblem work --- Mage/src/mage/Constants.java | 2 +- Mage/src/mage/game/GameState.java | 6 ++ Mage/src/mage/game/command/Command.java | 56 +++++++++++++++++++ Mage/src/mage/game/command/CommandObject.java | 49 ++++++++++++++++ 4 files changed, 112 insertions(+), 1 deletion(-) create mode 100644 Mage/src/mage/game/command/Command.java create mode 100644 Mage/src/mage/game/command/CommandObject.java diff --git a/Mage/src/mage/Constants.java b/Mage/src/mage/Constants.java index 4108dccf7bf..df7a7122a05 100644 --- a/Mage/src/mage/Constants.java +++ b/Mage/src/mage/Constants.java @@ -341,7 +341,7 @@ public final class Constants { } public enum Zone { - HAND, GRAVEYARD, LIBRARY, BATTLEFIELD, STACK, EXILED, ALL, OUTSIDE, PICK; + HAND, GRAVEYARD, LIBRARY, BATTLEFIELD, STACK, EXILED, ALL, OUTSIDE, PICK, COMMAND; public boolean match(Zone zone) { if (this == zone || this == ALL || zone == ALL) diff --git a/Mage/src/mage/game/GameState.java b/Mage/src/mage/game/GameState.java index 8b368be23da..94c5d1a52e5 100644 --- a/Mage/src/mage/game/GameState.java +++ b/Mage/src/mage/game/GameState.java @@ -44,6 +44,7 @@ import mage.abilities.TriggeredAbilities; import mage.abilities.effects.ContinuousEffect; import mage.abilities.effects.ContinuousEffects; import mage.game.combat.Combat; +import mage.game.command.Command; import mage.game.events.GameEvent.EventType; import mage.game.events.ZoneChangeEvent; import mage.game.permanent.Battlefield; @@ -76,6 +77,7 @@ public class GameState implements Serializable, Copyable { private UUID priorityPlayerId; private Turn turn; private SpellStack stack; + private Command command; private Exile exile; private Revealed revealed; private Map lookedAt = new HashMap(); @@ -98,6 +100,7 @@ public class GameState implements Serializable, Copyable { playerList = new PlayerList(); turn = new Turn(); stack = new SpellStack(); + command = new Command(); exile = new Exile(); revealed = new Revealed(); lookedAt = new HashMap(); @@ -118,6 +121,7 @@ public class GameState implements Serializable, Copyable { this.priorityPlayerId = state.priorityPlayerId; this.turn = state.turn.copy(); this.stack = state.stack.copy(); + this.command = state.command.copy(); this.exile = state.exile.copy(); this.revealed = state.revealed.copy(); for (UUID key: state.lookedAt.keySet()) { @@ -314,6 +318,7 @@ public class GameState implements Serializable, Copyable { public void restore(GameState state) { this.stack = state.stack; + this.command = state.command; this.effects = state.effects; this.triggers = state.triggers; this.combat = state.combat; @@ -347,6 +352,7 @@ public class GameState implements Serializable, Copyable { } battlefield.checkTriggers(event, game); stack.checkTriggers(event, game); + command.checkTriggers(event, game); delayed.checkTriggers(event, game); exile.checkTriggers(event, game); } diff --git a/Mage/src/mage/game/command/Command.java b/Mage/src/mage/game/command/Command.java new file mode 100644 index 00000000000..11b4b7250e8 --- /dev/null +++ b/Mage/src/mage/game/command/Command.java @@ -0,0 +1,56 @@ +/* +* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without modification, are +* permitted provided that the following conditions are met: +* +* 1. Redistributions of source code must retain the above copyright notice, this list of +* conditions and the following disclaimer. +* +* 2. Redistributions in binary form must reproduce the above copyright notice, this list +* of conditions and the following disclaimer in the documentation and/or other materials +* provided with the distribution. +* +* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED +* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR +* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* The views and conclusions contained in the software and documentation are those of the +* authors and should not be interpreted as representing official policies, either expressed +* or implied, of BetaSteward_at_googlemail.com. +*/ + +package mage.game.command; + +import java.util.ArrayList; +import mage.game.Game; +import mage.game.events.GameEvent; + +/** + * + * @author Viserion + */ +public class Command extends ArrayList { + + public Command () {} + + public Command(final Command command) { + // + } + + public void checkTriggers(GameEvent event, Game game) { + for (CommandObject commandObject: this) { + commandObject.checkTriggers(event, game); + } + } + + public Command copy() { + return new Command(this); + } +} diff --git a/Mage/src/mage/game/command/CommandObject.java b/Mage/src/mage/game/command/CommandObject.java new file mode 100644 index 00000000000..c0d422ebeec --- /dev/null +++ b/Mage/src/mage/game/command/CommandObject.java @@ -0,0 +1,49 @@ +/* +* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without modification, are +* permitted provided that the following conditions are met: +* +* 1. Redistributions of source code must retain the above copyright notice, this list of +* conditions and the following disclaimer. +* +* 2. Redistributions in binary form must reproduce the above copyright notice, this list +* of conditions and the following disclaimer in the documentation and/or other materials +* provided with the distribution. +* +* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED +* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR +* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* The views and conclusions contained in the software and documentation are those of the +* authors and should not be interpreted as representing official policies, either expressed +* or implied, of BetaSteward_at_googlemail.com. +*/ + +package mage.game.command; + +import mage.game.*; +import java.util.UUID; +import mage.MageObject; +import mage.game.events.GameEvent; + +/** +* +* @author Viserion +*/ + +public interface CommandObject extends MageObject { + + public UUID getSourceId(); + public UUID getControllerId(); + public void checkTriggers(GameEvent event, Game game); + + @Override + public CommandObject copy(); +}