Packagecom.whirled.contrib.card.trick
Classpublic class ScoreBreakdown

Holds the transient breakdown of the scores for a trick taking or other team card game. A score breakdown encapsualtes the details of all the contributions to a team's total score for a round. The breakdown can them be converted to text for local feedback.



Public Properties
 PropertyDefined by
  teamName : String
[read-only] Access the name of the team for this breakdown.
ScoreBreakdown
  total : int
[read-only] Access the total score for the breakdown.
ScoreBreakdown
Protected Properties
 PropertyDefined by
  _elements : Array
ScoreBreakdown
  _table : Table
ScoreBreakdown
  _team : Team
ScoreBreakdown
Public Methods
 MethodDefined by
  
ScoreBreakdown(table:Table, team:int)
Create a new score breakdown.
ScoreBreakdown
  
addPlayerAchievement(value:int, playerIdx:int, achievement:String):void
Adds a new achievement for the team that was orchestrated by one player in particular.
ScoreBreakdown
  
addTeamAchievement(value:int, achievement:String):void
Adds a new achivement for the team that contributes to the overall score for the round.
ScoreBreakdown
  
addTeamFailure(value:int, action:String):void
Adds a new failure for the team that contributes to the overall score for the round.
ScoreBreakdown
  
describe():Array
Get an array of String's, each describing one breakdown item added by the add functions above, suitable for the (English speaking) user's consumption.
ScoreBreakdown
  
getPlayerName(idx:int):String
Get the name of a given player.
ScoreBreakdown
Property detail
_elementsproperty
protected var _elements:Array
_tableproperty 
protected var _table:Table
_teamproperty 
protected var _team:Team
teamNameproperty 
teamName:String  [read-only]

Access the name of the team for this breakdown. Assumes there are 2 players on a team. TODO: allow for more than 2 players

Implementation
    public function get teamName():String
totalproperty 
total:int  [read-only]

Access the total score for the breakdown. This is a sum of all the values given in the add functions above.

Implementation
    public function get total():int
Constructor detail
ScoreBreakdown()constructor
public function ScoreBreakdown(table:Table, team:int)

Create a new score breakdown.

Parameters
table:Table — the table for the game
 
team:int — the index of the team being scored.
Method detail
addPlayerAchievement()method
public function addPlayerAchievement(value:int, playerIdx:int, achievement:String):void

Adds a new achievement for the team that was orchestrated by one player in particular. When converting to text, this causes a possessive form of the player's name to prefix the achievement text.

Parameters
value:int — the contribution to the team's score of the achievement
 
playerIdx:int — the index of the player within the team that has achieved
 
achievement:String — text describing the achievement, e.g. "refraining from taking any tricks"
addTeamAchievement()method 
public function addTeamAchievement(value:int, achievement:String):void

Adds a new achivement for the team that contributes to the overall score for the round. If the value is less than zero, it is implied that the team did not achieve the achievement and hence a "not" is prefixed to the text conversion for the item. If value is zero, the achievement is not recorded.

Parameters
value:int — the contribution of the achievement to the overall score
 
achievement:String — text describing the achievement, e.g. "winning all their tricks"
addTeamFailure()method 
public function addTeamFailure(value:int, action:String):void

Adds a new failure for the team that contributes to the overall score for the round. If the value is greater than zero, it is implied that the team did not fail and hence a "not" is prefixed to the text conversion for the item. If the value is zero, the achievement is not recorded.

Parameters
value:int — numeric contribution of the failure to the score, usually less than 0
 
action:String — text describing the failure, e.g. "taking too many tricks"
describe()method 
public function describe():Array

Get an array of String's, each describing one breakdown item added by the add functions above, suitable for the (English speaking) user's consumption.

Returns
Array
getPlayerName()method 
public function getPlayerName(idx:int):String

Get the name of a given player.

Parameters
idx:int — the index of the player within the team

Returns
String