Packagecom.whirled.contrib.card.trick
Classpublic class Scores
InheritanceScores Inheritance flash.events.EventDispatcher

Models the current scores for a trick taking card game.



Public Properties
 PropertyDefined by
  bids : Bids
[read-only] Access the bids of the game.
Scores
  table : Table
[read-only] Access the table the game is taking place at.
Scores
  target : int
[read-only] Access the target score of the game.
Scores
  totalTricks : int
[read-only] Access the total number of tricks (since last resetTricks call).
Scores
Protected Properties
 PropertyDefined by
  _bids : Bids
Scores
  _gameCtrl : GameControl
Scores
  _playerTricks : NetArray
Scores
  _scores : NetArray
Scores
  _table : Table
Scores
  _target : int
Scores
  _tricks : NetArray
Scores
Public Methods
 MethodDefined by
  
Scores(gameCtrl:GameControl, table:Table, bids:Bids, target:int)
Create a new scores container.
Scores
  
addScore(teamIdx:int, score:int):void
Increase a team's score.
Scores
  
addTrick(seat:int):void
Add a trick taken by the given player.
Scores
  
getBid(teamIdx:int):int
Get the total bid made by the team with the given index.
Scores
  
getPlayerTricks(seat:int):int
Get the number of tricks taken so far by the player in the given absolute seating position.
Scores
  
getScore(teamIdx:int):int
Get the score of the team with the given index.
Scores
  
getTricks(teamIdx:int):int
Get the number of tricks taken so far by the team with the given index.
Scores
  
Tally the current scores and get the winners and losers of the game.
Scores
  
resetScores():void
Reset the scores of all teams to 0.
Scores
  
resetTricks():void
Reset the tricks taken for all teams.
Scores
Protected Methods
 MethodDefined by
  
handleElementChanged(event:ElementChangedEvent):void
Scores
  
handlePropertyChanged(event:PropertyChangedEvent):void
Scores
Protected Constants
 ConstantDefined by
  PLAYER_TRICKS : String = "scores.playertricks"
[static]
Scores
  SCORES : String = "scores"
[static]
Scores
  TRICKS : String = "scores.tricks"
[static]
Scores
Property detail
_bidsproperty
protected var _bids:Bids
bidsproperty 
bids:Bids  [read-only]

Access the bids of the game.

Implementation
    public function get bids():Bids
_gameCtrlproperty 
protected var _gameCtrl:GameControl
_playerTricksproperty 
protected var _playerTricks:NetArray
_scoresproperty 
protected var _scores:NetArray
_tableproperty 
protected var _table:Table
tableproperty 
table:Table  [read-only]

Access the table the game is taking place at.

Implementation
    public function get table():Table
_targetproperty 
protected var _target:int
targetproperty 
target:int  [read-only]

Access the target score of the game.

Implementation
    public function get target():int
totalTricksproperty 
totalTricks:int  [read-only]

Access the total number of tricks (since last resetTricks call).

Implementation
    public function get totalTricks():int
_tricksproperty 
protected var _tricks:NetArray
Constructor detail
Scores()constructor
public function Scores(gameCtrl:GameControl, table:Table, bids:Bids, target:int)

Create a new scores container.

Parameters
gameCtrl:GameControl — the table these scores are at
 
table:Table — the bids object for the game
 
bids:Bids — the score that the teams are playing to
 
target:int
Method detail
addScore()method
public function addScore(teamIdx:int, score:int):void

Increase a team's score. Immediately sends a ScoresEvent.SCORES_CHANGED event.

Parameters
teamIdx:int — the index of the team scoring.
 
score:int — the amount to add to the team's total
addTrick()method 
public function addTrick(seat:int):void

Add a trick taken by the given player. Immediately sends a ScoresEvent.TRICKS_CHANGED event.

Parameters
seat:int — the absolute seating position of the player at the table
getBid()method 
public function getBid(teamIdx:int):int

Get the total bid made by the team with the given index.

Parameters
teamIdx:int

Returns
int
getPlayerTricks()method 
public function getPlayerTricks(seat:int):int

Get the number of tricks taken so far by the player in the given absolute seating position.

Parameters
seat:int

Returns
int
getScore()method 
public function getScore(teamIdx:int):int

Get the score of the team with the given index.

Parameters
teamIdx:int

Returns
int
getTricks()method 
public function getTricks(teamIdx:int):int

Get the number of tricks taken so far by the team with the given index.

Parameters
teamIdx:int

Returns
int
getWinnersAndLosers()method 
public function getWinnersAndLosers():WinnersAndLosers

Tally the current scores and get the winners and losers of the game. This considers all teams that share the highest score to be the winners, therefore there will always be at least one winner. There can only be multiple winners if there is a tie game, in which case there may be no losers. It is up to the game rules how to interpret this.

Returns
WinnersAndLosers
handleElementChanged()method 
protected function handleElementChanged(event:ElementChangedEvent):voidParameters
event:ElementChangedEvent
handlePropertyChanged()method 
protected function handlePropertyChanged(event:PropertyChangedEvent):voidParameters
event:PropertyChangedEvent
resetScores()method 
public function resetScores():void

Reset the scores of all teams to 0. Immediately sends a ScoresEvent.SCORES_CHANGED event for each team.

resetTricks()method 
public function resetTricks():void

Reset the tricks taken for all teams. Immediately sends a ScoresEvent.TRICKS_CHANGED event for each team.

Constant detail
PLAYER_TRICKSconstant
protected static const PLAYER_TRICKS:String = "scores.playertricks"
SCORESconstant 
protected static const SCORES:String = "scores"
TRICKSconstant 
protected static const TRICKS:String = "scores.tricks"