|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectedu.cuny.cat.server.GameClock
public class GameClock
This class implements a clock for a cat game.
The clock runs tick (second) by tick. A certain number of ticks makes a trading round, and a certain number of rounds makes a trading day. A cat game lasts one or more days. There is a game initialization period before the first day begins in a game and a day initialization before the first round begins in a day. Days are separated by day breaks and rounds by round breaks.
This game clock also allows a simulation of multiple games in a row by
specifying iterations > 1
.
The clock triggers time-related game events and notifies listeners of them,
including SimulationStartedEvent
, SimulationOverEvent
,
GameStartingEvent
, GameStartedEvent
, GameOverEvent
,
DayOpeningEvent
, DayOpenedEvent
, DayClosedEvent
,
RoundOpenedEvent
, RoundClosingEvent
, and
RoundClosedEvent
.
Parameters
base.iterations int >=1 (1 by default) |
(number of games to run in a row, solely used in a simulation) |
base.gamelen int >=1 (20 by default) |
(number of days in a game) |
base.daylen int >=1 (50 by default) |
(number of rounds in a day) |
base.roundlen int >=1 (10000 by default) |
(number of ticks in a round) |
base.roundclosinglen int >=1 (500 by default) |
(number of ticks for a closing round to be closed) |
base.gamebreak int >=1 (1000 by default) |
(the length of game break in terms of ticks) |
base.daybreak int >=1 (5 by default) |
(the length of a day break in terms of ticks) |
base.roundbreak int >=1 (100 by default) |
(the length of a round break in terms of ticks) |
base.gameinit int >=1 (2000 by default) |
(the length of game initialization period in terms of ticks) |
base.dayinit int >=1 (2000 by default) |
(the length of a day initialization in terms of ticks) |
base.synctimeout int >=1 (60000 by default) |
(the number of seconds the clock waits for all clients to respond to a timing event) |
Field Summary | |
---|---|
protected int |
day
|
protected int |
dayBreak
|
protected int |
dayInitLen
|
protected int |
dayLen
|
protected static int |
DEFAULT_SYNCTIMEOUT
|
protected java.util.LinkedList<AuctionEventListener> |
eventListeners
|
protected int |
gameBreak
|
protected int |
gameInitLen
|
protected int |
gameLen
|
protected CatpInfrastructure |
infrast
|
protected int |
iterations
|
protected boolean |
logging
|
protected boolean |
paused
|
protected Registry |
registry
|
protected int |
round
|
protected long |
round_start
|
protected int |
roundBreak
|
protected int |
roundClosingLen
|
protected int |
roundLen
|
protected edu.cuny.util.SyncTask |
syncClientListTask
|
protected edu.cuny.util.SyncTask |
syncFeeTask
|
protected edu.cuny.util.SyncTask |
syncRegisterTask
|
protected edu.cuny.util.SyncTask |
syncTask
|
protected int |
syncTimeout
|
protected java.lang.Thread |
thread
|
Constructor Summary | |
---|---|
GameClock()
|
Method Summary | |
---|---|
void |
addAuctionEventListener(AuctionEventListener listener)
|
void |
clearListeners()
|
protected void |
dispose()
|
protected void |
fireEvent(AuctionEvent event)
|
int |
getDay()
|
int |
getDayBreak()
|
int |
getDayLen()
|
int |
getGameLen()
|
int |
getRound()
|
int |
getRoundBreak()
|
int |
getRoundLen()
|
java.lang.Thread |
getThread()
|
int |
getTick()
|
int[] |
getTime()
|
java.lang.String |
getTimeText()
|
void |
initialize()
|
boolean |
isActive()
|
void |
pause()
notifies the clock to pause. |
void |
removeAuctionEventListener(AuctionEventListener listener)
|
void |
resume()
notifies the clock to resume running. |
void |
run()
Makes this clock start to tick, not meaning the game is starting. |
void |
setup(edu.cuny.config.param.ParameterDatabase parameters,
edu.cuny.config.param.Parameter base)
|
void |
start()
|
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected static final int DEFAULT_SYNCTIMEOUT
protected int syncTimeout
protected int iterations
protected int gameLen
protected int dayLen
protected int roundLen
protected int gameBreak
protected int dayBreak
protected int roundClosingLen
protected int roundBreak
protected int gameInitLen
protected int dayInitLen
protected boolean logging
protected int day
protected int round
protected long round_start
protected java.util.LinkedList<AuctionEventListener> eventListeners
protected java.lang.Thread thread
protected boolean paused
protected edu.cuny.util.SyncTask syncTask
protected edu.cuny.util.SyncTask syncRegisterTask
protected edu.cuny.util.SyncTask syncFeeTask
protected edu.cuny.util.SyncTask syncClientListTask
protected Registry registry
protected CatpInfrastructure infrast
Constructor Detail |
---|
public GameClock()
Method Detail |
---|
public void setup(edu.cuny.config.param.ParameterDatabase parameters, edu.cuny.config.param.Parameter base)
setup
in interface edu.cuny.config.param.Parameterizable
public void initialize()
protected void dispose()
public boolean isActive()
public void run()
run
in interface java.lang.Runnable
public int[] getTime()
public java.lang.String getTimeText()
public int getDay()
public int getRound()
public int getTick()
public int getGameLen()
public int getDayLen()
public int getRoundLen()
public int getDayBreak()
public int getRoundBreak()
public void addAuctionEventListener(AuctionEventListener listener)
public void removeAuctionEventListener(AuctionEventListener listener)
public void clearListeners()
protected void fireEvent(AuctionEvent event)
public void start()
public void pause()
public void resume()
public java.lang.Thread getThread()
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 |