Packagecom.whirled.contrib.card
Classpublic class Table

Class to perform various transformations between player id, absolute seats and relative seats. Most functions are of the form getXFromY where X and Y are one of: Id - the player id, a unique value across all players in whirled. Absolute - the seating position that is the same for all observers Relative - the seating position relative to the local player. This is mostly useful for the view of the game. Name - the name of the player. Name is not reversible (i.e. there is no getIdFromName). Team - the team of the player (also not reversible) TODO: The concept of a watcher at a table was added as an afterthought. Rethink the interface with this in mind.



Public Properties
 PropertyDefined by
  numPlayers : int
[read-only] Access the number of players at the table.
Table
  numTeams : int
[read-only] Get the number of teams.
Table
Protected Properties
 PropertyDefined by
  _localSeat : int
Table
  _playerIds : Array
Table
  _playerNames : Array
Table
  _teams : Array
Table
Public Methods
 MethodDefined by
  
Table(playerNames:Array, playerIds:Array, localSeat:int, teams:Array)
Create a new table.
Table
  
getAbsoluteFromId(id:int):int
Get the absolute seating position for a player id.
Table
  
getAbsoluteFromRelative(relative:int):int
Get the absolute seating position of a relative seating position.
Table
  
getIdFromAbsolute(absolute:int):int
Get the player id in an absolute seating position.
Table
  
getIdFromRelative(relative:int):int
Get the player id in a relative seating position.
Table
  
getIdsNotOnTeam(team:Team):Array
Get an array of player ids that are not on a given team.
Table
  
getIdsOnTeam(team:Team):Array
Get an array of player ids that are on a given team.
Table
  
getIdToLeft(id:int):int
Get the id of the player to the left of the player with a given id.
Table
  
getLocalId():int
The id of the local player.
Table
  
The absolute seat position of the local player.
Table
  
Get the absolute seat position of the local player's teammate.
Table
  
getNameFromAbsolute(absolute:int):String
Get the name of a player in an absolute seat.
Table
  
getNameFromId(id:int):String
Get the name of a player from the player's id.
Table
  
getNameFromRelative(relative:int):String
Get the name of a player in a relative seat.
Table
  
getRelativeFromAbsolute(absolute:int):int
Get the relative seating position from an absolute seating position.
Table
  
getRelativeFromId(id:int):int
Get the relative seating position for a player id.
Table
  
getSeatAlong(seat:int, hops:int):int
Get the seat a given number of seats away from an absolute or relative seating position.
Table
  
getSeatToLeft(seat:int):int
Get the seat to the left of an absolute or relative seating position.
Table
  
getTeam(index:int):Team
Get a team by index.
Table
  
Get the team that contains the player assigned to the given absolute seating position.
Table
  
Get the team that contains the player with the given id.
Table
  
Get the team that contains the player assigned to the given relative seating position.
Table
  
getTeammateAbsolute(seat:int):int
Get the absolute seat position of the teammate of the player in the given absolute seating position.
Table
  
getTeammateId(id:int):int
Get the id of the teammate of the player with the given id position.
Table
  
isWatcher():Boolean
Test if the local player is only watching (not playing)
Table
Property detail
_localSeatproperty
protected var _localSeat:int
numPlayersproperty 
numPlayers:int  [read-only]

Access the number of players at the table.

Implementation
    public function get numPlayers():int
numTeamsproperty 
numTeams:int  [read-only]

Get the number of teams.

Implementation
    public function get numTeams():int
_playerIdsproperty 
protected var _playerIds:Array
_playerNamesproperty 
protected var _playerNames:Array
_teamsproperty 
protected var _teams:Array
Constructor detail
Table()constructor
public function Table(playerNames:Array, playerIds:Array, localSeat:int, teams:Array)

Create a new table.

Parameters
playerNames:Array — names of the players, in absolute seating order
 
playerIds:Array — ids of the players, in absolute seating order
 
