Package net.sf.colossus.game
Class Game
- java.lang.Object
-
- net.sf.colossus.game.Game
-
- Direct Known Subclasses:
GameClientSide,GameServerSide
public class Game extends java.lang.ObjectAn ongoing game in Colossus. As opposed toVariantthis class holds information about an ongoing game and its status.
-
-
Field Summary
Fields Modifier and Type Field Description protected Battlebattleprivate BattleStrikebattleStrikeprivate CaretakercaretakerThe caretaker takes care of managing the available and dead creatures.private Engagementengagementprivate booleangameOverStatus 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 java.lang.StringgameOverMessageprivate static java.util.logging.LoggerLOGGERprivate intmovementRollLast movement roll for any player.protected PhasephaseThe current game phase (Split, Move, Fight, Muster)protected java.util.List<Player>playersThe state of the different players in the game.protected intturnNumberThe current turn number.private VariantvariantThe variant played in this game.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddPlayer(Player p)voidclearEngagementData()booleancontainsOpposingLegions(MasterHex hex)Return set of hexLabels for engagements found.voidcreateEngagement(MasterHex hex, Legion attacker, Legion defender)(package private) java.util.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 caretakerjava.util.Set<MasterHex>findEngagements()Return a set of all hexes with engagements.java.util.List<Legion>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).java.util.List<Legion>getAllLegions()Return a list of all legions of all players.LegiongetAttacker()BattlegetBattle()LegiongetBattleActiveLegion()MasterHexgetBattleSite()BattleStrikegetBattleStrike()intgetBattleTurnNumber()CaretakergetCaretaker()LegiongetDefender()java.util.List<Legion>getEnemyLegions(Player player)Return a list of all legions not belonging to player.java.util.List<Legion>getEnemyLegions(MasterHex hex, Player player)EngagementgetEngagement()LegiongetFirstEnemyLegion(MasterHex masterHex, Player player)Finds the first legion in a hex not belonging to a certain player.LegiongetFirstFriendlyLegion(MasterHex masterHex, Player player)LegiongetFirstLegion(MasterHex masterHex)java.util.List<Legion>getFriendlyLegions(MasterHex hex, Player player)java.lang.StringgetGameOverMessage()LegiongetLegionByMarkerId(java.lang.String markerId)java.util.List<Legion>getLegionsByHex(MasterHex masterHex)intgetMovementRoll()intgetNumEnemyLegions(MasterHex masterHex, Player player)intgetNumFriendlyLegions(MasterHex masterHex, Player player)protected intgetNumHumansRemaining()Returns the number of real players (Human or Network) which are still alive.intgetNumLegions(MasterHex masterHex)intgetNumLivingCreatures(CreatureType type)intgetNumLivingPlayers()intgetNumPlayers()intgetNumRemoteRemaining()PhasegetPhase()java.util.Collection<Player>getPlayers()java.util.Collection<java.lang.String>getPreliminaryPlayerNames()Get a list of preliminary player names, during game startup / clients connecting.intgetTurnNumber()Returns the current turn in the gameVariantgetVariant()booleanisEngagementInProgress()booleanisEngagementOngoing()booleanisGameOver()booleanisOccupied(MasterHex masterHex)booleanisPhase(Phase phase)booleanonlyAIsRemain()voidsetGameOver(boolean gameOver, java.lang.String message)voidsetMovementRoll(int roll)voidsetPhase(Phase phase)voidsetTurnNumber(int turn)Set the current turn number.
-
-
-
Field Detail
-
LOGGER
private static final java.util.logging.Logger LOGGER
-
variant
private final Variant variant
The variant played in this game.
-
players
protected final java.util.List<Player> players
The state of the different players in the game.
-
caretaker
private final Caretaker caretaker
The caretaker takes care of managing the available and dead creatures.
-
turnNumber
protected int turnNumber
The current turn number. Advance when every player has done his move
-
phase
protected Phase phase
The current game phase (Split, Move, Fight, Muster)
-
movementRoll
private int movementRoll
Last movement roll for any player.
-
gameOver
private boolean gameOver
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.
-
gameOverMessage
private java.lang.String gameOverMessage
-
engagement
private Engagement engagement
-
battle
protected Battle battle
-
battleStrike
private final BattleStrike battleStrike
-
-
Constructor Detail
-
Game
public Game(Variant variant, java.lang.String[] playerNames)
Create a Game object.- Parameters:
variant- The variant object, not nullplayerNames- Names of the players, not used yet
-
-
Method Detail
-
getVariant
public Variant getVariant()
-
addPlayer
public void addPlayer(Player p)
-
getPlayers
public java.util.Collection<Player> getPlayers()
-
getPreliminaryPlayerNames
public java.util.Collection<java.lang.String> 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
public Caretaker getCaretaker()
-
getMovementRoll
public int getMovementRoll()
-
setMovementRoll
public void setMovementRoll(int roll)
-
isGameOver
public boolean isGameOver()
-
getGameOverMessage
public java.lang.String getGameOverMessage()
-
setGameOver
public void setGameOver(boolean gameOver, java.lang.String message)
-
clearEngagementData
public void clearEngagementData()
-
isEngagementInProgress
public boolean isEngagementInProgress()
-
getEngagement
public Engagement getEngagement()
-
getBattle
public Battle getBattle()
-
getBattleActiveLegion
public Legion getBattleActiveLegion()
-
getBattleSite
public MasterHex getBattleSite()
-
getDefender
public Legion getDefender()
-
getAttacker
public Legion getAttacker()
-
findAvailableEligibleAngels
java.util.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 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
public java.util.List<Legion> getAllLegions()
Return a list of all legions of all players.
-
getNumLivingCreatures
public int getNumLivingCreatures(CreatureType type)
-
getNumLegions
public int getNumLegions(MasterHex masterHex)
-
getEnemyLegions
public java.util.List<Legion> getEnemyLegions(Player player)
Return a list of all legions not belonging to player.
-
isOccupied
public boolean isOccupied(MasterHex masterHex)
-
getFirstEnemyLegion
public Legion getFirstEnemyLegion(MasterHex masterHex, Player player)
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
public java.util.Set<MasterHex> 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
public boolean containsOpposingLegions(MasterHex hex)
Return set of hexLabels for engagements found.
-
findLegionsWithSummonables
public java.util.List<Legion> 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).
-
getLegionByMarkerId
public Legion getLegionByMarkerId(java.lang.String markerId)
-
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
public boolean isPhase(Phase phase)
-
setPhase
public void setPhase(Phase phase)
-
getPhase
public Phase getPhase()
-
isEngagementOngoing
public boolean isEngagementOngoing()
-
getBattleTurnNumber
public int getBattleTurnNumber()
-
getBattleStrike
public BattleStrike getBattleStrike()
-
-