Packagecom.whirled.avrg
Classpublic class PlayerSubControlBase
InheritancePlayerSubControlBase Inheritance TargetedSubControl Inheritance AbstractSubControl Inheritance AbstractControl Inheritance flash.events.EventDispatcher
SubclassesPlayerSubControlClient, PlayerSubControlServer

Provides services for a single player of an AVRG to the server agent and client.



Public Properties
 PropertyDefined by
  props : PropertySubControl
[read-only] Accesses the read-write properties of this player.
PlayerSubControlBase
Public Methods
 MethodDefined by
 Inherited
addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void
Registers an event listener.
AbstractControl
  
completeTask(taskId:String, payout:Number):void
This method calculates and awards a coin payout for the player.
PlayerSubControlBase
  
Quits the game for this player.
PlayerSubControlBase
 Inherited
doBatch(fn:Function, ... args):void
Execute the specified function as a batch of commands that will be sent to the server together.
AbstractSubControl
  
getBars():int
Returns this player's current bar balance.
PlayerSubControlBase
  
getCoins():int
Returns this player's current coin balance.
PlayerSubControlBase
  
getPartyId():int
Get the party id of this player.
PlayerSubControlBase
  
Returns the id of this player.
PlayerSubControlBase
  
Returns all item packs owned by this client's player (the default) or a specified player.
PlayerSubControlBase
  
Returns all level packs owned by this client's player (the default) or a specified player.
PlayerSubControlBase
  
getPlayerName():String
Returns the name of this player.
PlayerSubControlBase
  
getRoomId():int
Accesses the id of the room that this player is in.
PlayerSubControlBase
 Inherited
Get the targetId on which this control operates.
TargetedSubControl
  
holdsTrophy(ident:String):Boolean
Returns true if this client's player (the default) or a specified player has the trophy with the specified identifier.
PlayerSubControlBase
 Inherited
isConnected():Boolean
Are we connected and running inside the whirled environment, or has someone just loaded up our SWF by itself?
AbstractSubControl
  
moveToRoom(roomId:int, exitCoords:Array = null):void
Instructs this player's client to move to the specified room, or pass 0 to put the player in no room.
PlayerSubControlBase
  
playAvatarAction(action:String):void
Plays an action on this players avatar.
PlayerSubControlBase
 Inherited
removeEventListener(type:String, listener:Function, useCapture:Boolean = false):void
Unregisters an event listener.
AbstractControl
  
setAvatarLocation(x:Number, y:Number, z:Number, orient:Number):void
Sets the location and orientation of this player's avatar in room coordinates.
PlayerSubControlBase
  
setAvatarState(state:String):void
Sets the stats of this player's avatar.
PlayerSubControlBase
Events
 EventSummaryDefined by
   Dispatched when this player has just entered a room (or was already in the room and just started playing the game).PlayerSubControlBase
   Dispatched when this player has left a room (or has chosen to leave the game).PlayerSubControlBase
   Dispatched when this player has purchased new game content.PlayerSubControlBase
   Dispatched when this player has consumed an item pack.PlayerSubControlBase
   Dispatched when this player completes a task and receives a coin payout.PlayerSubControlBase
 Inherited Event.UNLOAD Dispatched when the SWF using this control has been unloaded.AbstractControl
Property detail
propsproperty
props:PropertySubControl  [read-only]

Accesses the read-write properties of this player. Properties marked as such will be persisted and restored whenever the player joins the game. Persistent properties should only be used when genuinely necessary. Persisting properties on a guest player will have no effect.

Implementation
    public function get props():PropertySubControl

See also

Method detail
completeTask()method
public function completeTask(taskId:String, payout:Number):void

This method calculates and awards a coin payout for the player. The actual amount is not under the direct control of the developer, but is calculated by Whirled from factors such as the number of people playing the game and the frequency and size of payouts the game makes. The payout factor is a number that should lie between 0 and 1, and the coin payout is a multiple of this amount. This means if the game calls this method with a factor of 0.3 for one player and 0.6 for another, the second player is guaranteed to get twice as many coins as the first. Use this guarantee to develop a fair payout structure for your game. The taskId is not used by the server at all. Its only purpose is to be echoed back in the AVRGamePlayerEvent.TASK_COMPLETED event that is dispatched as a result of this call. This event contains the taskId that was sent in along with the precise number of coins that were actually awarded to the player. The typical use of this event would be to display a nice popup window or graphical effect to salute the player's achivement, optionally including the coin amount.

Parameters
taskId:String
 
payout:Number
deactivateGame()method 
public function deactivateGame():void

