Package net.sf.colossus.game
Class Game
java.lang.Object
net.sf.colossus.game.Game
- Direct Known Subclasses:
GameClientSide
,GameServerSide
An ongoing game in Colossus.
As opposed to
Variant
this class holds information about an ongoing game
and its status.-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Battle
private final BattleStrike
private final Caretaker
The caretaker takes care of managing the available and dead creatures.private Engagement
private boolean
Status for Game is over and message for it On client side this also implies: If the game is over, then quitting does not require confirmation.private String
private static final Logger
private int
Last movement roll for any player.protected Phase
The current game phase (Split, Move, Fight, Muster)The state of the different players in the game.protected int
The current turn number.private final Variant
The variant played in this game. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
void
boolean
Return set of hexLabels for engagements found.void
createEngagement
(MasterHex hex, Legion attacker, Legion defender) (package private) List<CreatureType>
findAvailableEligibleAngels
(MasterBoardTerrain terrain, int score) Return a list of angel types that can be acquired based on the hex in which legion is, when reaching given score threshold, and if they are still available from caretakerReturn a set of all hexes with engagements.findLegionsWithSummonables
(Legion summoner) Return a set of all other unengaged legions of the legion's player that have summonables (not sorted in any particular order).Return a list of all legions of all players.int
getEnemyLegions
(Player player) Return a list of all legions not belonging to player.getEnemyLegions
(MasterHex hex, Player player) getFirstEnemyLegion
(MasterHex masterHex, Player player) Finds the first legion in a hex not belonging to a certain player.getFirstFriendlyLegion
(MasterHex masterHex, Player player) getFirstLegion
(MasterHex masterHex) getFriendlyLegions
(MasterHex hex, Player player) getLegionByMarkerId
(String markerId) getLegionsByHex
(MasterHex masterHex) int
int
getNumEnemyLegions
(MasterHex masterHex, Player player) int
getNumFriendlyLegions
(MasterHex masterHex, Player player) protected int
Returns the number of real players (Human or Network) which are still alive.int
getNumLegions
(MasterHex masterHex) int
int
int
int
getPhase()
Get a list of preliminary player names, during game startup / clients connecting.int
Returns the current turn in the gameboolean
boolean
boolean
boolean
isOccupied
(MasterHex masterHex) boolean
boolean
void
setGameOver
(boolean gameOver, String message) void
setMovementRoll
(int roll) void
void
setTurnNumber
(int turn) Set the current turn number.
-
Field Details
-
LOGGER
-
variant
The variant played in this game. -
players
The state of the different players in the game. -
caretaker
The caretaker takes care of managing the available and dead creatures. -
turnNumber
protected int turnNumberThe current turn number. Advance when every player has done his move -
phase
The current game phase (Split, Move, Fight, Muster) -
movementRoll
private int movementRollLast movement roll for any player. -
gameOver
private boolean gameOverStatus for Game is over and message for it On client side this also implies: If the game is over, then quitting does not require confirmation. -
gameOverMessage
-
engagement
-
battle
-
battleStrike
-
-
Constructor Details
-
Game
Create a Game object.- Parameters:
variant
- The variant object, not nullplayerNames
- Names of the players, not used yet
-
-
Method Details
-
getVariant
-
addPlayer
-
getPlayers
-
getPreliminaryPlayerNames
Get a list of preliminary player names, during game startup / clients connecting. Preliminary, because some of them might change their name later (e.g. the "byColor" ones).- Returns:
- List of player names
-
getNumPlayers
public int getNumPlayers() -
getNumLivingPlayers
public int getNumLivingPlayers() -
onlyAIsRemain
public boolean onlyAIsRemain()- Returns:
- Returns true if all still alive players are AIs
-
getNumHumansRemaining
protected int getNumHumansRemaining()Returns the number of real players (Human or Network) which are still alive. TODO partly same idea as "onlyAIsRemain()" -
getNumRemoteRemaining
public int getNumRemoteRemaining() -
getCaretaker
-
getMovementRoll
public int getMovementRoll() -
setMovementRoll
public void setMovementRoll(int roll) -
isGameOver
public boolean isGameOver() -
getGameOverMessage
-
setGameOver
-
createEngagement
-
clearEngagementData
public void clearEngagementData() -
isEngagementInProgress
public boolean isEngagementInProgress() -
getEngagement
-
getBattle
-
getBattleActiveLegion
-
getBattleSite
-
getDefender
-
getAttacker
-
findAvailableEligibleAngels
Return a list of angel types that can be acquired based on the hex in which legion is, when reaching given score threshold, and if they are still available from caretaker- Parameters:
terrain
- The terrain in which this legion wants to acquirescore
- A acquring threshold, e.g. in Default 100, ..., 400, 500- Returns:
- list of acquirables
-
getAllLegions
Return a list of all legions of all players. -
getNumLivingCreatures
-
getLegionsByHex
-
getNumEnemyLegions
-
getNumLegions
-
getFriendlyLegions
-
getEnemyLegions
Return a list of all legions not belonging to player. -
getEnemyLegions
-
getFirstFriendlyLegion
-
isOccupied
-
getFirstLegion
-
getNumFriendlyLegions
-
getFirstEnemyLegion
Finds the first legion in a hex not belonging to a certain player. Note that there is no assumption that the player has a legion in that location itself. This method is e.g. used to evaluate moves in the AI.- Parameters:
masterHex
- the hex where to look for enemy regions. Not null.player
- the player whose enemies we are looking for. Not null.- Returns:
- the first legion that is in the specified hex and does not belong to the given player, null if no such legion exists
-
findEngagements
Return a set of all hexes with engagements. TODO if we can be sure that the activePlayer is set properly, we could just create a set of all hexes he is on and then check if someone else occupies any of the same -
containsOpposingLegions
Return set of hexLabels for engagements found. -
findLegionsWithSummonables
Return a set of all other unengaged legions of the legion's player that have summonables (not sorted in any particular order). -
getLegionByMarkerId
-
setTurnNumber
public void setTurnNumber(int turn) Set the current turn number. Used only on client side; server side increments directly.- Parameters:
turn
- Set this number as current turn number
-
getTurnNumber
public int getTurnNumber()Returns the current turn in the game- Returns:
- returns the current turn number
-
isPhase
-
setPhase
-
getPhase
-
isEngagementOngoing
public boolean isEngagementOngoing() -
getBattleTurnNumber
public int getBattleTurnNumber() -
getBattleStrike
-