# Standings
The grand prix standings screens, drawn on this machine. Put it on any entity of a scene with a `GrandPrix` (entity named `GrandPrix`, or the one `grandPrix` names). It reads `gp:phase()` and `gp:standingsView()` (`{ cup, table, lastRace, final, secondsLeft }`, the shape `GP.sample("standings")` / `GP.sample("final")` return) and shows:
- **After each race** (`phase == "standings"`): a header with the cup, "Race 2 of 3" and the track just raced; the race result (finish order, swatch, time or DNF, points earned); and the cup table: place, place change since the previous race (up/down arrows with the number of places), name with a YOU tag on the local player's highlighted row, kart swatch in its paint, vehicle and CPU/PLAYER, a cell per race (points when rows carry `racePoints`, otherwise the finish place; DNS/OUT for races not run), and the total. The entrance plays in order: rows slide in standing where they were before the race, "+N" chips pop beside each total, totals count up as the chips fly on, then rows slide to their new places and the arrows pop in. Racers knocked out in an elimination cup are dimmed, struck through and stamped ELIMINATED (OUT in later races). A footer counts "Next race in N" (`secondsLeft`) and names the next track.
- **At the end of the cup** (`phase == "podium"`): the top centre of the screen stays clear for the 3D podium; a compact final table (gold, silver and bronze plates for the top three, wins, totals counting up) sits bottom left and a big CHAMPION banner with the winner's name, points and wins sits bottom centre. On a portrait phone the banner sits mid screen with the table under it.
With no GrandPrix in the scene, `preview` shows the screen with `GP.sample` data so a look can be built and checked without the race flow.
On narrow screens (phones, either way round) the race result shows first and the cup table follows after about 3.6 seconds, with tabs showing which is up. Every size and type scales from the screen size.
Enter, Space, gamepad A or a tap on the Skip button jump the entrance to its settled state. If the GrandPrix has a `requestContinue()` method, the button reads Continue once the screen has settled and the same inputs call it; without one, no Continue button is shown.
## Fields
- `style`: the look, one of `broadcast` (TV sports graphics: dark slab panels, yellow accents, slanted tabs, rows wiping in), `podium` (ceremony: navy glass, gold hairlines, serif type, gold/silver/bronze plates, a shining gold champion ribbon), `pixel` (8-bit scoreboard: blocky white frames, step shadows, pixel lettering from `grandPrixKit.pixelType`, stepped motion, blinking 1UP and prompts), `cartoon` (cream speech bubbles, thick ink outlines, comic type, bouncy entrances, a wobbling champion bubble) or `minimal` (white card, clean sans serif, thin dividers, blue accent). The catalog is `grandPrixKit.standingsStyles`.
- `preview`: `""`, `"standings"` or `"final"`: sample data when there is no GrandPrix.
- `previewElimination`: preview data as an elimination cup (last place drops out each race).
- `grandPrix`: name of the GrandPrix entity (default `GrandPrix`).
- `scale`: size multiplier on top of the automatic fit.
- `layer`: UI layer of the screen (default 60).
## Methods
- `replay()`: play the entrance again from the start.
- `seek(seconds)`: jump the entrance to that time (9 or more is the settled screen); for captures.
# GrandPrix
Runs a kart racing cup on racingKit: kart select, a run of races, points and standings after each race, and the podium, then a new cup. Put it on a synced entity named `GrandPrix` next to racingKit's `Race` (RaceDirector) and MatchFlow's `Match` entities; `require("grandPrixKit.api").setup{...}` makes all three.
The machine in charge of the race runs the cup and writes the synced state (phase, race, entrants and their picks, the championship table); every machine applies the current race (track direction, mood), sets up the karts it owns (vehicle body, look, paint, class tuning), seats its own player and lets players without a kart watch.
Fields: `cupName`, `format`, `points`, `tracks`, `moods`, `moodDriver`, `laps`, `karts`, `aiNames`, `selectSeconds`, `standingsSeconds`, `podiumSeconds`, `selectStyle`, `standingsStyle`, `trophyLook`, `podiumLook`, `autoStart`, `joinOnRequest`. State: `phase`, `raceIndex`, `cupNumber`, `secondsLeft`, `races`, `entrants`, `table`, `lastRace`, `joined`.
Methods: `getPhase()`, `isAuthority()`, `me()`, `getEntrants()`, `cupInfo()`, `currentRace()`, `getTable()`, `getLastRace()`, `selectView()`, `standingsView()`, `setPick(pick)`, `setReady(bool)`, `join()`, `hasJoined()`, `requestContinue()`, `startNow()`.
# TitleScreen
A menusKit title screen shown on each player's own machine before the grand prix. Pressing Play calls `GrandPrix:join()`, which puts that player into the cup (the GrandPrix needs `joinOnRequest`; `GP.setup{ title = ... }` sets both up).
Fields: `title`, `subtitle`, `theme` (any menusKit look), `layout` (list, rail, carousel, radial) and `gallery`. When `gallery` names an entity, the title adds a "Style Gallery" choice that closes the menu and moves the player to that entity, for a showroom or garage. `show()` opens the title again on this machine, for example from that room's way out.
Without menusKit it joins straight away.
# grandPrixKit.karts
The vehicles a grand prix offers: five vehiclesKit bodies (Go-Kart, Dune Buggy, Roadster, Muscle, Monster) tuned onto one kart-racing scale (top speed, motor torque, mass, steering), with stat bars (speed, acceleration, handling, weight, 0 to 1) computed from the tuned numbers. Also the looks (toy, low poly, realistic) and twelve paints with their colours. `vehicles()`, `looks()`, `paints()`, `get(id)`, `indexOf(list, id)`, `add(vehicle)`, `applyTune(entity, id)`.
# KartSelect
The kart select screen of a grand prix, in six styles a world switches between with one field. Put it on any entity of a scene that has a `grandPrixKit.GrandPrix` (or on its own with `preview` on). It draws only on this machine.
It shows itself while the GrandPrix is in its `select` phase (`gp:getPhase()`), the local player has joined (`gp:hasJoined()`) and `gp:me()` answers an entrant; otherwise it draws nothing and the player's camera is the one on screen. It reads `gp:selectView()` (`{ cup, entrants, me, secondsLeft, catalog }`, the shape of `GP.sample("select")`) and answers input with `gp:setPick({ vehicle, look, paint })` and `gp:setReady(bool)`, showing the new pick at once until the GrandPrix echoes it. With no GrandPrix in that phase and `preview` on, it draws `GP.sample("select")` and keeps picks locally, with a looping 30 second countdown.
Every style shows the vehicle name and blurb, stat bars for speed, acceleration, handling and weight (barsKit looks where the style has one), the look choice, paint swatches, a Ready button, every racer with their pick and ready state, the cup name and format, and the countdown.
## Styles
The style is read from this component's `style` field every frame, so switching is live (a GrandPrix may copy its own `selectStyle` onto it):
- `garage`: the real vehiclesKit model on a slowly turning steel turntable in a workshop under warm fluorescent tubes; smoked panels, amber stencil type, hazard stripes.
- `grid`: a fighting game roster of portrait cards with a 1P cursor and rival tags, the kart posed in a violet studio, a slanted name plate.
- `carousel`: every kart on a glossy turning carousel, the selected one swung to the front; white rounded cards.
- `arcade`: a pixel arcade cabinet with chunky 8-bit frames and step shadows around a CRT monitor showing the kart over a neon grid, a blinking PRESS START and a TIME counter.
- `hangar`: a sci-fi hangar, the kart hovering over a landing pad ringed in cyan, holographic glass panels with corner brackets.
- `minimal`: a plain clean list on a light background, no 3D.
The catalog (id, name, description, tags, theme) is `grandPrixKit.selectStyles`.
## 3D stage and camera
The 3D styles build their set with `grandPrixKit.selectStage` on this peer only (local entities, temporary, never synced or saved) at `stageX/Y/Z`, default 0, 400, 0, far above the track. The set's camera has priority 900, so it takes the screen only while the select is up; when the select ends the set and its camera are destroyed and the player's camera is the one drawing again. The camera frames the kart in the gap the layout leaves (between the side panels on a desktop, above the bottom sheet on a phone).
## Input
While the screen is up it holds the `grandPrixKit.kartSelect` input map, which stands the walking and driving schemes down. The screen registers at UI layer 950, above race HUDs and minimaps, so taps and clicks reach it.
- Keyboard: arrows or WASD move between rows (vehicle, look, paint, ready) and change the value; Q/E cycle the vehicle; Enter or Space toggles Ready; Escape takes it back.
- Gamepad: d-pad or left stick move and change; LB/RB cycle the vehicle; A (south) toggles Ready; B (east) takes it back.
- Touch and mouse: every card, look, swatch and the Ready button is a large tap target; arrow buttons beside the model cycle the vehicle.
Picks are locked while ready. Phone-sized screens (narrower than 640 points, or portrait) switch to a stacked layout: header, the model, then a bottom sheet.
## Fields
- `style`: `garage`, `grid`, `carousel`, `arcade`, `hangar` or `minimal`.
- `preview`: show sample data when there is no GrandPrix in its select phase (also draws in edit mode).
- `grandPrix`: name of the entity carrying the GrandPrix (default `GrandPrix`).
- `stageX`, `stageY`, `stageZ`: where the local 3D stage is built.
- `scale`: UI size multiplier.
- `inputMap`: the menu controls (default `grandPrixKit.kartSelect`).
## Methods
Call on the component ref (`ks:isOpen()`):
- `isOpen()`: whether the screen is up on this peer.
- `focusedRow()`: 1 vehicle, 2 look, 3 paint, 4 ready.
- `currentPick()`: `{ vehicle, look, paint, ready }` the screen shows for the local player, or nil.
- `isPreview()`: whether it is drawing sample data.
# grandPrixKit.api
The front door. `setup(opts)` puts a whole grand prix in a scene's build (MatchFlow, racingKit's race and HUD, karts, item boxes, the GrandPrix, the screens). `find()` returns the running GrandPrix, `catalog()` the vehicle, look and paint menus, and `sample(kind)` made-up data in the shapes every screen draws from, for building and previewing screens with no race running.