com.tootsville.game
Class VolleyballCourt

java.lang.Object
  extended by org.starhope.appius.game.GameEvent
      extended by com.tootsville.game.VolleyballCourt
All Implemented Interfaces:
Comparable<Object>, RoomListener, AcceptsMetronomeTicks, HasName

public class VolleyballCourt
extends GameEvent

Author:
brpocock@star-hope.org, ewinkelman

Field Summary
private  Volleyball ball
          Pointer to the user that represents the soccer ball
private  int lastX
          Last x coordinate of the last transmission
private  int lastY
          Last y coordinate of the last transmission
private  org.starhope.appius.geometry.Coord2D leftCenter
          Center of left field
private  org.starhope.appius.geometry.Polygon leftField
          The polygon that contains the dimensions of the left field
private  org.starhope.appius.geometry.Polygon net
          The polygon that contains the hit space for the net
private  org.starhope.appius.geometry.Coord3D realBallLocation
          Stores the real location of the volleyball
private  org.starhope.appius.geometry.Coord3D realBallVelocity
          Stores the real velocity of the volleyball TODO: Change to a vector 3D class
(package private)  ReentrantLock realLock
          Lock object for updating/reading real coordinates
private  org.starhope.appius.geometry.Coord2D rightCenter
          Center of right field
private  org.starhope.appius.geometry.Polygon rightField
          The polygon that contains the dimensions of the right field
private static long serialVersionUID
           
private  Room volleyballCourt
          Soccer field room object
 
Fields inherited from class org.starhope.appius.game.GameEvent
freezeTag, gameCode, gameState, players, rooms, scores, scoreWatchRooms
 
Constructor Summary
VolleyballCourt(Zone z)
           
 
Method Summary
 void acceptGameAction(AbstractUser u, org.json.JSONObject action)
          Broadcast message of a game action taking place
 void acceptOutOfBandMessage(AbstractUser sender, Room room, org.json.JSONObject body)
          Accept an out-of-band communications packet that was broadcast to a room in which this Listener is listening.
 void acceptPublicMessage(AbstractUser from, String message)
          Accept a public chat message.
 void acceptUserAction(Room r, AbstractUser u)
          User actions (go/do actions) propagate through this channel.
private  org.starhope.appius.geometry.Coord2D ballLocation()
          Gets where the clients think the ball is, taking into account the Z offset (2D projection of 3D coördinates)
 void destroySelf()
          Cleanup routine to make sure we get garbage collected properly
(package private)  void dropBall(org.starhope.appius.geometry.Coord2D coord2d, double height)
          Drops the ball from the given height at the specified coordinates
 String getGameEventPrefix()
          Get the prefix to be applied to event types for this game
 String getName()
          Return a user-visible, unique name for this class.
 void tick(long currentTime, long deltaTime)
          This method is called periodically from the metronome thread.
private  void updateBallLocation()
          Updates the ball's location
 
Methods inherited from class org.starhope.appius.game.GameEvent
acceptCommand, acceptCommand, acceptGameStateChange, acceptObjectJoinRoom, acceptObjectPartRoom, acceptPublicMessage, acceptUserVariableUpdate, changeGameState, compareTo, decrementScore, disconnect, equals, equals, getCountdownDuration, getEveryone, getGameCode, getGameDuration, getGameShortName, getLeaderBonus, getPlayers, getRoom, getRooms, getScoreWatchRooms, getSpectators, getTimer, getZone, hashCode, incrementScore, propagateGameStateChange, resetPlayers, sendEndEvents, sendStartEvents, toString, updateRoomVars, updateScore, updateScores
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

ball

private Volleyball ball
Pointer to the user that represents the soccer ball


leftField

private final org.starhope.appius.geometry.Polygon leftField
The polygon that contains the dimensions of the left field


rightField

private final org.starhope.appius.geometry.Polygon rightField
The polygon that contains the dimensions of the right field


net

private final org.starhope.appius.geometry.Polygon net
The polygon that contains the hit space for the net


volleyballCourt

private final Room volleyballCourt
Soccer field room object


leftCenter

private final org.starhope.appius.geometry.Coord2D leftCenter
Center of left field


rightCenter

private final org.starhope.appius.geometry.Coord2D rightCenter
Center of right field


lastX

private int lastX
Last x coordinate of the last transmission


