Namespace core.draft
The annual draft of new prospects.
Defined in: <js/core/draft.js>.
Constructor Attributes | Constructor Name and Description |
---|---|
Method Attributes | Method Name and Description |
---|---|
<static> |
core.draft.genOrder(cb)
Sets draft order and save it to the draftOrder object store.
|
<static> |
core.draft.genPlayers(cb)
Generate a set of draft prospects.
|
<static> |
core.draft.getOrder(cb)
Retrieve the current remaining draft order.
|
<static> |
core.draft.selectPlayer(pick, pid, cb)
Select a player for the current drafting team.
|
<static> |
core.draft.setOrder(draftOrder, cb)
Save draft order for future picks to the database.
|
<static> |
core.draft.untilUserOrEnd(cb)
Simulate draft picks until it's the user's turn or the draft is over.
|
Method Detail
<static>
core.draft.genOrder(cb)
Sets draft order and save it to the draftOrder object store.
This is currently based on winning percentage (no lottery).
- Parameters:
- {function()=} cb
- Optional callback function.
<static>
core.draft.genPlayers(cb)
Generate a set of draft prospects.
This is called before the draft occurs, otherwise there will be no one to draft!
- Parameters:
- {function()} cb
- Callback function.
<static>
core.draft.getOrder(cb)
Retrieve the current remaining draft order.
- Parameters:
- {function(Array. cb
- Callback function whose argument is an ordered array of pick objects.
<static>
core.draft.selectPlayer(pick, pid, cb)
Select a player for the current drafting team.
This can be called in response to the user clicking the "draft" button for a player, or by some other function like untilUserOrEnd.
- Parameters:
- {object} pick
- Pick object, like from getOrder, that contains information like the team, round, etc.
- {number} pid
- Integer player ID for the player to be drafted.
-
{function(
)=} cb - Optional callback function. Argument is the player ID that was drafted (same as pid input.. probably this can be eliminated, then).
<static>
core.draft.setOrder(draftOrder, cb)
Save draft order for future picks to the database.
- Parameters:
- {Array. draftOrder
- Ordered array of pick objects, as generated by genOrder.
- {function()=} cb
- Optional callback function.
<static>
core.draft.untilUserOrEnd(cb)
Simulate draft picks until it's the user's turn or the draft is over.
This could be made faster by passing a transaction around, so all the writes for all the picks are done in one transaction. But when calling selectPlayer elsewhere (i.e. in testing or in response to the user's pick), it needs to be sure that the transaction is complete before continuing. So I would need to create a special case there to account for it. Given that this isn't really *that* slow now, that probably isn't worth the complexity. Although... team.rosterAutoSort does precisely this... so maybe it would be a good idea...
- Parameters:
- {function(Array. cb
- Callback function. First argument is the list of draft picks (from getOrder). Second argument is a list of player IDs who were drafted during this function call, in order.