num(v: any, d: number) → number
| arg | type | description |
|---|
| v | any | |
| d | number | |
config(opts: any?) → any
A full config from partial options; unknown keys are kept, bad values fall back to defaults.
| arg | type | description |
|---|
| opts | any? | |
threshold(cfg: any, mult: number) → number
The combo count a multiplier starts at (x1 starts at 0).
| arg | type | description |
|---|
| cfg | any | |
| mult | number | |
multiplierFor(cfg: any, combo: number) → number
The multiplier a combo count earns: 1 + steps reached, capped at maxMultiplier.
| arg | type | description |
|---|
| cfg | any | |
| combo | number | |
topMultiplier(cfg: any) → number
The highest multiplier these rules can reach.
stepProgress(cfg: any, combo: number) → void
Progress from the current multiplier's step to the next: (frac 0..1, next combo count or nil at the top).
| arg | type | description |
|---|
| cfg | any | |
| combo | number | |
newPlayer(name: string?) → any
| arg | type | description |
|---|
| name | string? | |
award(cfg: any, amount: number, mult: number) → number
| arg | type | description |
|---|
| cfg | any | |
| amount | number | |
| mult | number | |
doBreak(cfg: any, p: any, now: number, reason: string, timeout: boolean) → any
| arg | type | description |
|---|
| cfg | any | |
| p | any | |
| now | number | |
| reason | string | |
| timeout | boolean | |
tick(cfg: any, p: any, now: number) → any
Time a combo out. Returns the break event, or nil when the combo is still alive.
With decay "step" a timeout drops one multiplier and gives a fresh window;
the combo can step down more than once if the player stays idle.
| arg | type | description |
|---|
| cfg | any | |
| p | any | |
| now | number | |
windowLeft(cfg: any, p: any, now: number) → number
Seconds left in the combo window (0 when there is no combo).
| arg | type | description |
|---|
| cfg | any | |
| p | any | |
| now | number | |
note(p: any, reason: string?, amount: number, awarded: number) → void
| arg | type | description |
|---|
| p | any | |
| reason | string? | |
| amount | number | |
| awarded | number | |
add(cfg: any, p: any, amount: number, now: number, opts: any?) → any
Add points. opts: combo (false: not a hit, does not grow or refresh the combo),
multiply (false: never multiplied; true with combo = false: multiplied by the
current multiplier), reason (a word for the breakdown, e.g. "coin").
Returns { kind, amount, awarded, multiplier, combo, stepUp, broke, total, big }.
| arg | type | description |
|---|
| cfg | any | |
| p | any | |
| amount | number | |
| now | number | |
| opts | any? | |
bonus(cfg: any, p: any, label: string, value: number) → any
A named bonus: never multiplied, never touches the combo, listed on its own in the breakdown.
| arg | type | description |
|---|
| cfg | any | |
| p | any | |
| label | string | |
| value | number | |
breakCombo(cfg: any, p: any, now: number, reason: string?) → any
Break the combo now (the game says so: a hit taken, a fall). Returns the break or nil.
| arg | type | description |
|---|
| cfg | any | |
| p | any | |
| now | number | |
| reason | string? | |
rate(value: number, targets: any?) → any
Rate a value against a level's targets.
targets.score = { one, two, three } points for 1, 2 and 3 stars (higher is better)
targets.time = { one, two, three } seconds for 1, 2 and 3 stars (lower is better)
targets.grades = { S = .., A = .., B = .., C = .. } optional explicit grade lines
Without explicit grades: S = 20% past three stars, A = three, B = two, C = one, D = below.
Returns { kind, value, stars, grade, frac, next, targets, gradeNext }.
| arg | type | description |
|---|
| value | number | |
| targets | any? | |
rank(rows: { any }, kind: string?, field: string?) → void
Rank rows by `field` (score: higher first; time: lower first). Equal values
share a place (1, 1, 3). Ties keep the order they came in. Returns a new array.
| arg | type | description |
|---|
| rows | { any } | |
| kind | string? | |
| field | string? | |
checkRemote(cfg: any, bucket: any, amount: number, now: number) → void
A token bucket per sending player. Returns ok, reason.
| arg | type | description |
|---|
| cfg | any | |
| bucket | any | |
| amount | number | |
| now | number | |