|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectgvprojects.igel.model.IgelGameKurmas
public class IgelGameKurmas
Game engine for Igel Argern
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface gvprojects.igel.model.IIgelGame |
---|
IIgelGame.GameEventListener |
Constructor Summary | |
---|---|
IgelGameKurmas(IgelGameParameters parameters)
Constructor |
|
IgelGameKurmas(IgelGameParameters parameters,
java.io.InputStream input)
Constructor allowing configuration from a file (or other stream source). |
Method Summary | |
---|---|
void |
addGameEventListener(IIgelGame.GameEventListener listener)
Add a IIgelGame.GameEventListener |
boolean |
canMoveHedgehog(int fromRow,
int fromColumn)
Return whether the the top hedgehog at [ fromRow ,
fromColumn ] can be moved forward. |
boolean |
canMoveHedgehog(int fromRow,
int fromColumn,
int toColumn)
Return whether the the top hedgehog at [ fromRow ,
fromColumn ] can be moved to column toColumn . |
boolean |
canPlaceHedgehog(int row)
returns true if the current player can place a hedgehog in row (applies to initial hedgehog
placement only). |
boolean |
canSlideHedgehog(int fromRow,
int fromColumn)
Return true if the current player can slide the hedgehog at [fromRow , fromColumn ] |
boolean |
canSlideHedgehog(int fromRow,
int fromColumn,
int toRow)
Return true if the current player can slide the hedgehog at [fromRow ,
fromColumn ] to [toRow , fromColumn ]. |
int |
currentDieValue()
return the current value of the die |
java.lang.String |
currentMessage()
Get the current message. |
int |
currentPlayer()
Return the current player's number. |
ICellState |
getCell(int row,
int column)
return the ICellState object at the given location |
IGameState |
getState()
get a read-only view of the game's current state. |
int |
hedgehogsPerPlayer()
Return the number of hedgehogs per player. |
void |
moveHedgehog(int fromRow,
int fromColumn,
int toColumn)
Move the top hedgehog at [ fromRow ,
fromColumn ] to column toColumn . |
int |
numColumns()
return the number of columns on the board. |
int |
numPlayers()
Return the number of players. |
int |
numRows()
return the number of rows on the board. |
void |
passSidewaysMove()
Pass the current user's sideways move. |
Phase |
phase()
Return the current game phase. |
void |
placeHedgehog(int row)
Make an initial placement of one of the current player's hedgehogs in row and increment the current player. |
void |
quickLayout()
Make an initial placement of all hedgehogs in round-robin order. |
void |
setNextRolls(java.lang.Integer i)
Set the value of the die rolls. |
void |
slideHedgehog(int fromRow,
int fromColumn,
int toRow)
Slide the hedgehog at the top of the specified cell to the specified row. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public IgelGameKurmas(IgelGameParameters parameters)
parameters
- an object containing all of the game parameters (num players, number of hedgehogs, etc.)
java.lang.IllegalArgumentException
- if parameters
is null, or any parameter has an illegal value.public IgelGameKurmas(IgelGameParameters parameters, java.io.InputStream input)
Note: Not all parameters
may be used. Typically, values specified in input
override those
values in parameters
parameters
- game parameters specified by the current user (e.g., from the configuration dialog).input
- game parameters contained in a file (or other data stream).
java.lang.IllegalArgumentException
- if any parameter is null or has an illegal valueMethod Detail |
---|
public int numRows()
IGameState
numRows
in interface IGameState
public int numColumns()
IGameState
numColumns
in interface IGameState
public int numPlayers()
IGameState
numPlayers
in interface IGameState
public int hedgehogsPerPlayer()
IGameState
hedgehogsPerPlayer
in interface IGameState
public Phase phase()
IGameState
phase
in interface IGameState
public int currentPlayer()
IGameState
currentPlayer
in interface IGameState
public ICellState getCell(int row, int column)
ICellState
object at the given location
getCell
in interface IGameState
row
- the row (indexed beginning at 0)column
- the column (indexed beginning at 0)
ICellState
object at the given location
java.lang.IllegalArgumentException
- if row
or column
is invalidpublic boolean canPlaceHedgehog(int row)
IIgelGame
true
if the current player can place a hedgehog in row
(applies to initial hedgehog
placement only).
canPlaceHedgehog
in interface IIgelGame
row
- the desired row
true
if the current player can place a hedgehog in row
, false
otherwise.public IGameState getState()
IIgelGame
getState
in interface IIgelGame
public void placeHedgehog(int row)
IIgelGame
row
and increment the current player.
placeHedgehog
in interface IIgelGame
row
- the rowpublic void addGameEventListener(IIgelGame.GameEventListener listener)
IIgelGame
IIgelGame.GameEventListener
addGameEventListener
in interface IIgelGame
listener
- the MessageChangeListener
to addpublic int currentDieValue()
currentDieValue
in interface IGameState
public java.lang.String currentMessage()
currentMessage
in interface IGameState
public boolean canSlideHedgehog(int fromRow, int fromColumn)
IIgelGame
true
if the current player can slide the hedgehog at [fromRow
, fromColumn
]
canSlideHedgehog
in interface IIgelGame
fromRow
- the current row of the player's hedgehog.fromColumn
- the current column of the player's hedgehog.
true
if the current player can slide the hedgehog at [fromRow
, fromColumn
].public boolean canSlideHedgehog(int fromRow, int fromColumn, int toRow)
IIgelGame
true
if the current player can slide the hedgehog at [fromRow
,
fromColumn
] to [toRow
, fromColumn
].
canSlideHedgehog
in interface IIgelGame
fromRow
- the current row of the player's hedgehog.fromColumn
- the current column of the player's hedgehog.toRow
- the destination row
true
if the current player can slide the hedgehog at [fromRow
,
fromColumn
] to [toRow
, fromColumn
]public void slideHedgehog(int fromRow, int fromColumn, int toRow)
slideHedgehog
in interface IIgelGame
fromRow
- the current row of the player's hedgehog.fromColumn
- the current column of the player's hedgehog.toRow
- the destination row.
java.lang.IllegalArgumentException
- if any of the parameters are out of range.
IllegalMoveException
- if the move is not valid.public boolean canMoveHedgehog(int fromRow, int fromColumn)
IIgelGame
fromRow
,
fromColumn
] can be moved forward. Note, the implementation in IgelGameKurmas
checks only that
the hedgehog at [fromRow
,
fromColumn
] may be moved. It does not check whether the hedgehog may move into [fromRow
,
fromColumn
+ 1]
canMoveHedgehog
in interface IIgelGame
fromRow
- the rowfromColumn
- the column
true
if the the top hedgehog at [fromRow
,
fromColumn
] can be moved forward.public boolean canMoveHedgehog(int fromRow, int fromColumn, int toColumn)
IIgelGame
fromRow
,
fromColumn
] can be moved to column toColumn
.
canMoveHedgehog
in interface IIgelGame
fromRow
- the rowfromColumn
- the columntoColumn
- the proposed new column
true
if the the top hedgehog at [fromRow
,
fromColumn
] can be moved to column toColumn
public void moveHedgehog(int fromRow, int fromColumn, int toColumn)
IIgelGame
fromRow
,
fromColumn
] to column toColumn
.
moveHedgehog
in interface IIgelGame
fromRow
- the rowfromColumn
- the columntoColumn
- the proposed new columnpublic void passSidewaysMove()
IIgelGame
passSidewaysMove
in interface IIgelGame
public void setNextRolls(java.lang.Integer i)
i
is null
, roll a random value. If i
is not null
, then the die should return i
setNextRolls
in interface IIgelGame
i
- fix the die roll at i
, or roll normally if i
is null
public void quickLayout()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |