Class Player
java.lang.Object
net.sf.colossus.game.Player
- Direct Known Subclasses:
PlayerClientSide, PlayerServerSide
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 Summary
FieldsModifier and TypeFieldDescriptionprivate PlayerColorThe label of the color we use.private booleanSet to true if the player is dead.private booleanOnly needed during loading of a game.private final GameThe game this information belongs to.The current legions owned by this player.Sorted set of available legion markers for this player.private intprivate StringA name for this player for UI purposes and as identifier.private final intThe number of the player in the game.private StringA string representing all players eliminated by this player.private intprivate MasterHexThe starting tower of the player.private StringThe type of player: local human, AI or network. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidaddMarkerAvailable(String markerId) voidaddPlayerElim(Player player) booleanvoidReturn the full basename for an angel of this player.getColor()booleanDuring loading of a game, this player was already dead in the game before saving.getGame()getLegionByMarkerId(String markerId) TODO should be List, but currently subclasses still use more specific types TODO should be unmodifiable, but at least PlayerServerSide.die(Player)still removes itemsintgetName()intintintintintgetScore()Return the full basename for the titan of this player.intintReturn the total value of all of this player's creatures.getType()booleanbooleanhasMoved()Check if the player has already moved.booleanbooleanisAI()booleanisDead()booleanisHuman()booleanbooleanisMarkerAvailable(String markerId) booleanbooleanisNone()voidvoidremoveLegion(Legion legion) voidremoveMarkerAvailable(String markerId) selectMarkerId(String markerId) Removes the selected marker from the list of those available.voidsetColor(PlayerColor color) voidsetDead(boolean dead) voidsetDeadBeforeSave(boolean val) voidsetMulligansLeft(int mulligansLeft) voidvoidsetPlayersElim(String playersEliminated) voidsetScore(int score) voidsetStartingTower(MasterHex startingTower) voidtoString()Overridden for debug/logging purposes.
-
Field Details
-
game
The game this information belongs to. -
name
A name for this player for UI purposes and as identifier. -
legions
-
number
private final int numberThe 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 deadSet to true if the player is dead. TODO check if that isn't equivalent to not having legions anymore -
deadBeforeSave
private boolean deadBeforeSaveOnly needed during loading of a game. Pulled up to game anyway, getNumLivingLegions needs it during loading. -
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
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
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
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
-
-
Constructor Details
-
Player
-
-
Method Details
-
getGame
-
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
-
setName
-
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
-
getType
-
isHuman
public boolean isHuman() -
isLocalHuman
public boolean isLocalHuman() -
isNetwork
public boolean isNetwork() -
isNone
public boolean isNone() -
isAI
public boolean isAI() -
setStartingTower
-
getStartingTower
-
setColor
-
getColor
-
getShortColor
-
getPlayersElim
-
setPlayersElim
-
addPlayerElim
-
getLegionByMarkerId
-
hasLegion
-
getTitanLegion
-
addLegion
-
removeLegion
-
removeAllLegions
public void removeAllLegions() -
addMarkerAvailable
-
removeMarkerAvailable
-
clearMarkersAvailable
public void clearMarkersAvailable() -
getMarkersAvailable
-
getNumMarkersAvailable
public int getNumMarkersAvailable() -
getFirstAvailableMarker
-
isMarkerAvailable
-
selectMarkerId
-
getNumCreatures
public int getNumCreatures() -
toString
-
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
Return the full basename for the titan of this player. -
getAngelBasename
Return the full basename for an angel of this player.
-