objects
Class Player

java.lang.Object
  |
  +--objects.Player

public class Player
extends java.lang.Object

This is a player class. It contains information on a player that currently attends to the game.

If you write a user defined client, you should not try change this object by calling any of it's setter methods, as it will make your view of the game different from all the other players' views.

Also note that for clients, not all getter methods return usable results, as the server doesn't send everything across. The following information is, however, updated and usable for this class:

In addition, if the player object matches the player controlled by this client, the following informatin is available:

Author:
Sverre H. Huseby <shh@thathost.com>

Constructor Summary
Player()
          Constructs a new player with the default settings.
Player(short id, java.lang.String name)
          Constructs a new player with the given id and name.
 
Method Summary
 void decBombsLeft(int sub)
          Decreases the number of bombs left by the given number.
 void decDamage(int sub)
          Decreases the damage by the given amount.
 void decPhaserHeat(int sub)
          Decreases phaser heat by the given amount, making sure it doesn't get below zero.
 int getAntiScore()
          Returns the number of times this player has been killed.
 int getBombsLeft()
          Gets the number of available targeting bombs.
 int getDamage()
          Gets the current damage level.
 double getDirection()
          Returns the direction of this object in radians.
 short getDirectionAsShort()
          Returns the direction of this object in radians, encoded in a short for transfer to the game server.
 short getId()
          Fetches the ID of this player.
 java.awt.Point getLocation()
          Fetches the location of this player within the world.
 java.lang.String getName()
          Fetches the name of this player.
 int getPhaserHeat()
          Gets the current phaser heat value.
 int getRatio()
          Gets a ratio between the number of kills and the number of times being killed.
 java.lang.String getRatioString()
          Creates a string that describes the ratio between the number of kills and the number of times killed.
 int getScore()
          Fetches the number of kills done by this player.
 Ship getShip()
          Returns the Ship object that is controlled by this player.
 void incAntiScore()
          Increases the number of times this player has been killed.
 void incBombsLeft(int add)
          Increases the number of bombs left by the given number.
 void incDamage(int add)
          Increases the damage by the given amount.
 void incPhaserHeat(int add)
          Increases phaser heat by the given amount, making sure it doesn't get above 100.
 void incScore()
          Increases the number of kills done by this player.
 boolean isAlive()
          Checks if this player is dead or alive.
 boolean isInView(DrawableGameObject o)
           
 boolean isPhaserOverheated()
          Checks if the phaser cannon is currently overheated.
 void setAlive(boolean alive)
          Sets whether this player is alive.
 void setAntiScore(int antiScore)
          Sets the number of times this player has been killed.
 void setBombsLeft(int bombsLeft)
          Sets the available number of targeting bombs.
 void setDamage(int damage)
          Sets the damage level of this player.
 void setDirection(double angle)
          Sets the direction of this object as an angle in radians.
 void setDirectionFromShort(short angle)
          Sets the direction of this object, encoded as a short, as sent from the game server.
 void setId(short id)
          Sets the ID of this player.
 void setLocation(int x, int y)
          Sets the location of this object within the world.
 void setLocation(java.awt.Point loc)
          Sets the location of this object within the world.
 void setName(java.lang.String name)
          Sets the name of this player.
 void setPhaserHeat(int phaserHeat)
          Sets the phaser cannon heat percent of this player.
 void setScore(int score)
          Sets the current score.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Player

public Player()
Constructs a new player with the default settings.


Player

public Player(short id,
              java.lang.String name)
Constructs a new player with the given id and name.

Parameters:
id - the ID of this player.
name - the name.
Method Detail

setId

public final void setId(short id)
Sets the ID of this player. The ID is used for identifying players when talking to the server.

Parameters:
id - the ID of this player.

getId

public final short getId()
Fetches the ID of this player. The ID is used for identifying players when talking to the server.

Returns:
the ID of this player.

setName

public final void setName(java.lang.String name)
Sets the name of this player.

Parameters:
name - the name.

getName

public final java.lang.String getName()
Fetches the name of this player.

Returns:
the name.

setScore

public final void setScore(int score)
Sets the current score. The score is the number of kills done by this player.

Parameters:
score - the new score.

incScore

public final void incScore()
Increases the number of kills done by this player.


getScore

public final int getScore()
Fetches the number of kills done by this player.

Returns:
the number of kills.

setLocation

public void setLocation(java.awt.Point loc)
Sets the location of this object within the world. This method maps directly to the matching method within the player's Ship object.

Parameters:
loc - the location.
See Also:
Ship

setLocation

public void setLocation(int x,
                        int y)
