net.sf.colossus.server
Class PlayerServerSide

java.lang.Object
  extended by net.sf.colossus.game.Player
      extended by net.sf.colossus.server.PlayerServerSide
All Implemented Interfaces:
java.lang.Comparable<PlayerServerSide>

public final class PlayerServerSide
extends Player
implements java.lang.Comparable<PlayerServerSide>

Class Player holds the data for one player in a Titan game.

Author:
David Ripton

Field Summary
private  LegionServerSide donor
          The legion which gave a summonable creature.
private  java.lang.String firstMarker
           
private  java.util.List<Legion> legionsBackup
           
private static java.util.logging.Logger LOGGER
           
private  int movementRoll
          TODO this might be better as a state in Game since there is always only one per game, not per player
private  java.lang.String playersEliminatedBackup
           
private  double score
           
private  boolean summoned
           
private  boolean teleported
          TODO PlayerClientSide just checks if any legion has teleported.
private  boolean titanEliminated
           
 
Constructor Summary
PlayerServerSide(java.lang.String name, GameServerSide game, java.lang.String shortTypeName)
           
 
Method Summary
(package private)  void addPoints(double points, boolean halfPoints)
          Add points to this player's score.
(package private)  void awardPoints(int points, LegionServerSide legion, boolean halfPoints)
          Award points and handle all acquiring related issues.
 void backupLoadedData()
           
(package private)  boolean canRecruit()
          Return true if any legion can recruit.
(package private)  void commitMoves()
           
 int compareTo(PlayerServerSide other)
          Players are sorted in order of decreasing starting tower.
(package private)  void computeMarkersAvailable()
          Set markersAvailable based on other available information.
(package private)  int countMobileLegions()
          Return the number of this player's legions that have legal non-teleport moves remaining.
(package private)  void die(Player slayer)
          Turns the player dead.
(package private)  void eliminateTitan()
           
(package private)  LegionServerSide getDonor()
           
(package private)  java.lang.String getFirstMarker()
           
 GameServerSide getGame()
          Overridden to return specific flavor of Game until the upper class is sufficient.
 java.util.List<LegionServerSide> getLegions()
          TODO remove once noone needs the specific version anymore
(package private)  int getMovementRoll()
           
 int getMovementRollSS()
           
 int getScore()
           
(package private)  java.lang.String getStatusInfo(boolean treatDeadAsAlive)
          Return a colon-separated string with a bunch of info for the status screen.
 void handleSlaying(Player slayer)
           
(package private)  boolean hasSummoned()
           
 boolean hasTeleported()
           
(package private)  void initMarkersAvailable()
           
(package private)  void initMarkersAvailable(java.lang.String shortColor)
           
(package private)  boolean isTitanEliminated()
           
(package private)  int legionsMoved()
          Return the number of this player's legions that have moved.
(package private)  void recombineIllegalSplits()
           
(package private)  void removeEmptyLegions()
          Remove all of this player's zero-height legions.
(package private)  void resetTurnState()
           
 boolean resyncBackupData()
           
(package private)  int rollMovement()
           
(package private)  void setDonor(LegionServerSide donor)
           
(package private)  void setFirstMarker(java.lang.String firstMarker)
           
(package private)  void setMovementRoll(int movementRoll)
           
 void setScore(int score)
           
(package private)  void setSummoned(boolean summoned)
           
(package private)  void setTeleported(boolean teleported)
           
 void setType(java.lang.String shortTypeName)
           
(package private)  boolean splitLegionHasForcedMove()
          Return true if two or more of this player's legions share a hex and they have a legal non-teleport move.
(package private)  void takeMulligan()
           
(package private)  void truncScore()
          Remove half-points.
(package private)  void undoAllMoves()
           
(package private)  void undoMove(Legion legion)
           
(package private)  void undoRecruit(Legion legion)
          Tell legion to do undo the recruiting and trigger needed messages to be sent to clients
(package private)  void undoReinforcement(Legion legion)
          Tell legion to do undo the reinforcement and trigger needed messages to be sent to clients (quite similar to undorecuit, but not exactly the same)
(package private)  void undoSplit(Legion splitoff)
           
 
Methods inherited from class net.sf.colossus.game.Player
addLegion, addMarkerAvailable, addPlayerElim, canTitanTeleport, clearMarkersAvailable, getAngelBasename, getColor, getDeadBeforeSave, getFirstAvailableMarker, getLegionByMarkerId, getMarkersAvailable, getMulligansLeft, getName, getNumber, getNumCreatures, getNumLegions, getNumMarkersAvailable, getPlayersElim, getShortColor, getStartingTower, getTitanBasename, getTitanLegion, getTitanPower, getTotalPointValue, getType, hasLegion, hasMoved, isAI, isDead, isHuman, isLocalHuman, isMarkerAvailable, isNetwork, isNone, removeAllLegions, removeLegion, removeMarkerAvailable, selectMarkerId, setColor, setDead, setDeadBeforeSave, setMulligansLeft, setName, setPlayersElim, setStartingTower, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

LOGGER

private static final java.util.logging.Logger LOGGER

score

private double score

summoned

private boolean summoned

teleported

private boolean teleported
TODO PlayerClientSide just checks if any legion has teleported. Pick one version and move up into Player.


movementRoll

private int movementRoll
TODO this might be better as a state in Game since there is always only one per game, not per player


titanEliminated

private boolean titanEliminated

donor

private LegionServerSide donor
The legion which gave a summonable creature.


firstMarker

private java.lang.String firstMarker

playersEliminatedBackup

private java.lang.String playersEliminatedBackup

legionsBackup

private final java.util.List<Legion> legionsBackup
Constructor Detail

PlayerServerSide

PlayerServerSide(java.lang.String name,
                 GameServerSide game,
                 java.lang.String shortTypeName)
Method Detail

getGame

public GameServerSide getGame()
Overridden to return specific flavor of Game until the upper class is sufficient.

Overrides:
getGame in class Player

setType

public void setType(java.lang.String shortTypeName)
Overrides:
setType in class Player

initMarkersAvailable

void initMarkersAvailable()

initMarkersAvailable

void initMarkersAvailable(java.lang.String shortColor)

computeMarkersAvailable

void computeMarkersAvailable()
Set markersAvailable based on other available information. NOTE: to be used only during loading a Game!


setFirstMarker

void setFirstMarker(java.lang.String firstMarker)

getFirstMarker

java.lang.String getFirstMarker()

compareTo

public int compareTo(PlayerServerSide other)
Players are sorted in order of decreasing starting tower. This is inconsistent with equals().

Specified by:
compareTo in interface java.lang.Comparable<PlayerServerSide>

hasTeleported

public boolean hasTeleported()
Overrides:
hasTeleported in class Player

setTeleported

void setTeleported(boolean teleported)

hasSummoned

boolean hasSummoned()

setSummoned

void setSummoned(boolean summoned)

getDonor

LegionServerSide getDonor()

setDonor

void setDonor(LegionServerSide donor)

removeEmptyLegions

void removeEmptyLegions()
Remove all of this player's zero-height legions.


getLegions

public java.util.List<LegionServerSide> getLegions()
TODO remove once noone needs the specific version anymore

Overrides:
getLegions in class Player

legionsMoved

int legionsMoved()
Return the number of this player's legions that have moved.


countMobileLegions

int countMobileLegions()
Return the number of this player's legions that have legal non-teleport moves remaining.


commitMoves

void commitMoves()

getMovementRollSS

public int getMovementRollSS()

getMovementRoll

int getMovementRoll()

setMovementRoll

void setMovementRoll(int movementRoll)

resetTurnState

void resetTurnState()

rollMovement

int rollMovement()

takeMulligan

void takeMulligan()

undoMove

void undoMove(Legion legion)

undoAllMoves

void undoAllMoves()

splitLegionHasForcedMove

boolean splitLegionHasForcedMove()
Return true if two or more of this player's legions share a hex and they have a legal non-teleport move.


canRecruit

boolean canRecruit()
Return true if any legion can recruit.


undoRecruit

void undoRecruit(Legion legion)
Tell legion to do undo the recruiting and trigger needed messages to be sent to clients

Parameters:
legion - The legion which undoes the recruiting

undoReinforcement

void undoReinforcement(Legion legion)
Tell legion to do undo the reinforcement and trigger needed messages to be sent to clients (quite similar to undorecuit, but not exactly the same)

Parameters:
legion - The legion which cancels the reinforcement

undoSplit

void undoSplit(Legion splitoff)

recombineIllegalSplits

void recombineIllegalSplits()

setScore

public void setScore(int score)
Overrides:
setScore in class Player

getScore

public int getScore()
Overrides:
getScore in class Player

addPoints

void addPoints(double points,
               boolean halfPoints)
Add points to this player's score. Update the status window to reflect the addition.


truncScore

void truncScore()
Remove half-points.


awardPoints

void awardPoints(int points,
                 LegionServerSide legion,
                 boolean halfPoints)
Award points and handle all acquiring related issues. Note that this is not used for adding points for cleaning up legions of a dead player!

Parameters:
points - the points to award
legion - the legion which is entitled to acquire due to that
halfPoints - this are already halfPoints (from fleeing)

die

void die(Player slayer)
Turns the player dead. This method calculates the points other players get, adds them to their score and then cleans up this player and marks him dead. TODO is it really the Player's role to assign points? I'd rather see that responsibility with the Game object TODO the slayer could be non-null if we introduce a null object (some object called e.g. "NOONE" that behaves like a Player as far as possible, giving a name and swallowing points)

Parameters:
slayer - The player who killed us. May be null if we just gave up or it is a draw.

handleSlaying

public void handleSlaying(Player slayer)

eliminateTitan

void eliminateTitan()

isTitanEliminated

boolean isTitanEliminated()

getStatusInfo

java.lang.String getStatusInfo(boolean treatDeadAsAlive)
Return a colon-separated string with a bunch of info for the status screen.


backupLoadedData

public void backupLoadedData()

resyncBackupData

public boolean resyncBackupData()