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.
protected var _localSeat:int
numPlayers:int [read-only]
Access the number of players at the table.
Implementation
public function get numPlayers():int
numTeams:int [read-only]
Get the number of teams.
Implementation
public function get numTeams():int
protected var _playerIds:Array
protected var _playerNames:Array
protected var _teams:Array
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 |
public function getAbsoluteFromId(id:int):int Get the absolute seating position for a player id.
Parameters
Returns
public function getAbsoluteFromRelative(relative:int):int Get the absolute seating position of a relative seating position.
Parameters
Returns
public function getIdFromAbsolute(absolute:int):int Get the player id in an absolute seating position.
Parameters
Returns
public function getIdFromRelative(relative:int):int Get the player id in a relative seating position.
Parameters
Returns
public function getIdsNotOnTeam(team:Team):Array Get an array of player ids that are not on a given team.
Parameters
Returns
public function getIdsOnTeam(team:Team):Array Get an array of player ids that are on a given team.
Parameters
Returns
public function getIdToLeft(id:int):int Get the id of the player to the left of the player with a given id.
Parameters
Returns
public function getLocalId():int The id of the local player.
Returns
public function getLocalSeat():int The absolute seat position of the local player.
Returns
public function getLocalTeammate():int Get the absolute seat position of the local player's teammate.
Returns
Throws
| — if the team is not exactly 2 players |
public function getNameFromAbsolute(absolute:int):String Get the name of a player in an absolute seat.
Parameters
Returns
public function getNameFromId(id:int):String Get the name of a player from the player's id.
Parameters
Returns
public function getNameFromRelative(relative:int):String Get the name of a player in a relative seat.
Parameters
Returns
public function getRelativeFromAbsolute(absolute:int):int Get the relative seating position from an absolute seating position.
Parameters
Returns
public function getRelativeFromId(id:int):int Get the relative seating position for a player id.
Parameters
Returns
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
public function getSeatToLeft(seat:int):int Get the seat to the left of an absolute or relative seating position.
Parameters
Returns
public function getTeam(index:int):Team Get a team by index.
Parameters
Returns
public function getTeamFromAbsolute(seat:int):Team Get the team that contains the player assigned to the given absolute seating position.
Parameters
Returns
public function getTeamFromId(id:int):Team Get the team that contains the player with the given id.
Parameters
Returns
public function getTeamFromRelative(seat:int):Team Get the team that contains the player assigned to the given relative seating position.
Parameters
Returns
public function getTeammateAbsolute(seat:int):int Get the absolute seat position of the teammate of the player in the given absolute seating
position.
Parameters
Returns
Throws
| — if the team is not exactly 2 players |
public function getTeammateId(id:int):int Get the id of the teammate of the player with the given id
position.
Parameters
Returns
Throws
| — if the team is not exactly 2 players |
public function isWatcher():Boolean Test if the local player is only watching (not playing)
Returns