de.adom.jade.kernel
Class Game

java.lang.Object
  extended by de.adom.jade.kernel.Game
All Implemented Interfaces:
java.io.Serializable

public final class Game
extends java.lang.Object
implements java.io.Serializable

Stores all global data. Also all the meta data for the game is managed in this class.

Game time is measured in ticks. An average action taken by an absolutely average person costs 1000 ticks (or energy points). The basic assumption is that 100 ticks equal 1 second. Since the amount of ticks is measured in a long variable, JADE is able to run for about 1.067.519.911.673 game days, which in JADE time (12 months with 28 days each) is equal to 3.177.142.594 game years. That should be sufficient even for those folks who tried to find the end of the infinite dungeon in ADOM.

See Also:
Serialized Form

Method Summary
 void addActorListener(ActorListener actorListener)
          Adds an actor listener to the game.
 long createGUID()
          Creates a new GUID.
 void fireAfterActionEvent(Actor actor)
          Fires an actor event after an actor acts.
 void fireBeforeActionEvent(Actor actor)
          Fires an actor event before an actor acts.
static Game getInstance()
          The game kernel is implemented as a singleton.
 LocationManager getLocationManager()
          Returns the location manager for the whole world.
 PC getPC()
          Returns the global PC instance.
 long getTime()
          Returns the current game time.
static UserInterface getUserInterface()
          Returns the user interface for this game.
 int random(int upper)
          Returns a random number in the given range of 0...
 void removeActorListener(ActorListener actorListener)
          Removes an actor listener from the game.
 void setPC(PC thePC)
          Sets the PC for the game.
 void setTime(long theTicks)
          Sets the game time.
static void setUserInterface(UserInterface theUI)
          Sets the valid user interface for this game.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

setUserInterface

public static void setUserInterface(UserInterface theUI)
Sets the valid user interface for this game.

Parameters:
theUI - the user interface for this game

getUserInterface

public static UserInterface getUserInterface()
Returns the user interface for this game.

Returns:
the user interface for this game

setTime

public void setTime(long theTicks)
Sets the game time.

Parameters:
theTicks - the game time (in ticks)

getTime

public long getTime()
Returns the current game time.

Returns:
the current game time (in ticks)

setPC

public void setPC(PC thePC)
Sets the PC for the game. Right now the decision to include this method makes the game inherently single-player altough some other aspects of the game are designed with a hint of multi-player capabilities. But it is my basic notion that roguelike games are not really well-suited for multiplaye aspects so for now JADE will be single-player.

Parameters:
thePC - the PC instance to use

getPC

public PC getPC()
Returns the global PC instance.

Returns:
the global PC instance

addActorListener

public void addActorListener(ActorListener actorListener)
Adds an actor listener to the game.

Parameters:
actorListener - the listener

removeActorListener

public void removeActorListener(ActorListener actorListener)
Removes an actor listener from the game.

Parameters:
actorListener - the listener

fireBeforeActionEvent

public void fireBeforeActionEvent(Actor actor)
Fires an actor event before an actor acts.

Parameters:
actor - the responsible actor

fireAfterActionEvent

public void fireAfterActionEvent(Actor actor)
Fires an actor event after an actor acts.

Parameters:
actor - the responsible actor

getInstance

public static Game getInstance()
The game kernel is implemented as a singleton. This method provides access to the game kernel singleton.

Returns:
the game kernel singleton

createGUID

public long createGUID()
Creates a new GUID.

Returns:
a new GUID
See Also:
GUIDCarrier

getLocationManager

public LocationManager getLocationManager()
Returns the location manager for the whole world.

Returns:
the location manager

random

public int random(int upper)
Returns a random number in the given range of 0...upper-1.

Parameters:
upper - the upper limit of the random number; a number in the range of 0...upper-1 will be created