Namespace core.team
Functions operating on team objects, or parts of team objects.
Defined in: <js/core/team.js>.
Constructor Attributes | Constructor Name and Description |
---|---|
Method Attributes | Method Name and Description |
---|---|
<static> |
core.team.addSeasonRow(t)
Add a new row of season attributes to a team object.
|
<static> |
core.team.addStatsRow(t, playoffs)
Add a new row of stats to a team object.
|
<static> |
core.team.generate(tm)
Create a new team object.
|
<static> |
core.team.rosterAutoSort(ot, tid, cb)
Sort a team's roster based on player ratings.
|
Method Detail
<static>
{Object}
core.team.addSeasonRow(t)
Add a new row of season attributes to a team object.
There should be one season attributes row for each year, and a new row should be added for each team at the start of a season.
- Parameters:
- {Object} t
- Team object.
- Returns:
- {Object} Updated team object.
<static>
{Object}
core.team.addStatsRow(t, playoffs)
Add a new row of stats to a team object.
A row contains stats for unique values of (season, playoffs). So new rows need to be added when a new season starts or when a team makes the playoffs.
- Parameters:
- {Object} t
- Team object.
- {=boolean} playoffs
- Is this stats row for the playoffs or not? Default false.
- Returns:
- {Object} Updated team object.
<static>
{Object}
core.team.generate(tm)
Create a new team object.
- Parameters:
- {Object} tm
- Team metadata object, likely from util.helpers.getTeams.
- Returns:
- {Object} Team object to insert in the database.
<static>
core.team.rosterAutoSort(ot, tid, cb)
Sort a team's roster based on player ratings.
If ot is null, then the callback will run only after the transaction finishes (i.e. only after the updated roster order is actually saved to the database). If ot is not null, then the callback might run earlier, so don't rely on the updated roster order actually being in the database yet.
So, ot should NOT be null if you're sorting multiple roster as a component of some larger operation, but the results of the sorts don't actually 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).
- 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.
- {number} tid
- Team ID.
- {function()=} cb
- Optional callback.