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 Details

    • size

      private final int size
      Size of gameboard. The gameboard has equal size in width and height. The size should be an odd number.
    • players

      private Player[] players
      An array of two players in the game. Note that in the implementation of Game.start() the first player in this array moves first when game starts.
    • initialBoard

      private Piece[][] 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

      private Place centralPlace
      The central square of the gameboard.
    • numMovesProtection

      private final int numMovesProtection
      This number means: within the first numMovesProtection number of moves in the game, capturing Pieces is not allowed.
  • Constructor Details

    • Configuration

      public Configuration​(int size, Player[] players, int numMovesProtection)
      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

      public Configuration​(int size, Player[] players)
  • Method Details

    • addInitialPiece

      public void addInitialPiece​(Piece piece, Place place)
      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 added
      place - place to put the piece
    • addInitialPiece

      public void addInitialPiece​(Piece piece, int x, int y)
    • getSize

      public int getSize()
    • getPlayers

      public Player[] getPlayers()
    • getInitialBoard

      public Piece[][] getInitialBoard()
    • getCentralPlace

      public Place getCentralPlace()
    • getNumMovesProtection

      public int getNumMovesProtection()
    • clone

      public Configuration clone() throws java.lang.CloneNotSupportedException
      Overrides:
      clone in class java.lang.Object
      Throws:
      java.lang.CloneNotSupportedException