localSeat:int — the absolulte seat of the local player
 
teams:Array
Method detail
getAbsoluteFromId()method
public function getAbsoluteFromId(id:int):int

Get the absolute seating position for a player id.

Parameters
id:int

Returns
int
getAbsoluteFromRelative()method 
public function getAbsoluteFromRelative(relative:int):int

Get the absolute seating position of a relative seating position.

Parameters
relative:int

Returns
int
getIdFromAbsolute()method 
public function getIdFromAbsolute(absolute:int):int

Get the player id in an absolute seating position.

Parameters
absolute:int

Returns
int
getIdFromRelative()method 
public function getIdFromRelative(relative:int):int

Get the player id in a relative seating position.

Parameters
relative:int

Returns
int
getIdsNotOnTeam()method 
public function getIdsNotOnTeam(team:Team):Array

Get an array of player ids that are not on a given team.

Parameters
team:Team

Returns
Array
getIdsOnTeam()method 
public function getIdsOnTeam(team:Team):Array

Get an array of player ids that are on a given team.

Parameters
team:Team

Returns
Array
getIdToLeft()method 
public function getIdToLeft(id:int):int

Get the id of the player to the left of the player with a given id.

Parameters
id:int

Returns
int
getLocalId()method 
public function getLocalId():int

The id of the local player.

Returns
int
getLocalSeat()method 
public function getLocalSeat():int

The absolute seat position of the local player.

Returns
int
getLocalTeammate()method 
public function getLocalTeammate():int

Get the absolute seat position of the local player's teammate.

Returns
int

Throws
— if the team is not exactly 2 players
getNameFromAbsolute()method 
public function getNameFromAbsolute(absolute:int):String

Get the name of a player in an absolute seat.

Parameters
absolute:int

Returns
String
getNameFromId()method 
public function getNameFromId(id:int):String

Get the name of a player from the player's id.

Parameters
id:int

Returns
String
getNameFromRelative()method 
public function getNameFromRelative(relative:int):String

Get the name of a player in a relative seat.

Parameters
relative:int

Returns
String
getRelativeFromAbsolute()method 
public function getRelativeFromAbsolute(absolute:int):int

Get the relative seating position from an absolute seating position.

Parameters
absolute:int

Returns
int
getRelativeFromId()method 
public function getRelativeFromId(id:int):int

Get the relative seating position for a player id.

Parameters
id:int

Returns
int
getSeatAlong()method 
public function getSeatAlong(seat:int, hops:int):int

Get the seat a given number of seats away from an absolute or relative seating position.

Parameters
seat:int — the number of seats away, absolute value must be no more than the number of players.
 
hops:int

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

Get the seat to the left of an absolute or relative seating position.

Parameters
seat:int

Returns
int
getTeam()method 
public function getTeam(index:int):Team

Get a team by index.

Parameters
index:int

Returns
Team
getTeamFromAbsolute()method 
public function getTeamFromAbsolute(seat:int):Team

Get the team that contains the player assigned to the given absolute seating position.

Parameters
seat:int

Returns
Team
getTeamFromId()method 
public function getTeamFromId(id:int):Team

Get the team that contains the player with the given id.

Parameters
id:int

Returns
Team
getTeamFromRelative()method 
public function getTeamFromRelative(seat:int):Team

Get the team that contains the player assigned to the given relative seating position.

Parameters
seat:int

Returns
Team
getTeammateAbsolute()method 
public function getTeammateAbsolute(seat:int):int

Get the absolute seat position of the teammate of the player in the given absolute seating position.

Parameters
seat:int

Returns
int

Throws
— if the team is not exactly 2 players
getTeammateId()method 
public function getTeammateId(id:int):int

Get the id of the teammate of the player with the given id position.

Parameters
id:int

Returns
int

Throws
— if the team is not exactly 2 players
isWatcher()method 
public function isWatcher():Boolean

Test if the local player is only watching (not playing)

Returns
Boolean