lastY

private int lastY
Last y coordinate of the last transmission


realBallLocation

private org.starhope.appius.geometry.Coord3D realBallLocation
Stores the real location of the volleyball


realBallVelocity

private org.starhope.appius.geometry.Coord3D realBallVelocity
Stores the real velocity of the volleyball TODO: Change to a vector 3D class


realLock

final ReentrantLock realLock
Lock object for updating/reading real coordinates

Constructor Detail

VolleyballCourt

public VolleyballCourt(Zone z)
                throws GameLogicException,
                       NotFoundException
Parameters:
z - zone
Throws:
GameLogicException - WRITEME
NotFoundException - WRITEME
Method Detail

acceptGameAction

public void acceptGameAction(AbstractUser u,
                             org.json.JSONObject action)
Description copied from interface: RoomListener
Broadcast message of a game action taking place

Parameters:
u - the sender
action - The game action. The verb is in action.getString("action").
See Also:
RoomListener.acceptGameAction(org.starhope.appius.user.AbstractUser, org.json.JSONObject)

acceptOutOfBandMessage

public void acceptOutOfBandMessage(AbstractUser sender,
                                   Room room,
                                   org.json.JSONObject body)
Description copied from interface: RoomListener
Accept an out-of-band communications packet that was broadcast to a room in which this Listener is listening.

Parameters:
sender - The sender of the OOB message
room - The room in which the OOB message is being broadcast
body - A JSON object containing the OOB message. The contents of this message are not constrained.
See Also:
RoomListener.acceptOutOfBandMessage(org.starhope.appius.user.AbstractUser, org.starhope.appius.game.Room, org.json.JSONObject)

acceptPublicMessage

public void acceptPublicMessage(AbstractUser from,
                                String message)
Description copied from interface: RoomListener
Accept a public chat message. This prototype does not specify the room, on the (potentially invalid) assumption that the room listener doesn't care from which room the speech was made.

Parameters:
from - The speaker
message - The spoken text or /emote
See Also:
RoomListener.acceptPublicMessage(org.starhope.appius.user.AbstractUser, java.lang.String)

acceptUserAction

public void acceptUserAction(Room r,
                             AbstractUser u)
Description copied from interface: RoomListener
User actions (go/do actions) propagate through this channel.

Parameters:
r - the room in which the user is taking an action
u - the user taking an action
See Also:
RoomListener.acceptUserAction(org.starhope.appius.game.Room, org.starhope.appius.user.AbstractUser)

ballLocation

private org.starhope.appius.geometry.Coord2D ballLocation()
Gets where the clients think the ball is, taking into account the Z offset (2D projection of 3D coördinates)

Returns:
where the clients think the ball is, taking into account the Z offset

destroySelf

public void destroySelf()
Cleanup routine to make sure we get garbage collected properly

Overrides:
destroySelf in class GameEvent

dropBall

void dropBall(org.starhope.appius.geometry.Coord2D coord2d,
              double height)
Drops the ball from the given height at the specified coordinates

Parameters:
coord2d - Drop location
height - Drop height

getGameEventPrefix

public String getGameEventPrefix()
Description copied from class: GameEvent
Get the prefix to be applied to event types for this game

Specified by:
getGameEventPrefix in class GameEvent
Returns:
the string prefix used to find event types for this game
See Also:
GameEvent.getGameEventPrefix()

getName

public String getName()
Description copied from interface: HasName
Return a user-visible, unique name for this class. This name may not necessarily be globally unique, but must be unique across all objects of this class. For example, having both a User and a Zone named “Lightning” is acceptable, but there may not be two users with the same name.

Returns:
a user-visible string name for this instance
See Also:
HasName.getName()

tick

public void tick(long currentTime,
                 long deltaTime)
          throws UserDeadException
Description copied from interface: AcceptsMetronomeTicks
This method is called periodically from the metronome thread. To save computation, it receives both the current time since epoch in milliseconds at the start of the global tick propagation, and the delta time since the previous metronome tick.

Specified by:
tick in interface AcceptsMetronomeTicks
Overrides:
tick in class GameEvent
Parameters:
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
Throws:
UserDeadException - if a user has died during this tick
See Also:
GameEvent.tick(long, long)

updateBallLocation

private void updateBallLocation()
Updates the ball's location