|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
public interface Move
All moves should implement this interface and obey the contract described below.
(1) They should be immutable.
(2) They should overide Object.equals() to test for logical
equality.
(3) They should store 'before' and 'after' values for all properties of the world object that they change.
(4) The changes they encapsulate should be stored in an address space independent way, so that a move generated on a client can be serialised, sent over a network, and then deserialised and executed on a server. To achieve this, they should refer to items in the game world via either their coorinates, e.g. tile 10,50, or their position in a list, e.g. train #4.
(5) They should be undoable. To achieve this, they need to store the information necessary to undo the change. E.g. a change-terrain-type move might store the tile coorindates, the terrain type before the change and the terrain type after the change.
(6) The tryDoMove and tryUndoMove methods should test whether the move is valid but leave the gameworld unchanged
MoveStatus,
World,
PreMove| Method Summary | |
|---|---|
MoveStatus |
doMove(World w,
FreerailsPrincipal p)
Executes this move on the specifed world object. |
MoveStatus |
tryDoMove(World w,
FreerailsPrincipal p)
Tests whether this Move can be executed on the specifed world object, this method should leave the world object unchanged. |
MoveStatus |
tryUndoMove(World w,
FreerailsPrincipal p)
Tests whether this Move can be undone on the specifed world object, this method should leave the world object unchanged. |
MoveStatus |
undoMove(World w,
FreerailsPrincipal p)
If doMove has just been executed on the specified world
object, calling this method changes the state of the world object back to
how it was before doMove was called. |
| Method Detail |
|---|
MoveStatus tryDoMove(World w,
FreerailsPrincipal p)
MoveStatus tryUndoMove(World w,
FreerailsPrincipal p)
MoveStatus doMove(World w,
FreerailsPrincipal p)
MoveStatus undoMove(World w,
FreerailsPrincipal p)
doMove has just been executed on the specified world
object, calling this method changes the state of the world object back to
how it was before doMove was called.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||