mirror of
https://github.com/correl/mage.git
synced 2025-01-12 19:25:44 +00:00
changes to support multiplayer
This commit is contained in:
parent
7d27c06329
commit
313ff97119
5 changed files with 123 additions and 13 deletions
|
@ -30,12 +30,14 @@ package mage.interfaces;
|
||||||
|
|
||||||
import java.rmi.Remote;
|
import java.rmi.Remote;
|
||||||
import java.rmi.RemoteException;
|
import java.rmi.RemoteException;
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import mage.Constants.MultiplayerAttackOption;
|
||||||
|
import mage.Constants.RangeOfInfluence;
|
||||||
import mage.cards.decks.DeckCardLists;
|
import mage.cards.decks.DeckCardLists;
|
||||||
import mage.game.GameException;
|
import mage.game.GameException;
|
||||||
import mage.interfaces.callback.CallbackServer;
|
import mage.interfaces.callback.CallbackServer;
|
||||||
|
import mage.view.GameTypeView;
|
||||||
import mage.view.TableView;
|
import mage.view.TableView;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -48,20 +50,21 @@ public interface Server extends Remote, CallbackServer {
|
||||||
public UUID registerClient(String userName, UUID clientId) throws RemoteException, MageException;
|
public UUID registerClient(String userName, UUID clientId) throws RemoteException, MageException;
|
||||||
public void deregisterClient(UUID sessionId) throws RemoteException, MageException;
|
public void deregisterClient(UUID sessionId) throws RemoteException, MageException;
|
||||||
|
|
||||||
public String[] getGameTypes() throws RemoteException, MageException;
|
public List<GameTypeView> getGameTypes() throws RemoteException, MageException;
|
||||||
public String[] getPlayerTypes() throws RemoteException, MageException;
|
public String[] getPlayerTypes() throws RemoteException, MageException;
|
||||||
public String[] getDeckTypes() throws RemoteException, MageException;
|
public String[] getDeckTypes() throws RemoteException, MageException;
|
||||||
|
|
||||||
//table methods
|
//table methods
|
||||||
public TableView createTable(UUID sessionId, UUID roomId, String gameType, String deckType, List<String> playerTypes) throws RemoteException, MageException;
|
public TableView createTable(UUID sessionId, UUID roomId, String gameType, String deckType, List<String> playerTypes, MultiplayerAttackOption attackOption, RangeOfInfluence range) throws RemoteException, MageException;
|
||||||
public boolean joinTable(UUID sessionId, UUID roomId, UUID tableId, int seatNum, String name, DeckCardLists deckList) throws RemoteException, MageException, GameException;
|
public boolean joinTable(UUID sessionId, UUID roomId, UUID tableId, int seatNum, String name, DeckCardLists deckList) throws RemoteException, MageException, GameException;
|
||||||
public boolean watchTable(UUID sessionId, UUID roomId, UUID tableId) 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 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 leaveTable(UUID sessionId, UUID roomId, UUID tableId) throws RemoteException, MageException;
|
||||||
|
public void swapSeats(UUID sessionId, UUID roomId, UUID tableId, int seatNum1, int seatNum2) throws RemoteException, MageException;
|
||||||
public void removeTable(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 boolean isTableOwner(UUID sessionId, UUID roomId, UUID tableId) throws RemoteException, MageException;
|
||||||
public TableView getTable(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;
|
public List<TableView> getTables(UUID roomId) throws RemoteException, MageException;
|
||||||
|
|
||||||
//chat methods
|
//chat methods
|
||||||
public void sendChatMessage(UUID chatId, String userName, String message) throws RemoteException, MageException;
|
public void sendChatMessage(UUID chatId, String userName, String message) throws RemoteException, MageException;
|
||||||
|
|
92
Mage.Common/src/mage/view/GameTypeView.java
Normal file
92
Mage.Common/src/mage/view/GameTypeView.java
Normal file
|
@ -0,0 +1,92 @@
|
||||||
|
/*
|
||||||
|
* 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.game.GameType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author BetaSteward_at_googlemail.com
|
||||||
|
*/
|
||||||
|
public class GameTypeView implements Serializable {
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
private int minPlayers;
|
||||||
|
private int maxPlayers;
|
||||||
|
private int numTeams;
|
||||||
|
private int playersPerTeam;
|
||||||
|
private boolean useRange;
|
||||||
|
private boolean useAttackOption;
|
||||||
|
|
||||||
|
public GameTypeView(GameType gameType) {
|
||||||
|
this.name = gameType.getName();
|
||||||
|
this.minPlayers = gameType.getMinPlayers();
|
||||||
|
this.maxPlayers = gameType.getMaxPlayers();
|
||||||
|
this.numTeams = gameType.getNumTeams();
|
||||||
|
this.playersPerTeam = gameType.getPlayersPerTeam();
|
||||||
|
this.useAttackOption = gameType.isUseAttackOption();
|
||||||
|
this.useRange = gameType.isUseRange();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMinPlayers() {
|
||||||
|
return minPlayers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMaxPlayers() {
|
||||||
|
return maxPlayers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getNumTeams() {
|
||||||
|
return numTeams;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getPlayersPerTeam() {
|
||||||
|
return playersPerTeam;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isUseRange() {
|
||||||
|
return useRange;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isUseAttackOption() {
|
||||||
|
return useAttackOption;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -84,8 +84,12 @@ public class GameView implements Serializable {
|
||||||
this.turn = game.getTurnNum();
|
this.turn = game.getTurnNum();
|
||||||
if (game.getActivePlayerId() != null)
|
if (game.getActivePlayerId() != null)
|
||||||
this.activePlayerName = game.getPlayer(game.getActivePlayerId()).getName();
|
this.activePlayerName = game.getPlayer(game.getActivePlayerId()).getName();
|
||||||
|
else
|
||||||
|
this.activePlayerName = "";
|
||||||
if (game.getPriorityPlayerId() != null)
|
if (game.getPriorityPlayerId() != null)
|
||||||
this.priorityPlayerName = game.getPlayer(game.getPriorityPlayerId()).getName();
|
this.priorityPlayerName = game.getPlayer(game.getPriorityPlayerId()).getName();
|
||||||
|
else
|
||||||
|
this.priorityPlayerName = "";
|
||||||
for (CombatGroup combatGroup: game.getCombat().getGroups()) {
|
for (CombatGroup combatGroup: game.getCombat().getGroups()) {
|
||||||
combat.add(new CombatGroupView(combatGroup, game));
|
combat.add(new CombatGroupView(combatGroup, game));
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,6 +48,8 @@ public class PlayerView implements Serializable {
|
||||||
private int life;
|
private int life;
|
||||||
private int libraryCount;
|
private int libraryCount;
|
||||||
private int handCount;
|
private int handCount;
|
||||||
|
private boolean isActive;
|
||||||
|
private boolean hasLeft;
|
||||||
private ManaPoolView manaPool;
|
private ManaPoolView manaPool;
|
||||||
private CardsView graveyard = new CardsView();
|
private CardsView graveyard = new CardsView();
|
||||||
private Map<UUID, PermanentView> battlefield = new HashMap<UUID, PermanentView>();
|
private Map<UUID, PermanentView> battlefield = new HashMap<UUID, PermanentView>();
|
||||||
|
@ -59,6 +61,8 @@ public class PlayerView implements Serializable {
|
||||||
this.libraryCount = player.getLibrary().size();
|
this.libraryCount = player.getLibrary().size();
|
||||||
this.handCount = player.getHand().size();
|
this.handCount = player.getHand().size();
|
||||||
this.manaPool = new ManaPoolView(player.getManaPool());
|
this.manaPool = new ManaPoolView(player.getManaPool());
|
||||||
|
this.isActive = (player.getId().equals(game.getActivePlayerId()));
|
||||||
|
this.hasLeft = player.hasLeft();
|
||||||
for (Card card: player.getGraveyard().values()) {
|
for (Card card: player.getGraveyard().values()) {
|
||||||
graveyard.add(new CardView(card));
|
graveyard.add(new CardView(card));
|
||||||
}
|
}
|
||||||
|
@ -69,35 +73,42 @@ public class PlayerView implements Serializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getLife() {
|
public int getLife() {
|
||||||
return life;
|
return this.life;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getLibraryCount() {
|
public int getLibraryCount() {
|
||||||
return libraryCount;
|
return this.libraryCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getHandCount() {
|
public int getHandCount() {
|
||||||
return handCount;
|
return this.handCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ManaPoolView getManaPool() {
|
public ManaPoolView getManaPool() {
|
||||||
return manaPool;
|
return this.manaPool;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CardsView getGraveyard() {
|
public CardsView getGraveyard() {
|
||||||
return graveyard;
|
return this.graveyard;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<UUID, PermanentView> getBattlefield() {
|
public Map<UUID, PermanentView> getBattlefield() {
|
||||||
return battlefield;
|
return this.battlefield;
|
||||||
}
|
}
|
||||||
|
|
||||||
public UUID getPlayerId() {
|
public UUID getPlayerId() {
|
||||||
return playerId;
|
return this.playerId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return this.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isActive() {
|
||||||
|
return this.isActive;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasLeft() {
|
||||||
|
return this.hasLeft;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,8 +46,8 @@ public class SeatView implements Serializable {
|
||||||
if (seat.getPlayer() != null) {
|
if (seat.getPlayer() != null) {
|
||||||
this.playerId = seat.getPlayer().getId();
|
this.playerId = seat.getPlayer().getId();
|
||||||
this.playerName = seat.getPlayer().getName();
|
this.playerName = seat.getPlayer().getName();
|
||||||
this.playerType = seat.getPlayerType();
|
|
||||||
}
|
}
|
||||||
|
this.playerType = seat.getPlayerType();
|
||||||
}
|
}
|
||||||
|
|
||||||
public UUID getPlayerId() {
|
public UUID getPlayerId() {
|
||||||
|
|
Loading…
Reference in a new issue