Package net.sf.colossus.webcommon
Class GameInfo
java.lang.Object
net.sf.colossus.webcommon.GameInfo
One object of this this class represents a game for which players/users
have enrolled to play it together.
It starts in state "PROPOSED" as type either instantly or scheduled.
Then its state will change along the sequence of states
PROPOSED, DUE, ACTIVATED, STARTING, READY_TO_CONNECT, RUNNING, ENDING
as denoted in the GameState enum.
The actual running/starting of the game will be handled by different
classes, namely GameOnServer and (to be done) GameOnClient.
The same class is also used at client side, but only part of the data
is used there (e.g. the user has only a name, not a socket).
- Author:
- Clemens Katzer
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enum
Enum for the possible states of a game:static enum
Enum for the possible TYPES of a game (scheduled or instant, perhaps later also template?) -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final boolean
private boolean
private int
private int
private String
private String
private IGameRunner
private String
private String
private static final Logger
private int
private int
private static int
private GameInfo.GameState
temporary backup during startingAttemptprivate int
private int
private User
private long
private GameInfo.GameState
private String
private int
private GameInfo.GameType
private boolean
private String
private String
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
Have enough players enrolled (at least "min")void
boolean
static GameInfo
fromString
(String[] tokens, HashMap<String, GameInfo> games, boolean fromFile) boolean
boolean
getMax()
getMin()
private static int
int
int
getPort()
int
boolean
boolean
Have enough players enrolled (at least "min")boolean
isDue()
Has the scheduled time come?boolean
isEnrolled
(String searchName) boolean
isFirstInEnrolledList
(String name) boolean
boolean
boolean
boolean
private static GameInfo.GameType
makeTypeFromStarttime
(long startTime) void
markStarting
(User starter) boolean
reEnrollIfNecessary
(User newUser) boolean
boolean
removeIfEnrolled
(String newName) TODO remove overlap with isEnrolled If user with name "newName" is found, remove it from game, so that it can be safely enrolled again.void
setBalancedTowers
(boolean val) void
setDuration
(String val) void
setEnrolledCount
(Integer val) void
setEventExpiring
(String val) void
void
void
setHostingHost
(String host) void
setInitiator
(String val) void
void
static void
setNextFreeGameId
(int id) Server calls this to set it high enough that existing directories in games work directory are not overwrittenvoid
setOnlineCount
(int count) void
setPlayerList
(ArrayList<User> playerlist) void
setPort
(int nr) void
setStartTime
(String val) void
setState
(GameInfo.GameState state) void
setSummary
(String val) void
void
setUnlimitedMulligans
(boolean val) void
setVariant
(String val) void
setViewmode
(String val) void
storeToOptionsObject
(Options gameOptions, String localPlayerName, boolean noAIs) boolean
updateOnlineCount
(int newCount) boolean
static boolean
wouldBeInstantGame
(long startTime)
-
Field Details
-
LOGGER
-
nextFreeGameId
private static int nextFreeGameId -
gameId
-
type
-
state
-
oldState
temporary backup during startingAttempt -
startingUser
-
portNr
private int portNr -
hostingHost
-
gameRunner
-
initiator
-
variant
-
viewmode
-
autosave
private final boolean autosave- See Also:
-
eventExpiring
-
unlimitedMulligans
private boolean unlimitedMulligans -
balancedTowers
private boolean balancedTowers -
min
private int min -
target
private int target -
max
private int max -
onlineCount
private int onlineCount -
startTime
private long startTime -
duration
private int duration -
summary
-
enrolledPlayers
private int enrolledPlayers -
players
-
-
Constructor Details
-
GameInfo
-
GameInfo
-
GameInfo
-
-
Method Details
-
setNextFreeGameId
public static void setNextFreeGameId(int id) Server calls this to set it high enough that existing directories in games work directory are not overwritten- Parameters:
id
- Next games should have higher number than given id
-
getNextFreeGameId
private static int getNextFreeGameId() -
wouldBeInstantGame
public static boolean wouldBeInstantGame(long startTime) -
makeTypeFromStarttime
-
fromString
-
toString
-
setState
-
getGameState
-
isScheduledGame
public boolean isScheduledGame() -
getStateString
-
getGameId
-
setGameId
-
setGameRunner
-
getGameRunner
-
getPort
public int getPort() -
setPort
public void setPort(int nr) -
setHostingHost
-
getHostingHost
-
getInitiator
-
setInitiator
-
getStartTime
-
setStartTime
-
getDuration
-
setDuration
-
getSummary
-
setSummary
-
getVariant
-
setVariant
-
getViewmode
-
getAutosave
public boolean getAutosave() -
setViewmode
-
getEventExpiring
-
setEventExpiring
-
getUnlimitedMulligans
public boolean getUnlimitedMulligans() -
setUnlimitedMulligans
public void setUnlimitedMulligans(boolean val) -
getBalancedTowers
public boolean getBalancedTowers() -
setBalancedTowers
public void setBalancedTowers(boolean val) -
hasEnoughPlayers
public boolean hasEnoughPlayers()Have enough players enrolled (at least "min")- Returns:
- true or false whether enough (at least 'min') players are already enrolled to this game
-
allEnrolledOnline
public boolean allEnrolledOnline()Have enough players enrolled (at least "min")- Returns:
- true or false whether all enrolled players are online
-
isDue
public boolean isDue()Has the scheduled time come?- Returns:
- true if the game can be started according to schedule
-
getMin
-
setMin
-
getTargetInteger
-
getTarget
public int getTarget() -
setTarget
-
getMax
-
setMax
-
getEnrolledCount
-
enoughPlayersEnrolled
public boolean enoughPlayersEnrolled() -
getOnlineCount
public int getOnlineCount() -
setOnlineCount
public void setOnlineCount(int count) -
setEnrolledCount
-
getPlayers
-
getPlayerListAsString
-
isFirstInEnrolledList
-
reEnrollIfNecessary
-
removeIfEnrolled
TODO remove overlap with isEnrolled If user with name "newName" is found, remove it from game, so that it can be safely enrolled again. E.g. after user reconnected or accidental double click to enroll button- Parameters:
newName
-- Returns:
- Whether user was found
-
isEnrolled
-
setPlayerList
-
updateOnlineCount
public boolean updateOnlineCount(int newCount) -
enroll
-
unenroll
-
storeToOptionsObject
-
relevantForSaving
public boolean relevantForSaving() -
isStartable
public boolean isStartable() -
isRunning
public boolean isRunning() -
wasAlreadyStarted
public boolean wasAlreadyStarted() -
markStarting
-
isStarting
public boolean isStarting() -
cancelStarting
public void cancelStarting() -
getStartingUser
-