Class games.Battle.shared.comm.Command
All Packages Class Hierarchy This Package Previous Next Index
Class games.Battle.shared.comm.Command
java.lang.Object
|
+----games.Battle.shared.comm.BattlePacket
|
+----games.Battle.shared.comm.Command
- public class Command
- extends BattlePacket
A command is issued from the game client to the game server,
and represents a request from a player to the game engine
to modify his/her state on the game board. There are a variety
of possible commands, which are detailed in the Battle.sys.Symbols
class. When the game server receives a command from
the client, it can choose to execute it, or to ignore it, if
the command was not legal.
-
Command()
- Creates a default command which can then be filled using the
readFrom(is) method.
-
Command(int, short, int, int, int, int)
- Creates a command based on the given data, which it can then
send to a data stream using the writeTo(os) method.
-
asciiDump()
- Dump a text version of this command, for debugging.
-
fromBytes(byte[])
- With the given array of bytes, fill this command object
with data.
-
getCol()
- Return the column this command represents.
-
getId()
- Return the command id for this command.
-
getPlayer()
- Return the player id for this command.
-
getRow()
- Return the row this command represents.
-
getX()
- Return the x position within a cell this command originated from.
-
getY()
- Return the y position within a cell this command originated from.
-
toBytes()
- Convert this Command to an array of bytes for transmission.
-
toString()
- convert to a string representation
Command
public Command()
- Creates a default command which can then be filled using the
readFrom(is) method. The server will probably be the only
user of this method.
Command
public Command(int player,
short id,
int row,
int col,
int x,
int y)
- Creates a command based on the given data, which it can then
send to a data stream using the writeTo(os) method. The client
is probably the only user of this method.
- Parameters:
- player - who issued this command
- id - what command does this represent
- row - what row on the game board did this command come from
- col - what column on the game board did this command come from
- x - what x-position within the given cell did the command come from
- y - what y-position within the given cell did the command come from
toString
public String toString()
- convert to a string representation
- Overrides:
- toString in class Object
asciiDump
public void asciiDump()
- Dump a text version of this command, for debugging.
getPlayer
public final int getPlayer()
- Return the player id for this command.
getId
public final short getId()
- Return the command id for this command.
getRow
public final int getRow()
- Return the row this command represents. This data may or may
not be relevant for every command.
getCol
public final int getCol()
- Return the column this command represents. This data may or
may not be relevant for every command.
getX
public final int getX()
- Return the x position within a cell this command originated from.
This data may or may not be relevant for every command.
getY
public final int getY()
- Return the y position within a cell this command originated from.
This data may or may not be relevant for every command.
toBytes
protected byte[] toBytes()
- Convert this Command to an array of bytes for transmission.
- Overrides:
- toBytes in class BattlePacket
fromBytes
protected void fromBytes(byte data[])
- With the given array of bytes, fill this command object
with data.
- Parameters:
- data - the data to fill the command with.
- Overrides:
- fromBytes in class BattlePacket
All Packages Class Hierarchy This Package Previous Next Index