Class Player

java.lang.Object
net.sf.colossus.game.Player
Direct Known Subclasses:
PlayerClientSide, PlayerServerSide

public class Player extends Object
A player in a game. This class holds all information describing a player in a game, such as the current legions and the score. Instances of this class are always bound to an instance of Game. TODO there is an excessive amount of methods around the markersAvailable list.
  • Field Details

    • game

      private final Game game
      The game this information belongs to.
    • name

      private String name
      A name for this player for UI purposes and as identifier.
    • legions

      private final List<Legion> legions
      The current legions owned by this player.
    • number

      private final int number
      The number of the player in the game. TODO clarify if this is just an arbitrary number (in which case we might want to get rid of it) or the actual turn sequence
    • dead

      private boolean dead
      Set to true if the player is dead. TODO check if that isn't equivalent to not having legions anymore
    • deadBeforeSave

      private boolean deadBeforeSave
      Only needed during loading of a game. Pulled up to game anyway, getNumLivingLegions needs it during loading.
    • startingTower

      private MasterHex startingTower
      The starting tower of the player. TODO this should be kind-of final: once a tower has been assigned, it shouldn't change anymore -- but assigning the towers has probably to happen a while after all players are created. We could at least at an assertion into the setter that it is allowed to change the value only if it was not set before.
    • color

      private PlayerColor color
      The label of the color we use. TODO this should really be an object representing a markerset TODO similar to startingTower this should be set only once but probably can't be set in the constructor.
    • type

      private String type
      The type of player: local human, AI or network. TODO make typesafe version TODO shouldn't this be final? It should be possible to set that in the constructor. Unless we have to allow changes e.g. for humans dropping out of the game (in which case the todo should be read as "add some documentation regarding that ;-) ).
    • playersEliminated

      private String playersEliminated
      A string representing all players eliminated by this player. The format is just a sequence of the short, two-character versions of the colors, e.g. "BkRd". TODO this should really be a List
    • mulligansLeft

      private int mulligansLeft
    • score

      private int score
    • markersAvailable

      private final SortedSet<String> markersAvailable
      Sorted set of available legion markers for this player.
  • Constructor Details

    • Player

      public Player(Game game, String playerName, int number)
  • Method Details

    • getGame

      public Game getGame()
    • getLegions

      public List<? extends Legion> getLegions()
      TODO should be List, but currently subclasses still use more specific types TODO should be unmodifiable, but at least PlayerServerSide.die(Player) still removes items
    • getNumber

      public int getNumber()
    • getName

      public String getName()
    • setName

      public void setName(String name)
    • isDead

      public boolean isDead()
    • setDead

      public void setDead(boolean dead)
    • getDeadBeforeSave

      public boolean getDeadBeforeSave()
      During loading of a game, this player was already dead in the game before saving. No client needs to be created for this player, and all legion activities/reveals are skipped.
      Returns:
      True if player was dead
    • setDeadBeforeSave

      public void setDeadBeforeSave(boolean val)
    • setType

      public void setType(String type)
    • getType

      public String getType()
    • isHuman

      public boolean isHuman()
    • isLocalHuman

      public boolean isLocalHuman()
    • isNetwork

      public boolean isNetwork()
    • isNone

      public boolean isNone()
    • isAI

      public boolean isAI()
    • setStartingTower

      public void setStartingTower(MasterHex startingTower)
    • getStartingTower

      public MasterHex getStartingTower()
    • setColor

      public void setColor(PlayerColor color)
    • getColor

      public PlayerColor getColor()
    • getShortColor

      public String getShortColor()
    • getPlayersElim

      public String getPlayersElim()
    • setPlayersElim

      public void setPlayersElim(String playersEliminated)
    • addPlayerElim

      public void addPlayerElim(Player player)
    • getLegionByMarkerId

      public Legion getLegionByMarkerId(String markerId)
    • hasLegion

      public boolean hasLegion(String markerId)
    • getTitanLegion

      public Legion getTitanLegion()
    • addLegion

      public void addLegion(Legion legion)
    • removeLegion

      public void removeLegion(Legion legion)
    • removeAllLegions

      public void removeAllLegions()
    • addMarkerAvailable

      public void addMarkerAvailable(String markerId)
    • removeMarkerAvailable

      public void removeMarkerAvailable(String markerId)
    • clearMarkersAvailable

      public void clearMarkersAvailable()
    • getMarkersAvailable

      public Set<String> getMarkersAvailable()
    • getNumMarkersAvailable

      public int getNumMarkersAvailable()
    • getFirstAvailableMarker

      public String getFirstAvailableMarker()
    • isMarkerAvailable

      public boolean isMarkerAvailable(String markerId)
    • selectMarkerId

      public String selectMarkerId(String markerId)
      Removes the selected marker from the list of those available. Returns the markerId if it was present, or null if it was not.
    • getNumCreatures

      public int getNumCreatures()
    • toString

      public String toString()
      Overridden for debug/logging purposes.
      Overrides:
      toString in class Object
    • setMulligansLeft

      public void setMulligansLeft(int mulligansLeft)
    • getMulligansLeft

      public int getMulligansLeft()
    • setScore

      public void setScore(int score)
    • getScore

      public int getScore()
    • getTitanPower

      public int getTitanPower()
    • canTitanTeleport

      public boolean canTitanTeleport()
    • getTotalPointValue

      public int getTotalPointValue()
      Return the total value of all of this player's creatures.
    • hasTeleported

      public boolean hasTeleported()
    • hasMoved

      public boolean hasMoved()
      Check if the player has already moved.
      Returns:
      true iff at least one legion of the player has been moved
    • getNumLegions

      public int getNumLegions()
    • getTitanBasename

      public String getTitanBasename()
      Return the full basename for the titan of this player.
    • getAngelBasename

      public String getAngelBasename()
      Return the full basename for an angel of this player.