dk.itu.smds.torusman
Class LocalMan

java.lang.Object
  extended by dk.itu.smds.torusman.LocalMan
All Implemented Interfaces:
Man

public class LocalMan
extends java.lang.Object
implements Man


Nested Class Summary
 class LocalMan.Other
          Structure to hold other's position and data freshness.
 
Field Summary
 int key_down
           
 int key_left
           
 int key_right
           
 int key_up
           
 ManData manData
          Man and team ID, and position and direction within the board.
 java.util.Hashtable otherMen
          A table mapping other men's ID to their current position
 Scores scores
          A table mapping a teamID to current score.
 int time
          The LocalMan's notion of time.
 
Constructor Summary
LocalMan()
          Nullary constructor, used only for deserialization.
LocalMan(byte manId, byte teamId, int key_up, int key_down, int key_left, int key_right)
           
 
Method Summary
 void deserialize(java.io.DataInputStream in)
          Deserialize this man from a stream.
 byte getManId()
          The id of the man.
 byte getX()
          X coordinate of current board that the man is on.
 byte getY()
          Y coordinate of current board that the man is on.
 void movedTo(ManData manData)
          Callback handle to be invoked when a man has moved to a new position.
 void serialize(java.io.DataOutputStream out)
          Serialize this man to a stream.
 void updatePoints(Scores scores)
          Callback handle to be invoked when scores have been updated.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

manData

public ManData manData
Man and team ID, and position and direction within the board.


time

public int time
The LocalMan's notion of time. The time displayed on the playing field is some constant fraction of this value.


otherMen

public java.util.Hashtable otherMen
A table mapping other men's ID to their current position


scores

public Scores scores
A table mapping a teamID to current score.


key_up

public int key_up

key_down

public int key_down

key_left

public int key_left

key_right

public int key_right
Constructor Detail

LocalMan

public LocalMan(byte manId,
                byte teamId,
                int key_up,
                int key_down,
                int key_left,
                int key_right)

LocalMan

public LocalMan()
Nullary constructor, used only for deserialization.

Method Detail

getManId

public byte getManId()
Description copied from interface: Man
The id of the man.

Specified by:
getManId in interface Man

getX

public byte getX()
Description copied from interface: Man
X coordinate of current board that the man is on.

Specified by:
getX in interface Man

getY

public byte getY()
Description copied from interface: Man
Y coordinate of current board that the man is on.

Specified by:
getY in interface Man

movedTo

public void movedTo(ManData manData)
Description copied from interface: Man
Callback handle to be invoked when a man has moved to a new position.

Specified by:
movedTo in interface Man

updatePoints

public void updatePoints(Scores scores)
Description copied from interface: Man
Callback handle to be invoked when scores have been updated.

Specified by:
updatePoints in interface Man
Parameters:
scores - Table mapping teamId to team points.

serialize

public void serialize(java.io.DataOutputStream out)
               throws java.io.IOException
Description copied from interface: Man
Serialize this man to a stream.

Specified by:
serialize in interface Man
Throws:
java.io.IOException

deserialize

public void deserialize(java.io.DataInputStream in)
                 throws java.io.IOException
Description copied from interface: Man
Deserialize this man from a stream.

Specified by:
deserialize in interface Man
Throws:
java.io.IOException