Class Game

  • Direct Known Subclasses:
    GameClientSide, GameServerSide

    public class Game
    extends java.lang.Object
    An ongoing game in Colossus. As opposed to Variant this class holds information about an ongoing game and its status.
    • 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
      • battle

        protected Battle battle
    • Constructor Detail

      • Game

        public Game​(Variant variant,
                    java.lang.String[] playerNames)
        Create a Game object.
        Parameters:
        variant - The variant object, not null
        playerNames - 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 acquire
        score - 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)
      • getLegionsByHex

        public java.util.List<Legion> getLegionsByHex​(MasterHex masterHex)
      • getNumEnemyLegions

        public int getNumEnemyLegions​(MasterHex masterHex,
                                      Player player)
      • getNumLegions

        public int getNumLegions​(MasterHex masterHex)
      • getFriendlyLegions

        public java.util.List<Legion> getFriendlyLegions​(MasterHex hex,
                                                         Player player)
      • 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)
      • getNumFriendlyLegions

        public int getNumFriendlyLegions​(MasterHex masterHex,
                                         Player player)
      • 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()