package de.htw_berlin.HoboOthello.core;

/**
 * Created by laura on 17.11.16.
 */
public class Board {

    public static final int STANDARD_BOARD_SIZE_EIGHT = 8;
    public static final int SMALL_BOARD_SIZE_SIX = 6;
    public static final int LARGE_BOARD_SIZE_TEN = 10;

    private Field[][] fields;

    /**
     * Constructor of Board which declares and constructs an two dimensional array of fields
     * Small size of Board is 6 x 6
     * Standard size of Board is 8 x 8
     * Large size of Board is 10 x 10
     * Calls a method to fill the field with default values
     */

    public Board(int i) {
        switch (i) {
            case 6:
                fields = new Field[SMALL_BOARD_SIZE_SIX][SMALL_BOARD_SIZE_SIX];
                fields = fillWithDefaultValues(fields);
                break;
            case 8:
                fields = new Field[STANDARD_BOARD_SIZE_EIGHT][STANDARD_BOARD_SIZE_EIGHT];
                fields = fillWithDefaultValues(fields);
                break;
            case 10:
                fields = new Field[LARGE_BOARD_SIZE_TEN][LARGE_BOARD_SIZE_TEN];
                fields = fillWithDefaultValues(fields);
                break;
            default:
                System.out.println("Invalid size for a HoboOthello Board");
                //todo : decide if case 8 becomes default
        }
    }


    /**
     * Method which fills fields with default values.
     * Default value of a field is:
     * <p>
     * +------------+
     * |            |
     * |            |
     * |     BW     |
     * |     WB     |
     * |            |
     * |            |
     * +------------+
     * <p>
     *
     * @param fields fields which are being filled
     * @return fields with default values (true, false, false)
     */
    private Field[][] fillWithDefaultValues(Field[][] fields) {
        for (int i = 0; i < fields.length; i++) {
            for (int j = 0; j < fields.length; j++) {
                fields[i][j] = new Field();
            }
        }

        // add starting stones for both players
        fields[fields.length / 2 - 1][fields.length / 2 - 1].setBlack();
        fields[fields.length / 2][fields.length / 2 - 1].setWhite();
        fields[fields.length / 2 - 1][fields.length / 2].setWhite();
        fields[fields.length / 2][fields.length / 2].setBlack();

        return fields;
    }
}

@@ -266,16 +266,199 @@
  = 10;%0A%0A
+%0A    /**%0A     * Set the curret Player%0A     * true == Black%0A     * false == White%0A     * default is Black cause Black start the game%0A     */%0A    private boolean CurrentPlayer = true;%0A%0A
     priv
@@ -2546,11 +2546,1318 @@
 s;%0A    %7D
+%0A%0A    public boolean isCurrentPlayer() %7B%0A        return CurrentPlayer;%0A    %7D%0A%0A    /**%0A     * Get current Player and return it as easy readable char,%0A     * is designed to debug the code%0A     * @return b == Black Player%0A     *         w == White Player%0A     */%0A    public char isCurrentPlayerAsChar() %7B%0A        if (CurrentPlayer) %7B%0A            return 'b';%0A        %7D else %7B%0A            return 'w';%0A        %7D%0A    %7D%0A%0A    public void setCurrentPlayer(boolean currentPlayer) %7B%0A        CurrentPlayer = currentPlayer;%0A    %7D%0A%0A    /**%0A     * Set the current User with a Char, is added to%0A     * debug the code%0A     * @param currentPlayer b == Black%0A     *                      w == White%0A     */%0A    public void setCurrentPlayerAsChar(char currentPlayer) %7B%0A        switch (currentPlayer) %7B%0A            case 'b':%0A                this.CurrentPlayer = true;%0A                break;%0A            case 'w':%0A                this.CurrentPlayer = false;%0A                break;%0A            default:%0A                //todo return a waring for wrong input%0A        %7D%0A    %7D%0A%0A    /**%0A     * set the next Player%0A     * if current User is Black than it will be set to white%0A     * and if the current User is White it will be set to Black%0A     */%0A    public void setNextPlayer() %7B%0A        this.CurrentPlayer = !this.CurrentPlayer;%0A    %7D
 %0A%7D%0A

add current Player