|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectes.ucm.fdi.hysteria.console.Engine
public class Engine
Represents the game engine that controls the execution of the game since the beginning to the end, dealing with the configuration, the input stream and the output stream.
Field Summary | |
---|---|
protected GameConfig |
_config
Configuration |
protected java.util.Deque<Game> |
_future
|
protected Game |
_game
The game |
protected Game |
_gameCopy
A referential copy of the game. |
protected java.util.Deque<Game> |
_history
|
protected java.io.InputStream |
_in
Input Stream... just in case |
protected Message |
_lastMessage
|
protected boolean |
_online
|
protected java.io.ObjectInputStream |
_onlineIos
|
protected java.io.ObjectOutputStream |
_onlineOos
|
protected java.io.PrintStream |
_out
Output Stream... just in case |
protected Parser |
_parser
The parser |
protected MP3Player |
_player
|
protected java.net.Socket |
_socket
|
static java.lang.String |
FLAG_AUTODESCRIBEFIRSTLOCATION
Flag for auto-describing first location (the name of the property). |
static java.lang.String |
FLAG_PLAYMUSIC
Flag for playing music (the name of the property). |
static java.lang.String |
FLAG_SHOWCONNECTIONS
Flag for showing connections (the name of the property). |
static java.lang.String |
FLAG_SHOWCONNECTIONS_STATE
|
static java.lang.String |
FLAG_SHOWENGINEINFO
Flag for showing engine information (the name of the property). |
static java.lang.String |
FLAG_SHOWGAMEINFO
Flag for showing game information (the name of the property). |
static java.lang.String |
FLAG_SHOWITEMVALUES
Flag for showing the numerical value of the game items (the name of the property). |
static java.lang.String |
FLAG_SHOWITEMWEIGHTS
Flag for showing the weight of the game items (the name of the property). |
static java.lang.String |
FLAG_SHOWLOCATIONITEMS
Flag for showing the items of each location (the name of the property). |
static java.lang.String |
LIMIT_COMMANDHISTORYSIZE
Limit of command history size for the undo command (the name of the property). |
static java.lang.String |
LIMIT_INVENTORYCAPACITY
Limit of inventory capacity (the name of the property). |
static java.lang.String |
MESSAGE_ENGINEHELP
Message of help information from the engine (the name of the property). |
static java.lang.String |
MESSAGE_GAMEOVER
Message of game over (the name of the property). |
static java.lang.String |
MESSAGE_LOCATIONWITHEXITS
|
static java.lang.String |
MESSAGE_LOCATIONWITHITEMS
Message of location with items (the name of the property). |
static java.lang.String |
MESSAGE_LOCATIONWITHOUTEXITS
|
static java.lang.String |
MESSAGE_LOCATIONWITHOUTITEMS
Message of location without items (the name of the property). |
static java.lang.String |
MESSAGE_OBSTACLE_CLOSED
Message of obstacle closed found (the name of the property). |
static java.lang.String |
MESSAGE_OBSTACLE_FREE
Message of no obstacle found (the name of the property). |
static java.lang.String |
MESSAGE_OBSTACLE_OPEN
Message of obstacle opened found (the name of the property). |
static java.lang.String |
MESSAGE_PLAYERSCORE
Message of the player score (the name of the property). |
static java.lang.String |
MESSAGE_PROMPT
Message of prompt for the player (the name of the property). |
static java.lang.String |
MESSAGE_UNKNOWNCOMMAND
Message of unknown command (the name of the property). |
static java.lang.String |
UNIT_POINTS
Unit of measurement for points in-game This property is called "unit.points" and its default value is "points". |
static java.lang.String |
UNIT_POINTS_AB
Unit of measurement for weights in-game abbreviated This property is called "unit.points.ab" and its default value is "p's". |
static java.lang.String |
UNIT_WEIGHT
Unit of measurement for weights in-game This property is called "unit.weight" and its default value is "kilos". |
static java.lang.String |
UNIT_WEIGHT_AB
Unit of measurement for weights in-game abbreviated This property is called "unit.weight.ab" and its default value is "k's". |
Constructor Summary | |
---|---|
Engine(Game game)
Constructs the game engine using a given game. |
|
Engine(Game game,
java.io.InputStream input)
Constructs the game engine using a given game and a given input stream. |
|
Engine(Game game,
java.io.InputStream input,
java.io.OutputStream output)
Constructs the game engine using a given game, a given input stream and a given output stream. |
|
Engine(Game game,
java.io.OutputStream output)
Constructs the game engine using a given game and a given output stream. |
|
Engine(Game game,
java.util.Properties config)
Constructs the game engine using a given game and a given configuration. |
|
Engine(Game game,
java.util.Properties config,
java.io.InputStream input)
Constructs the game engine using a given game, a given configuration and a given output stream. |
|
Engine(Game game,
java.util.Properties config,
java.io.InputStream input,
java.io.OutputStream output)
Constructs the game engine using a given game, a given configuration, a given input stream and a given output stream. |
|
Engine(Game game,
java.util.Properties config,
java.io.OutputStream output)
Constructs the game engine using a given game, a given configuration and a given input stream. |
Method Summary | |
---|---|
protected int |
getRedoableCommands()
It asks about the number of redo games stored |
java.net.Socket |
getSocket()
|
protected int |
getUndoableCommands()
It asks about the number of undo games stored |
java.util.Vector<UserFileData> |
getUserFileVector()
|
boolean |
isOnline()
|
boolean |
loadGame(java.lang.String path)
|
boolean |
redo()
It requests a cloned and future game to be the principal game |
java.lang.String |
reportLocationInfo()
|
void |
run()
Runs the main loop of the game execution. |
boolean |
saveGame(java.lang.String path)
|
void |
setConfig(java.util.Properties config)
Sets a new configuration. |
void |
setInput(java.io.InputStream input)
Sets the input stream for the game engine. |
void |
setOutput(java.io.OutputStream output)
Sets the output stream for the game engine. |
void |
setSocket(java.net.Socket sock,
java.io.ObjectInputStream ios,
java.io.ObjectOutputStream oos)
|
boolean |
undo()
It requests a cloned and past game to be the principal game |
protected void |
updateMusic()
Manages the music. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String UNIT_WEIGHT
public static final java.lang.String UNIT_WEIGHT_AB
public static final java.lang.String UNIT_POINTS
public static final java.lang.String UNIT_POINTS_AB
public static final java.lang.String FLAG_AUTODESCRIBEFIRSTLOCATION
public static final java.lang.String FLAG_SHOWENGINEINFO
public static final java.lang.String FLAG_SHOWGAMEINFO
public static final java.lang.String FLAG_SHOWITEMVALUES
public static final java.lang.String FLAG_SHOWITEMWEIGHTS
public static final java.lang.String FLAG_SHOWLOCATIONITEMS
public static final java.lang.String FLAG_PLAYMUSIC
public static final java.lang.String LIMIT_COMMANDHISTORYSIZE
public static final java.lang.String LIMIT_INVENTORYCAPACITY
public static final java.lang.String MESSAGE_ENGINEHELP
public static final java.lang.String MESSAGE_GAMEOVER
public static final java.lang.String MESSAGE_LOCATIONWITHITEMS
public static final java.lang.String MESSAGE_LOCATIONWITHOUTITEMS
public static final java.lang.String MESSAGE_PLAYERSCORE
public static final java.lang.String MESSAGE_PROMPT
public static final java.lang.String MESSAGE_UNKNOWNCOMMAND
public static final java.lang.String FLAG_SHOWCONNECTIONS
public static final java.lang.String FLAG_SHOWCONNECTIONS_STATE
public static final java.lang.String MESSAGE_LOCATIONWITHEXITS
public static final java.lang.String MESSAGE_LOCATIONWITHOUTEXITS
public static final java.lang.String MESSAGE_OBSTACLE_OPEN
public static final java.lang.String MESSAGE_OBSTACLE_CLOSED
public static final java.lang.String MESSAGE_OBSTACLE_FREE
protected Game _game
protected Game _gameCopy
protected Parser _parser
protected java.io.InputStream _in
protected java.io.PrintStream _out
protected GameConfig _config
protected java.util.Deque<Game> _history
protected java.util.Deque<Game> _future
protected MP3Player _player
protected java.net.Socket _socket
protected boolean _online
protected java.io.ObjectOutputStream _onlineOos
protected java.io.ObjectInputStream _onlineIos
protected Message _lastMessage
Constructor Detail |
---|
public Engine(Game game) throws java.lang.IllegalArgumentException
game
- The game
java.lang.IllegalArgumentException
- Argument game cannot be nullpublic Engine(Game game, java.io.InputStream input) throws java.lang.IllegalArgumentException
game
- The gameinput
- Input Stream
java.lang.IllegalArgumentException
- Arguments game and input cannot be nullpublic Engine(Game game, java.io.InputStream input, java.io.OutputStream output) throws java.lang.IllegalArgumentException
game
- The gameinput
- Input streamoutput
- Output stream
java.lang.IllegalArgumentException
- Arguments game, input and output cannot be nullpublic Engine(Game game, java.io.OutputStream output) throws java.lang.IllegalArgumentException
game
- The gameoutput
- Output stream
java.lang.IllegalArgumentException
- Arguments game and output cannot be nullpublic Engine(Game game, java.util.Properties config) throws java.lang.IllegalArgumentException
game
- The gameconfig
- The config
java.lang.IllegalArgumentException
- Arguments game and input cannot be nullpublic Engine(Game game, java.util.Properties config, java.io.InputStream input) throws java.lang.IllegalArgumentException
game
- The gameconfig
- The configinput
- Input stream
java.lang.IllegalArgumentException
- Arguments game, config and input cannot be nullpublic Engine(Game game, java.util.Properties config, java.io.InputStream input, java.io.OutputStream output) throws java.lang.IllegalArgumentException
game
- The gameconfig
- The configinput
- Input streamoutput
- Output stream
java.lang.IllegalArgumentException
- Argument game, config, input and output cannot be nullpublic Engine(Game game, java.util.Properties config, java.io.OutputStream output) throws java.lang.IllegalArgumentException
game
- The gameconfig
- The configoutput
- Output stream
java.lang.IllegalArgumentException
- Arguments game, config and output cannot be nullMethod Detail |
---|
public void run()
public void setConfig(java.util.Properties config) throws java.lang.IllegalArgumentException
config
- The config
java.lang.IllegalArgumentException
- Argument config cannot be nullpublic void setInput(java.io.InputStream input) throws java.lang.IllegalArgumentException
input
- Input stream
java.lang.IllegalArgumentException
- Argument input cannot be nullpublic void setOutput(java.io.OutputStream output) throws java.lang.IllegalArgumentException
output
- Output stream
java.lang.IllegalArgumentException
- Argument output cannot be nullpublic boolean undo()
public boolean redo()
protected int getUndoableCommands()
protected int getRedoableCommands()
protected void updateMusic()
public boolean saveGame(java.lang.String path) throws java.io.FileNotFoundException, java.io.IOException, java.lang.ClassNotFoundException
java.io.FileNotFoundException
java.io.IOException
java.lang.ClassNotFoundException
public boolean loadGame(java.lang.String path) throws java.io.IOException, java.lang.ClassNotFoundException
java.io.IOException
java.lang.ClassNotFoundException
public java.util.Vector<UserFileData> getUserFileVector() throws java.io.IOException, java.lang.ClassNotFoundException
java.io.IOException
java.lang.ClassNotFoundException
public void setSocket(java.net.Socket sock, java.io.ObjectInputStream ios, java.io.ObjectOutputStream oos)
public java.net.Socket getSocket()
public boolean isOnline()
public java.lang.String reportLocationInfo()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |