Class PreGameController


  • public final class PreGameController
    extends FreeColClientHolder
    The controller that will be used before the game starts.
    • Field Detail

      • logger

        private static final java.util.logging.Logger logger
    • Constructor Detail

      • PreGameController

        public PreGameController​(FreeColClient freeColClient)
        The constructor to use.
        Parameters:
        freeColClient - The FreeColClient for the game.
    • Method Detail

      • addPlayerHandler

        public void addPlayerHandler​(java.util.List<Player> players)
        Handle an addPlayer message.
        Parameters:
        players - The Players to add.
      • sendChat

        public void sendChat​(java.lang.String message)
        Sends a chat message.
        Parameters:
        message - The text of the message.
      • chatHandler

        public void chatHandler​(java.lang.String sender,
                                java.lang.String message,
                                java.awt.Color color,
                                boolean pri)
        Display a chat message.
        Parameters:
        sender - The sender of the chat message.
        message - What to say.
        color - The message color.
        pri - If true, the message is private.
      • errorHandler

        public void errorHandler​(StringTemplate template,
                                 java.lang.String message)
        Handle an error.
        Parameters:
        template - A StringTemplate describing the error.
        message - A backup string describing the error.
      • logoutHandler

        public void logoutHandler​(Player player,
                                  Game.LogoutReason reason)
        Handle a player logging out.
        Parameters:
        player - The Player that is logging out.
        reason - The LogoutReason why the player left.
      • readyHandler

        public void readyHandler​(Player player,
                                 boolean ready)
        Handle a ready message.
        Parameters:
        player - The Player whose readiness changed.
        ready - The new readiness state.
      • requestLaunch

        public void requestLaunch()
        Requests the game to be started. This will only be successful if all players are ready to start the game.
      • setAvailable

        public void setAvailable​(Nation nation,
                                 NationOptions.NationState state)
        Sets a nation's state.
        Parameters:
        nation - The Nation to set.
        state - The NationState value to set.
      • setAvailableHandler

        public void setAvailableHandler​(Nation nation,
                                        NationOptions.NationState nationState)
        Handle a setAvailable message.
        Parameters:
        nation - The Nation to set.
        nationState - The NationState value to set.
      • setColor

        public void setColor​(Nation nation,
                             java.awt.Color color)
        Sets a nation's colour.
        Parameters:
        nation - The Nation to set the color for.
        color - The Color to set.
      • setColorHandler

        public void setColorHandler​(Nation nation,
                                    java.awt.Color color)
        Handle a setColor message.
        Parameters:
        nation - The Nation to set the color for.
        color - The Color to set.
      • setNation

        public void setNation​(Nation nation)
        Sets this client's player's nation.
        Parameters:
        nation - Which Nation this player wishes to set.
      • setNationType

        public void setNationType​(NationType nationType)
        Sets this client's player's nation type.
        Parameters:
        nationType - Which nation type this player wishes to set.
      • setNationTypeHandler

        public void setNationTypeHandler​(NationType nationType)
        Handle a nation type change.
        Parameters:
        nationType - Which nation type this player wishes to set.
      • setReady

        public void setReady​(boolean ready)
        Sets this client to be (or not be) ready to start the game.
        Parameters:
        ready - Indicates whether or not this client is ready to start the game.
      • startGameHandler

        public void startGameHandler()
        Handle starting the game. Wait until map is received from server (sometimes a startGame message arrives arrives when map is still null). Make sure we do this in a new thread so as not to block the input handler from receiving the map!
      • startGameInternal

        private boolean startGameInternal()
        Internal start of the game.
        Returns:
        True if the player should continue, false if we are in a debug run and should be skipping turns.
      • updateHandler

        public void updateHandler​(java.util.List<FreeColObject> objects)
        Handles an update.
        Parameters:
        objects - The FreeColObjects to update.
      • updateGameOptions

        public void updateGameOptions()
        Update the GameOptions at the server. This method should be called after updating that object.
      • updateGameOptionsHandler

        public void updateGameOptionsHandler​(OptionGroup gameOptions)
        Handle new game options.
        Parameters:
        gameOptions - The OptionGroup containing the game options.
      • updateMapGeneratorOptions

        public void updateMapGeneratorOptions()
        Update the MapGeneratorOptions at the server. This method should be called after updating that object.
      • updateMapGeneratorOptionsHandler

        public void updateMapGeneratorOptionsHandler​(OptionGroup mapOptions)
        Handle new map options.
        Parameters:
        mapOptions - An OptionGroup containing the map options.