Packagecom.whirled.contrib.card
Classpublic class TurnTimer
InheritanceTurnTimer Inheritance flash.events.EventDispatcher
SubclassesTrickTurnTimer

Regulates the length of time consumed by a player making a move. Basically just listens for turn changes and dispatches events when a certain amount of time has passed. Reduces the amount of time allowed for a player's turn each time that player misses, reducing the annoyance of other players if someone goes AFK or offline or just isn't fast enough. The base turn time is restored within a small number of turns if the player returns to making moves.



Public Properties
 PropertyDefined by
  debug : Function
Access a function to be called for outputting messages about turn timing.
TurnTimer
  playTime : Number
Access the amount of time allowed for playing a card.
TurnTimer
Protected Properties
 PropertyDefined by
  _amInControl : Function
TurnTimer
  _debug : Function
TurnTimer
  _enabled : Boolean = true
TurnTimer
  _gameCtrl : GameControl
TurnTimer
  _lastTurnHolder : int = 0
TurnTimer
  _playTime : Number = 10
TurnTimer
  _table : Table
TurnTimer
  _timer : Timer
TurnTimer
  turnHolder : int
[read-only]
TurnTimer
Public Methods
 MethodDefined by
  
TurnTimer(gameCtrl:GameControl, table:Table, useServerAgent:Boolean = false)
Creates a new turn timer for a given game control and table.
TurnTimer
  
disable():void
Disable the turn timer.
TurnTimer
  
restart():void
Restart the timer for the current turnholder.
TurnTimer
Protected Methods
 MethodDefined by
  
addHistory(turnHolder:int, expired:Boolean, count:int):void
TurnTimer
  
countExpiries(seat:int):int
TurnTimer
  
getCurrentTurnTimeBase(turnHolder:int):Number
Get the base amount of time that should be allowed for the current turn.
TurnTimer
  
handleMessage(event:MessageReceivedEvent):void
TurnTimer
  
handleTurnChanged(event:StateChangedEvent):void
TurnTimer
  
timerListener(event:TimerEvent):void
TurnTimer
Protected Constants
 ConstantDefined by
  EXPIRY_TRACKER : String = "turntimer.expirytracker"
[static]
TurnTimer
  HISTORY_EFFECT : Array
[static]
TurnTimer
  HISTORY_MASK : int = 0x0000000F
[static]
TurnTimer
  HISTORY_SIZE : int = 4
[static]
TurnTimer
  MSG_EXPIRED : String = "turntimer.stop"
[static]
TurnTimer
  MSG_START : String = "turntimer.start"
[static]
TurnTimer
Property detail
_amInControlproperty
protected var _amInControl:Function
_debugproperty 
protected var _debug:Function
debugproperty 
debug:Function  [read-write]

Access a function to be called for outputting messages about turn timing. The function must take a single string argument and return void. If set to null, no debug output will occur.

Implementation
    public function get debug():Function
    public function set debug(value:Function):void
_enabledproperty 
protected var _enabled:Boolean = true
_gameCtrlproperty 
protected var _gameCtrl:GameControl
_lastTurnHolderproperty 
protected var _lastTurnHolder:int = 0
_playTimeproperty 
protected var _playTime:Number = 10
playTimeproperty 
playTime:Number  [read-write]

Access the amount of time allowed for playing a card.

Implementation
    public function get playTime():Number
    public function set playTime(value:Number):void
_tableproperty 
protected var _table:Table
_timerproperty 
protected var _timer:Timer
turnHolderproperty 
turnHolder:int  [read-only]Implementation
    protected function get turnHolder():int
Constructor detail
TurnTimer()constructor
public function TurnTimer(gameCtrl:GameControl, table:Table, useServerAgent:Boolean = false)

Creates a new turn timer for a given game control and table.

Parameters
gameCtrl:GameControl — the game control
 
table:Table — the table where turns are being timed
 
useServerAgent:Boolean (default = false) — the bids (needed because more time is allowed for bidding)
Method detail
addHistory()method
protected function addHistory(turnHolder:int, expired:Boolean, count:int):voidParameters
turnHolder:int
 
expired:Boolean
 
count:int
countExpiries()method 
protected function countExpiries(seat:int):intParameters
seat:int

Returns
int
disable()method 
public function disable():void

Disable the turn timer. For debugging specific game play situations.

getCurrentTurnTimeBase()method 
protected function getCurrentTurnTimeBase(turnHolder:int):Number

Get the base amount of time that should be allowed for the current turn. The time is automatically diminished proprtionally to the number of turns the player has missed. Subclasses should override to accout for different game play situations.

Parameters
turnHolder:int

Returns
Number
handleMessage()method 
protected function handleMessage(event:MessageReceivedEvent):voidParameters
event:MessageReceivedEvent
handleTurnChanged()method 
protected function handleTurnChanged(event:StateChangedEvent):voidParameters
event:StateChangedEvent
restart()method 
public function restart():void

Restart the timer for the current turnholder. Used if there is a multi-stage turn where the turn holder does not change.

timerListener()method 
protected function timerListener(event:TimerEvent):voidParameters
event:TimerEvent
Constant detail
EXPIRY_TRACKERconstant
protected static const EXPIRY_TRACKER:String = "turntimer.expirytracker"
HISTORY_EFFECTconstant 
protected static const HISTORY_EFFECT:Array
HISTORY_MASKconstant 
protected static const HISTORY_MASK:int = 0x0000000F
HISTORY_SIZEconstant 
protected static const HISTORY_SIZE:int = 4
MSG_EXPIREDconstant 
protected static const MSG_EXPIRED:String = "turntimer.stop"
MSG_STARTconstant 
protected static const MSG_START:String = "turntimer.start"