public class Players
extends java.lang.Object
implements java.io.Serializable
Persistent collection of players indexed by nick.
Each player has nick, password, points and accumulated points. Data is persisted using serialization and backup each time a new user is created or points are changed.
This class is a singleton
Modifier and Type | Method and Description |
---|---|
void |
addPoints(java.lang.String nick,
int points)
Add points to player
|
(package private) void |
cleanup()
Clears all players stored in this instances.
|
static java.io.File |
getHome()
Current home directory, where the data file is stored
|
static Players |
getInstance()
Get single instance of this class
|
Player |
getPlayer(java.lang.String nick) |
void |
resetPoints(java.lang.String nick)
Reset points of current round while keeping accumulated points
|
static void |
setHome(java.io.File home)
Update home directory, where the data file is stored
|
boolean |
verify(java.lang.String nick,
java.lang.String password)
Verify player's password.
|
public static java.io.File getHome()
public static void setHome(java.io.File home)
home
- directorypublic static Players getInstance()
public boolean verify(java.lang.String nick, java.lang.String password)
nick
- of playerpassword
- of playertrue
if passwords match; false
otherwisepublic void resetPoints(java.lang.String nick) throws WWWordzException
nick
- of playerWWWordzException
- if player is unknownpublic void addPoints(java.lang.String nick, int points) throws WWWordzException
nick
- of playerpoints
- to addWWWordzException
- if player is unknownpublic Player getPlayer(java.lang.String nick)
void cleanup()