Class Index | File Index

Classes


Namespace core.contractNegotiation

All aspects of contract negotiation.
Defined in: <js/core/contractNegotiation.js>.

Namespace Summary
Constructor Attributes Constructor Name and Description
 
Method Summary
Method Attributes Method Name and Description
<static>  
core.contractNegotiation.accept(pid, cb)
Accept the player's offer.
<static>  
core.contractNegotiation.cancel(pid)
Cancel contract negotiations with a player.
<static>  
core.contractNegotiation.cancelAll(cb)
Cancel all ongoing contract negotiations.
<static>  
core.contractNegotiation.create(ot, pid, resigning, cb)
Start a new contract negotiation with a player.
<static>  
core.contractNegotiation.offer(pid, teamAmount, teamYears, cb)
Make an offer to a player.
<static>  
core.contractNegotiation.validAmount(years)
Restrict the input to between g.minContract and g.maxContract, the valid amount of annual thousands of dollars for a contract.
<static>  
core.contractNegotiation.validYears(years)
Restrict the input to between 1 and 5, the valid number of years for a contract.
Namespace Detail
core.contractNegotiation
Method Detail
<static> core.contractNegotiation.accept(pid, cb)
Accept the player's offer. If successful, then the team's current roster will be displayed.
Parameters:
{number} pid
An integer that must correspond with the player ID of a player in an ongoing negotiation.
{function(string=)} cb
Callback to be run only after the contract is successfully accepted. If an error occurs, pass a string error message.

<static> core.contractNegotiation.cancel(pid)
Cancel contract negotiations with a player.
Parameters:
{number} pid
An integer that must correspond with the player ID of a player in an ongoing negotiation.

<static> core.contractNegotiation.cancelAll(cb)
Cancel all ongoing contract negotiations. Currently, the only time there should be multiple ongoing negotiations in the first place is when a user is resigning players at the end of the season, although that should probably change eventually.
Parameters:
{function()=} cb
Optional callback.

<static> core.contractNegotiation.create(ot, pid, resigning, cb)
Start a new contract negotiation with a player. If ot is null, then the callback will run only after the transaction finishes (i.e. only after the new negotiation is actually saved to the database). If ot is not null, then the callback might run earlier, so don't rely on the negotiation actually being in the database yet. So, ot should NOT be null if you're starting multiple negotiations as a component of some larger operation, but the presence of a particular negotiation in the database doesn't matter. ot should be null if you need to ensure that the roster order is updated before you do something that will read the roster order (like updating the UI). (WARNING: This means that there is actually a race condition for when this is called from season.newPhaseResignPlayers is the UI is updated before the user's teams negotiations are all saved to the database! In practice, this doesn't seem to be a problem now, but it could be eventually.)
Parameters:
{IDBTransaction|null} ot
An IndexedDB transaction on gameAttributes, messages, negotiations, and players, readwrite; if null is passed, then a new transaction will be used.
{number} pid
An integer that must correspond with the player ID of a free agent.
{boolean} resigning
Set to true if this is a negotiation for a contract extension, which will allow multiple simultaneous negotiations. Set to false otherwise.
{function(string=)} cb
Callback to be run only after a successful negotiation is started. If an error occurs, pass a string error message.

<static> core.contractNegotiation.offer(pid, teamAmount, teamYears, cb)
Make an offer to a player.
Parameters:
{number} pid
An integer that must correspond with the player ID of a player in an ongoing negotiation.
{number} teamAmount
Teams's offer amount in thousands of dollars per year (between 500 and 20000).
{number} teamYears
Team's offer length in years (between 1 and 5).
{function()=} cb
Optional callback.

<static> {number} core.contractNegotiation.validAmount(years)
Restrict the input to between g.minContract and g.maxContract, the valid amount of annual thousands of dollars for a contract.
Parameters:
{number} years
Annual salary, in thousands of dollars, to be validated.
Returns:
{number} An integer between g.minContract and g.maxContract, rounded to the nearest $10k.

<static> {number} core.contractNegotiation.validYears(years)
Restrict the input to between 1 and 5, the valid number of years for a contract.
Parameters:
{number} years
Number of years, to be validated.
Returns:
{number} An integer between 1 and 5.

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