From ca44bbedfcd4eb99e594edf4abde5d94f588b7d7 Mon Sep 17 00:00:00 2001 From: BetaSteward Date: Sat, 20 Mar 2010 03:06:01 +0000 Subject: [PATCH] Initial --- Mage.Common/build.xml | 74 ++ Mage.Common/nbproject/build-impl.xml | 704 ++++++++++++++++++ Mage.Common/nbproject/genfiles.properties | 8 + Mage.Common/nbproject/project.properties | 66 ++ Mage.Common/nbproject/project.xml | 25 + .../src/mage/interfaces/ChatClient.java | 45 ++ Mage.Common/src/mage/interfaces/Client.java | 48 ++ .../src/mage/interfaces/GameClient.java | 58 ++ .../src/mage/interfaces/GameReplayClient.java | 48 ++ .../src/mage/interfaces/MageException.java | 41 + Mage.Common/src/mage/interfaces/Server.java | 95 +++ .../src/mage/view/AbilityPickerView.java | 55 ++ Mage.Common/src/mage/view/CardView.java | 146 ++++ Mage.Common/src/mage/view/CardsView.java | 57 ++ .../src/mage/view/CombatGroupView.java | 76 ++ Mage.Common/src/mage/view/ExileView.java | 60 ++ Mage.Common/src/mage/view/GameView.java | 131 ++++ Mage.Common/src/mage/view/ManaPoolView.java | 81 ++ Mage.Common/src/mage/view/PermanentView.java | 86 +++ Mage.Common/src/mage/view/PlayerView.java | 103 +++ Mage.Common/src/mage/view/SeatView.java | 65 ++ .../src/mage/view/StackAbilityView.java | 66 ++ Mage.Common/src/mage/view/TableView.java | 83 +++ 23 files changed, 2221 insertions(+) create mode 100644 Mage.Common/build.xml create mode 100644 Mage.Common/nbproject/build-impl.xml create mode 100644 Mage.Common/nbproject/genfiles.properties create mode 100644 Mage.Common/nbproject/project.properties create mode 100644 Mage.Common/nbproject/project.xml create mode 100644 Mage.Common/src/mage/interfaces/ChatClient.java create mode 100644 Mage.Common/src/mage/interfaces/Client.java create mode 100644 Mage.Common/src/mage/interfaces/GameClient.java create mode 100644 Mage.Common/src/mage/interfaces/GameReplayClient.java create mode 100644 Mage.Common/src/mage/interfaces/MageException.java create mode 100644 Mage.Common/src/mage/interfaces/Server.java create mode 100644 Mage.Common/src/mage/view/AbilityPickerView.java create mode 100644 Mage.Common/src/mage/view/CardView.java create mode 100644 Mage.Common/src/mage/view/CardsView.java create mode 100644 Mage.Common/src/mage/view/CombatGroupView.java create mode 100644 Mage.Common/src/mage/view/ExileView.java create mode 100644 Mage.Common/src/mage/view/GameView.java create mode 100644 Mage.Common/src/mage/view/ManaPoolView.java create mode 100644 Mage.Common/src/mage/view/PermanentView.java create mode 100644 Mage.Common/src/mage/view/PlayerView.java create mode 100644 Mage.Common/src/mage/view/SeatView.java create mode 100644 Mage.Common/src/mage/view/StackAbilityView.java create mode 100644 Mage.Common/src/mage/view/TableView.java diff --git a/Mage.Common/build.xml b/Mage.Common/build.xml new file mode 100644 index 00000000000..0fc63e1666b --- /dev/null +++ b/Mage.Common/build.xml @@ -0,0 +1,74 @@ + + + + + + + + + + + Builds, tests, and runs the project Mage.Common. + + + diff --git a/Mage.Common/nbproject/build-impl.xml b/Mage.Common/nbproject/build-impl.xml new file mode 100644 index 00000000000..7cfeb779aca --- /dev/null +++ b/Mage.Common/nbproject/build-impl.xml @@ -0,0 +1,704 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set src.dir + Must set test.src.dir + Must set build.dir + Must set dist.dir + Must set build.classes.dir + Must set dist.javadoc.dir + Must set build.test.classes.dir + Must set build.test.results.dir + Must set build.classes.excludes + Must set dist.jar + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + To run this application from the command line without Ant, try: + + + + + + + java -cp "${run.classpath.with.dist.jar}" ${main.class} + + + + + + + + + + + + + + + + + + + + + + + To run this application from the command line without Ant, try: + + java -jar "${dist.jar.resolved}" + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set run.class + + + + Must select one file in the IDE or set run.class + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set debug.class + + + + + Must select one file in the IDE or set debug.class + + + + + Must set fix.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + + + + + Some tests failed; see details above. + + + + + + + + + Must select some files in the IDE or set test.includes + + + + Some tests failed; see details above. + + + + + Must select one file in the IDE or set test.class + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + + + + + + + + + + + + + diff --git a/Mage.Common/nbproject/genfiles.properties b/Mage.Common/nbproject/genfiles.properties new file mode 100644 index 00000000000..310fc88fdc1 --- /dev/null +++ b/Mage.Common/nbproject/genfiles.properties @@ -0,0 +1,8 @@ +build.xml.data.CRC32=4a867bf3 +build.xml.script.CRC32=694651d3 +build.xml.stylesheet.CRC32=958a1d3e@1.26.2.45 +# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. +# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. +nbproject/build-impl.xml.data.CRC32=4a867bf3 +nbproject/build-impl.xml.script.CRC32=75dacc91 +nbproject/build-impl.xml.stylesheet.CRC32=5c621a33@1.26.2.45 diff --git a/Mage.Common/nbproject/project.properties b/Mage.Common/nbproject/project.properties new file mode 100644 index 00000000000..c52e0e61ba8 --- /dev/null +++ b/Mage.Common/nbproject/project.properties @@ -0,0 +1,66 @@ +application.title=Mage.Common +application.vendor=BetaSteward_at_googlemail.com +build.classes.dir=${build.dir}/classes +build.classes.excludes=**/*.java,**/*.form +# This directory is removed when the project is cleaned: +build.dir=build +build.generated.dir=${build.dir}/generated +build.generated.sources.dir=${build.dir}/generated-sources +# Only compile against the classpath explicitly listed here: +build.sysclasspath=ignore +build.test.classes.dir=${build.dir}/test/classes +build.test.results.dir=${build.dir}/test/results +# Uncomment to specify the preferred debugger connection transport: +#debug.transport=dt_socket +debug.classpath=\ + ${run.classpath} +debug.test.classpath=\ + ${run.test.classpath} +# This directory is removed when the project is cleaned: +dist.dir=dist +dist.jar=${dist.dir}/Mage.Common.jar +dist.javadoc.dir=${dist.dir}/javadoc +excludes= +includes=** +jar.compress=false +javac.classpath=\ + ${reference.Mage.jar} +# Space-separated list of extra javac options +javac.compilerargs= +javac.deprecation=false +javac.source=1.6 +javac.target=1.6 +javac.test.classpath=\ + ${javac.classpath}:\ + ${build.classes.dir}:\ + ${libs.junit.classpath}:\ + ${libs.junit_4.classpath} +javadoc.additionalparam= +javadoc.author=false +javadoc.encoding=${source.encoding} +javadoc.noindex=false +javadoc.nonavbar=false +javadoc.notree=false +javadoc.private=false +javadoc.splitindex=true +javadoc.use=true +javadoc.version=false +javadoc.windowtitle= +meta.inf.dir=${src.dir}/META-INF +platform.active=default_platform +project.license=bsd +project.Mage=../Mage +reference.Mage.jar=${project.Mage}/dist/Mage.jar +run.classpath=\ + ${javac.classpath}:\ + ${build.classes.dir} +# Space-separated list of JVM arguments used when running the project +# (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value +# or test-sys-prop.name=value to set system properties for unit tests): +run.jvmargs= +run.test.classpath=\ + ${javac.test.classpath}:\ + ${build.test.classes.dir} +source.encoding=UTF-8 +src.dir=src +test.src.dir=test diff --git a/Mage.Common/nbproject/project.xml b/Mage.Common/nbproject/project.xml new file mode 100644 index 00000000000..db504036416 --- /dev/null +++ b/Mage.Common/nbproject/project.xml @@ -0,0 +1,25 @@ + + + org.netbeans.modules.java.j2seproject + + + Mage.Common + + + + + + + + + + Mage + jar + + jar + clean + jar + + + + diff --git a/Mage.Common/src/mage/interfaces/ChatClient.java b/Mage.Common/src/mage/interfaces/ChatClient.java new file mode 100644 index 00000000000..a99cd0925ed --- /dev/null +++ b/Mage.Common/src/mage/interfaces/ChatClient.java @@ -0,0 +1,45 @@ +/* +* 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.interfaces; + +import java.rmi.Remote; +import java.rmi.RemoteException; +import java.util.UUID; + +/** + * + * @author BetaSteward_at_googlemail.com + */ +public interface ChatClient extends Remote { + + public void receiveMessage(String message) throws RemoteException; + public String getName() throws RemoteException; + public UUID getId() throws RemoteException; + +} diff --git a/Mage.Common/src/mage/interfaces/Client.java b/Mage.Common/src/mage/interfaces/Client.java new file mode 100644 index 00000000000..e5f2b4cca1b --- /dev/null +++ b/Mage.Common/src/mage/interfaces/Client.java @@ -0,0 +1,48 @@ +/* +* 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.interfaces; + +import java.rmi.Remote; +import java.rmi.RemoteException; +import java.util.UUID; + +/** + * + * @author BetaSteward_at_googlemail.com + */ +public interface Client extends Remote { + + public UUID getId() throws RemoteException; + public UUID getPlayerId() throws RemoteException; + public void gameStarted(UUID gameId, UUID playerId) throws RemoteException; + public String getUserName() throws RemoteException; + public void watchGame(UUID gameId) throws RemoteException; + public void replayGame(UUID gameId) throws RemoteException; + +} diff --git a/Mage.Common/src/mage/interfaces/GameClient.java b/Mage.Common/src/mage/interfaces/GameClient.java new file mode 100644 index 00000000000..bc543c64d58 --- /dev/null +++ b/Mage.Common/src/mage/interfaces/GameClient.java @@ -0,0 +1,58 @@ +/* +* 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.interfaces; + +import java.rmi.Remote; +import java.rmi.RemoteException; +import java.util.UUID; +import mage.view.AbilityPickerView; +import mage.view.CardsView; +import mage.view.GameView; + +/** + * + * @author BetaSteward_at_googlemail.com + */ +public interface GameClient extends Remote { + + public UUID getId() throws RemoteException; + public void update(GameView gameView) throws RemoteException; + public void init(GameView gameView) throws RemoteException; + public void ask(String question, GameView gameView) throws RemoteException; + public void inform(String message, GameView gameView) throws RemoteException; + public void target(String message, CardsView cardView, boolean required, GameView gameView) throws RemoteException; + public void gameOver(String message) throws RemoteException; + public void select(String message, GameView gameView) throws RemoteException; + public void playMana(String message, GameView gameView) throws RemoteException; + public void playXMana(String message, GameView gameView) throws RemoteException; + public void chooseAbility(AbilityPickerView abilityView) throws RemoteException; + public void choose(String message, String[] choices) throws RemoteException; + public void revealCards(String name, CardsView cards) throws RemoteException; + public void getAmount(int min, int max) throws RemoteException; +} diff --git a/Mage.Common/src/mage/interfaces/GameReplayClient.java b/Mage.Common/src/mage/interfaces/GameReplayClient.java new file mode 100644 index 00000000000..798c979fdb1 --- /dev/null +++ b/Mage.Common/src/mage/interfaces/GameReplayClient.java @@ -0,0 +1,48 @@ +/* +* 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.interfaces; + +import java.rmi.Remote; +import java.rmi.RemoteException; +import java.util.UUID; +import mage.view.GameView; + +/** + * + * @author BetaSteward_at_googlemail.com + */ +public interface GameReplayClient extends Remote { + + public UUID getId() throws RemoteException; + public void update(GameView game) throws RemoteException; + public void init(GameView gameView) throws RemoteException; + public void gameOver(String message) throws RemoteException; + public void message(String message) throws RemoteException; + +} diff --git a/Mage.Common/src/mage/interfaces/MageException.java b/Mage.Common/src/mage/interfaces/MageException.java new file mode 100644 index 00000000000..47b0914e207 --- /dev/null +++ b/Mage.Common/src/mage/interfaces/MageException.java @@ -0,0 +1,41 @@ +/* +* 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.interfaces; + +/** + * + * @author BetaSteward_at_googlemail.com + */ +public class MageException extends Exception { + + public MageException(String message) { + super(message); + } + +} diff --git a/Mage.Common/src/mage/interfaces/Server.java b/Mage.Common/src/mage/interfaces/Server.java new file mode 100644 index 00000000000..44413a4d3f9 --- /dev/null +++ b/Mage.Common/src/mage/interfaces/Server.java @@ -0,0 +1,95 @@ +/* +* 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.interfaces; + +import java.rmi.Remote; +import java.rmi.RemoteException; +import java.rmi.AccessException; +import java.util.Collection; +import java.util.List; +import java.util.UUID; +import mage.Constants.DeckType; +import mage.cards.decks.DeckCardLists; +import mage.view.TableView; + +/** + * + * @author BetaSteward_at_googlemail.com + */ +public interface Server extends Remote { + + public UUID registerClient(Client c) throws RemoteException, MageException; + public void deregisterClient(UUID sessionId) throws RemoteException, MageException; + + public String[] getGameTypes() throws RemoteException, MageException; + public String[] getPlayerTypes() throws RemoteException, MageException; + + //table methods + public TableView createTable(UUID sessionId, UUID roomId, String gameType, DeckType deckType, List playerTypes) throws RemoteException, MageException; + public boolean joinTable(UUID sessionId, UUID roomId, UUID tableId, int seatNum, String name, DeckCardLists deckList) throws RemoteException, MageException; + public boolean watchTable(UUID sessionId, UUID roomId, UUID tableId) throws RemoteException, MageException; + public boolean replayTable(UUID sessionId, UUID roomId, UUID tableId) throws RemoteException, MageException; + public void leaveTable(UUID sessionId, UUID roomId, UUID tableId) throws RemoteException, MageException; + public void removeTable(UUID sessionId, UUID roomId, UUID tableId) throws RemoteException, MageException; + public boolean isTableOwner(UUID sessionId, UUID roomId, UUID tableId) throws RemoteException, MageException; + public TableView getTable(UUID roomId, UUID tableId) throws RemoteException, MageException; + public Collection getTables(UUID roomId) throws RemoteException, MageException; + + //chat methods + public void sendChatMessage(UUID chatId, String userName, String message) throws RemoteException, MageException; + public void joinChat(UUID chatId, ChatClient chatClient) throws RemoteException, MageException; + public void leaveChat(UUID chatId, UUID clientId) throws RemoteException, MageException; + public UUID getTableChatId(UUID tableId) throws RemoteException, MageException; + public UUID getGameChatId(UUID gameId) throws RemoteException, MageException; + public UUID getRoomChatId(UUID roomId) throws RemoteException, MageException; + + //room methods + public UUID getMainRoomId() throws RemoteException, MageException; + + //game methods + public void startGame(UUID sessionId, UUID roomId, UUID tableId) throws RemoteException, MageException; + public void joinGame(UUID gameId, UUID sessionId, GameClient gameClient) throws RemoteException, MageException; + public void watchGame(UUID gameId, UUID sessionId, GameClient gameClient) throws RemoteException, MageException; + public void stopWatching(UUID gameId, UUID clientId) throws RemoteException, MageException; + public void sendPlayerUUID(UUID gameId, UUID sessionId, UUID data) throws RemoteException, MageException; + public void sendPlayerString(UUID gameId, UUID sessionId, String data) throws RemoteException, MageException; + public void sendPlayerBoolean(UUID gameId, UUID sessionId, Boolean data) throws RemoteException, MageException; + public void sendPlayerInteger(UUID gameId, UUID sessionId, Integer data) throws RemoteException, MageException; + public void concedeGame(UUID gameId, UUID sessionId) throws RemoteException, MageException; + + //replay methods + public void replayGame(UUID gameId, UUID sessionId, GameReplayClient replayClient) throws RemoteException, MageException; + public void stopReplay(UUID sessionId) throws RemoteException, MageException; + public void nextPlay(UUID sessionId) throws RemoteException, MageException; + public void previousPlay(UUID sessionId) throws RemoteException, MageException; + + //test methods + public void cheat(UUID gameId, UUID sessionId, DeckCardLists deckList) throws RemoteException, MageException; + +} diff --git a/Mage.Common/src/mage/view/AbilityPickerView.java b/Mage.Common/src/mage/view/AbilityPickerView.java new file mode 100644 index 00000000000..353d5f4f4d9 --- /dev/null +++ b/Mage.Common/src/mage/view/AbilityPickerView.java @@ -0,0 +1,55 @@ +/* +* 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.view; + +import java.io.Serializable; +import java.util.Collection; +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; +import mage.abilities.ActivatedAbility; + +/** + * + * @author BetaSteward_at_googlemail.com + */ +public class AbilityPickerView implements Serializable { + + private Map choices = new HashMap(); + + public AbilityPickerView(Collection abilities) { + for (ActivatedAbility ability: abilities) { + choices.put(ability.getId(), ability.getRule()); + } + } + + public Map getChoices() { + return choices; + } +} diff --git a/Mage.Common/src/mage/view/CardView.java b/Mage.Common/src/mage/view/CardView.java new file mode 100644 index 00000000000..a013dda9b7c --- /dev/null +++ b/Mage.Common/src/mage/view/CardView.java @@ -0,0 +1,146 @@ +/* +* 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.view; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; +import mage.Constants.CardType; +import mage.ObjectColor; +import mage.abilities.costs.mana.ManaCosts; +import mage.cards.Card; +import mage.game.permanent.Permanent; + +/** + * + * @author BetaSteward_at_googlemail.com + */ +public class CardView implements Serializable { + + protected UUID id; + protected String name; + protected List rules; + protected String power; + protected String toughness; + protected String loyalty; + protected List cardTypes; + protected List subTypes; + protected List superTypes; + protected ObjectColor color; + protected List manaCost; + protected String art; + + public CardView(Card card) { + this.id = card.getId(); + this.name = card.getName(); + this.rules = formatRules(card.getRules()); + if (card instanceof Permanent) { + this.power = Integer.toString(card.getPower().getValue()); + this.toughness = Integer.toString(card.getToughness().getValue()); + this.loyalty = Integer.toString(card.getLoyalty().getValue()); + } else { + this.power = card.getPower().toString(); + this.toughness = card.getToughness().toString(); + this.loyalty = card.getLoyalty().toString(); + } + this.cardTypes = card.getCardType(); + this.subTypes = card.getSubtype(); + this.superTypes = card.getSupertype(); + this.color = card.getColor(); + this.manaCost = card.getManaCost().getSymbols(); + this.art = card.getArt(); + } + + protected CardView() { + + } + + protected List formatRules(List rules) { + List newRules = new ArrayList(); + for (String rule: rules) { + newRules.add(formatRule(rule)); + } + return newRules; + } + + protected String formatRule(String rule) { + String replace = rule.replace("{this}", this.name); + replace = replace.replace("{source}", this.name); + return replace; + } + + public String getName() { + return name; + } + + public List getRules() { + return rules; + } + + public String getPower() { + return power; + } + + public String getToughness() { + return toughness; + } + + public String getLoyalty() { + return loyalty; + } + + public List getCardTypes() { + return cardTypes; + } + + public List getSubTypes() { + return subTypes; + } + + public List getSuperTypes() { + return superTypes; + } + + public ObjectColor getColor() { + return color; + } + + public List getManaCost() { + return manaCost; + } + + public String getArt() { + return art; + } + + public UUID getId() { + return id; + } +} diff --git a/Mage.Common/src/mage/view/CardsView.java b/Mage.Common/src/mage/view/CardsView.java new file mode 100644 index 00000000000..5d7d5d5f4d3 --- /dev/null +++ b/Mage.Common/src/mage/view/CardsView.java @@ -0,0 +1,57 @@ +/* +* 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.view; + +import java.util.ArrayList; +import java.util.Collection; +import mage.cards.Card; +import mage.cards.Cards; + +/** + * + * @author BetaSteward_at_googlemail.com + */ +public class CardsView extends ArrayList { + + + public CardsView() {} + + public CardsView(Collection cards) { + for (Card card: cards) { + this.add(new CardView(card)); + } + } + + public CardsView(Cards cards) { + for (Card card: cards.values()) { + this.add(new CardView(card)); + } + } + +} diff --git a/Mage.Common/src/mage/view/CombatGroupView.java b/Mage.Common/src/mage/view/CombatGroupView.java new file mode 100644 index 00000000000..92675ea9119 --- /dev/null +++ b/Mage.Common/src/mage/view/CombatGroupView.java @@ -0,0 +1,76 @@ +/* +* 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.view; + +import java.io.Serializable; +import java.util.UUID; +import mage.game.GameState; +import mage.game.combat.CombatGroup; +import mage.game.permanent.Permanent; +import mage.players.Player; + +/** + * + * @author BetaSteward_at_googlemail.com + */ +public class CombatGroupView implements Serializable { + + private CardsView attackers = new CardsView(); + private CardsView blockers = new CardsView(); + private String defenderName; + + public CombatGroupView(CombatGroup combatGroup, GameState game) { + Player player = game.getPlayer(combatGroup.getDefenderId()); + if (player != null) { + this.defenderName = player.getName(); + } + else { + Permanent perm = game.getPermanent(combatGroup.getDefenderId()); + this.defenderName = perm.getName(); + } + for (UUID id: combatGroup.getAttackers()) { + attackers.add(new PermanentView(game.getPermanent(id))); + } + for (UUID id: combatGroup.getBlockers()) { + blockers.add(new PermanentView(game.getPermanent(id))); + } + } + + public String getDefenderName() { + return defenderName; + } + + public CardsView getAttackers() { + return attackers; + } + + public CardsView getBlockers() { + return blockers; + } +} diff --git a/Mage.Common/src/mage/view/ExileView.java b/Mage.Common/src/mage/view/ExileView.java new file mode 100644 index 00000000000..8497af06f17 --- /dev/null +++ b/Mage.Common/src/mage/view/ExileView.java @@ -0,0 +1,60 @@ +/* +* 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.view; + +import java.util.UUID; +import mage.cards.Card; +import mage.game.ExileZone; + +/** + * + * @author BetaSteward_at_googlemail.com + */ +public class ExileView extends CardsView { + + private String name; + private UUID id; + + public ExileView(ExileZone exileZone) { + this.name = exileZone.getName(); + this.id = exileZone.getId(); + for (Card card: exileZone.values()) { + this.add(new CardView(card)); + } + } + + public String getName() { + return name; + } + + public UUID getId() { + return id; + } + +} diff --git a/Mage.Common/src/mage/view/GameView.java b/Mage.Common/src/mage/view/GameView.java new file mode 100644 index 00000000000..f98ea7512a4 --- /dev/null +++ b/Mage.Common/src/mage/view/GameView.java @@ -0,0 +1,131 @@ +/* +* 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.view; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; +import mage.Constants.PhaseStep; +import mage.Constants.TurnPhase; +import mage.game.ExileZone; +import mage.game.GameState; +import mage.game.combat.CombatGroup; +import mage.game.stack.Spell; +import mage.game.stack.StackAbility; +import mage.game.stack.StackObject; +import mage.players.Player; + +/** + * + * @author BetaSteward_at_googlemail.com + */ +public class GameView implements Serializable { + + private List players = new ArrayList(); + private CardsView hand; + private CardsView stack = new CardsView(); + private List exiles = new ArrayList(); + private List combat = new ArrayList(); + private TurnPhase phase; + private PhaseStep step; + private String activePlayerName = ""; + private String priorityPlayerName = ""; + private int turn; + + public GameView(GameState game) { + for (Player player: game.getPlayers().values()) { + players.add(new PlayerView(player, game)); + } + for (StackObject stackObject: game.getStack()) { + if (stackObject instanceof StackAbility) { + stack.add(new StackAbilityView((StackAbility)stackObject, game.getObject(stackObject.getSourceId()).getName())); + } + else { + stack.add(new CardView((Spell)stackObject)); + } + } + for (ExileZone exileZone: game.getExile().getExileZones()) { + exiles.add(new ExileView(exileZone)); + } + this.phase = game.getPhase(); + this.step = game.getStep(); + this.turn = game.getTurnNum(); + if (game.getTurn().getActivePlayerId() != null) + this.activePlayerName = game.getPlayer(game.getTurn().getActivePlayerId()).getName(); + if (game.getTurn().getPriorityPlayerId() != null) + this.priorityPlayerName = game.getPlayer(game.getTurn().getPriorityPlayerId()).getName(); + for (CombatGroup combatGroup: game.getCombat().getGroups()) { + combat.add(new CombatGroupView(combatGroup, game)); + } + } + + public List getPlayers() { + return players; + } + + public CardsView getHand() { + return hand; + } + + public void setHand(CardsView hand) { + this.hand = hand; + } + + public TurnPhase getPhase() { + return phase; + } + + public PhaseStep getStep() { + return step; + } + + public CardsView getStack() { + return stack; + } + + public List getExile() { + return exiles; + } + + public List getCombat() { + return combat; + } + + public int getTurn() { + return this.turn; + } + + public String getActivePlayerName() { + return activePlayerName; + } + + public String getPriorityPlayerName() { + return priorityPlayerName; + } +} diff --git a/Mage.Common/src/mage/view/ManaPoolView.java b/Mage.Common/src/mage/view/ManaPoolView.java new file mode 100644 index 00000000000..cc3b0ef7180 --- /dev/null +++ b/Mage.Common/src/mage/view/ManaPoolView.java @@ -0,0 +1,81 @@ +/* +* 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.view; + +import java.io.Serializable; +import mage.players.ManaPool; + +/** + * + * @author BetaSteward_at_googlemail.com + */ +public class ManaPoolView implements Serializable { + + private int red; + private int green; + private int blue; + private int white; + private int black; + private int colorless; + + public ManaPoolView(ManaPool pool) { + this.red = pool.getRed(); + this.green = pool.getGreen(); + this.blue = pool.getBlue(); + this.white = pool.getWhite(); + this.black = pool.getBlack(); + this.colorless = pool.getColorless(); + + } + + public int getRed() { + return red; + } + + public int getGreen() { + return green; + } + + public int getBlue() { + return blue; + } + + public int getWhite() { + return white; + } + + public int getBlack() { + return black; + } + + public int getColorless() { + return colorless; + } + +} diff --git a/Mage.Common/src/mage/view/PermanentView.java b/Mage.Common/src/mage/view/PermanentView.java new file mode 100644 index 00000000000..9cf715ccd29 --- /dev/null +++ b/Mage.Common/src/mage/view/PermanentView.java @@ -0,0 +1,86 @@ +/* +* 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.view; + +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; +import mage.game.GameState; +import mage.game.permanent.Permanent; + +/** + * + * @author BetaSteward_at_googlemail.com + */ +public class PermanentView extends CardView { + + private boolean tapped; + private boolean flipped; + private boolean phasedIn; + private boolean faceUp; + private int damage; + private List attachments; + + public PermanentView(Permanent permanent) { + super(permanent); + this.tapped = permanent.isTapped(); + this.flipped = permanent.isFlipped(); + this.phasedIn = permanent.isPhasedIn(); + this.faceUp = permanent.isFaceUp(); + this.damage = permanent.getDamage(); + if (permanent.getAttachments().size() > 0) { + attachments = new ArrayList(); + attachments.addAll(permanent.getAttachments()); + } + } + + public boolean isTapped() { + return tapped; + } + + public int getDamage() { + return damage; + } + + public boolean isFlipped() { + return flipped; + } + + public boolean isPhasedIn() { + return phasedIn; + } + + public boolean isFaceUp() { + return faceUp; + } + + public List getAttachments() { + return attachments; + } +} diff --git a/Mage.Common/src/mage/view/PlayerView.java b/Mage.Common/src/mage/view/PlayerView.java new file mode 100644 index 00000000000..09690986969 --- /dev/null +++ b/Mage.Common/src/mage/view/PlayerView.java @@ -0,0 +1,103 @@ +/* +* 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.view; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; +import mage.cards.Card; +import mage.game.GameState; +import mage.game.permanent.Permanent; +import mage.players.Player; + +/** + * + * @author BetaSteward_at_googlemail.com + */ +public class PlayerView implements Serializable { + + private UUID playerId; + private String name; + private int life; + private int libraryCount; + private int handCount; + private ManaPoolView manaPool; + private CardsView graveyard = new CardsView(); + private Map battlefield = new HashMap(); + + public PlayerView(Player player, GameState game) { + this.playerId = player.getId(); + this.name = player.getName(); + this.life = player.getLife(); + this.libraryCount = player.getLibrary().size(); + this.handCount = player.getHand().size(); + this.manaPool = new ManaPoolView(player.getManaPool()); + for (Card card: player.getGraveyard().values()) { + graveyard.add(new CardView(card)); + } + for (Permanent permanent: game.getBattlefield().getAllPermanents(player.getId())) { + PermanentView view = new PermanentView(permanent); + battlefield.put(view.getId(), view); + } + } + + public int getLife() { + return life; + } + + public int getLibraryCount() { + return libraryCount; + } + + public int getHandCount() { + return handCount; + } + + public ManaPoolView getManaPool() { + return manaPool; + } + + public CardsView getGraveyard() { + return graveyard; + } + + public Map getBattlefield() { + return battlefield; + } + + public UUID getPlayerId() { + return playerId; + } + + public String getName() { + return name; + } + +} diff --git a/Mage.Common/src/mage/view/SeatView.java b/Mage.Common/src/mage/view/SeatView.java new file mode 100644 index 00000000000..3834ead47b4 --- /dev/null +++ b/Mage.Common/src/mage/view/SeatView.java @@ -0,0 +1,65 @@ +/* +* 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.view; + +import java.io.Serializable; +import java.util.UUID; +import mage.game.Seat; + +/** + * + * @author BetaSteward_at_googlemail.com + */ +public class SeatView implements Serializable { + + private UUID playerId; + private String playerName; + private String playerType; + + public SeatView(Seat seat) { + if (seat.getPlayer() != null) { + this.playerId = seat.getPlayer().getId(); + this.playerName = seat.getPlayer().getName(); + this.playerType = seat.getPlayerType(); + } + } + + public UUID getPlayerId() { + return playerId; + } + + public String getPlayerName() { + return playerName; + } + + public String getPlayerType() { + return playerType; + } + +} diff --git a/Mage.Common/src/mage/view/StackAbilityView.java b/Mage.Common/src/mage/view/StackAbilityView.java new file mode 100644 index 00000000000..f273e4c9048 --- /dev/null +++ b/Mage.Common/src/mage/view/StackAbilityView.java @@ -0,0 +1,66 @@ +/* +* 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.view; + +import java.util.ArrayList; +import mage.game.stack.StackAbility; + +/** + * + * @author BetaSteward_at_googlemail.com + */ +public class StackAbilityView extends CardView { + + private String sourceName; + + public StackAbilityView(StackAbility ability, String sourceName) { + this.id = ability.getId(); + this.name = "Ability"; + this.sourceName = sourceName; + this.rules = new ArrayList(); + rules.add(formatRule(ability.getRule())); + this.power = ability.getPower().toString(); + this.toughness = ability.getToughness().toString(); + this.loyalty = ability.getLoyalty().toString(); + this.cardTypes = ability.getCardType(); + this.subTypes = ability.getSubtype(); + this.superTypes = ability.getSupertype(); + this.color = ability.getColor(); + this.manaCost = ability.getManaCost().getSymbols(); + this.art = ""; + } + + @Override + protected String formatRule(String rule) { + String newRule = rule.replace("{this}", this.name); + newRule.replace("{source}", this.sourceName); + return newRule; + } + +} diff --git a/Mage.Common/src/mage/view/TableView.java b/Mage.Common/src/mage/view/TableView.java new file mode 100644 index 00000000000..596e927f569 --- /dev/null +++ b/Mage.Common/src/mage/view/TableView.java @@ -0,0 +1,83 @@ +/* +* 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.view; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; +import mage.Constants.DeckType; +import mage.Constants.TableState; +import mage.game.Seat; +import mage.game.Table; + +/** + * + * @author BetaSteward_at_googlemail.com + */ +public class TableView implements Serializable { + + private UUID tableId; + private String gameType; + private DeckType deckType; + private TableState tableState; + private List seats = new ArrayList(); + + public TableView(Table table) { + this.tableId = table.getId(); + this.gameType = table.getGameType(); + this.deckType = table.getDeckType(); + this.tableState = table.getState(); + for (Seat seat: table.getSeats()) { + seats.add(new SeatView(seat)); + } + } + + public UUID getTableId() { + return tableId; + } + + public String getGameType() { + return gameType; + } + + public DeckType getDeckType() { + return deckType; + } + + public TableState getTableState() { + return tableState; + } + + public List getSeats() { + return seats; + } + + +}