Class Index | File Index

Classes


Namespace core.player

Functions operating on player objects, or parts of player objects.
Defined in: <js/core/player.js>.

Namespace Summary
Constructor Attributes Constructor Name and Description
 
Method Summary
Method Attributes Method Name and Description
<static>  
core.player.addRatingsRow(p)
Add a new row of ratings to a player object.
<static>  
core.player.addStatsRow(p, playoffs, season)
Add a new row of stats to a player object.
<static>  
core.player.addToFreeAgents(ot, p, phase, cb)
Adds player to the free agents list.
<static>  
core.player.bonus(p, amount, randomizeExp)
Add or subtract amount from all current ratings and update the player's contract appropriately.
<static>  
core.player.contract(ratings, randomizeExp)
Generate a contract for a player.
<static>  
core.player.develop(p, years, generate)
Develop (increase/decrease) player's ratings.
<static>  
core.player.limitRating(rating)
Limit a rating to between 0 and 100.
<static>  
core.player.ovr(ratings)
Calculates the overall rating by averaging together all the other ratings.
<static>  
core.player.pos(ratings)
Assign a position (PG, SG, SF, PF, C, G, GF, FC) based on ratings.
<static>  
core.player.release(transaction, p, cb)
Release player.
<static>  
core.player.skills(ratings)
Assign "skills" based on ratings.
Namespace Detail
core.player
Method Detail
<static> {Object} core.player.addRatingsRow(p)
Add a new row of ratings to a player object. There should be one ratings row for each year a player is not retired, and a new row should be added for each non-retired player at the start of a season.
Parameters:
{Object} p
Player object.
Returns:
{Object} Updated player object.

<static> {Object} core.player.addStatsRow(p, playoffs, season)
Add a new row of stats to a player object. A row contains stats for unique values of (team, season, playoffs). So new rows need to be added when a player joins a new team, when a new season starts, or when a player's team makes the playoffs. The team ID in p.tid will be used in the stats row, so if a player is changing teams, update p.tid before calling this.
Parameters:
{Object} p
Player object.
{=boolean} playoffs
Is this stats row for the playoffs or not? Default false.
{=season} season
The season for the stats row. Defaults to g.season. This option should probably be eliminated eventually, as g.season should always be set.
Returns:
{Object} Updated player object.

<static> core.player.addToFreeAgents(ot, p, phase, cb)
Adds player to the free agents list. This should be THE ONLY way that players are added to the free agents list, because this will also calculate their demanded contract. But currently, the free agents generated at the beginning of the game don't use this function.
Parameters:
{(IDBObjectStore|IDBTransaction|null)} ot
An IndexedDB object store or transaction on players readwrite; if null is passed, then a new transaction will be used.
{Object} p
Player object.
{?number} phase
An integer representing the game phase to consider this transaction under (defaults to g.phase if null).
{function()} cb
Callback function.

<static> {Object} core.player.bonus(p, amount, randomizeExp)
Add or subtract amount from all current ratings and update the player's contract appropriately. This should only be called when generating players for a new league. Otherwise, develop should be used.
Parameters:
{Object} p
Player object.
{number} amount
Number to be added to each rating (can be negative).
{boolean} randomizeExp
Should the number of years on the player's contract be randomized?.
Returns:
{Object} Updated player object.

<static> {Object.} core.player.contract(ratings, randomizeExp)
Generate a contract for a player.
Parameters:
{Object.} ratings
Ratings object.
{boolean} randomizeExp
If true, then it is assumed that some random amount of years has elapsed since the contract was signed, thus decreasing the expiration date. This is used when generating players in a new league.
Returns:
{Object.} Object containing two properties with integer values, "amount" with the contract amount in thousands of dollars and "exp" with the contract expiration year.

<static> {Object} core.player.develop(p, years, generate)
Develop (increase/decrease) player's ratings. This operates on whatever the last row of p.ratings is.
Parameters:
{Object} p
Player object.
{number} years
Number of years to develop (default 1).
{generate} generate
Generating a new player? (default false). If true, then the player's age is also updated based on years.
Returns:
{Object} Updated player object.

<static> {number} core.player.limitRating(rating)
Limit a rating to between 0 and 100.
Parameters:
{number} rating
Input rating.
Returns:
{number} If rating is below 0, 0. If rating is above 100, 100. Otherwise, rating.

<static> {number} core.player.ovr(ratings)
Calculates the overall rating by averaging together all the other ratings.
Parameters:
{Object.} ratings
Player's ratings object.
Returns:
{number} Overall rating.

<static> {string} core.player.pos(ratings)
Assign a position (PG, SG, SF, PF, C, G, GF, FC) based on ratings.
Parameters:
{Object.} ratings
Ratings object.
Returns:
{string} Position.

<static> core.player.release(transaction, p, cb)
Release player. This keeps track of what the player's current team owes him, and then calls player.addToFreeAgents.
Parameters:
{IDBTransaction} transaction
An IndexedDB transaction on players and releasedPlayers, readwrite.
{Object} p
Player object.
{function()} cb
Callback function.

<static> {Array.} core.player.skills(ratings)
Assign "skills" based on ratings. "Skills" are discrete categories, like someone is a 3 point shooter or they aren't. These are displayed next to the player's name generally, and are also used in game simulation. The possible skills are: * Three Point Shooter (3) * Athlete (A) * Ball Handler (B) * Interior Defender (Di) * Perimeter Defender (Dp) * Post Scorer (Po) * Passer (Ps) * Rebounder (R)
Parameters:
{Object.} ratings
Ratings object.
Returns:
{Array.} Array of skill IDs.

Documentation generated by JsDoc Toolkit 2.4.0 on Fri Mar 01 2013 11:45:19 GMT-0500 (EST)