Namespace core.season
Somewhat of a hodgepodge. Basically, this is for anything related to a single season that doesn't deserve to be broken out into its own file. Currently, this includes things that happen when moving between phases of the season (i.e. regular season to playoffs) and scheduling. As I write this, I realize that it might make more sense to break up those two classes of functions into two separate modules, but oh well.
Defined in: <js/core/season.js>.
Constructor Attributes | Constructor Name and Description |
---|---|
Method Attributes | Method Name and Description |
---|---|
<static> |
core.season.awards(cb)
Compute the awards (MVP, etc) after a season finishes.
|
<static> |
core.season.getSchedule(ot, numDays, cb)
Get an array of games from the schedule.
|
<static> |
core.season.newPhase(phase, cb)
Set a new phase of the game.
|
<static> |
core.season.newPhaseCb(phase, phaseText, cb, reload)
Common tasks run after a new phrase is set.
|
<static> |
core.season.newSchedule(cb)
Creates a new regular season schedule.
|
<static> |
core.season.setSchedule(tids, cb)
Save the schedule to the database, overwriting what's currently there.
|
Method Detail
<static>
core.season.awards(cb)
Compute the awards (MVP, etc) after a season finishes.
The awards are saved to the "awards" object store.
- Parameters:
- {function()} cb
- Callback function run after the database operations finish.
<static>
core.season.getSchedule(ot, numDays, cb)
Get an array of games from the schedule.
- Parameters:
- {(IDBObjectStore|IDBTransaction|null)} ot
- An IndexedDB object store or transaction on schedule; if null is passed, then a new transaction will be used.
- {number} numDays
- Number of days of games requested. Currently, this will return all games if 0 is passed or one day of games if any number greater than 0 is passed.
- {function(Array)} cb
- Callback function that takes the requested schedule array as its only argument.
<static>
core.season.newPhase(phase, cb)
Set a new phase of the game.
This function is called to do all the crap that must be done during transitions between phases of the game, such as moving from the regular season to the playoffs. Phases are defined in the c.PHASE_* global variables. The phase update may happen asynchronously if the database must be accessed, so do not rely on g.phase being updated immediately after this function is called. Instead, pass a callback.
- Parameters:
- {number} phase
- Numeric phase ID. This should always be one of the c.PHASE_* variables defined in globals.js.
- {function()=} cb
- Optional callback run after the phase change is completed.
<static>
core.season.newPhaseCb(phase, phaseText, cb, reload)
Common tasks run after a new phrase is set.
This updates the phase, executes a callback, and (if necessary) reloads the UI. It should only be called from one of the NewPhase* functions defined below.
- Parameters:
- {number} phase
- Integer representing the new phase of the game (see other functions in this module).
- {string} phaseText
- Textual representation of the new phase, which will be displayed in the UI.
- {function()=} cb
- Optional callback run after the phase is set and the play menu is updated.
- {boolean=} reload
- Optional boolean (defaul false) which, if set to true, will reload the current page before (after? both?) calling the callback.
<static>
core.season.newSchedule(cb)
Creates a new regular season schedule.
This makes an NBA-like schedule in terms of conference matchups, division matchups, and home/away games.
- Parameters:
- {function(Array)} cb
- Callback to run after the schedule is generated. The argument is a list of all the season's games, where each entry in the list is a list of the home team ID and the away team ID.
<static>
core.season.setSchedule(tids, cb)
Save the schedule to the database, overwriting what's currently there.
- Parameters:
- {Array} tids
- A list of lists, each containing the team IDs of the home and away teams, respectively, for every game in the season, respectively.
- {function()} cb
- Callback function run after the database operations finish.