puttCourse.scorecard: a strokes-vs-par scorecard for any number of players and
holes: a small data model (record strokes, totals, to-par, leader) and a renderer
with six looks (classicPaper, tropicalWood, neonArcade, pixelArcade, candyPop,
parchment) that fits a phone screen. Draws on this machine only: every machine
shows its own copy from the same numbers (keep them in a synced component or send
them with the course events).
normHoles(holes: any) → void
| arg | type | description |
|---|
| holes | any | |
new(holes: any, players: any?) → any
A new card. holes: list of pars or { par, name }; players: list of { id, name, colour }.
| arg | type | description |
|---|
| holes | any | |
| players | any? | |
addPlayer(self: any, p: any) → any
Add a player { id, name, colour }. Returns the row.
| arg | type | description |
|---|
| self | any | |
| p | any | |
record(self: any, playerId: any, index: number, strokes: number) → void
Record strokes for a player on hole `index` (1-based).
| arg | type | description |
|---|
| self | any | |
| playerId | any | |
| index | number | |
| strokes | number | |
total(self: any, playerId: any) → number
Total strokes so far.
| arg | type | description |
|---|
| self | any | |
| playerId | any | |
toPar(self: any, playerId: any) → number
Strokes against par over the holes played (negative = under par).
| arg | type | description |
|---|
| self | any | |
| playerId | any | |
leader(self: any) → any
The player with the fewest strokes against par (ties: first listed), or nil.
| arg | type | description |
|---|
| self | any | |
par(self: any) → number
Total par of the course.
| arg | type | description |
|---|
| self | any | |
lbl(text: string, size: number, colour: string, extra: any?) → any
| arg | type | description |
|---|
| text | string | |
| size | number | |
| colour | string | |
| extra | any? | |
cell(w: number, h: number, child: any, bg: string?, extra: any?) → any
| arg | type | description |
|---|
| w | number | |
| h | number | |
| child | any | |
| bg | string? | |
| extra | any? | |
fmtPar(d: number) → string
| arg | type | description |
|---|
| d | number | |
render(players: any, holes: any?, style: string?, opts: any?) → any
The scorecard as a widget tree (for embedding in your own screen). `players` is a card or a list of
{ name, colour, strokes = { ... } }; `holes` a list of pars (ignored when a card is given).
opts: width (px, default fits the viewport), title, current (hole index to highlight).
| arg | type | description |
|---|
| players | any | |
| holes | any? | |
| style | string? | |
| opts | any? | |
show(players: any, holes: any?, style: string?, opts: any?) → void
Show the scorecard centred on screen (this machine). Same arguments as render; opts.onClose is
called when the player taps it (it hides itself unless opts.keep).
| arg | type | description |
|---|
| players | any | |
| holes | any? | |
| style | string? | |
| opts | any? | |
hide( ) → void
Hide the scorecard.
isShown( ) → boolean
Whether the scorecard is up.
onCallback(id: string) → boolean
Taps on the card arrive at a component's `onCallback(id)`: forward them here
(`if Scorecard.onCallback(id) then return end`). Answers true when it was the card's.
| arg | type | description |
|---|
| id | string | |