com.ibm.ruler
Interface IObject

All Known Subinterfaces:
ICastle, IKnight, IPeasant

public interface IObject

This interface is implemented by all objects in the game. It allows you to get the location of any object, and to determine the distance and heading to or from the object.


Method Summary
 int getDirectionTo(int x, int y)
          Returns the approximate direction (the closest of the 8 possible move directions) to the given position from this object.
 int getDistanceTo(int x, int y)
          Returns the minimum number of squares (units) between this object and the given position.
 int getId()
          Returns the id of this object.
 IRuler getRuler()
          Returns the ruler that commands this object.
 int getX()
          Returns the X position of the object.
 int getY()
          Returns the Y position of the object.
 boolean isAlive()
          Returns true if this object is alive, and false otherwise.
 

Method Detail

getDirectionTo

public int getDirectionTo(int x,
                          int y)
Returns the approximate direction (the closest of the 8 possible move directions) to the given position from this object.

Returns:
int

getDistanceTo

public int getDistanceTo(int x,
                         int y)
Returns the minimum number of squares (units) between this object and the given position. This is also the minimum number of moves that would be required to move to the given position.

Returns:
int

getId

public int getId()
Returns the id of this object. No two objects have the same id.

Returns:
int

getRuler

public IRuler getRuler()
Returns the ruler that commands this object.

Returns:
com.ibm.ruler.IRuler

getX

public int getX()
Returns the X position of the object.

Returns:
int

getY

public int getY()
Returns the Y position of the object.

Returns:
int

isAlive

public boolean isAlive()
Returns true if this object is alive, and false otherwise. All objects returned from the API methods will always be alive. This method only exists so that you can find out if any objects that you have cached between moves are still alive.

Returns:
boolean