|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.sourceforge.simplegamenet.specs.to.PlayerSettings
An abstract superclass which represents all player settings for one player, identified by a
playerID. For each player, there is one single PlayerSettings
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#playerSettingsUpdated(PlayerSettings, PlayerSettings)
event.
These player settings should only be changed by the player (using the "Player Settings" panel in
the "Chat" tab and a PlayerSettingsPanel
created
with the createPlayerSettingsPanel()
method) or by the game server (using custom
methods). The player is not allowed to change these player settings if the game is playing. The
game server can change these player settings at any time but should call net.sourceforge.simplegamenet.framework.model.ServerEngineImpl#refreshPlayerSettings(Integer)
so
all clients update their copy.
PlayerSettingsMap
,
PlayerSettingsPanel
,
Serialized FormField Summary | |
static int |
BOT
The player type of a bot. |
protected Engine |
engine
The EngineImpl of the current application. |
static int |
HOST
The player type of the host. |
static int |
MAXIMUM_NICKNAME_LENGTH
The maximum length of a player's nickname |
static int |
OBSERVING
The playing state of a player observing the game. |
static int |
PARTICIPATING
The playing state of a player participating in the game. |
static int |
USER
The player type of a user, different from the host. |
Constructor Summary | |
PlayerSettings(Engine engine,
Integer playerID,
int playerType,
String nickname,
int playingState)
Constructs new players settings. |
Method Summary | |
int |
compareTo(Object object)
Compares two player settings based on their playerIDs. |
abstract PlayerSettings |
createChangedPlayerSettings(PlayerSettingsPanel playerSettingsPanel)
Creates a new PlayerSettings based on the PlayerSettingsPanel . |
abstract PlayerSettingsPanel |
createPlayerSettingsPanel()
Creates a new PlayerSettingsPanel based on these player settings. |
boolean |
equals(Object object)
Compares two player settings based on their playerIDs. |
String |
getNickname()
Get the nickname of the player. |
Integer |
getPlayerID()
Gets the playerID of the player. |
int |
getPlayerType()
Gets the player type ( HOST , USER or BOT ) of the player. |
int |
getPlayingState()
Gets the playing state ( PARTICIPATING or OBSERVING ) of the player. |
boolean |
isChangePlayerSettingsAllowed(PlayerSettings changedPlayerSettings)
Returns true if the current game state allows these player settings to be
updated to the changed player settings. |
boolean |
isChattingAllowedDuringGame()
Returns true if the player is allowed to chat while the game is playing.
|
void |
setEngine(Engine engine)
Sets the engine for these game settings. |
void |
setNickname(String nickname)
Sets the nickname for these player settings. |
void |
setPlayingState(int playingState)
Sets the playing state ( PARTICIPATING or OBSERVING ) of the player. |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int MAXIMUM_NICKNAME_LENGTH
public static final int HOST
public static final int USER
public static final int BOT
public static final int PARTICIPATING
public static final int OBSERVING
protected transient Engine engine
EngineImpl
of the current application. This variable allows the methods of
these player settings to know the game settings, the player settings of other players, the
game state, etc.
Constructor Detail |
public PlayerSettings(Engine engine, Integer playerID, int playerType, String nickname, int playingState)
GameSettings
to create player settings for a new player with GameSettings.createDefaultPlayerSettings(Integer, int, String)
.
This class PlayerSettings
can be extended directly to use custom settings or one
of the configurable player settings from the net.sourceforge.simplegamenet.specs.tools
package can be used, such as StandardPlayerSettings
or ColoredPlayerSettings
.
engine
- the engine of the current applicationplayerID
- the playerID which uniquely identifies the player, which never changesplayerType
- the type of the player (HOST
, USER
or BOT
),
which never changesnickname
- the nickname of the playerplayingState
- the playing state of the player (PARTICIPATING
or OBSERVING
)Method Detail |
public abstract PlayerSettingsPanel createPlayerSettingsPanel()
PlayerSettingsPanel
based on these player settings. This new
PlayerSettingsPanel
is shown in the "Player Settings" panel in the "Chat" tab
only with the player whose player settings it represent.
PlayerSettingsPanel
public abstract PlayerSettings createChangedPlayerSettings(PlayerSettingsPanel playerSettingsPanel)
PlayerSettings
based on the PlayerSettingsPanel
. This
method fetches all the data a player can edit with custom methods from the
PlayerSettingsPanel
and copies any non editable data from these player settings
into the new PlayerSettings
.
This method will never be called when the game is playing because the player is not allowed
to change his player settings during the game.
PlayerSettings
public boolean isChangePlayerSettingsAllowed(PlayerSettings changedPlayerSettings)
true
if the current game state allows these player settings to be
updated to the changed player settings. This method is called after createChangedPlayerSettings(PlayerSettingsPanel)
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 player to change his player settings
to certain settings sometimes.
changedPlayerSettings
- the changed player settings created by createChangedPlayerSettings(PlayerSettingsPanel)
true
if the player settings are allowed to changepublic boolean isChattingAllowedDuringGame()
true
if the player is allowed to chat while the game is playing.
If a subclass does not overwrite this method it always returns true
.
true
if the player is allowed to chat while the game is playingpublic Integer getPlayerID()
public int getPlayerType()
HOST
, USER
or BOT
) of the player.
public String getNickname()
public int getPlayingState()
PARTICIPATING
or OBSERVING
) of the player.
public void setPlayingState(int playingState)
PARTICIPATING
or OBSERVING
) of the player. Afther
this method the game server should call net.sourceforge.simplegamenet.framework.model.ServerEngineImpl#refreshPlayerSettings(Integer)
with the playerID of these player settings.
playingState
- the playing state of the playerpublic boolean equals(Object object)
object
- the object to compare these player settings against
public int compareTo(Object object)
compareTo
in interface Comparable
object
- the object to compare these player settings against
public final void setEngine(Engine engine)
engine
- public void setNickname(String nickname)
nickname
-
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |