added an ArrayList of Player in game and added the received methods in clientgamelogic
This commit is contained in:
		@@ -2,8 +2,36 @@
 | 
			
		||||
 | 
			
		||||
import pp.mdga.game.Game;
 | 
			
		||||
import pp.mdga.message.client.ClientMessage;
 | 
			
		||||
import pp.mdga.message.server.ActivePlayer;
 | 
			
		||||
import pp.mdga.message.server.AnyPiece;
 | 
			
		||||
import pp.mdga.message.server.Briefing;
 | 
			
		||||
import pp.mdga.message.server.CeremonyMessage;
 | 
			
		||||
import pp.mdga.message.server.Dice;
 | 
			
		||||
import pp.mdga.message.server.DiceAgain;
 | 
			
		||||
import pp.mdga.message.server.DiceNow;
 | 
			
		||||
import pp.mdga.message.server.EndOfTurn;
 | 
			
		||||
import pp.mdga.message.server.LobbyAccept;
 | 
			
		||||
import pp.mdga.message.server.LobbyDeny;
 | 
			
		||||
import pp.mdga.message.server.LobbyPlayerJoin;
 | 
			
		||||
import pp.mdga.message.server.LobbyPlayerLeave;
 | 
			
		||||
import pp.mdga.message.server.MoveMessage;
 | 
			
		||||
import pp.mdga.message.server.NoTurn;
 | 
			
		||||
import pp.mdga.message.server.PauseGame;
 | 
			
		||||
import pp.mdga.message.server.PlayCard;
 | 
			
		||||
import pp.mdga.message.server.PossibleCard;
 | 
			
		||||
import pp.mdga.message.server.PossiblePiece;
 | 
			
		||||
import pp.mdga.message.server.RankingResponse;
 | 
			
		||||
import pp.mdga.message.server.RankingRollAgain;
 | 
			
		||||
import pp.mdga.message.server.ReconnectBriefing;
 | 
			
		||||
import pp.mdga.message.server.ResumeGame;
 | 
			
		||||
import pp.mdga.message.server.ServerInterpreter;
 | 
			
		||||
import pp.mdga.message.server.ServerStartGame;
 | 
			
		||||
import pp.mdga.message.server.StartPiece;
 | 
			
		||||
import pp.mdga.message.server.UpdateReady;
 | 
			
		||||
import pp.mdga.message.server.UpdateTSK;
 | 
			
		||||
import pp.mdga.message.server.WaitPiece;
 | 
			
		||||
 | 
			
		||||
public class ClientGameLogic {
 | 
			
		||||
public class ClientGameLogic implements ServerInterpreter {
 | 
			
		||||
    static final System.Logger LOGGER = System.getLogger(ClientGameLogic.class.getName());
 | 
			
		||||
 | 
			
		||||
    private Game game;
 | 
			
		||||
@@ -32,4 +60,139 @@ public Game getGame(){
 | 
			
		||||
    public ClientState getState(){
 | 
			
		||||
        return state;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(ActivePlayer msg) {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(AnyPiece msg) {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(Briefing msg) {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(CeremonyMessage msg) {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(Dice msg) {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(DiceAgain msg) {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(DiceNow msg) {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(EndOfTurn msg) {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(LobbyAccept msg) {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(LobbyDeny msg) {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(LobbyPlayerJoin msg) {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(LobbyPlayerLeave msg) {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(MoveMessage msg) {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(NoTurn msg) {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(PauseGame msg) {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(PlayCard msg) {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(PossibleCard msg) {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(PossiblePiece msg) {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(RankingResponse msg) {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(RankingRollAgain msg) {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(ReconnectBriefing msg) {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(ResumeGame msg) {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(ServerStartGame msg) {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(StartPiece msg) {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(UpdateReady msg) {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(UpdateTSK msg) {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(WaitPiece msg) {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -19,6 +19,7 @@ public class Game {
 | 
			
		||||
    private Board board;
 | 
			
		||||
    private Color activeColor;
 | 
			
		||||
    private List<Color> order;
 | 
			
		||||
    private final ArrayList<Player> playerList = new ArrayList<>(4);
 | 
			
		||||
 | 
			
		||||
    private final ArrayList<Observer> observers = new ArrayList<>();
 | 
			
		||||
    private Player startPlayer;
 | 
			
		||||
@@ -400,4 +401,16 @@ public Piece getPieceThroughIdentifier(String identifier) {
 | 
			
		||||
        int index = Integer.parseInt(parts[1]);
 | 
			
		||||
        return board.getPlayerData().get(color).getPieces()[index];
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public ArrayList<Player> getPlayerList() {
 | 
			
		||||
        return playerList;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void addPlayerToList(Player player) {
 | 
			
		||||
        playerList.add(player);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void removePlayerFromList(Player player) {
 | 
			
		||||
        playerList.remove(player);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -11,6 +11,7 @@ public class Player {
 | 
			
		||||
    private Statistic playerStatistic;
 | 
			
		||||
    private ArrayList<BonusCard> handCards;
 | 
			
		||||
    private final int id;
 | 
			
		||||
    private Color color;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This constructor constructs a new Player object
 | 
			
		||||
@@ -88,4 +89,22 @@ public BonusCard removeHandCard(BonusCard card) {
 | 
			
		||||
    public int getId() {
 | 
			
		||||
        return id;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This method returns the color of the player
 | 
			
		||||
     *
 | 
			
		||||
     * @return the color of the player
 | 
			
		||||
     */
 | 
			
		||||
    public Color getColor() {
 | 
			
		||||
        return color;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This method sets the color of the player
 | 
			
		||||
     *
 | 
			
		||||
     * @param color the new color of the player
 | 
			
		||||
     */
 | 
			
		||||
    public void setColor(Color color) {
 | 
			
		||||
        this.color = color;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user