|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.starhope.appius.sql.SQLPeerDatum
org.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)
|
Method Summary | |
---|---|
void |
acceptCommand(AbstractUser u,
AbstractRoom arena,
String[] command)
|
void |
acceptCommand(User user,
AbstractRoom 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(AbstractRoom room,
RoomListener newListener)
Notification that someone has entered the room. |
void |
acceptObjectPartRoom(AbstractRoom room,
RoomListener object)
Notification that someone has left a room |
void |
acceptPublicMessage(AbstractUser sender,
AbstractRoom room,
String message)
This is an overriding method. |
protected void |
changeGameState(GameStateFlag newState)
|
int |
compareTo(GameEvent other)
This is an overriding method. |
protected void |
decrementScore(int userID,
int howMuch)
decrease a user's score, but do not allow it to drop below 0. |
boolean |
equals(GameEvent other)
Stupid case of equals override. |
boolean |
equals(Object other)
This is an overriding method. |
protected String |
getCacheUniqueID()
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()
|
RoomAndZone |
getLocation()
This is an overriding method. |
Set<AbstractUser> |
getPlayers()
|
AbstractRoom |
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()
|
AbstractZone |
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(AppiusClaudiusCaecus 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. |
protected void |
set(ResultSet rs)
This is an overriding method. |
void |
tick(long currentTime,
long deltaTime)
This method is called periodically from the metronome thread. |
String |
toString()
This is an overriding method. |
private 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 org.starhope.appius.sql.SQLPeerDatum |
---|
changed, findInCache, flush, get, saveInCache, set, toJSON |
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 |
Field Detail |
---|
private static final long serialVersionUID
private static ConcurrentLinkedQueue<Map.Entry<GameEvent,GameStateFlag>> stateChangeQueue
private boolean endingSolo
protected boolean freezeTag
protected 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)
z
- the zone in which the game is being playedMethod Detail |
---|
public static void propagateGameStateChange()
public void acceptCommand(AbstractUser u, AbstractRoom 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(User user, AbstractRoom 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(AbstractRoom room, RoomListener newListener)
RoomListener
acceptObjectJoinRoom
in interface RoomListener
room
- The roomnewListener
- The thing (probably user) enteringRoomListener.acceptObjectJoinRoom(AbstractRoom,
RoomListener)
public void acceptObjectPartRoom(AbstractRoom room, RoomListener object)
RoomListener
acceptObjectPartRoom
in interface RoomListener
room
- The roomobject
- The thing (probably user) departingRoomListener.acceptObjectPartRoom(AbstractRoom,
RoomListener)
public void acceptPublicMessage(AbstractUser sender, AbstractRoom 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,
AbstractRoom, String)
protected void changeGameState(GameStateFlag newState)
newState
- the new state of the gamepublic int compareTo(GameEvent other)
compareTo
in interface Comparable<GameEvent>
other
- the other game event
Comparable.compareTo(java.lang.Object)
protected void decrementScore(int userID, int howMuch)
userID
- who lost pointshowMuch
- the number of points to losepublic boolean equals(GameEvent other)
other
- other game event
public boolean equals(Object other)
equals
in class Object
Object.equals(java.lang.Object)
protected String getCacheUniqueID()
getCacheUniqueID
in class SQLPeerDatum
SQLPeerDatum.getCacheUniqueID()
protected long getCountdownDuration()
public Set<AbstractUser> getEveryone()
public char getGameCode()
protected long getGameDuration()
public abstract String getGameEventPrefix()
public String getGameShortName()
protected int getLeaderBonus()
public RoomAndZone getLocation()
getLocation
in interface RoomListener
RoomListener.getLocation()
public Set<AbstractUser> getPlayers()
public AbstractRoom getRoom()
getRoom
in interface RoomListener
RoomListener.getRoom()
public Set<Room> getRooms()
public Set<Room> getScoreWatchRooms()
public Set<AbstractUser> getSpectators()
public long getTimer()
public AbstractZone 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(AppiusClaudiusCaecus 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()
protected void set(ResultSet rs) throws SQLException
set
in class SQLPeerDatum
rs
- The result of an SQL query, with the cursor already
pointed at the row describing this specific instance
of the object.
SQLException
- if the database fails somehowSQLPeerDatum.set(java.sql.ResultSet)
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()
private 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 |