|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectbluegammon.logic.Rules
Contains state of rules and logic of deciding valid moves.
Field Summary | |
static int |
EVEN_OUT
Flag denoting that a piece must go out on an even dice |
static int |
MAX_FIVE
Flag denoting that there may be maximum five pieces on a row |
Method Summary | |
static int |
getRuleFlags()
Returns current rule settings as an integer. |
static boolean |
isAnyRuleSet()
Returns true if any special rule has been enabled. |
static boolean |
isSet(int rule)
Queries if a rule is enabled or not. |
static boolean |
isValidFromGuard(BoardState state,
int to,
int[] player,
int[] opponent)
Returns if a move is valid from guardposition to specified position. |
static boolean |
isValidMove(BoardState state,
int from,
int to,
boolean white,
int[] player,
int[] opponent)
Returns if a move is valid from specified position to specified position. |
static int |
loadRules(java.io.DataInputStream dis)
Loads rules. |
static int |
saveRules(java.io.DataOutputStream dos)
Saves rules. |
static void |
set(int rule,
boolean set)
Enables/disables a rule. |
static void |
setRuleFlags(int flags)
Sets current rules as an integer. |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int MAX_FIVE
public static final int EVEN_OUT
Method Detail |
public static boolean isAnyRuleSet()
public static void set(int rule, boolean set)
rule
- The rule.set
- true to enable, false to disable.public static boolean isSet(int rule)
rule
- The rule.
public static boolean isValidFromGuard(BoardState state, int to, int[] player, int[] opponent)
state
- The board state.to
- The destination index to move piece to.player
- Player indices.opponent
- Opponend indices.
public static boolean isValidMove(BoardState state, int from, int to, boolean white, int[] player, int[] opponent)
state
- The board state.from
- The source index to move piece from.to
- The destination index to move piece to.white
- The color of the piece.player
- Player indices.opponent
- Opponend indices.
public static int getRuleFlags()
public static void setRuleFlags(int flags)
flags
- Current rule settings.public static int loadRules(java.io.DataInputStream dis) throws java.io.IOException
dis
- The stream to read from.
java.io.IOException
- if loading fails.public static int saveRules(java.io.DataOutputStream dos) throws java.io.IOException
dos
- The stream to write to.
java.io.IOException
- if save failed.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |