Class PlayerServerSide

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

public final class PlayerServerSide extends Player implements Comparable<PlayerServerSide>
Class Player holds the data for one player in a Titan game.
Author:
David Ripton
  • Field Details

    • LOGGER

      private static final 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 String firstMarker
    • playersEliminatedBackup

      private String playersEliminatedBackup
    • legionsBackup

      private final List<Legion> legionsBackup
    • previousUndoRecruitLegion

      private Legion previousUndoRecruitLegion
  • Constructor Details

  • Method Details

    • 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(String shortTypeName)
      Overrides:
      setType in class Player
    • initMarkersAvailable

      void initMarkersAvailable()
    • initMarkersAvailable

      void initMarkersAvailable(String shortColor)
    • computeMarkersAvailable

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

      void setFirstMarker(String firstMarker)
    • getFirstMarker

      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 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 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

      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()