mirror of
https://github.com/magefree/mage.git
synced 2025-12-29 23:12:10 -08:00
Initial
This commit is contained in:
parent
a4ecfa58fa
commit
ca44bbedfc
23 changed files with 2221 additions and 0 deletions
45
Mage.Common/src/mage/interfaces/ChatClient.java
Normal file
45
Mage.Common/src/mage/interfaces/ChatClient.java
Normal file
|
|
@ -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;
|
||||
|
||||
}
|
||||
48
Mage.Common/src/mage/interfaces/Client.java
Normal file
48
Mage.Common/src/mage/interfaces/Client.java
Normal file
|
|
@ -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;
|
||||
|
||||
}
|
||||
58
Mage.Common/src/mage/interfaces/GameClient.java
Normal file
58
Mage.Common/src/mage/interfaces/GameClient.java
Normal file
|
|
@ -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;
|
||||
}
|
||||
48
Mage.Common/src/mage/interfaces/GameReplayClient.java
Normal file
48
Mage.Common/src/mage/interfaces/GameReplayClient.java
Normal file
|
|
@ -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;
|
||||
|
||||
}
|
||||
41
Mage.Common/src/mage/interfaces/MageException.java
Normal file
41
Mage.Common/src/mage/interfaces/MageException.java
Normal file
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
95
Mage.Common/src/mage/interfaces/Server.java
Normal file
95
Mage.Common/src/mage/interfaces/Server.java
Normal file
|
|
@ -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<String> 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<TableView> 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;
|
||||
|
||||
}
|
||||
55
Mage.Common/src/mage/view/AbilityPickerView.java
Normal file
55
Mage.Common/src/mage/view/AbilityPickerView.java
Normal file
|
|
@ -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<UUID, String> choices = new HashMap<UUID, String>();
|
||||
|
||||
public AbilityPickerView(Collection<? extends ActivatedAbility> abilities) {
|
||||
for (ActivatedAbility ability: abilities) {
|
||||
choices.put(ability.getId(), ability.getRule());
|
||||
}
|
||||
}
|
||||
|
||||
public Map<UUID, String> getChoices() {
|
||||
return choices;
|
||||
}
|
||||
}
|
||||
146
Mage.Common/src/mage/view/CardView.java
Normal file
146
Mage.Common/src/mage/view/CardView.java
Normal file
|
|
@ -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<String> rules;
|
||||
protected String power;
|
||||
protected String toughness;
|
||||
protected String loyalty;
|
||||
protected List<CardType> cardTypes;
|
||||
protected List<String> subTypes;
|
||||
protected List<String> superTypes;
|
||||
protected ObjectColor color;
|
||||
protected List<String> 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<String> formatRules(List<String> rules) {
|
||||
List<String> newRules = new ArrayList<String>();
|
||||
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<String> getRules() {
|
||||
return rules;
|
||||
}
|
||||
|
||||
public String getPower() {
|
||||
return power;
|
||||
}
|
||||
|
||||
public String getToughness() {
|
||||
return toughness;
|
||||
}
|
||||
|
||||
public String getLoyalty() {
|
||||
return loyalty;
|
||||
}
|
||||
|
||||
public List<CardType> getCardTypes() {
|
||||
return cardTypes;
|
||||
}
|
||||
|
||||
public List<String> getSubTypes() {
|
||||
return subTypes;
|
||||
}
|
||||
|
||||
public List<String> getSuperTypes() {
|
||||
return superTypes;
|
||||
}
|
||||
|
||||
public ObjectColor getColor() {
|
||||
return color;
|
||||
}
|
||||
|
||||
public List<String> getManaCost() {
|
||||
return manaCost;
|
||||
}
|
||||
|
||||
public String getArt() {
|
||||
return art;
|
||||
}
|
||||
|
||||
public UUID getId() {
|
||||
return id;
|
||||
}
|
||||
}
|
||||
57
Mage.Common/src/mage/view/CardsView.java
Normal file
57
Mage.Common/src/mage/view/CardsView.java
Normal file
|
|
@ -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<CardView> {
|
||||
|
||||
|
||||
public CardsView() {}
|
||||
|
||||
public CardsView(Collection<Card> cards) {
|
||||
for (Card card: cards) {
|
||||
this.add(new CardView(card));
|
||||
}
|
||||
}
|
||||
|
||||
public CardsView(Cards cards) {
|
||||
for (Card card: cards.values()) {
|
||||
this.add(new CardView(card));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
76
Mage.Common/src/mage/view/CombatGroupView.java
Normal file
76
Mage.Common/src/mage/view/CombatGroupView.java
Normal file
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
60
Mage.Common/src/mage/view/ExileView.java
Normal file
60
Mage.Common/src/mage/view/ExileView.java
Normal file
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
131
Mage.Common/src/mage/view/GameView.java
Normal file
131
Mage.Common/src/mage/view/GameView.java
Normal file
|
|
@ -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<PlayerView> players = new ArrayList<PlayerView>();
|
||||
private CardsView hand;
|
||||
private CardsView stack = new CardsView();
|
||||
private List<ExileView> exiles = new ArrayList<ExileView>();
|
||||
private List<CombatGroupView> combat = new ArrayList<CombatGroupView>();
|
||||
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<PlayerView> 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<ExileView> getExile() {
|
||||
return exiles;
|
||||
}
|
||||
|
||||
public List<CombatGroupView> getCombat() {
|
||||
return combat;
|
||||
}
|
||||
|
||||
public int getTurn() {
|
||||
return this.turn;
|
||||
}
|
||||
|
||||
public String getActivePlayerName() {
|
||||
return activePlayerName;
|
||||
}
|
||||
|
||||
public String getPriorityPlayerName() {
|
||||
return priorityPlayerName;
|
||||
}
|
||||
}
|
||||
81
Mage.Common/src/mage/view/ManaPoolView.java
Normal file
81
Mage.Common/src/mage/view/ManaPoolView.java
Normal file
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
86
Mage.Common/src/mage/view/PermanentView.java
Normal file
86
Mage.Common/src/mage/view/PermanentView.java
Normal file
|
|
@ -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<UUID> 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<UUID>();
|
||||
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<UUID> getAttachments() {
|
||||
return attachments;
|
||||
}
|
||||
}
|
||||
103
Mage.Common/src/mage/view/PlayerView.java
Normal file
103
Mage.Common/src/mage/view/PlayerView.java
Normal file
|
|
@ -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<UUID, PermanentView> battlefield = new HashMap<UUID, PermanentView>();
|
||||
|
||||
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<UUID, PermanentView> getBattlefield() {
|
||||
return battlefield;
|
||||
}
|
||||
|
||||
public UUID getPlayerId() {
|
||||
return playerId;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
}
|
||||
65
Mage.Common/src/mage/view/SeatView.java
Normal file
65
Mage.Common/src/mage/view/SeatView.java
Normal file
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
66
Mage.Common/src/mage/view/StackAbilityView.java
Normal file
66
Mage.Common/src/mage/view/StackAbilityView.java
Normal file
|
|
@ -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<String>();
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
83
Mage.Common/src/mage/view/TableView.java
Normal file
83
Mage.Common/src/mage/view/TableView.java
Normal file
|
|
@ -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<SeatView> seats = new ArrayList<SeatView>();
|
||||
|
||||
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<SeatView> getSeats() {
|
||||
return seats;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue