T
- the Game class being used by the server. Will correspond to the type of information retrieved by the Environment
class.public interface Spaceship<T>
Spaceship's are autonomous and issue commands through callbacks to the server using this class's methods. The flow operations is as follows:
registerShip(int, int, int)
to get registration
information and forwards registration to the serverEnvironment
and waiting for
a commandgetNextCommand(Environment)
and sends the returned
command back to the serverModifier and Type | Method and Description |
---|---|
ShipCommand |
getNextCommand(Environment<T> env)
Issues a command to be executed by this ship on the server.
|
RegistrationData |
registerShip(int numImages,
int worldWidth,
int worldHeight)
Registers a ship with the server so it can begin issuing commands.
|
void |
shipDestroyed(java.lang.String lastDestroyedBy)
Notifies a ship that it has been destroyed and respawned.
|
RegistrationData registerShip(int numImages, int worldWidth, int worldHeight)
numImages
- the number of images available for the ship's
appearance on the serverworldWidth
- the width of the current world in pixelsworldHeight
- the height of the current world in pixelsShipCommand getNextCommand(Environment<T> env)
Commands are executed one at a time, except for non-blocking commands. Commands cannot be issued except when requested by the server. The server will process each command, then send the new environment (representing the result of the issued command and any actions taken by other entities in the game world) back to the ship and request a new command.
env
- the current environment provided by the servervoid shipDestroyed(java.lang.String lastDestroyedBy)
lastDestroyedBy
- string containing the name of the player's ship or the object type name and #ID of the entity which destroyed your ship.