Sets the location of this object within the world. This method maps directly to the matching method within the player's Ship object.

Parameters:
x - the x-coordinate.
y - the y-coordinate.
See Also:
Ship

getLocation

public final java.awt.Point getLocation()
Fetches the location of this player within the world. This method maps directly to the matching method within the player's Ship object.

Returns:
the location.
See Also:
Ship

setDirection

public final void setDirection(double angle)
Sets the direction of this object as an angle in radians. This method maps directly to the matching method within the player's Ship object.

Parameters:
angle - the angle in radians.
See Also:
Ship

getDirection

public final double getDirection()
Returns the direction of this object in radians. This method maps directly to the matching method within the player's Ship object.

Returns:
the direction.
See Also:
Ship

setDirectionFromShort

public final void setDirectionFromShort(short angle)
Sets the direction of this object, encoded as a short, as sent from the game server. This method maps directly to the matching method within the player's Ship object.

Parameters:
angle - the angle encoded as a short.
See Also:
Ship

getDirectionAsShort

public final short getDirectionAsShort()
Returns the direction of this object in radians, encoded in a short for transfer to the game server. This method maps directly to the matching method within the player's Ship object.

Returns:
the direction.
See Also:
Ship

getShip

public final Ship getShip()
Returns the Ship object that is controlled by this player.

Returns:
the Ship object.

setAlive

public final void setAlive(boolean alive)
Sets whether this player is alive.

Parameters:
alive - true to indicate that the player is alive, false to indicate that he/she is dead.

isAlive

public final boolean isAlive()
Checks if this player is dead or alive.

Returns:
true if the player is alive, false otherwise.

setDamage

public final void setDamage(int damage)
Sets the damage level of this player. Damage is between 0 and 100, with 100 indicating that the player is destroyed.

Parameters:
damage - the damage level.

incDamage

public final void incDamage(int add)
Increases the damage by the given amount. If damage gets above 100, it is set to 100.

Parameters:
add - the amount to add.

decDamage

public final void decDamage(int sub)
Decreases the damage by the given amount. If damage gets below 0, it is set to 0.

Parameters:
sub - the amount to subtract.

getDamage

public final int getDamage()
Gets the current damage level. Damage is between 0 and 100, with 100 indicating that the player is destroyed.

Returns:
the damage level.

setPhaserHeat

public final void setPhaserHeat(int phaserHeat)
Sets the phaser cannon heat percent of this player. The heat is a number between 0 and 100. Values above 75 or so indicates that the cannon is overheated, and it won't fire.

Parameters:
phaserHeat - the phaser heat value.

incPhaserHeat

public final void incPhaserHeat(int add)
Increases phaser heat by the given amount, making sure it doesn't get above 100.

Parameters:
add - the number to add.

decPhaserHeat

public final void decPhaserHeat(int sub)
Decreases phaser heat by the given amount, making sure it doesn't get below zero.

Parameters:
sub - the number to subtract.

getPhaserHeat

public final int getPhaserHeat()
Gets the current phaser heat value. The heat is a number between 0 and 100. Values above 75 or so indicates that the cannon is overheated, and it won't fire.

Returns:
the phaser heat value.

isPhaserOverheated

public final boolean isPhaserOverheated()
Checks if the phaser cannon is currently overheated.

Returns:
true if overheated, false otherwise.

setBombsLeft

public final void setBombsLeft(int bombsLeft)
Sets the available number of targeting bombs.

Parameters:
bombsLeft - the number of bombs.

incBombsLeft

public final void incBombsLeft(int add)
Increases the number of bombs left by the given number.

Parameters:
add - the number to add.

decBombsLeft

public final void decBombsLeft(int sub)
Decreases the number of bombs left by the given number.

Parameters:
sub - the number to subtract.

getBombsLeft

public final int getBombsLeft()
Gets the number of available targeting bombs.

Returns:
the number of bombs left.

setAntiScore

public final void setAntiScore(int antiScore)
Sets the number of times this player has been killed.

Parameters:
antiScore - the number of times killed.

incAntiScore

public final void incAntiScore()
Increases the number of times this player has been killed.


getAntiScore

public final int getAntiScore()
Returns the number of times this player has been killed.

Returns:
number of times killed.

getRatio

public final int getRatio()
Gets a ratio between the number of kills and the number of times being killed.

Returns:
the ratio.

getRatioString

public final java.lang.String getRatioString()
Creates a string that describes the ratio between the number of kills and the number of times killed. Used when scores are displayed.

Returns:
a string.

isInView

public final boolean isInView(DrawableGameObject o)