com.threerings.parlor.tourney.server
Class TourneyManager

java.lang.Object
  extended by com.threerings.parlor.tourney.server.TourneyManager
All Implemented Interfaces:
TourneyCodes, TourneyProvider, InvocationCodes, InvocationProvider

public abstract class TourneyManager
extends Object
implements TourneyProvider, TourneyCodes

Controls a running tourney.


Field Summary
protected  TourneyConfig _config
          Our touney configuration.
protected  InvocationManager _invmgr
           
protected  Comparable<?> _key
          The key this tourney is recorded under.
protected  BodyLocator _locator
           
protected  RootDObjectManager _omgr
           
protected  long _startTime
          The time, in milliseconds, when the tourney starts.
protected  TourniesManager _tmgr
           
protected  TourneyObject _trobj
          Our distributed tourney object.
protected static long MINUTE
          One minute in milliseconds.
 
Fields inherited from interface com.threerings.parlor.tourney.data.TourneyCodes
ALREADY_IN_PROGRESS, ALREADY_IN_TOURNEY, CANCELLED, FAILED_ENTRY_FEE, HAS_PLAYERS, NOT_IN_TOURNEY, TOO_LATE, TOO_LATE_LEAVE
 
Fields inherited from interface com.threerings.presents.data.InvocationCodes
ACCESS_DENIED, E_ACCESS_DENIED, E_INTERNAL_ERROR, GLOBAL_GROUP, INTERNAL_ERROR
 
Constructor Summary
TourneyManager()
           
 
Method Summary
 void cancel(ClientObject caller, InvocationService.ConfirmListener listener)
          Handles a TourneyService.cancel(com.threerings.presents.client.InvocationService.ConfirmListener) request.
 void cancelTourney(String cause)
          Cancel the tourney, return entry fees to all participants.
 int init(TourneyConfig config, Comparable<?> key)
          Initializes this tourney manager and prepares it for operation.
 boolean isFinished()
          Returns true if the tourney is finished.
 boolean isPaused()
          Returns true if the tourney is paused.
 boolean isPending()
          Returns true if the tourney is pending.
 boolean isRunning()
          Returns true if the tourney is running.
 void join(ClientObject caller, InvocationService.ConfirmListener listener)
          Handles a TourneyService.join(com.threerings.presents.client.InvocationService.ConfirmListener) request.
protected abstract  void joinTourney(BodyObject body)
          Will throw an InvocationException if the user cannot join the tourney.
 void leave(ClientObject caller, InvocationService.ConfirmListener listener)
          Handles a TourneyService.leave(com.threerings.presents.client.InvocationService.ConfirmListener) request.
protected  Participant makeParticipant(BodyObject body)
          Creates a Participant record for the specified user.
abstract  void notifyAllParticipants(String msg)
           
protected  void releaseTourney()
          Releases the tourney from the tourney manager, and removes the tourney from the list of tournies.
 boolean shouldStart(long now)
          Returns true if it is time or past time the tourney starts.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_config

protected TourneyConfig _config
Our touney configuration.


_trobj

protected TourneyObject _trobj
Our distributed tourney object.


_startTime

protected long _startTime
The time, in milliseconds, when the tourney starts.


_key

protected Comparable<?> _key
The key this tourney is recorded under.


_omgr

@Inject
protected RootDObjectManager _omgr

_invmgr

@Inject
protected InvocationManager _invmgr

_locator

@Inject
protected BodyLocator _locator

_tmgr

@Inject
protected TourniesManager _tmgr

MINUTE

protected static long MINUTE
One minute in milliseconds.

Constructor Detail

TourneyManager

public TourneyManager()
Method Detail

init

public int init(TourneyConfig config,
                Comparable<?> key)
Initializes this tourney manager and prepares it for operation.

Returns:
the oid of this manager's tourney object.

cancel

public void cancel(ClientObject caller,
                   InvocationService.ConfirmListener listener)
            throws InvocationException
Description copied from interface: TourneyProvider
Handles a TourneyService.cancel(com.threerings.presents.client.InvocationService.ConfirmListener) request.

Specified by:
cancel in interface TourneyProvider
Throws:
InvocationException

join

public void join(ClientObject caller,
                 InvocationService.ConfirmListener listener)
          throws InvocationException
Description copied from interface: TourneyProvider
Handles a TourneyService.join(com.threerings.presents.client.InvocationService.ConfirmListener) request.

Specified by:
join in interface TourneyProvider
Throws:
InvocationException

leave

public void leave(ClientObject caller,
                  InvocationService.ConfirmListener listener)
           throws InvocationException
Description copied from interface: TourneyProvider
Handles a TourneyService.leave(com.threerings.presents.client.InvocationService.ConfirmListener) request.

Specified by:
leave in interface TourneyProvider
Throws:
InvocationException

cancelTourney

public void cancelTourney(String cause)
Cancel the tourney, return entry fees to all participants.


isFinished

public boolean isFinished()
Returns true if the tourney is finished.


isPending

public boolean isPending()
Returns true if the tourney is pending.


isRunning

public boolean isRunning()
Returns true if the tourney is running.


isPaused

public boolean isPaused()
Returns true if the tourney is paused.


shouldStart

public boolean shouldStart(long now)
Returns true if it is time or past time the tourney starts.


makeParticipant

protected Participant makeParticipant(BodyObject body)
Creates a Participant record for the specified user.


notifyAllParticipants

public abstract void notifyAllParticipants(String msg)

releaseTourney

protected void releaseTourney()
Releases the tourney from the tourney manager, and removes the tourney from the list of tournies.


joinTourney

protected abstract void joinTourney(BodyObject body)
                             throws InvocationException
Will throw an InvocationException if the user cannot join the tourney.

Throws:
InvocationException