com.liquidatom.derbyscore.domain
Class Bout

java.lang.Object
  extended by com.liquidatom.derbyscore.domain.Bout
All Implemented Interfaces:
ClockListener, TeamListener, java.util.concurrent.locks.ReadWriteLock

@ThreadSafe
public class Bout
extends java.lang.Object
implements ClockListener, TeamListener, java.util.concurrent.locks.ReadWriteLock

A domain object which represents a bout between two teams.

Author:
Russell Francis (russ@metro-six.com)

Field Summary
static Duration INTERMISSION_DURATION
           
static Duration JAM_DURATION
           
static Duration LINEUP_DURATION
           
static Duration OVERTIME_LINEUP_DURATION
           
static Duration PERIOD_DURATION
           
static Duration TEAM_TIMEOUT_DURATION
           
 
Constructor Summary
Bout(Team teamA, Team teamB)
           
 
Method Summary
 boolean addListener(BoutListener listener)
           
 void beginJam()
           
 void endJam()
           
 int getAdDigit()
           
 BoutState getBoutState()
           
 Clock getJamClock()
           
 Team getLead()
          Returns the team which currently has lead or null if the lead jammer status has not been assigned to any particular team for this jam.
 int getPeriod()
           
 Clock getPeriodClock()
           
 Team getTeamA()
           
 Team getTeamB()
           
 boolean isOvertime()
           
 boolean isTeamALead()
           
 boolean isTeamBLead()
           
 boolean isTimeout()
           
 void lineup()
           
 void markConfigured()
           
 void officialTimeout()
           
 void onBegin(Clock clock)
           
 void onChanged(Clock clock)
           
 void onChanged(Team team)
          Invoked when the state of the team is changed.
 void onEnd(Clock clock)
           
 void onPause(Clock clock)
           
 void onResume(Clock clock)
           
 void onTerminate(Clock clock)
           
 java.util.concurrent.locks.Lock readLock()
           
 boolean removeListener(BoutListener listener)
           
protected  void setBoutState(BoutState boutState)
           
 void setLead(Team lead)
          Set the team which has lead jammer status.
 void setOvertime(boolean overtime)
           
 void setPeriod(int period)
           
 void timeout()
          Call a timeout for the given team, in order for a timeout to be successfully called, the bout must be in the LINEUP state and the team must have a positive number of timeouts remaining.
 java.util.concurrent.locks.Lock writeLock()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PERIOD_DURATION

public static final Duration PERIOD_DURATION

JAM_DURATION

public static final Duration JAM_DURATION

TEAM_TIMEOUT_DURATION

public static final Duration TEAM_TIMEOUT_DURATION

LINEUP_DURATION

public static final Duration LINEUP_DURATION

INTERMISSION_DURATION

public static final Duration INTERMISSION_DURATION

OVERTIME_LINEUP_DURATION

public static final Duration OVERTIME_LINEUP_DURATION
Constructor Detail

Bout

public Bout(Team teamA,
            Team teamB)
Method Detail

addListener

public boolean addListener(BoutListener listener)

removeListener

public boolean removeListener(BoutListener listener)

getLead

public Team getLead()
Returns the team which currently has lead or null if the lead jammer status has not been assigned to any particular team for this jam.

Returns:
The team which has the lead jammer status or null if it has not been assigned to any team.

isTeamALead

public boolean isTeamALead()

isTeamBLead

public boolean isTeamBLead()

setLead

public void setLead(Team lead)
Set the team which has lead jammer status.

Parameters:
lead - The team which has lead jammer status or null if the status should be cleared from both teams.

getPeriod

public int getPeriod()

setPeriod

public void setPeriod(int period)

isOvertime

public boolean isOvertime()

setOvertime

public void setOvertime(boolean overtime)

getBoutState

public BoutState getBoutState()

setBoutState

protected void setBoutState(BoutState boutState)

getAdDigit

public int getAdDigit()

isTimeout

public boolean isTimeout()

getPeriodClock

public Clock getPeriodClock()

getJamClock

public Clock getJamClock()

getTeamA

public Team getTeamA()

getTeamB

public Team getTeamB()

markConfigured

public void markConfigured()

timeout

public void timeout()
Call a timeout for the given team, in order for a timeout to be successfully called, the bout must be in the LINEUP state and the team must have a positive number of timeouts remaining.


officialTimeout

public void officialTimeout()

beginJam

public void beginJam()

lineup

public void lineup()

endJam

public void endJam()

onPause

public void onPause(Clock clock)
Specified by:
onPause in interface ClockListener

onResume

public void onResume(Clock clock)
Specified by:
onResume in interface ClockListener

onChanged

public void onChanged(Clock clock)
Specified by:
onChanged in interface ClockListener

onBegin

public void onBegin(Clock clock)
Specified by:
onBegin in interface ClockListener

onEnd

public void onEnd(Clock clock)
Specified by:
onEnd in interface ClockListener

onTerminate

public void onTerminate(Clock clock)
Specified by:
onTerminate in interface ClockListener

onChanged

public void onChanged(Team team)
Description copied from interface: TeamListener
Invoked when the state of the team is changed.

Specified by:
onChanged in interface TeamListener
Parameters:
team - The team which recently changed.

readLock

public java.util.concurrent.locks.Lock readLock()
Specified by:
readLock in interface java.util.concurrent.locks.ReadWriteLock

writeLock

public java.util.concurrent.locks.Lock writeLock()
Specified by:
writeLock in interface java.util.concurrent.locks.ReadWriteLock