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.

Constructor Index

 o Command()
Creates a default command which can then be filled using the readFrom(is) method.
 o 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.

Method Index

 o asciiDump()
Dump a text version of this command, for debugging.
 o fromBytes(byte[])
With the given array of bytes, fill this command object with data.
 o getCol()
Return the column this command represents.
 o getId()
Return the command id for this command.
 o getPlayer()
Return the player id for this command.
 o getRow()
Return the row this command represents.
 o getX()
Return the x position within a cell this command originated from.
 o getY()
Return the y position within a cell this command originated from.
 o toBytes()
Convert this Command to an array of bytes for transmission.
 o toString()
convert to a string representation

Constructors

 o 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.
 o 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

Methods

 o toString
  public String toString()
convert to a string representation
Overrides:
toString in class Object
 o asciiDump
  public void asciiDump()
Dump a text version of this command, for debugging.
 o getPlayer
  public final int getPlayer()
Return the player id for this command.
 o getId
  public final short getId()
Return the command id for this command.
 o getRow
  public final int getRow()
Return the row this command represents. This data may or may not be relevant for every command.
 o getCol
  public final int getCol()
Return the column this command represents. This data may or may not be relevant for every command.
 o 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.
 o 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.
 o toBytes
  protected byte[] toBytes()
Convert this Command to an array of bytes for transmission.
Overrides:
toBytes in class BattlePacket
 o 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