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, scoutingRank)
Add a new row of ratings to a player object.
<static>  
core.player.addStatsRow(p, playoffs)
Add a new row of stats to a player object.
<static>  
core.player.addToFreeAgents(ot, p, phase, baseMoods, 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.develop(p, years, generate, coachingRank)
Develop (increase/decrease) player's ratings.
<static>  
core.player.genContract(ratings, randomizeExp)
Generate a contract for a player.
<static>  
core.player.genFuzz(scoutingRank)
Generate fuzz.
<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.setContract(p, contract, signed)
Store a contract in a player object.
<static>  
core.player.skills(ratings)
Assign "skills" based on ratings.
Namespace Detail
core.player
Method Detail
<static> {Object} core.player.addRatingsRow(p, scoutingRank)
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.
{number} scoutingRank
Between 1 and 30, the rank of scouting spending, probably over the past 3 years via core.finances.getRankLastThree.
Returns:
{Object} Updated player object.

<static> {Object} core.player.addStatsRow(p, playoffs)
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.
Returns:
{Object} Updated player object.

<static> core.player.addToFreeAgents(ot, p, phase, baseMoods, 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 and mood.
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).
{Array.} baseMoods
Vector of base moods for each team from 0 to 1, as generated by genBaseMoods.
{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.develop(p, years, generate, coachingRank)
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).
{boolean=} generate
Generating a new player? (default false). If true, then the player's age is also updated based on years.
{number=} coachingRank
From 1 to 30, where 1 is best coaching staff and 30 is worst. Default is 15.5
Returns:
{Object} Updated player object.

<static> {Object.} core.player.genContract(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> {number} core.player.genFuzz(scoutingRank)
Generate fuzz. Fuzz is random noise that is added to a player's displayed ratings, depending on the scouting budget.
Parameters:
{number} scoutingRank
Between 1 and 30, the rank of scouting spending, probably over the past 3 years via core.finances.getRankLastThree.
Returns:
{number} Fuzz, between -5 and 5.

<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, releasedPlayers, and teams, readwrite.
{Object} p
Player object.
{function()} cb
Callback function.

<static> {Object} core.player.setContract(p, contract, signed)
Store a contract in a player object.
Parameters:
{Object} p
Player object.
{Object} contract
Contract object with two properties, exp (year) and amount (thousands of dollars).
{boolean} signed
Is this an official signed contract (true), or just part of a negotiation (false)?
Returns:
{Object} Updated player object.

<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 Wed Apr 10 2013 23:08:32 GMT-0400 (EDT)