package backend;


import game.api.GameState;
import game.impl.Board;
import game.impl.DieRollFactory;
import game.impl.Move;
import game.impl.Player;

import java.util.List;

public class OthelloGameState implements GameState{

    private State state;
    private GameActionsHandler gameActionsHandler;

    public OthelloGameState(State state, GameActionsHandler gameActionsHandler){
        this.state = state;
        this.gameActionsHandler = gameActionsHandler;
    }

    public OthelloGameState(){
        this.state = new State();
        this.gameActionsHandler = new GameActionsHandler(this.state);
    }

    @Override
    public List<Player> getPlayers() {
        return state.getPlayers();
    }

    @Override
    public Board getBoard() {
        return state.getBoard();
    }

    @Override
    public String getMessage() {
        return state.getMessage();
    }

    @Override
    public Player getLastPlayer() {
        return state.getLastPlayer();
    }

    @Override
    public Player getPlayerInTurn() {
        return state.getCurrentPlayer();
    }

    @Override
    public DieRollFactory getDieRollFactory() {
        return null;
    }



    @Override
    public Boolean hasEnded() {
        return gameActionsHandler.hasEndedCheck();
    }

    @Override
    public Player getWinner() {
        return gameActionsHandler.calculateWinner();
    }

    @Override
    public Boolean proposeMove(Move move) {
        if(!gameActionsHandler.validateMove(move))
            return false;

        gameActionsHandler.executeMove(move);
        return true;
    }

    @Override
    public void reset() {
        gameActionsHandler.reset();
    }
}

@@ -1667,11 +1667,156 @@
 );%0A    %7D
+%0A%0A    public boolean canUndo()%7B%0A        return state.getLastExecutedActionIndex() %3E 0;%0A    %7D%0A%0A    public void undo()%7B%0A        state.undo();%0A    %7D
 %0A%7D%0A

Undo added in GameState