Packagecom.whirled.avrg
Classpublic class PlayerSubControlServer
InheritancePlayerSubControlServer Inheritance PlayerSubControlBase Inheritance TargetedSubControl Inheritance AbstractSubControl Inheritance AbstractControl Inheritance flash.events.EventDispatcher
ImplementsMessageSubControl

Provides the server agent for an AVR game with services related to a single player.

See also

AVRServerGameControl.getPlayer()


Public Properties
 PropertyDefined by
 Inheritedprops : PropertySubControl
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
  
awardPrize(ident:String):void
Awards the specified prize item to this player.
PlayerSubControlServer
  
awardTrophy(ident:String):Boolean
Awards the specified trophy to this player.
PlayerSubControlServer
 Inherited
completeTask(taskId:String, payout:Number):void
This method calculates and awards a coin payout for the player.
PlayerSubControlBase
  
consumeItemPack(ident:String):Boolean
Consumes the specified item pack for this player.
PlayerSubControlServer
 Inherited
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
 Inherited
getBars():int
Returns this player's current bar balance.
PlayerSubControlBase
 Inherited
getCoins():int
Returns this player's current coin balance.
PlayerSubControlBase
 Inherited
getPartyId():int
Get the party id of this player.
PlayerSubControlBase
  
Returns the id of this player.
PlayerSubControlServer
 Inherited
Returns all item packs owned by this client's player (the default) or a specified player.
PlayerSubControlBase
 Inherited
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.
PlayerSubControlServer
 Inherited
getRoomId():int
Accesses the id of the room that this player is in.
PlayerSubControlBase
 Inherited
Get the targetId on which this control operates.
TargetedSubControl
 Inherited
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
 Inherited
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
 Inherited
playAvatarAction(action:String):void
Plays an action on this players avatar.
PlayerSubControlBase
  
purchaseItemPack(ident:String):void
Purchases the item pack with the specified identifier on behalf of the player.
PlayerSubControlServer
 Inherited
removeEventListener(type:String, listener:Function, useCapture:Boolean = false):void
Unregisters an event listener.
AbstractControl
  
sendMessage(name:String, value:Object = null):void
Sends a message to this player only.
PlayerSubControlServer
 Inherited
setAvatarLocation(x:Number, y:Number, z:Number, orient:Number):void
Sets the location and orientation of this player's avatar in room coordinates.
PlayerSubControlBase
 Inherited
setAvatarState(state:String):void
Sets the stats of this player's avatar.
PlayerSubControlBase
Events
 EventSummaryDefined by
 Inherited Dispatched when this player has just entered a room (or was already in the room and just started playing the game).PlayerSubControlBase
 Inherited Dispatched when this player has left a room (or has chosen to leave the game).PlayerSubControlBase
 Inherited Dispatched when this player has purchased new game content.PlayerSubControlBase
 Inherited Dispatched when this player has consumed an item pack.PlayerSubControlBase
 Inherited 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
Method detail
awardPrize()method
public function awardPrize(ident:String):void

Awards the specified prize item to this player. If the supplied prize identifier is not valid, this will not be known until the request is processed on the server, so the method will return successfully but no prize will have been awarded. Thus you should be careful not to misspell your prize identifier in your code or in the associated prize item.

Note: a game is only allowed to award a prize once per game session. This is to guard against bugs that might try to award many hundreds of the same prize to a user while playing a game. If you eallywant to award multiple instances of a prize, you will need to make different prize items with unique identifiers which all reference the same target item.

Note also: because a game anaward the same prize more than once if the player earns the prize in separate game sessions, a game that wishes to only award a prize once should couple the award of the prize with the award of a trophy and then structure their code like so:

     if (_ctrl.awardTrophy("special_award_trophy")) {
         _ctrl.awardPrize("special_award_avatar");
     }
     

The first time the player accomplishes the necessary goal, they will be awarded the trophy and the prize. Subsequently, awardTrophy() will return false indicating that the player already has the trophy in question and the prize will not be awarded. Alternatively the game could store whether or not the player has earned the prize in a user cookie.

Parameters
ident:String
awardTrophy()method 
public function awardTrophy(ident:String):Boolean

Awards the specified trophy to this player. If the supplied trophy identifier is not valid, this will not be known until the request is processed on the server, so the method will return succcessfully but no trophy will be awarded. Thus, you should be careful not to misspell your trophy identifier in your code or in the associated trophy source item.

Parameters
ident:String

Returns
Boolean — true if the trophy was requested, false if the player already has that trophy.
consumeItemPack()method 
public function consumeItemPack(ident:String):Boolean

Consumes the specified item pack for this player. The player must currently own at least one copy of the item pack. On success, a GameContentEvent.PLAYER_CONTENT_CONSUMED event will be dispatched on this control (on both the client and server).

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

Parameters
ident:String — the identifier of the item pack to be consumed.

Returns
Boolean — true if the consume request was sent, false if the the player is known not to own at least one copy of the item pack.
getPlayerId()method 
public override 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
getPlayerName()method 
public override function getPlayerName():String

Returns the name of this player.

Returns
String
purchaseItemPack()method 
public function purchaseItemPack(ident:String):void

Purchases the item pack with the specified identifier on behalf of the player. If the purchase cannot be completed due to a lack of funds or other reason the player will be notified via chat feedback. A GameContentEvent.PLAYER_CONTENT_ADDED event will be issued if the purchase succeeds.

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

Parameters
ident:String
sendMessage()method 
public function sendMessage(name:String, value:Object = null):void

Sends a message to this player only. Clients receive messages by listening for MessageReceivedEvents on theis PlayerSubControlClient.

Parameters
name:String
 
value:Object (default = null)

See also