|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.starhope.appius.game.GameEvent
public abstract class GameEvent
A GameEvent is a room-wide (or multi-room) game that occurs within the larger context of the game. Think “arena” or similar.
Field Summary | |
---|---|
private boolean |
endingSolo
Shitty recursion guard endingSolo (GameEvent) |
protected boolean |
freezeTag
freeze game actions |
protected char |
gameCode
the one-char identifier for this game |
protected GameStateFlag |
gameState
the current game state (mode) |
private ConcurrentHashMap<Integer,Integer> |
playerEvents
the events in the global events table for each player, used for recording scores |
protected ConcurrentSkipListSet<Integer> |
players
the players (in any room) |
protected ConcurrentSkipListSet<Room> |
rooms
The rooms which this GameEvent controls |
protected ConcurrentHashMap<Integer,Integer> |
scores
the current scores for all players |
protected ConcurrentSkipListSet<Room> |
scoreWatchRooms
The rooms which this GameEvent will report the score to (in addition to rooms ) scoreWatchRooms (GameEvent) |
private static long |
serialVersionUID
Java serialization unique ID serialVersionUID (long) |
private static ConcurrentLinkedQueue<Map.Entry<GameEvent,GameStateFlag>> |
stateChangeQueue
Queue for state changes in all GameEvents |
private long |
timer
The game (countdown/play time) timer |
private Zone |
zone
The zone zone (GameEvent) |
Constructor Summary | |
---|---|
protected |
GameEvent(Zone z,
char c)
|
Method Summary | |
---|---|
void |
acceptCommand(AbstractUser u,
Room arena,
String[] command)
|
void |
acceptCommand(GeneralUser user,
Room room,
Zone zone2,
String[] command)
Accept a developer-level command and react to it. |
void |
acceptGameStateChange(GameEvent game,
GameStateFlag newGameState)
This is an overriding method. |
void |
acceptObjectJoinRoom(Room room,
RoomListener newListener)
Notification that someone has entered the room. |
void |
acceptObjectPartRoom(Room room,
RoomListener object)
Notification that someone has left a room |
void |
acceptPublicMessage(AbstractUser sender,
Room room,
String message)
This is an overriding method. |
void |
acceptUserVariableUpdate(AbstractUser user,
String varName,
String varValue)
Receive notification of the change of an user variable |
protected void |
changeGameState(GameStateFlag newState)
|
int |
compareTo(Object o)
|
protected void |
decrementScore(int userID,
int howMuch)
decrease a user's score, but do not allow it to drop below 0. |
void |
destroySelf()
Destroy this event — during Zone shutdown usually |
void |
disconnect()
disconnect the game event from the associated rooms. |
private void |
endAllEvents()
close out all pending events |
boolean |
equals(GameEvent other)
Stupid case of equals override. |
boolean |
equals(Object other)
This is an overriding method. |
protected long |
getCountdownDuration()
Time (in ms) for the game countdown period timer. |
Set<AbstractUser> |
getEveryone()
|
char |
getGameCode()
|
protected long |
getGameDuration()
Time (in ms) for the game play period timer. |
abstract String |
getGameEventPrefix()
Get the prefix to be applied to event types for this game |
String |
getGameShortName()
|
protected int |
getLeaderBonus()
|
Set<AbstractUser> |
getPlayers()
|
Room |
getRoom()
This is an overriding method. |
Set<Room> |
getRooms()
Get all of the rooms participating in this GameEvent |
Set<Room> |
getScoreWatchRooms()
Get all of the rooms which are either participating in this GameEvent, or monitoring its scores |
Set<AbstractUser> |
getSpectators()
|
long |
getTimer()
|
Zone |
getZone()
This is an overriding method. |
int |
hashCode()
This is an overriding method. |
void |
incrementScore(int who,
int howMuch)
|
static void |
propagateGameStateChange()
Propagate any waiting game state changes to listeners |
protected void |
resetPlayers()
Clear all players; clear all scores; put all users into player or spectator queues |
protected void |
sendEndEvents(String gameMoniker)
|
private void |
sendScoreUpdate(NetIOThread playerThread,
int score,
AbstractUser player)
Send an update on the score of the game to a player |
protected void |
sendStartEvents(String gameMoniker)
Send the start of events to all players |
private void |
sendTimers()
Send the game timers out to players and spectators. |
void |
tick(long currentTime,
long deltaTime)
This method is called periodically from the metronome thread. |
String |
toString()
This is an overriding method. |
protected void |
updateRoomVars()
Send updated room variables with the game score and status. |
protected void |
updateScore(AbstractUser who)
notify a player of their score |
protected void |
updateScores()
update all players of their scores and update room vars to boot |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface org.starhope.appius.util.HasName |
---|
getName |
Methods inherited from interface org.starhope.appius.game.RoomListener |
---|
acceptGameAction, acceptOutOfBandMessage, acceptPublicMessage, acceptUserAction |
Field Detail |
---|
private static final long serialVersionUID
private static ConcurrentLinkedQueue<Map.Entry<GameEvent,GameStateFlag>> stateChangeQueue
private boolean endingSolo
protected boolean freezeTag
protected final char gameCode
protected GameStateFlag gameState
private final ConcurrentHashMap<Integer,Integer> playerEvents
protected ConcurrentSkipListSet<Integer> players
protected final ConcurrentSkipListSet<Room> rooms
protected final ConcurrentHashMap<Integer,Integer> scores
protected final ConcurrentSkipListSet<Room> scoreWatchRooms
rooms
) scoreWatchRooms (GameEvent)
private long timer
private final Zone zone
Constructor Detail |
---|
protected GameEvent(Zone z, char c)
z
- the zone in which the game is being playedc
- the game code characterMethod Detail |
---|
public static void propagateGameStateChange()
public void acceptCommand(AbstractUser u, Room arena, String[] command)
u
- The operator issuing the commandarena
- The room in which the operator's command is being
executedcommand
- The command and parameterspublic void acceptCommand(GeneralUser user, Room room, Zone zone2, String[] command)
zone2
- The zone in which the game is attached (should be
"zone" usually)room
- The room in which the invoking user existsuser
- The invoking usercommand
- A command string split on whitespacepublic void acceptGameStateChange(GameEvent game, GameStateFlag newGameState)
acceptGameStateChange
in interface RoomListener
game
- The GameEvent whose state is changingnewGameState
- The new stateRoomListener.acceptGameStateChange(org.starhope.appius.game.GameEvent,
org.starhope.appius.game.GameStateFlag)
public void acceptObjectJoinRoom(Room room, RoomListener newListener)
RoomListener
acceptObjectJoinRoom
in interface RoomListener
room
- The roomnewListener
- The thing (probably user) enteringRoomListener.acceptObjectJoinRoom(Room,
RoomListener)
public void acceptObjectPartRoom(Room room, RoomListener object)
RoomListener
acceptObjectPartRoom
in interface RoomListener
room
- The roomobject
- The thing (probably user) departingRoomListener.acceptObjectPartRoom(Room,
RoomListener)
public void acceptPublicMessage(AbstractUser sender, Room room, String message)
acceptPublicMessage
in interface RoomListener
sender
- The speakerroom
- The room in which the words were spokenmessage
- The spoken text or /emoteRoomListener.acceptPublicMessage(AbstractUser,
Room, String)
public void acceptUserVariableUpdate(AbstractUser user, String varName, String varValue)
acceptUserVariableUpdate
in interface RoomListener
user
- The user updating their variablevarName
- The name of the variable (key)varValue
- The new value (null if unset)protected void changeGameState(GameStateFlag newState)
newState
- the new state of the gamepublic int compareTo(Object o)
compareTo
in interface Comparable<Object>
Comparable.compareTo(java.lang.Object)
protected void decrementScore(int userID, int howMuch)
userID
- who lost pointshowMuch
- the number of points to losepublic void destroySelf()
public void disconnect()
private void endAllEvents()
public boolean equals(GameEvent other)
other
- other game event
public boolean equals(Object other)
equals
in class Object
Object.equals(java.lang.Object)
protected long getCountdownDuration()
public Set<AbstractUser> getEveryone()
public char getGameCode()
protected long getGameDuration()
public abstract String getGameEventPrefix()
public String getGameShortName()
protected int getLeaderBonus()
public Set<AbstractUser> getPlayers()
public Room getRoom()
getRoom
in interface RoomListener
RoomListener.getRoom()
public Set<Room> getRooms()
public Set<Room> getScoreWatchRooms()
public Set<AbstractUser> getSpectators()
public long getTimer()
public Zone getZone()
getZone
in interface RoomListener
RoomListener.getZone()
public int hashCode()
hashCode
in class Object
Object.hashCode()
public void incrementScore(int who, int howMuch)
who
- user ID of the player to have score increasedhowMuch
- increment amount, can be negativeprotected void resetPlayers()
protected void sendEndEvents(String gameMoniker)
gameMoniker
- The unique event moniker for this gameprivate void sendScoreUpdate(NetIOThread playerThread, int score, AbstractUser player)
playerThread
- The player's AppiusClaudiusCaecus server
threadscore
- the player's scoreplayer
- the player him/her-selfprotected void sendStartEvents(String gameMoniker)
gameMoniker
- The game's unique event monikerprivate void sendTimers()
public void tick(long currentTime, long deltaTime) throws UserDeadException
AcceptsMetronomeTicks
tick
in interface AcceptsMetronomeTicks
currentTime
- Time since epoch at the start of the global
metronome propagation, as per
System.currentTimeMillis()deltaTime
- Delta-time in milliseconds since the prior
global metronome tick
UserDeadException
- if a user has died during this tickAcceptsMetronomeTicks.tick(long,
long)
public String toString()
toString
in class Object
Object.toString()
protected void updateRoomVars()
protected void updateScore(AbstractUser who)
who
- the player whose score is being sentprotected void updateScores()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |