Package net.sf.colossus.game
Class Player
- java.lang.Object
-
- net.sf.colossus.game.Player
-
- Direct Known Subclasses:
PlayerClientSide,PlayerServerSide
public class Player extends java.lang.ObjectA 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 ofGame. TODO there is an excessive amount of methods around the markersAvailable list.
-
-
Field Summary
Fields Modifier and Type Field Description private PlayerColorcolorThe label of the color we use.private booleandeadSet to true if the player is dead.private booleandeadBeforeSaveOnly needed during loading of a game.private GamegameThe game this information belongs to.private java.util.List<Legion>legionsThe current legions owned by this player.private java.util.SortedSet<java.lang.String>markersAvailableSorted set of available legion markers for this player.private intmulligansLeftprivate java.lang.StringnameA name for this player for UI purposes and as identifier.private intnumberThe number of the player in the game.private java.lang.StringplayersEliminatedA string representing all players eliminated by this player.private intscoreprivate MasterHexstartingTowerThe starting tower of the player.private java.lang.StringtypeThe type of player: local human, AI or network.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddLegion(Legion legion)voidaddMarkerAvailable(java.lang.String markerId)voidaddPlayerElim(Player player)booleancanTitanTeleport()voidclearMarkersAvailable()java.lang.StringgetAngelBasename()Return the full basename for an angel of this player.PlayerColorgetColor()booleangetDeadBeforeSave()During loading of a game, this player was already dead in the game before saving.java.lang.StringgetFirstAvailableMarker()GamegetGame()LegiongetLegionByMarkerId(java.lang.String markerId)java.util.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 itemsjava.util.Set<java.lang.String>getMarkersAvailable()intgetMulligansLeft()java.lang.StringgetName()intgetNumber()intgetNumCreatures()intgetNumLegions()intgetNumMarkersAvailable()java.lang.StringgetPlayersElim()intgetScore()java.lang.StringgetShortColor()MasterHexgetStartingTower()java.lang.StringgetTitanBasename()Return the full basename for the titan of this player.LegiongetTitanLegion()intgetTitanPower()intgetTotalPointValue()Return the total value of all of this player's creatures.java.lang.StringgetType()booleanhasLegion(java.lang.String markerId)booleanhasMoved()Check if the player has already moved.booleanhasTeleported()booleanisAI()booleanisDead()booleanisHuman()booleanisLocalHuman()booleanisMarkerAvailable(java.lang.String markerId)booleanisNetwork()booleanisNone()voidremoveAllLegions()voidremoveLegion(Legion legion)voidremoveMarkerAvailable(java.lang.String markerId)java.lang.StringselectMarkerId(java.lang.String markerId)Removes the selected marker from the list of those available.voidsetColor(PlayerColor color)voidsetDead(boolean dead)voidsetDeadBeforeSave(boolean val)voidsetMulligansLeft(int mulligansLeft)voidsetName(java.lang.String name)voidsetPlayersElim(java.lang.String playersEliminated)voidsetScore(int score)voidsetStartingTower(MasterHex startingTower)voidsetType(java.lang.String type)java.lang.StringtoString()Overridden for debug/logging purposes.
-
-
-
Field Detail
-
game
private final Game game
The game this information belongs to.
-
name
private java.lang.String name
A name for this player for UI purposes and as identifier.
-
legions
private final java.util.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 tostartingTowerthis should be set only once but probably can't be set in the constructor.
-
type
private java.lang.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 java.lang.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 java.util.SortedSet<java.lang.String> markersAvailable
Sorted set of available legion markers for this player.
-
-
Constructor Detail
-
Player
public Player(Game game, java.lang.String playerName, int number)
-
-
Method Detail
-
getGame
public Game getGame()
-
getLegions
public java.util.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 java.lang.String getName()
-
setName
public void setName(java.lang.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(java.lang.String type)
-
getType
public java.lang.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 java.lang.String getShortColor()
-
getPlayersElim
public java.lang.String getPlayersElim()
-
setPlayersElim
public void setPlayersElim(java.lang.String playersEliminated)
-
addPlayerElim
public void addPlayerElim(Player player)
-
getLegionByMarkerId
public Legion getLegionByMarkerId(java.lang.String markerId)
-
hasLegion
public boolean hasLegion(java.lang.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(java.lang.String markerId)
-
removeMarkerAvailable
public void removeMarkerAvailable(java.lang.String markerId)
-
clearMarkersAvailable
public void clearMarkersAvailable()
-
getMarkersAvailable
public java.util.Set<java.lang.String> getMarkersAvailable()
-
getNumMarkersAvailable
public int getNumMarkersAvailable()
-
getFirstAvailableMarker
public java.lang.String getFirstAvailableMarker()
-
isMarkerAvailable
public boolean isMarkerAvailable(java.lang.String markerId)
-
selectMarkerId
public java.lang.String selectMarkerId(java.lang.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 java.lang.String toString()
Overridden for debug/logging purposes.- Overrides:
toStringin classjava.lang.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 java.lang.String getTitanBasename()
Return the full basename for the titan of this player.
-
getAngelBasename
public java.lang.String getAngelBasename()
Return the full basename for an angel of this player.
-
-