Package net.sf.colossus.game
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 PlayerColor
The label of the color we use.private boolean
Set to true if the player is dead.private boolean
Only needed during loading of a game.private final Game
The game this information belongs to.The current legions owned by this player.Sorted set of available legion markers for this player.private int
private String
A name for this player for UI purposes and as identifier.private final int
The number of the player in the game.private String
A string representing all players eliminated by this player.private int
private MasterHex
The starting tower of the player.private String
The type of player: local human, AI or network. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
void
addMarkerAvailable
(String markerId) void
addPlayerElim
(Player player) boolean
void
Return the full basename for an angel of this player.getColor()
boolean
During 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 itemsint
getName()
int
int
int
int
int
getScore()
Return the full basename for the titan of this player.int
int
Return the total value of all of this player's creatures.getType()
boolean
boolean
hasMoved()
Check if the player has already moved.boolean
boolean
isAI()
boolean
isDead()
boolean
isHuman()
boolean
boolean
isMarkerAvailable
(String markerId) boolean
boolean
isNone()
void
void
removeLegion
(Legion legion) void
removeMarkerAvailable
(String markerId) selectMarkerId
(String markerId) Removes the selected marker from the list of those available.void
setColor
(PlayerColor color) void
setDead
(boolean dead) void
setDeadBeforeSave
(boolean val) void
setMulligansLeft
(int mulligansLeft) void
void
setPlayersElim
(String playersEliminated) void
setScore
(int score) void
setStartingTower
(MasterHex startingTower) void
toString()
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
The current legions owned by this player. -
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 tostartingTower
this 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
Sorted set of available legion markers for this player.
-
-
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
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
Overridden for debug/logging purposes. -
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.
-