Release for version 2

This commit is contained in:
2020-12-07 23:39:25 +02:00
parent a4d5299514
commit 2230cac96e
6 changed files with 92 additions and 65 deletions
+22 -2
View File
@@ -218,7 +218,13 @@ class Board {
/** @return the size of each site of the board. */
int size () { return N; }
/**
* Boards utility to give access to other player moves.
*
* @param playerId The id of player who asks
* @return The moves data of all other players
*/
int[][] getOpponentMoves (int playerId) {
int[][] ret = new int[moves.size()-1][Const.moveItems];
int ii= 0, ri =0;
@@ -229,12 +235,26 @@ class Board {
}
return ret;
}
/**
* Utility function to create player IDs
* @return The generated player id.
*/
int generatePlayerId () {
moves.add(null);
return moves.size() -1;
}
/**
* Utility to update the moves of each player.
*
* This function is used by the players to update their position on the board.
* After that a player can read other player positions using getOpponentMoves()
* @see getOpponentMoves()
*
* @param m Reference to new move data
* @param playerId The id of the player who update his/her data.
*/
void updateMove(int[] m, int playerId) {
moves.set(playerId, Arrays.stream(m).boxed().toArray(Integer[]::new));
}