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 enumEnum for the possible states of a game:static enumEnum for the possible TYPES of a game (scheduled or instant, perhaps later also template?) -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final booleanprivate booleanprivate intprivate intprivate Stringprivate Stringprivate IGameRunnerprivate Stringprivate Stringprivate static final Loggerprivate intprivate intprivate static intprivate GameInfo.GameStatetemporary backup during startingAttemptprivate intprivate intprivate Userprivate longprivate GameInfo.GameStateprivate Stringprivate intprivate GameInfo.GameTypeprivate booleanprivate Stringprivate String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanHave enough players enrolled (at least "min")voidbooleanstatic GameInfofromString(String[] tokens, HashMap<String, GameInfo> games, boolean fromFile) booleanbooleangetMax()getMin()private static intintintgetPort()intbooleanbooleanHave enough players enrolled (at least "min")booleanisDue()Has the scheduled time come?booleanisEnrolled(String searchName) booleanisFirstInEnrolledList(String name) booleanbooleanbooleanbooleanprivate static GameInfo.GameTypemakeTypeFromStarttime(long startTime) voidmarkStarting(User starter) booleanreEnrollIfNecessary(User newUser) booleanbooleanremoveIfEnrolled(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.voidsetBalancedTowers(boolean val) voidsetDuration(String val) voidsetEnrolledCount(Integer val) voidsetEventExpiring(String val) voidvoidvoidsetHostingHost(String host) voidsetInitiator(String val) voidvoidstatic voidsetNextFreeGameId(int id) Server calls this to set it high enough that existing directories in games work directory are not overwrittenvoidsetOnlineCount(int count) voidsetPlayerList(ArrayList<User> playerlist) voidsetPort(int nr) voidsetStartTime(String val) voidsetState(GameInfo.GameState state) voidsetSummary(String val) voidvoidsetUnlimitedMulligans(boolean val) voidsetVariant(String val) voidsetViewmode(String val) voidstoreToOptionsObject(Options gameOptions, String localPlayerName, boolean noAIs) booleanupdateOnlineCount(int newCount) booleanstatic booleanwouldBeInstantGame(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
-