Class Configuration
java.lang.Object
castle.comp3021.assignment.protocol.Configuration
- All Implemented Interfaces:
java.lang.Cloneable
public class Configuration
extends java.lang.Object
implements java.lang.Cloneable
Game configuration, including:
1. size of gameboard
2. place (square) of central square in classical Jeson Mor
3. the initial game board with pieces on it, which is configurable through
addInitialPiece(Piece, Place)
4. the two players.-
Field Summary
Fields Modifier and Type Field Description private Place
centralPlace
The central square of the gameboard.private Piece[][]
initialBoard
The initial map of the gameboard, containing initial pieces and their places.private int
numMovesProtection
This number means: within the firstnumMovesProtection
number of moves in the game, capturingPiece
s is not allowed.private Player[]
players
An array of two players in the game.private int
size
Size of gameboard. -
Constructor Summary
Constructors Constructor Description Configuration(int size, Player[] players)
Configuration(int size, Player[] players, int numMovesProtection)
Constructor of configuration -
Method Summary
Modifier and Type Method Description void
addInitialPiece(Piece piece, int x, int y)
void
addInitialPiece(Piece piece, Place place)
Add piece to the initial gameboard.Configuration
clone()
Place
getCentralPlace()
Piece[][]
getInitialBoard()
int
getNumMovesProtection()
Player[]
getPlayers()
int
getSize()
-
Field Details
-
size
private final int sizeSize of gameboard. The gameboard has equal size in width and height. The size should be an odd number. -
players
An array of two players in the game. Note that in the implementation ofGame.start()
the first player in this array moves first when game starts. -
initialBoard
The initial map of the gameboard, containing initial pieces and their places. This map has keys for all places in the gameboard, with or without pieces. If there is no piece in one place, the place is mapped to null. -
centralPlace
The central square of the gameboard. -
numMovesProtection
private final int numMovesProtectionThis number means: within the firstnumMovesProtection
number of moves in the game, capturingPiece
s is not allowed.
-
-
Constructor Details
-
Configuration
Constructor of configuration- Parameters:
size
- size of the gameboard.players
- an array of two players in the game, the first player should move first when game starts.numMovesProtection
- the first number of moves where capturing pieces is not allowed
-
Configuration
-
-
Method Details
-
addInitialPiece
Add piece to the initial gameboard. The player that this piece belongs to will be automatically added into the configuration.- Parameters:
piece
- piece to be addedplace
- place to put the piece
-
addInitialPiece
-
getSize
public int getSize() -
getPlayers
-
getInitialBoard
-
getCentralPlace
-
getNumMovesProtection
public int getNumMovesProtection() -
clone
- Overrides:
clone
in classjava.lang.Object
- Throws:
java.lang.CloneNotSupportedException
-