Package net.sf.freecol.client.control
Class PreGameController
- java.lang.Object
-
- net.sf.freecol.client.control.FreeColClientHolder
-
- net.sf.freecol.client.control.PreGameController
-
public final class PreGameController extends FreeColClientHolder
The controller that will be used before the game starts.
-
-
Field Summary
Fields Modifier and Type Field Description private static java.util.logging.Logger
logger
-
Constructor Summary
Constructors Constructor Description PreGameController(FreeColClient freeColClient)
The constructor to use.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addPlayerHandler(java.util.List<Player> players)
Handle an addPlayer message.void
chatHandler(java.lang.String sender, java.lang.String message, java.awt.Color color, boolean pri)
Display a chat message.void
errorHandler(StringTemplate template, java.lang.String message)
Handle an error.void
logoutHandler(Player player, Game.LogoutReason reason)
Handle a player logging out.void
readyHandler(Player player, boolean ready)
Handle a ready message.void
requestLaunch()
Requests the game to be started.void
sendChat(java.lang.String message)
Sends a chat message.void
setAvailable(Nation nation, NationOptions.NationState state)
Sets a nation's state.void
setAvailableHandler(Nation nation, NationOptions.NationState nationState)
Handle a setAvailable message.void
setColor(Nation nation, java.awt.Color color)
Sets a nation's colour.void
setColorHandler(Nation nation, java.awt.Color color)
Handle a setColor message.void
setNation(Nation nation)
Sets this client's player's nation.void
setNationType(NationType nationType)
Sets this client's player's nation type.void
setNationTypeHandler(NationType nationType)
Handle a nation type change.void
setReady(boolean ready)
Sets this client to be (or not be) ready to start the game.void
startGameHandler()
Handle starting the game.private boolean
startGameInternal()
Internal start of the game.void
updateGameOptions()
Update theGameOptions
at the server.void
updateGameOptionsHandler(OptionGroup gameOptions)
Handle new game options.void
updateHandler(java.util.List<FreeColObject> objects)
Handles an update.void
updateMapGeneratorOptions()
Update theMapGeneratorOptions
at the server.void
updateMapGeneratorOptionsHandler(OptionGroup mapOptions)
Handle new map options.-
Methods inherited from class net.sf.freecol.client.control.FreeColClientHolder
askServer, currentPlayerIsMyPlayer, getClientOptions, getConnectController, getFreeColClient, getFreeColServer, getGame, getGUI, getMap, getMyPlayer, getSpecification, igc, pgc
-
-
-
-
Constructor Detail
-
PreGameController
public PreGameController(FreeColClient freeColClient)
The constructor to use.- Parameters:
freeColClient
- TheFreeColClient
for the game.
-
-
Method Detail
-
addPlayerHandler
public void addPlayerHandler(java.util.List<Player> players)
Handle an addPlayer message.- Parameters:
players
- ThePlayer
s 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
- AStringTemplate
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
- ThePlayer
that is logging out.reason
- TheLogoutReason
why the player left.
-
readyHandler
public void readyHandler(Player player, boolean ready)
Handle a ready message.- Parameters:
player
- ThePlayer
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
- TheNation
to set.state
- TheNationState
value to set.
-
setAvailableHandler
public void setAvailableHandler(Nation nation, NationOptions.NationState nationState)
Handle a setAvailable message.- Parameters:
nation
- TheNation
to set.nationState
- TheNationState
value to set.
-
setColor
public void setColor(Nation nation, java.awt.Color color)
Sets a nation's colour.- Parameters:
nation
- TheNation
to set the color for.color
- TheColor
to set.
-
setColorHandler
public void setColorHandler(Nation nation, java.awt.Color color)
Handle a setColor message.- Parameters:
nation
- TheNation
to set the color for.color
- TheColor
to set.
-
setNation
public void setNation(Nation nation)
Sets this client's player's nation.- Parameters:
nation
- WhichNation
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
- TheFreeColObject
s to update.
-
updateGameOptions
public void updateGameOptions()
Update theGameOptions
at the server. This method should be called after updating that object.
-
updateGameOptionsHandler
public void updateGameOptionsHandler(OptionGroup gameOptions)
Handle new game options.- Parameters:
gameOptions
- TheOptionGroup
containing the game options.
-
updateMapGeneratorOptions
public void updateMapGeneratorOptions()
Update theMapGeneratorOptions
at the server. This method should be called after updating that object.
-
updateMapGeneratorOptionsHandler
public void updateMapGeneratorOptionsHandler(OptionGroup mapOptions)
Handle new map options.- Parameters:
mapOptions
- AnOptionGroup
containing the map options.
-
-