package org.amc.game.chessserver;

import org.amc.game.chess.ChessBoard;
import org.amc.game.chess.ChessGame;
import org.amc.game.chess.Colour;
import org.amc.game.chess.Player;

public class ServerChessGame {
    public enum status{
        IN_PROGRESS,
        AWAITING_PLAYER,
        FINISHED
    }
    
    private ChessGame chessGame=null;
    private status currentStatus;
    private Player player;

    public ServerChessGame(Player player) {
        this.player=player;
        this.player.setColour(Colour.WHITE);
        this.currentStatus=status.AWAITING_PLAYER;
    }
    
    public void addOpponent(Player player){
        if(!this.currentStatus.equals(status.FINISHED)){
            player.setColour(Colour.BLACK);
            chessGame=new ChessGame(new ChessBoard(),this.player,player);
            this.currentStatus=status.IN_PROGRESS;
        }
    }

    public final status getCurrentStatus() {
        return currentStatus;
    }

    public final Player getPlayer() {
        return player;
    }

    public final void setCurrentStatus(status currentStatus) {
        this.currentStatus = currentStatus;
    }

    public final ChessGame getChessGame() {
        return chessGame;
    }
}

@@ -399,16 +399,45 @@
  player;
+%0A    private Player opponent;
 %0A%0A    pu
@@ -754,16 +754,50 @@
 BLACK);%0A
+            this.opponent=player;%0A
         
@@ -1270,10 +1270,85 @@
 ;%0A    %7D%0A
+    %0A    public final Player getOpponent()%7B%0A        return opponent;%0A    %7D%0A
 %7D%0A

add Opponent to ServerChessGame