|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectnet.sourceforge.simplegamenet.specs.to.GameSettings
An abstract superclass which represents all game settings that determine how a game is played.
There is one single GameSettings object during a server session and every connected
client holds a copy. A server session spawns over several game sessions, which start and stop
with game start and end events.
GameServer#gameSettingsUpdated(GameSettings, GameSettings) event.
These game settings should only be changed by the host (using the "Game Settings" tab and a
GameSettingsPanel created with the createGameSettingsPanel() method) or by the game server (using custom methods). The host is not
allowed to change these game settings if the game is playing. The game server can change these
game settings at any time but should call net.sourceforge.simplegamenet.framework.model.ServerEngineImpl#refreshGameSettings()
so all clients update their copy.
net.sourceforge.simplegamenet.framework.model.EngineImpl#getGameSettings(),
GameSettingsPanel,
Serialized Form| Field Summary | |
protected Engine |
engine
The EngineImpl of the current application. |
| Constructor Summary | |
protected |
GameSettings()
Constructs new game settings. |
| Method Summary | |
abstract GameSettings |
createChangedGameSettings(GameSettingsPanel gameSettingsPanel)
Creates a new GameSettings based on the GameSettingsPanel. |
PlayerSettings |
createDefaultPlayerSettings(Integer playerID,
int playerType,
String nickname)
Creates a new PlayerSettings based on the current game state. |
abstract GameSettingsPanel |
createGameSettingsPanel()
Creates a new GameSettingsPanel based on these game settings. |
boolean |
isChangeGameSettingsAllowed(GameSettings changedGameSettings)
Returns true if the current game state allows these game settings to be updated
to the changed game settings. |
boolean |
isChangePlayerSettingsAllowed(PlayerSettings currentPlayerSettings,
PlayerSettings changedPlayerSettings)
Return true if the current game state and these game settings allow a player to
change his player settings.
|
boolean |
isCreateDefaultPlayerSettingsAllowed(int playerType)
Returns true if the current game state and these game settings allow the new
player to connect. |
boolean |
isStartGameAllowed()
Returns true if the current game state allows a game to be started.
|
void |
setEngine(Engine engine)
Sets the Engine for these game settings. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
protected transient Engine engine
EngineImpl of the current application. This variable allows the methods of
these game settings to know the player settings of each player, the game state, etc.
Initially this variable is null, but when an engine is created it is set by the
SimpleGameNet framework. During construction this variable is null and during
the methods createGameSettingsPanel() and createChangedGameSettings(net.sourceforge.simplegamenet.specs.gui.GameSettingsPanel)
it can be null.
| Constructor Detail |
protected GameSettings()
GameFactory
to create game settings for him with GameFactory.createDefaultGameSettings().
This class GameSettings can be extended directly to use custom settings or one
of the configurable game settings from the net.sourceforge.simplegamenet.specs.tools
package can be used, such as MultiPlayerGameSettings or TwoPlayerGameSettings.
During the construction the engine variable is null.
| Method Detail |
public abstract GameSettingsPanel createGameSettingsPanel()
GameSettingsPanel based on these game settings. This new
GameSettingsPanel is shown in the "Connection wizard" dialog or the "Game
settings" tab. That panel is enabled with the host which allows him to change the game
settings, but it is disabled with all other users, who can just see the game settings.
During this method the engine variable can be null.
GameSettingsPanelpublic abstract GameSettings createChangedGameSettings(GameSettingsPanel gameSettingsPanel)
GameSettings based on the GameSettingsPanel. This
method fetches all the data a host can edit with custom methods from the
GameSettingsPanel and copies any non editable data from these game settings into
the new GameSettings.
This method will never be called when the game is playing because the host is not allowed to
change the game settings during the game.
During this method the engine variable can be null.
gameSettingsPanel - a GameSettingsPanel changed by the host
GameSettingspublic boolean isChangeGameSettingsAllowed(GameSettings changedGameSettings)
true if the current game state allows these game settings to be updated
to the changed game settings. This method is called after createChangedGameSettings(GameSettingsPanel) has been called.
If a subclass does not overwrite this method it always returns true. A subclass
should override this method if it wants to prevent the host to change the game settings to
certain settings sometimes.
changedGameSettings - the changed game settings created by createChangedGameSettings(net.sourceforge.simplegamenet.specs.gui.GameSettingsPanel)
true if the game settings are allowed to changepublic boolean isCreateDefaultPlayerSettingsAllowed(int playerType)
true if the current game state and these game settings allow the new
player to connect. If true the createDefaultPlayerSettings(Integer, int,
String) is called next, which will decide whether the new player becomes a participant or
observer.
If a subclass does not overwrite this method it always returns true. A subclass
should overwrite this method if it wants to block new players sometimes.
playerType - the new player's playerType, as defined in PlayerSettings
true if the player is allowed to connect
public PlayerSettings createDefaultPlayerSettings(Integer playerID,
int playerType,
String nickname)
PlayerSettings based on the current game state. Subclasses that
overwrite this method should not make any changes to the playerID, playerType or nickname and
pass it to the constructor of a subclass of PlayerSettings, together with the
engine variable.
If a subclass does not overwrite this method it creates a new StandardPlayerSettings,
a participating if the game is not playing and observing if the game is playing. A subclass
should overwrite this method if it wants to use custom PlayerSettings.
playerID - the new player's unique identificationplayerType - the new player's playerType, as defined in PlayerSettingsnickname - the new player's preferred nickname filtered from bad language if bad
language is filtered by the server.
public boolean isChangePlayerSettingsAllowed(PlayerSettings currentPlayerSettings,
PlayerSettings changedPlayerSettings)
true if the current game state and these game settings allow a player to
change his player settings.
If true the PlayerSettings.isChangePlayerSettingsAllowed(PlayerSettings)
is called next, which checks if the old player settings allow the change.
If a subclass does not overwrite this method it always returns true. A subclass
should overwrite this method if it wants to block players changing their player settings
sometimes.
currentPlayerSettings - the current player settingschangedPlayerSettings - the changed player settings
true if player is allowed to change his player settingspublic boolean isStartGameAllowed()
true if the current game state allows a game to be started.
If a subclass does not overwrite this method it always returns true. A subclass
should overwrite this method if it wants to disallow a game to be started, for example when
there aren't enough participants.
true if a game is allowed to startpublic final void setEngine(Engine engine)
engine -
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||