Quits the game for this player. This method should be called for example when the user closes the HUD of a game.

getBars()method 
public function getBars():int

Returns this player's current bar balance.

Note: this functionality is only allowed for approved games. This method will silently fail for unapproved games. The approval process is still being developed.

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

Returns this player's current coin balance.

Note: this functionality is only allowed for approved games. This method will silently fail for unapproved games. The approval process is still being developed.

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

Get the party id of this player.

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

Returns the id of this player. This id is the member id and can be used to view the member's profile (www.whirled.com/#people-{id}).

Returns
int
getPlayerItemPacks()method 
public function getPlayerItemPacks():Array

Returns all item packs owned by this client's player (the default) or a specified player. The packs are returned as an array of objects with the following properties:

     ident - string identifier of item pack
     name - human readable name of item pack
     mediaURL - URL for item pack content
     count - the number of copies of this item pack owned by this player
     

Returns
Array
getPlayerLevelPacks()method 
public function getPlayerLevelPacks():Array

Returns all level packs owned by this client's player (the default) or a specified player. The packs are returned as an array of objects with the following properties:

     ident - string identifier of item pack
     name - human readable name of item pack
     mediaURL - URL for item pack content
     premium - boolean indicating that content is premium or not
     

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

Returns the name of this player.

Returns
String
getRoomId()method 
public function getRoomId():int

Accesses the id of the room that this player is in. Returns 0 if the player is not in any room. This may happen immediately after the player joins the game or just after the player leaves another room.

Returns
int
holdsTrophy()method 
public function holdsTrophy(ident:String):Boolean

Returns true if this client's player (the default) or a specified player has the trophy with the specified identifier.

Parameters
ident:String

Returns
Boolean
moveToRoom()method 
public function moveToRoom(roomId:int, exitCoords:Array = null):void

Instructs this player's client to move to the specified room, or pass 0 to put the player in no room. The given exit coordinates are a 3-tuple specifying in room coordinates where the avatar should appear to walk to when leaving the room. If not given, the avatar will just disappear.

Hard-wiring valid room ids should be avoided. Room ids can be obtained from properties stored by an admininstrative interface or from a server agent message containing currently active rooms.

Note that this is not guaranteed to succeed. The request may be denied.

Parameters
roomId:int
 
exitCoords:Array (default = null)

See also

playAvatarAction()method 
public function playAvatarAction(action:String):void

Plays an action on this players avatar.

Parameters
action:String

See also

setAvatarLocation()method 
public function setAvatarLocation(x:Number, y:Number, z:Number, orient:Number):void

Sets the location and orientation of this player's avatar in room coordinates.

Parameters
x:Number
 
y:Number
 
z:Number
 
orient:Number

See also

setAvatarState()method 
public function setAvatarState(state:String):void

Sets the stats of this player's avatar.

Parameters
state:String

See also

Event detail
enteredRoomevent 
Event object type: com.whirled.avrg.AVRGamePlayerEvent
AVRGamePlayerEvent.type property = com.whirled.avrg.AVRGamePlayerEvent.ENTERED_ROOM

Dispatched when this player has just entered a room (or was already in the room and just started playing the game).

An event type dispatched when the player has entered a new room.
name - not used
value :int - the id of the scene entered

See also

leftRoomevent  
Event object type: com.whirled.avrg.AVRGamePlayerEvent
AVRGamePlayerEvent.type property = com.whirled.avrg.AVRGamePlayerEvent.LEFT_ROOM

Dispatched when this player has left a room (or has chosen to leave the game).

An event type dispatched when the player leaves a room.
key - not used
value :int - the id of the scene left

See also

PlayerContentAddedevent  
Event object type: com.whirled.game.GameContentEvent
GameContentEvent.type property = com.whirled.game.GameContentEvent.PLAYER_CONTENT_ADDED

Dispatched when this player has purchased new game content.

Indicates that the a player has purchased new game content.

PlayerContentConsumedevent  
Event object type: com.whirled.game.GameContentEvent
GameContentEvent.type property = com.whirled.game.GameContentEvent.PLAYER_CONTENT_CONSUMED

Dispatched when this player has consumed an item pack.

Indicates that the a player has consumed an item pack. contentType() for this event will always be ITEM_PACK.

taskCompletedevent  
Event object type: com.whirled.avrg.AVRGamePlayerEvent
AVRGamePlayerEvent.type property = com.whirled.avrg.AVRGamePlayerEvent.TASK_COMPLETED

Dispatched when this player completes a task and receives a coin payout.

An event type dispatched when the player receives some coins.
name - the id of the task that was completed
value :int - the amount of coins awarded

See also