sv
Class Game

java.lang.Object
  extended bysv.Game

public class Game
extends java.lang.Object

The game itself; contains the field, ammo and player information.

Author:
florian

Field Summary
static int F_ERROR
           
static int HIT
          field contains a ship, which was hit.
static int MISS
          field contains a miss (tried to hit ...)
static int SEA
          field contains sea (maybe undiscovered or a sea field on own side)
static int SHIP
          field contains a ship (on own side)
 
Constructor Summary
Game()
           
 
Method Summary
 int getAmmo()
          ...
 java.lang.String getName()
          get player name
 boolean getReady()
          used while syncronizing the game with other instance
 void gotResult(int x, int y, int z)
          signalize result achieved from other instance. change status of field to given constant (process hit, if necessary)
 int gotShot(int x, int y)
          signalize that we got shot ... process coordinates a return result
 void setAmmo(int a)
          set ammo (also at beginning!)
 void setName(java.lang.String n)
          set player name
 void setNetDaemon(NetDaemon nd)
          set network daemon (to shorten communication routes)
 void setReady(boolean r)
          used while syncronizing the game with other instance
 void setShips()
          set ships on own field.
 void setView(View v)
          set view of the game (to shorten communication routes)
 int shoot(int x, int y)
          try to shoot at field with given coords
 void updateScoreBoard()
          communicate with an update the score board to the actual values.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

F_ERROR

public static final int F_ERROR
See Also:
Constant Field Values

SEA

public static final int SEA
field contains sea (maybe undiscovered or a sea field on own side)

See Also:
Constant Field Values

MISS

public static final int MISS
field contains a miss (tried to hit ...)

See Also:
Constant Field Values

HIT

public static final int HIT
field contains a ship, which was hit.

See Also:
Constant Field Values

SHIP

public static final int SHIP
field contains a ship (on own side)

See Also:
Constant Field Values
Constructor Detail

Game

public Game()
Method Detail

setName

public void setName(java.lang.String n)
set player name

Parameters:
n -

getName

public java.lang.String getName()
get player name

Returns:

setAmmo

public void setAmmo(int a)
set ammo (also at beginning!)

Parameters:
a -

getAmmo

public int getAmmo()
...

Returns:
shots in int

setReady

public void setReady(boolean r)
used while syncronizing the game with other instance

Parameters:
r - ready or not

getReady

public boolean getReady()
used while syncronizing the game with other instance

Returns:
ready or not ...

setNetDaemon

public void setNetDaemon(NetDaemon nd)
set network daemon (to shorten communication routes)

Parameters:
nd -

setView

public void setView(View v)
set view of the game (to shorten communication routes)

Parameters:
v -

shoot

public int shoot(int x,
                 int y)
try to shoot at field with given coords

Parameters:
x -
y -
Returns:
0 so far ...

gotShot

public int gotShot(int x,
                   int y)
signalize that we got shot ... process coordinates a return result

Parameters:
x - x coord
y - y coord
Returns:
new content of field (stauts signalized by game's finals)

gotResult

public void gotResult(int x,
                      int y,
                      int z)
signalize result achieved from other instance. change status of field to given constant (process hit, if necessary)

Parameters:
x - x coord
y - y coord
z - final corresponding to game's finals.

setShips

public void setShips()
set ships on own field. some strategies maybe used, the most simple way ist to generate random positions of single fields. Attention: there has to be a constant number of fields set.


updateScoreBoard

public void updateScoreBoard()
communicate with an update the score board to the actual values.