public class MancalaGame extends java.lang.Object implements Game<MancalaState,MancalaBoard>
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
GAME_BOARD_TRANFORMER
The transformer to create the view FXML
|
static java.lang.String |
GAME_NAME
The name of this game
|
Constructor and Description |
---|
MancalaGame()
Default constructor used by GameFactory
|
MancalaGame(MancalaGame game)
Creates a semi deep copy of the given MancalaGame (State is copied, board is kept the same)
|
MancalaGame(MancalaState state,
MancalaBoard board)
Creates a new MancalaGame
|
Modifier and Type | Method and Description |
---|---|
WinState |
checkIfPlayerWins()
Checks if a player is winning.
|
MancalaBoard |
getBoard()
Returns the board configuration of the current game.
|
java.util.List<java.lang.String> |
getSelectableSlots()
Returns a list of selectable slots for the current game state and current board
|
MancalaState |
getState()
Returns the state of the current game.
|
java.io.InputStream |
getViewXml()
Returns the view as an FXML inputstream.
|
static void |
init()
Registers MancalaGame to the GameFactory and initializes MancalaHumanAgent
|
void |
loadBoard(java.io.InputStream boardStream)
This is called at the beginning loading the board.
|
int |
nextPlayer()
Finishes the current players turn and starting the turn of the next player.
|
boolean |
selectSlot(java.lang.String id)
Selects the slot with the given ID and calculates the turn.
|
public static final java.lang.String GAME_BOARD_TRANFORMER
public static final java.lang.String GAME_NAME
public MancalaGame()
public MancalaGame(MancalaGame game)
game
- The game that should be copied.public MancalaGame(MancalaState state, MancalaBoard board)
state
- If null the default MancalaState of the board is generated (placing stones_per_slot many
stones on each slot). If not null the given state is used.board
- The board that should be used for this MancalaGamepublic static void init()
public java.io.InputStream getViewXml()
Game
getViewXml
in interface Game<MancalaState,MancalaBoard>
public void loadBoard(java.io.InputStream boardStream)
Game
loadBoard
in interface Game<MancalaState,MancalaBoard>
boardStream
- InputStream of the board XMLpublic boolean selectSlot(java.lang.String id)
id
- The ID of the slot that has been selectedpublic java.util.List<java.lang.String> getSelectableSlots()
public WinState checkIfPlayerWins()
public MancalaBoard getBoard()
Game
getBoard
in interface Game<MancalaState,MancalaBoard>
public int nextPlayer()
Game
nextPlayer
in interface Game<MancalaState,MancalaBoard>
public MancalaState getState()
Game
getState
in interface Game<MancalaState,MancalaBoard>