|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectgames.sy.ScotlandYard
public class ScotlandYard
Field Summary | |
---|---|
static int |
BLACK_FARE
|
static int |
BUS
|
static int |
DETECTIVE1
|
static int |
DETECTIVE2
|
static int |
DETECTIVE3
|
static int |
DETECTIVE4
|
static int |
DETECTIVE5
|
static int |
MR_X
|
static int |
TAXI
|
static int |
UNDERGROUND
|
Constructor Summary | |
---|---|
ScotlandYard()
Initializes a game with default map |
|
ScotlandYard(int[] sl)
Initializes a game with default map and given initial locations |
|
ScotlandYard(java.lang.String map)
Initializes a game with selected map |
|
ScotlandYard(java.lang.String map,
int[] sl)
Initializes a game with selected map and initial locations |
|
ScotlandYard(java.lang.String map,
java.lang.String settings)
Initializes a game with selected map and settings |
Method Summary | |
---|---|
static boolean |
doubleMove(int move)
Returns whether the move is combined with a double move ticket |
static int |
from(int move)
Returns the source location of a move |
int |
getMaxRound()
Returns the maximum number of rounds (default: 24) |
int |
getNumDoubleMoves()
Returns the number of double move tickets left |
int |
getNumLocations()
Returns the number of locations (default: 199) |
int |
getNumMovesPlayed()
Returns the number of moves played |
int |
getNumPlayers()
Returns the number of players (default: 6) |
int |
getNumTickets(int player,
int type)
Returns the number of tickets a player has left of a type |
int |
getPlayedMrXTicket(int round)
Returns the ticket type played by Mr X in a given round |
int |
getPlayerLocation(int player)
Returns location of the player |
int |
getPlayerLocationAtRound(int player,
int round)
Returns location of the player in a given round |
int |
getRound()
Returns the round number |
java.util.ArrayList<java.lang.Integer> |
getValidMoves(int player)
Returns list of valid moves for the player (without double move ticket) |
java.util.ArrayList<java.lang.Integer> |
getValidMoves(int player,
boolean dm)
Returns list of valid moves for the player |
static int |
intRep(int player)
Makes an integer representation of an empty move |
static int |
intRep(int player,
int from,
int type,
int target,
boolean doubleMove)
Makes an integer representation of a move. type must be ScotlandYard.TAXI, ScotlandYard.BUS, ScotlandYard.UNDERGROUND or ScotlandYard.BLACK_FARE |
boolean |
isFinished()
Checks whether the game is finished |
boolean |
isLegal(int move)
Checks whether a move is legal |
boolean |
isMaxRoundReached()
Checks whether the maximum number of rounds is reached |
int |
isMrXCaptured()
Checks whether Mr X is captured |
boolean |
isStuck(int player)
Checks whether a detective is stuck |
boolean |
isSurfaceRound(int round)
Returns whether the round is a surface round |
boolean |
move(int move)
Performs a move |
boolean |
move(int move,
boolean updateDpl)
Performs a move |
static java.lang.String |
moveString(int move)
Gives a String representation of a move |
static int |
player(int move)
Returns the player of a move |
void |
reset()
Resets the game |
static int |
target(int move)
Returns the target location of a move |
java.lang.String |
toString()
|
static int |
type(int move)
Returns the ticket type of a move. |
boolean |
undo(int move)
Undoes a move |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int TAXI
public static final int BUS
public static final int UNDERGROUND
public static final int BLACK_FARE
public static final int MR_X
public static final int DETECTIVE1
public static final int DETECTIVE2
public static final int DETECTIVE3
public static final int DETECTIVE4
public static final int DETECTIVE5
Constructor Detail |
---|
public ScotlandYard()
public ScotlandYard(int[] sl)
sl
- the initial locations of the playerspublic ScotlandYard(java.lang.String map)
map
- the map namepublic ScotlandYard(java.lang.String map, int[] sl)
map
- the map namesl
- the initial locations of the playerspublic ScotlandYard(java.lang.String map, java.lang.String settings)
map
- the map namesettings
- the settings fileMethod Detail |
---|
public void reset()
public int getNumPlayers()
public int getNumMovesPlayed()
public int getNumLocations()
public int getRound()
public boolean isSurfaceRound(int round)
round
-
public int getMaxRound()
public java.util.ArrayList<java.lang.Integer> getValidMoves(int player)
player
-
public java.util.ArrayList<java.lang.Integer> getValidMoves(int player, boolean dm)
player
- dm
- whether or not to include moves with double move ticket
public int getNumDoubleMoves()
public boolean move(int move)
move
-
public boolean move(int move, boolean updateDpl)
move
- updateDpl
- whether or not to update list of possible locations
public boolean isLegal(int move)
move
-
public boolean undo(int move)
move
-
public int getPlayerLocation(int player)
player
-
public int getPlayerLocationAtRound(int player, int round)
player
- round
-
public int getPlayedMrXTicket(int round)
round
-
public int getNumTickets(int player, int type)
player
- type
-
public int isMrXCaptured()
public boolean isStuck(int player)
player
-
public boolean isMaxRoundReached()
public boolean isFinished()
public static int intRep(int player, int from, int type, int target, boolean doubleMove)
player
- from
- type
- target
- doubleMove
-
public static int intRep(int player)
player
-
public static int player(int move)
move
-
public static int from(int move)
move
-
public static int type(int move)
move
-
public static int target(int move)
move
-
public static boolean doubleMove(int move)
move
-
public static java.lang.String moveString(int move)
move
-
public java.lang.String toString()
toString
in class java.lang.Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |