public class Board
extends java.lang.Object
implements java.lang.Cloneable
Modifier and Type | Field and Description |
---|---|
static int |
Bar
When dealing with pointArrays, the special value Bar is 25
|
static int |
Home
When dealing with pointArrays, the special value Home is 0
|
static int |
O
The player playing the 'O' pieces.
|
static int |
turnO
O's turn is marked with 1
|
static int |
turnX
X's turn is marked with -1
|
static int |
X
The player playing the 'X' pieces.
|
static int |
XOnot
We don't know if it is player O or player X
|
Constructor and Description |
---|
Board()
Create an empty board
|
Modifier and Type | Method and Description |
---|---|
void |
clearDice()
When you pick up the dice, 0 them out so there is a visual cue.
|
Board |
clone()
Clone this board
|
int[] |
getBar()
Get the number of checkers on the bar for both players.
|
int |
getCanMove()
Return the number of pieces the player can move this turn.
|
int |
getCube()
Get the number displayed on the double cube
|
int[][] |
getDice()
Get the 2x2 array of both player's both dice
|
int |
getDirection()
-1 If you play from position 24 to position 1.
1 If you play from position 1 to position 24. |
int |
getDirectionFromName(java.lang.String name)
Get the playing direction for this player
|
int |
getHasCube()
Who has the doubling cube?
-1 = noone, X = X, O = O
|
int[] |
getHome()
Get the number of checkers in both player's homes.
|
int |
getMatchLength()
Get the number of points in the match
|
int[] |
getMatchScore()
Get the score for both players in this match
|
int[] |
getPipCount()
Calculate and return the number of pips for both players.
|
java.lang.String[] |
getPlayerName()
Get the list of player names who are playing this game.
|
int[] |
getPoints()
Fetch the points array, the checkers on the board.
|
int |
getResigningPoints() |
static java.lang.String |
getTurnAsText(int turn)
Get turnXO as text.
|
boolean[] |
getWasDoubled()
Is there a pending double on the table?
|
int |
getWhoIsResigning() |
int |
getWhosTurn()
Get who's turn it is.
|
int |
getXO()
Get whether you are playing as X or O
|
java.lang.String |
getXOAsText()
Get XO as text.
|
static java.lang.String |
getXOAsText(int xo)
Get XO as text.
|
int |
getXOFromName(java.lang.String name)
|
boolean |
isAcceptDeclineDouble()
Are you in a state where you are required to accept or decline a double?
|
boolean |
isAcceptDeclineResign()
Are you in a state where you are required to accept or decline a resign?
|
boolean |
isOpponentMayDouble() |
boolean |
isRace()
Is this game a race?
Determine whether all of your checkers are past the opponent's checkers
|
boolean |
isYouMayDouble()
Are You allowed to double?
|
boolean |
isYouPlaying()
Are you playing or just watching?
|
boolean |
isYourMove()
Is it your turn to move? That is, have you rolled and should move checkers?
|
boolean |
isYourTurnToRollOrDouble()
Is it your turn?
|
void |
onMatchOver(java.lang.String winner,
java.lang.String score)
Handle the '* wins the match' message.
|
void |
parseFibsBoard(java.lang.String s)
Parse the board state from Fibs.
|
void |
parseFibsBoard(java.lang.String s,
boolean debugMode)
Parse a board for debug analysis.
|
void |
setAcceptDeclineDouble()
We have been doubled and need to accept or decline
|
void |
setAcceptDeclineResign(boolean enabled) |
void |
setPlayerName(int which,
java.lang.String name)
Set the value of one of the playerNames.
|
void |
setResigningPoints(int resigningPoints) |
void |
setSortDice(boolean sortDice)
Set the flag saying we want sorted dice or not
|
void |
setStartPositions()
Place all checkers on their start positions
|
void |
setWasDoubled(int xo)
Is there a pending double on the table?
|
void |
setWhoIsResigning(int xo)
Someone wants to resign, this is the player
|
void |
setYourTurnToRollOrDouble(boolean yourTurnToRollOrDouble)
Set your turn to roll or double
|
static int |
xoToTurn(int xo)
|
public static final int O
public static final int X
public static final int turnX
public static final int turnO
public static final int XOnot
public static final int Home
public static final int Bar
public static int xoToTurn(int xo)
xo
- The board player.public Board clone()
clone
in class java.lang.Object
public void setSortDice(boolean sortDice)
sortDice
- true = sort the dice, false = deal with them as receivedpublic boolean isYourTurnToRollOrDouble()
public void setYourTurnToRollOrDouble(boolean yourTurnToRollOrDouble)
yourTurnToRollOrDouble
- the yourTurnToRollOrDouble to setpublic void setAcceptDeclineDouble()
public boolean isAcceptDeclineDouble()
public boolean isAcceptDeclineResign()
public void setAcceptDeclineResign(boolean enabled)
public void setWhoIsResigning(int xo)
xo
- Board.X or Board.O wants to resignpublic int getWhoIsResigning()
public void setResigningPoints(int resigningPoints)
public int getResigningPoints()
public int[] getPoints()
public int[] getBar()
public int[] getHome()
public boolean[] getWasDoubled()
public void setWasDoubled(int xo)
public boolean isYouMayDouble()
public boolean isOpponentMayDouble()
public boolean isYouPlaying()
public boolean isYourMove()
public java.lang.String[] getPlayerName()
public void setPlayerName(int which, java.lang.String name)
public int getMatchLength()
public int[] getMatchScore()
public void setStartPositions()
public int getXO()
public java.lang.String getXOAsText()
public static java.lang.String getXOAsText(int xo)
public static java.lang.String getTurnAsText(int turn)
public void clearDice()
public int getWhosTurn()
public int getXOFromName(java.lang.String name)
name
- The player's name to checkXOnot
for non-matchpublic int getDirectionFromName(java.lang.String name)
name
- The player name to checkpublic int getCube()
public int getHasCube()
public int getDirection()
public int[][] getDice()
public int getCanMove()
public void onMatchOver(java.lang.String winner, java.lang.String score)
public int[] getPipCount()
MatchStatusPanel
.public boolean isRace()
public void parseFibsBoard(java.lang.String s)
s
- The board0 1 2 3 4 5 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 board:You:someplayer:3:0:0:0:-2:0:0:0:0:5:0:3:0:0:0:-5:5:0:0:0:-3:0:-5:0:0:0:0:2:0:1:6:2:0:0:1:1:1:0:1:-1:0:25:0:0:0:0:2:0:0:0
public void parseFibsBoard(java.lang.String s, boolean debugMode)
s
- The board stringdebugMode
- If true then actually parse.