Namespace core.game
Everything about games except the actual simulation. So, loading the schedule, loading the teams, saving the results, and handling multi-day simulations and what happens when there are no games left to play.
Defined in: <js/core/game.js>.
Constructor Attributes | Constructor Name and Description |
---|---|
Method Attributes | Method Name and Description |
---|---|
<static> |
core.game.loadTeams(transaction, cb)
Load all teams into an array of team objects.
|
<static> |
core.game.play(numDays, start)
Play one or more days of games.
|
Method Detail
<static>
core.game.loadTeams(transaction, cb)
Load all teams into an array of team objects.
The team objects contain all the information needed to simulate games. It would be more efficient if it only loaded team data for teams that are actually playing, particularly in the playoffs.
- Parameters:
- {IDBTransaction} transaction
- An IndexedDB transaction on players and teams.
- {function(Array)} cb
- Callback function that takes the array of team objects as its only argument.
<static>
core.game.play(numDays, start)
Play one or more days of games.
This also handles the case where there are no more games to be played by switching the phase to either the playoffs or before the draft, as appropriate.
- Parameters:
- {number} numDays
- An integer representing the number of days to be simulated. If numDays is larger than the number of days remaining, then all games will be simulated up until either the end of the regular season or the end of the playoffs, whichever happens first.
- {boolean} start
- Is this a new request from the user to play games (true) or a recursive callback to simulate another day (false)? If true, then there is a check to make sure simulating games is allowed.