|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.sourceforge.simplegamenet.specs.to.GameSettings
net.sourceforge.simplegamenet.specs.tools.TwoPlayerGameSettings
Field Summary |
Fields inherited from class net.sourceforge.simplegamenet.specs.to.GameSettings |
engine |
Constructor Summary | |
TwoPlayerGameSettings()
|
|
TwoPlayerGameSettings(int defaultMaximumConnectionsAmount)
|
|
TwoPlayerGameSettings(int defaultMaximumConnectionsAmount,
int minimumMaximumConnectionsAmount,
int maximumMaximumConnectionsAmount)
|
Method Summary | |
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. |
GameSettingsPanel |
createGameSettingsPanel()
Creates a new GameSettingsPanel based on these game settings. |
int |
getMaximumConnectionsAmount()
|
int |
getMaximumMaximumConnectionsAmount()
|
int |
getMinimumMaximumConnectionsAmount()
|
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 |
setMaximumConnectionsAmount(int maximumConnectionsAmount)
|
void |
setMaximumMaximumConnectionsAmount(int maximumMaximumConnectionsAmount)
|
void |
setMinimumMaximumConnectionsAmount(int minimumMaximumConnectionsAmount)
|
Methods inherited from class net.sourceforge.simplegamenet.specs.to.GameSettings |
setEngine |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public TwoPlayerGameSettings()
public TwoPlayerGameSettings(int defaultMaximumConnectionsAmount) throws IllegalArgumentException
public TwoPlayerGameSettings(int defaultMaximumConnectionsAmount, int minimumMaximumConnectionsAmount, int maximumMaximumConnectionsAmount)
Method Detail |
public GameSettingsPanel createGameSettingsPanel()
GameSettings
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
.
createGameSettingsPanel
in class GameSettings
GameSettingsPanel
public GameSettings createChangedGameSettings(GameSettingsPanel gameSettingsPanel)
GameSettings
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
.
createChangedGameSettings
in class GameSettings
gameSettingsPanel
- a GameSettingsPanel
changed by the host
GameSettings
public boolean isChangeGameSettingsAllowed(GameSettings changedGameSettings)
GameSettings
true
if the current game state allows these game settings to be updated
to the changed game settings. This method is called after GameSettings.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.
isChangeGameSettingsAllowed
in class GameSettings
changedGameSettings
- the changed game settings created by GameSettings.createChangedGameSettings(net.sourceforge.simplegamenet.specs.gui.GameSettingsPanel)
true
if the game settings are allowed to changepublic boolean isCreateDefaultPlayerSettingsAllowed(int playerType)
GameSettings
true
if the current game state and these game settings allow the new
player to connect. If true
the GameSettings.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.
isCreateDefaultPlayerSettingsAllowed
in class GameSettings
playerType
- the new player's playerType, as defined in PlayerSettings
true
if the player is allowed to connectpublic PlayerSettings createDefaultPlayerSettings(Integer playerID, int playerType, String nickname)
GameSettings
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
.
createDefaultPlayerSettings
in class GameSettings
playerID
- the new player's unique identificationplayerType
- the new player's playerType, as defined in PlayerSettings
nickname
- 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)
GameSettings
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.
isChangePlayerSettingsAllowed
in class GameSettings
currentPlayerSettings
- the current player settingschangedPlayerSettings
- the changed player settings
true
if player is allowed to change his player settingspublic boolean isStartGameAllowed()
GameSettings
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.
isStartGameAllowed
in class GameSettings
true
if a game is allowed to startpublic int getMaximumConnectionsAmount()
public void setMaximumConnectionsAmount(int maximumConnectionsAmount)
public int getMinimumMaximumConnectionsAmount()
public void setMinimumMaximumConnectionsAmount(int minimumMaximumConnectionsAmount)
public int getMaximumMaximumConnectionsAmount()
public void setMaximumMaximumConnectionsAmount(int maximumMaximumConnectionsAmount)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |