Class Index | File Index

Classes


Namespace core.trade

Trades between the user's team and other teams.
Defined in: <js/core/trade.js>.

Namespace Summary
Constructor Attributes Constructor Name and Description
 
Method Summary
Method Attributes Method Name and Description
<static>  
core.trade.clear(cb)
Remove all players currently added to the trade.
<static>  
core.trade.create(tid, pid, cb)
Start a new trade with a team.
<static>  
core.trade.getOtherTid(cb)
Gets the team ID for the team that the user is trading with.
<static>  
core.trade.getPlayers(cb)
Get the arrays containing the player IDs in the trade for both teams.
<static>  
core.trade.propose(cb)
Proposes the current trade in the database.
<static>  
core.trade.summary(otherTid, userPids, otherPids, cb)
Create a summary of the trade, for eventual display to the user.
<static>  
core.trade.updatePlayers(userPids, otherPids, cb)
Validates that players are allowed to be traded and updates the database.
Namespace Detail
core.trade
Method Detail
<static> core.trade.clear(cb)
Remove all players currently added to the trade.
Parameters:
{function()} cb
Callback function.

<static> core.trade.create(tid, pid, cb)
Start a new trade with a team. One of tid or pid can be set. If both are set, then tid is ignored. If neither are set, a tid of 0 is used.
Parameters:
{?number} tid
An integer representing the team ID of the team the user wants to trade with, or null if pid is set.
{?number} pid
An integer representing the ID of a player to be automatically added to the trade, or null if no player should be added immediately. If not null, a trade will be initiated with that player's team, regardless of what tid is set to.
{function()} cb
Callback function.

<static> core.trade.getOtherTid(cb)
Gets the team ID for the team that the user is trading with.
Parameters:
{function(number)} cb
Callback function. The argument is the other team's tid.

<static> core.trade.getPlayers(cb)
Get the arrays containing the player IDs in the trade for both teams.
Parameters:
{function(Array.|Array.)} cb
Callback function. Arguments are arrays containing the player IDs for the user's team and the other team, respectively.

<static> core.trade.propose(cb)
Proposes the current trade in the database. Before proposing the trade, the trade is validated to ensure that all player IDs match up with team IDs.
Parameters:
{function(boolean|string)} cb
Callback function. The first argument is a boolean for whether the trade was accepted or not. The second argumetn is a string containing a message to be dispalyed to the user.

<static> core.trade.summary(otherTid, userPids, otherPids, cb)
Create a summary of the trade, for eventual display to the user.
Parameters:
{number} otherTid
Team ID for the team that the user is trading with.
{Array.} userPids
An array of player ID's representing the players on the user's team in the trade.
{Array.} otherPids
An array of player ID's representing the players on the other team in the trade.
{function(Object)} cb
Callback function. The argument is an object containing the trade summary.

<static> core.trade.updatePlayers(userPids, otherPids, cb)
Validates that players are allowed to be traded and updates the database. If any of the player IDs submitted do not correspond with the two teams that are trading, they will be ignored.
Parameters:
{Array.} userPids
An array of player ID's representing the players on the user's team in the trade.
{Array.} otherPids
An array of player ID's representing the players on the other team in the trade.
{function(Array.|Array.)} cb
Callback function. Arguments are the same as the inputs, but with invalid entries removed.

Documentation generated by JsDoc Toolkit 2.4.0 on Wed Apr 10 2013 23:08:32 GMT-0400 (EDT)