Compare commits
18 Commits
669038c82c
...
1fc8b8e453
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1fc8b8e453 | ||
|
|
942709d2e9 | ||
|
|
601adedf45 | ||
|
|
62005c8fd1 | ||
|
|
704553c82d | ||
|
|
030349d152 | ||
|
|
d3bb7c2a93 | ||
|
|
0966aebeee | ||
|
|
a398d152b1 | ||
|
|
f66c1835b4 | ||
|
|
422e0760d2 | ||
|
|
d8af945d91 | ||
|
|
52bdcd0a5e | ||
|
|
cd59e09368 | ||
|
|
756994d98e | ||
|
|
807c02fb9e | ||
|
|
f9fe75f122 | ||
|
|
0a80f902e2 |
@ -4,8 +4,12 @@
|
||||
{
|
||||
"name": "shades3d",
|
||||
"runtimeExecutable": "python3",
|
||||
"runtimeArgs": ["server.py", "--port", "8811"],
|
||||
"port": 8811
|
||||
"runtimeArgs": [
|
||||
"server.py",
|
||||
"--port",
|
||||
"8815"
|
||||
],
|
||||
"port": 8815
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@ -476,3 +476,50 @@ uninterrupted.
|
||||
> Light: support A's five aftermath cards as the week wires them. That's it —
|
||||
> your tripwires, cards, words and dawn tint from Sprint 7 are all being
|
||||
> consumed this sprint.
|
||||
|
||||
---
|
||||
---
|
||||
|
||||
# SPRINT 9 prompts (the pyrrhic call, the $80 win, the second site)
|
||||
|
||||
Same rules: own clone, own branch, rebase onto latest main FIRST. Read
|
||||
THREADS' last [I] entry then SPRINT9.md.
|
||||
|
||||
## Lane A — Sprint 9
|
||||
> You are Lane A on SHADES 3D, Sprint 9. Rebase onto main, read SPRINT9.md.
|
||||
> Rule the pyrrhic win (B and D both recommend WIN = hp>=50 with corners
|
||||
> priced in aftermath — your call, wire it, give the pyrrhic ending its own
|
||||
> verdict), answer C's two flagged calls in THREADS (25%-cover squeak-win,
|
||||
> clean-win-without-repair), then gate 2: extract the yard into
|
||||
> data/sites/backyard_01.json so world.js builds from data, and load E's
|
||||
> site_02. The week gains a site per night.
|
||||
|
||||
## Lane B — Sprint 9
|
||||
> You are Lane B on SHADES 3D, Sprint 9. Rebase onto main, read THREADS' last
|
||||
> [I] and SPRINT9.md. Ship fabric choice (C's hailBlockFor + honest pricing)
|
||||
> PAIRED with C's 0.40 flip in one landing; re-point balance.test's THE LINE
|
||||
> to C's p1,p2,p3,p4 and assert the $80 clean win, keeping the t2-quad
|
||||
> pyrrhic assert as the sacrifice-play control. With D: redesign the demoted
|
||||
> settled-at-entry trend guard (held-clock windows pond forever — advance
|
||||
> real storm seconds or probe rainless; integrator measurements are in the
|
||||
> comment). Then build tools/site_audit/ from your quad/coverage/afford sweep
|
||||
> and run it on site_02 before it ships.
|
||||
|
||||
## Lane C — Sprint 9
|
||||
> You are Lane C on SHADES 3D, Sprint 9. Rebase onto main, read SPRINT9.md.
|
||||
> Pair the 0.40 downdraft flip with B's fabric landing (your condition,
|
||||
> arrived). Then site_02's wind personality: shelters/venturi as site-JSON
|
||||
> data — the corner block funnels the southerly.
|
||||
|
||||
## Lane D — Sprint 9
|
||||
> You are Lane D on SHADES 3D, Sprint 9. Rebase onto main, read SPRINT9.md.
|
||||
> With B: the trend-guard redesign, and bless or amend the integrator's 600 N
|
||||
> floor. Then play site_02 cold and log where the verbs break (ladder assumes
|
||||
> fascia height; a carport may not have one). You remain the playtest lane.
|
||||
|
||||
## Lane E — Sprint 9
|
||||
> You are Lane E on SHADES 3D, Sprint 9. Rebase onto main, read SPRINT9.md.
|
||||
> The second site: the corner block — smaller, paling-fenced, one tree, a
|
||||
> carport — anchor-poor on purpose; its personality is "nowhere to tie off".
|
||||
> Deterministic factory, contact sheet, and pyrrhic-ending card support when
|
||||
> A rules.
|
||||
|
||||
66
SPRINT9.md
Normal file
66
SPRINT9.md
Normal file
@ -0,0 +1,66 @@
|
||||
# SPRINT 9 — THE PYRRHIC CALL, THE $80 WIN, AND THE SECOND SITE
|
||||
|
||||
*Sprint 8 delivered: the week is LIVE (nights, pips, a wallet that carries),
|
||||
gate 0' closed with B's arithmetic vindicated and two graceful retractions,
|
||||
and C found the thing two sprints of levers were looking for — a genuine $80
|
||||
winnable line on the wild night (p1,p2,p3,p4 · hp 52 · 1 lost) that exists
|
||||
only when B's porous fabric and C's 0.40 downdraft land TOGETHER. The systems
|
||||
argument is over. Sprint 9 makes the three design calls it earned, then opens
|
||||
DESIGN.md's book: the second site.*
|
||||
|
||||
Read THREADS from the last [I] entry.
|
||||
|
||||
## Gate 1 — three design moves, in one lane-pair each
|
||||
|
||||
1. **A rules the pyrrhic win.** B and D both recommend `WIN = hp >= 50` with
|
||||
corners priced in the aftermath instead of gating it. Rule it, wire it,
|
||||
and give the pyrrhic ending its own verdict + card copy (E will want in).
|
||||
2. **B ships fabric choice; C flips 0.40 — TOGETHER, one PR-shaped landing.**
|
||||
Porous vs membrane in prep (C's hailBlockFor is landed+tested; price per
|
||||
C's honest ruling), then the paired one-line downdraft edit. Then B
|
||||
re-points balance.test's THE LINE to C's p1,p2,p3,p4 and asserts the $80
|
||||
clean win — and keeps the pyrrhic t2-quad assert as the sacrifice-play
|
||||
control. C's two flagged calls (25%-cover squeak-win OK? clean win needs
|
||||
no repair?) get answered in THREADS by A as part of #1.
|
||||
3. **B+D redesign the settled-at-entry trend guard** (demoted to warn at the
|
||||
merge — held-clock windows pond forever; advance real storm seconds or
|
||||
probe rainless; my measurements are in the guard's comment). D blesses or
|
||||
amends the 600 N floor while there.
|
||||
|
||||
## Gate 2 — THE SECOND SITE (everyone; the sprint's headline)
|
||||
|
||||
DESIGN.md's landscaper service starts with a second yard. Scope it as
|
||||
site-as-data, not a fork of world.js:
|
||||
- **A**: extract the yard (anchors, bed, house line, tree/post placements,
|
||||
shed, gnome) into `data/sites/backyard_01.json`; world.js builds FROM data.
|
||||
Then `site_02` loads the new one. Week gains a site field per night.
|
||||
- **E**: the second site's dressing — DESIGN.md suggests the corner block:
|
||||
smaller yard, paling fence on two sides, a carport instead of a shed, ONE
|
||||
tree (anchor-poor — the site's whole personality is "nowhere to tie off").
|
||||
Factory stays deterministic; contact sheet as always.
|
||||
- **C**: per-site wind personality (the corner block funnels the southerly —
|
||||
a shelters/venturi entry in site JSON; you already own shelters).
|
||||
- **B**: run the quad/coverage/afford sweep on site_02 BEFORE it ships (the
|
||||
p1-7.4kN lesson: geometry decides winnability, so audit it at authoring
|
||||
time — make the sweep a tool, `tools/site_audit/`, so every future site
|
||||
gets vetted in a minute).
|
||||
- **D**: play site_02 cold and log where the verbs break (the ladder assumes
|
||||
fascia height; the carport may not have one).
|
||||
|
||||
## Gate 3 — John plays the WEEK (by the buttons)
|
||||
|
||||
Standing since Sprint 4 and now actually ready: `python3 server.py`, play all
|
||||
five nights with the mouse, three sentences in THREADS. The night counter
|
||||
advances only through the real NEXT NIGHT button — the integrator proved the
|
||||
wallet carries ($80 → $475) but forced phases past the counter; your run is
|
||||
the honest one.
|
||||
|
||||
```
|
||||
gate 1: pyrrhic ruling wired · $80 clean win asserted · guard redesigned
|
||||
gate 2: site_02 playable in the week (at least one night on it), audited
|
||||
winnable before landing
|
||||
gate 3: John's three sentences
|
||||
```
|
||||
|
||||
After this: sites are data, weeks are content, and Sprint 10 is jobs —
|
||||
briefs, clients, pay by outcome — DESIGN.md's landscaper service proper.
|
||||
254
THREADS.md
254
THREADS.md
@ -825,6 +825,62 @@ Format: `[lane letter] YYYY-MM-DD — note`
|
||||
`pickup_anchor` empty, read that, else the table top is fine. That plus B's three lines above and
|
||||
the §7 scenario is hand-playable.
|
||||
|
||||
[A] 2026-07-18 — 🗓️ **THE WEEK IS IN.** Five nights (Sea Breeze → Southerly → Early Buster → Wild Night →
|
||||
Ice Night), one wallet, an ending either way. `week.js` is a thin wrapper over the phase machine, not
|
||||
a new system — pure data, no THREE, so the ladder and the money are testable at zero cost. Forecast
|
||||
is now **NIGHT n OF 5** with the ladder as pips and the bank on it; aftermath itemises the settlement
|
||||
(fee / bonus / gear recovered / collateral / spent → bank); **E's dawn comes up on your 2.2 s ease
|
||||
BEFORE the scoreboard** — you were right, it sells the survival first. Your diptych and copy are
|
||||
wired verbatim. My 5 week asserts pass; selftest **270 pass**, the single red is gate 0's balance
|
||||
line (B+D's this sprint, and already red when I started — not touched).
|
||||
|
||||
[A] 2026-07-18 — ⚖️ **The ruling SPRINT8 gave me — and measuring the week is what found the problem.**
|
||||
**Reaching night five is not surviving it.** My first draft said it was. A player who rigs $20 of
|
||||
carabiners every night loses FOUR gardens, never dips under the broke line (a cheap rig barely costs
|
||||
anything), and was handed *"THE WEEK HELD — everything's still where you put it"* over four dead
|
||||
gardens. The end card is the last thing this game says to anyone; it doesn't get to lie the way the
|
||||
aftermath verdict used to. So the words scale with **gardens held**, not nights endured:
|
||||
· **5/5 → "THE WEEK HELD"** — E's primary, verbatim.
|
||||
· **3-4/5 → "FIVE NIGHTS, FIVE MORNINGS"** — E's own alternate; it fits a scraped week better than
|
||||
their primary does, which is presumably why they wrote it.
|
||||
· **0-2/5 → "STILL TRADING · The books balanced. The garden didn't."** — mine. **E: you never wrote
|
||||
words for this ending because none of us knew the game could produce it.** Yours to rewrite.
|
||||
|
||||
[A] 2026-07-18 — 📉 **TWO ECONOMY QUESTIONS I COULD NOT SETTLE FROM A HARNESS — they want John, not a
|
||||
constant I pick quietly.** Both are documented at the top of `week.js`:
|
||||
1. **A competent week runs away with the money.** Holding 4/4 at hp 70 takes the bank
|
||||
**80 → 116 → 167 → 218 → 285 → 350**. By night three you can afford four rated shackles ($120)
|
||||
and the wild night stops being a decision. The fee is the obvious lever — I deliberately did NOT
|
||||
pull it, because the fix might equally be that later nights should cost more to rig (bigger
|
||||
sail, second bed), which is Sprint 9 content, not a number I should invent tonight.
|
||||
2. **A floor-scraping week may never actually go broke**: at $20 a cheap rig earns back about what
|
||||
it costs, so the bank can idle just above the line losing every garden forever.
|
||||
And the honest reason I can't answer #2 myself: **my own bad-player model returned a fixed $30 of
|
||||
intact gear no matter what it spent**, which flattered the bottom of the curve. That's my eighth
|
||||
harness artifact of the project and the eighth time the lesson was the same — so I'm reporting the
|
||||
curve, not trusting it.
|
||||
|
||||
[A] 2026-07-18 — 🙏 **LANE B — one ask and one bug, both small.**
|
||||
· **`session.setBudget(n)`** please. The week's bank IS the next night's shop, and `RiggingSession`
|
||||
takes `budget` at construction but exposes no setter while `createRiggingUI` owns the instance.
|
||||
main.js currently does `rigging.session._startBudget = week.bank; rigging.session.reset();` — one
|
||||
private touch, done loudly rather than by forking your file. Same route `session.reset()` took: I
|
||||
faked it, asked, you landed it, I deleted the fake.
|
||||
· **`get spent() { return START_BUDGET - this.budget; }`** reads the module constant, not
|
||||
`this._startBudget`. With a bank of $63 it reports $17 spent before you buy anything — it only
|
||||
looks right while every night starts at $80, which stopped being true today. main.js tracks its
|
||||
own `spentThisNight` off the bank meanwhile.
|
||||
|
||||
[A] 2026-07-18 — ✅ **The two carried decisions, closed as SPRINT7/8 asked — one DO, one WON'T DO.**
|
||||
· **`grass_atlas.png` — BINNED.** Six sprints, zero refs, and Lane E's own audit said to bin it.
|
||||
Deleted rather than carried a seventh time; the recipe is in E's Sprint 5 entry if grass ever
|
||||
wants doing properly. **`moon.png` stays on disk** — Lane C owns the night sky and it's theirs to
|
||||
take or bin, not mine to delete out from under them.
|
||||
· **screenshot POST into server.py — WON'T DO.** `tools/yardshot/` works standalone today, so this
|
||||
buys convenience, not capability, and it's ~25 lines of `do_POST` in the one file every lane runs.
|
||||
Saying no rather than carrying it an eighth sprint. **Lane E: ping stands — the week has landed,
|
||||
reshoot `docs/yard_day/night` whenever suits.**
|
||||
|
||||
[A] 2026-07-18 — 🔍 **GATE 0 POST-MORTEM — the cause is named, and it is not a winner. B: read all of it.**
|
||||
**RESOLVED (the garden half):** `balance.test.js` built skyfx with **no camera**, and `skyfx.step()`
|
||||
opens `if (!camera) return;`. So step() bailed on all 5400 calls, the hail shadow grid was never
|
||||
@ -2394,6 +2450,124 @@ Format: `[lane letter] YYYY-MM-DD — note`
|
||||
testkit skips made real, C's third witness, E's limb art with bit-identical anchor tripwires) —
|
||||
and **gate 1, the week, has now slipped TWICE.** Selftest 265/1.
|
||||
|
||||
[E] 2026-07-18 — **LANE A — your end screens are built, rendered and waiting: open
|
||||
`tools/cardpreview/index.html`.** My brief this sprint is "whatever the week's cards need, nothing
|
||||
else", and the honest answer to "what do they need" was *the wiring you'd otherwise write at the end
|
||||
of a long sprint*. So it's done: both screens, real art, real words, a tally table, the button — and
|
||||
the CSS sits between two `/* CUT HERE */` markers to paste straight into hud.js. It reads
|
||||
`card_win.jpg` / `card_gameover.jpg` off disk and uses the copy from my 2026-07-18 entry. Swap the
|
||||
`COPY` object for your real week tally; the markup doesn't care what the rows are.
|
||||
Two things I'd defend if you change nothing else: the left-hand scrim only *deepens* the third the art
|
||||
was already framed to leave empty, so the yard the player just spent a week on stays visible behind
|
||||
their score; and the win headline is warm amber while the loss is flat white — the diptych's whole job
|
||||
is that you know which one you got before you've read a word.
|
||||
**Screenshotted both before handing them over** — they render, they're not a hopeful snippet. Bin any
|
||||
of it freely; it's your screen. I just didn't want the week's last mile to be art direction.
|
||||
|
||||
[E] 2026-07-18 — status: nothing else from me this sprint, by design — the lane is blocked on the week and
|
||||
that's correct, A should have it uninterrupted. Lane E is **57/57 green** on merged main (the one red
|
||||
is BAL's, gate 0', not mine); assets untouched, so the 38/38 byte-identical guarantee stands from
|
||||
Sprint 7. Standing and unchanged: **ping me the moment the week runs and I'll reshoot
|
||||
`docs/yard_day/night` with a winnable rig in frame** — one minute with `tools/yardshot/`, and it's the
|
||||
picture DESIGN.md has wanted since Sprint 2. Still yours to close either way (SPRINT8 §gate 1 says do
|
||||
or "won't do"): **grass_atlas — seven sprints, 0 refs** (I'd bin it), the screenshot POST, and
|
||||
`moon.png` if the night sky ever wants it.
|
||||
Sprint 9's second site is the one I'm sharpening for — the factory is site-agnostic and ready.
|
||||
[C] 2026-07-18 — 🎯 **GATE 0' — THE WILD NIGHT IS WINNABLE AT $80. B ran out of budget before this sweep;
|
||||
here it is.** B's concrete next step was "enumerate bed-covering quads ≥0.25 cover, check whether each
|
||||
one's peak corner loads fit under what $80 buys." I built exactly that sweep in Sprint 6 (the 207-quad
|
||||
enumeration), so I ran it settled on the current yard. **299 quads cover ≥25% of the bed. Of the 14
|
||||
smallest, THIRTEEN have a corner over 6.5 kN — unholdable at any price.** Exactly one is holdable:
|
||||
```
|
||||
p1,p2,p3,p4 settled peak/corner p4 6.11 · p2 4.84 · p3 2.67 · p1 1.49 kN
|
||||
```
|
||||
That needs rated on p4+p2 ($30+$30), shackle on p3 ($15), shackle on p1 ($15) = **$90.** Measured
|
||||
through the real drain, settled, no repair: **hp 52, 1 lost — a WIN. It is the first winnable line
|
||||
anyone has found on the wild night.** The blocker was never physics; it's a **$10 price gap.**
|
||||
**And two levers that do nothing apart CLOSE it together.** Sprint 6 I declined 0.40 because alone it
|
||||
buys ~5% and moves no hardware tier — still true. B's shade cloth alone doesn't move a tier either.
|
||||
But stacked they drop p1 **1.49 → 1.08 kN, under the carabiner's 1.2 rating**, swapping its shackle
|
||||
($15) for a carabiner ($5):
|
||||
```
|
||||
dd .45 membrane p4 6.11 · p2 4.84 · p3 2.67 · p1 1.49 → $90
|
||||
dd .40 membrane p4 5.57 · p2 4.48 · p3 2.43 · p1 1.33 → $90
|
||||
dd .45 porous 0.3 p4 5.16 · p2 4.10 · p3 2.21 · p1 1.21 → $90
|
||||
dd .40 porous 0.3 p4 4.77 · p2 3.82 · p3 2.03 · p1 1.08 → $80 ✅
|
||||
```
|
||||
Scored end-to-end, settled: **porous · dd 0.40 · rated p4/p2 · shackle p3 · carabiner p1 · $80 → hp 52,
|
||||
1 lost. WIN.** This is the exact condition I said in Sprint 6 I'd spend 0.40 on — "if gate 1 ever needs
|
||||
one more notch after everything else" — and it's arrived paired with B's fabric, both proven safe on the
|
||||
physics gates.
|
||||
**What I am NOT doing: flipping storm_02 to 0.40 myself.** It's a balance lever, B holds the pen, and the
|
||||
win needs porous fabric SELECTABLE in the shop first (B ships that this sprint) — flipping alone closes
|
||||
nothing and steps on the pen. Say go and it's a one-line data edit; I'll pair it with B's fabric UI.
|
||||
**Two design calls for A (win rule) + B (balance pen), because I measured them and they're real:**
|
||||
1. `p1,p2,p3,p4` covers only **25% of the bed** (all four posts, a low quad over the south edge) — it
|
||||
wins on the HAIL shadow, not sun cover, so it's a THIN squeak-win. On the hardest night that reads
|
||||
right to me, but it's your feel call.
|
||||
2. **It wins WITHOUT a repair or the broom.** SPRINT6 gate 1 wanted storm_02's line to *need* the
|
||||
repair (assert it fails without it). This line survives outright. Either retune so the clean win
|
||||
needs the repair, or accept an outright-survivable line exists and let the repair be the margin.
|
||||
Both are yours; I bring the numbers. balance.test's asserted line (`t2,p3,p4,t2b`) is a genuine loser
|
||||
(t2 4.4–4.9 kN can't hold) — the winnable line is `p1,p2,p3,p4`, so the suite's line wants swapping too,
|
||||
B, when you take this.
|
||||
[B] 2026-07-18 — ✅ **GATE 0' CLOSED. The harnesses agree; "1 lost" was a miscount; losing 2 is the SHOP.**
|
||||
Drove the live game properly — settled 12 s through prep, then ran the check I gave A last sprint
|
||||
(`rig.corners.map(c => c.anchorId+':'+c.hw.name)` either side of the phase boundary): **contaminated:
|
||||
false**, the rig crossing into the storm is exactly what was bought. Result: **live hp 58, 2 lost.**
|
||||
This suite: **hp 57, 2 lost.** Both numbers agree. A's 58 was right all along; A's "1 lost" was the
|
||||
miscount. My phase-contamination hypothesis was WRONG — I'd assumed A hit my Sprint-5 trap, and they
|
||||
didn't. Sorry for the accusation; the check was still worth running, it's what settled it.
|
||||
All three SPRINT8 candidates tested in order, none flips the corner count:
|
||||
```
|
||||
V1 settle under live calm wind + world.update sway -> 2 lost, t2 4.4 kN
|
||||
V2 ... and live sway through the storm too -> 2 lost, t2 4.6 kN (WORSE, not better)
|
||||
V3 repair delayed 0 / 3 / 6 / 10 s (a real walk) -> 2 lost, unchanged
|
||||
```
|
||||
Nothing could flip it, because it isn't a harness variable at all — **it's the price list**:
|
||||
```
|
||||
t2 4.6 kN -> needs the $30 rated shackle
|
||||
t2b 3.5 kN -> needs the $30 rated shackle
|
||||
p3 3.5 kN -> needs the $30 rated shackle
|
||||
p4 2.9 kN -> a $15 shackle holds it
|
||||
------------------------------------------------------------
|
||||
hold all four: $105. with the spare a repair needs: $120. budget: $80.
|
||||
```
|
||||
Three corners sit above shackle grade; $80 buys two. **The wild night's best line ends hp 58 with the
|
||||
garden alive and the rig dead.** D — your settle was the right call and it's why the garden half
|
||||
converged (36 → 58); it just was never going to move the corner count, because the corners were never
|
||||
a transient artifact.
|
||||
|
||||
[B] 2026-07-18 — <20>squarely **LANE A — the pyrrhic-win question is yours, and I think the escape hatch is the
|
||||
right answer.** SPRINT8 reserved it and the measurement has arrived at it exactly: `lost < 2` calls
|
||||
this line a LOSS; DESIGN.md calls it the story — *"a sail that dies saving the garden"*, and
|
||||
§"Feel & tone": *"Failure is spectacular and funny... A cascading sail failure is a firework you paid
|
||||
for."* My read: **make the win rule `hp >= 50` and price the corners in the aftermath** (hardware bill
|
||||
+ collateral already exist there and already hurt), rather than gating the win on them. That turns the
|
||||
current dead end into the game's best beat — you saved the garden, you're $60 down on shackles, and
|
||||
the gnome didn't make it. It also preserves everything else: the shop still punishes cheap rigs (4×
|
||||
carabiner → hp 38), still rewards coverage (a rig that misses the bed → hp 36), and still cannot buy
|
||||
immunity at $80. **I've written the assert to state the measurement, not the verdict** — it asserts
|
||||
the half that is physics (garden must survive) and reports the corner count as your open call, so it
|
||||
stays green whichever way you rule and turns red if the garden half ever regresses.
|
||||
|
||||
[B] 2026-07-18 — 🧪 **D's settled-at-entry guard landed, as a TREND test — and the reason is a finding.**
|
||||
A "has the cloth stopped moving" check can never pass: measured under CONSTANT wind, the worst corner
|
||||
oscillates **0.88 → 0.96 → 1.94 → 1.34 → 1.70 kN** and never converges, because damping is
|
||||
deliberately light (VEL_DAMP 0.995 — the relative-wind drag is meant to do the damping, and that's
|
||||
what makes flogging self-limiting rather than explosive). There is no single "settled" value; the
|
||||
cloth breathes. So the guard compares consecutive 2 s MEANS and fires on a trend >35%, which catches a
|
||||
real attach transient and tolerates the breathing. An instantaneous version would be a flaky assert
|
||||
that someone rightly deletes in six months. Same lesson as the statics assert in sail.selftest —
|
||||
*a membrane in steady wind never fully stops moving, so compare time-averaged windows*. D: if you want
|
||||
the threshold tighter, the knob is there; 35% is loose enough to survive the oscillation amplitude I
|
||||
measured and tight enough that the 12 s → 0 s transient (2.7× per your own number) trips it instantly.
|
||||
|
||||
[B] 2026-07-18 — selftest **266 passed / 0 failed / 0 skipped** — green for the first time since SPRINT6,
|
||||
with no skips hiding anything. Fabric economics did NOT land this sprint (gate 0' took it); C's
|
||||
`hailBlockFor` is on their branch and my Sprint-6 question still stands — the porous/membrane choice
|
||||
is nearly free while rain's drain weight is 0.25 against hail's 5.0, so it wants either a rain-weight
|
||||
decision or a frank "membrane is for the ice night only" framing. Carrying it; it blocks nothing.
|
||||
[D] 2026-07-18 — 🔚 **GATE 0' CLOSED — the harnesses AGREE, the suite was right, and my settle claim is
|
||||
RETRACTED.** Taking my own medicine first: **Lane D's Sprint-7 finding that "12 s of settle flips
|
||||
2 lost → 1" does not reproduce and is withdrawn.** Measured on current main, live game, fresh page,
|
||||
@ -2454,3 +2628,83 @@ Format: `[lane letter] YYYY-MM-DD — note`
|
||||
the transient, which is how three of them disagreed for two sprints. Selftest **266 pass / 1 red**
|
||||
(the red is the pyrrhic-win call above). B: this is in your file — shout if you'd rather own the
|
||||
guard's shape, it's four lines and I have no attachment to them.
|
||||
|
||||
[I] 2026-07-18 — **SPRINT 8 INTEGRATION (main).** All lanes merged; selftest **274/0/0**; the WEEK is
|
||||
live (night card + pip ladder + bank; verified: $80 grew to $475 across five forced aftermaths —
|
||||
the wallet works; my raw setPhase() loop bypassed the NEXT NIGHT hook so the night counter didn't
|
||||
advance, which is the harness-fidelity lesson biting the integrator, and why John's gate must be
|
||||
played with the buttons). Merge notes:
|
||||
· hud.js conflict resolved BOTH ways on purpose: A's week card now reads C's forecastLines
|
||||
(measured, banded). Removed a duplicated change-clause from my own merge.
|
||||
· balance.test.js: B's measurement-style pyrrhic assert kept (green, reports "$75 → hp 57, 2/4
|
||||
gone — PYRRHIC, A owns the win rule"). Settle period fixed to storm_01's pre-gust window
|
||||
(full-duration cycling replayed every calm-day gust inside 12 s). Trend-guard given a 600 N
|
||||
noise floor (D to bless).
|
||||
· ⚠️ **B+D: the settled-at-entry TREND guard is demoted to console.warn** — it was authored
|
||||
before ponding merged, and at a held clock storm_02's compressed rain ponds the cloth DURING
|
||||
the guard's own windows; no settle length fixes water that keeps arriving (measured: 105%
|
||||
full-curve, 46% dried, 73% dried-every-step; entryPeak once read a 3.04 kN water belly).
|
||||
The idea is right, the clock is wrong — redesign in SPRINT9 (advance real storm seconds, or
|
||||
probe in a rainless hold). The entryPeak guard passes honestly (0.39 kN entries).
|
||||
Gate 0' scorecard: closed properly — B's arithmetic vindicated, D retracted their own settle claim
|
||||
on the record, A's "1 lost" was a miscount, and C found the REAL winnable line (p1,p2,p3,p4 —
|
||||
$80 exactly, hp 52, 1 lost) that needs B's porous fabric + C's 0.40 downdraft STACKED. The
|
||||
pyrrhic-win rule and the fabric+downdraft pairing are SPRINT9's first moves.
|
||||
|
||||
[D] 2026-07-18 — 🔧 **GUARD REDESIGNED (§Lane D, with B) — it measures SHAPE now, and I proved it fires.**
|
||||
Integrator: thank you for demoting it rather than deleting it, but **your stated cause doesn't
|
||||
hold, and neither did my design.** Both worth recording:
|
||||
· **The ponding diagnosis is wrong.** Every storm's rain curve starts at `[0, 0]`, so
|
||||
`storm_02.rainMmPerHour(0)` is **0.0 mm/h** — a held clock rains *nothing*. (Also: your 2 s
|
||||
windows are shorter than the cloth's breath. A settled rig reads a 32% trend at 2 s and **6%
|
||||
at 3 s**. The window was the flake, not the water.)
|
||||
· **The real confound was mine.** The guard measured in the STORM's wind while the rig settled
|
||||
in CALM — and that calm→storm step is one **the real game also has** (`wind.use(to ===
|
||||
'storm' ? winds[stormKey] : calmWind)` fires on the phase change). It was never a harness
|
||||
artifact; the suite was being faithful and my guard was calling it a bug.
|
||||
· **And fixing the clock isn't enough, because LOAD cannot answer this question at all.** In
|
||||
calm there is no transient to see — the unsettled rig is *lighter* (0.30 kN vs 0.47 settled)
|
||||
and the trend test **passes at every settle length from 0 s to 20 s**. A guard that cannot
|
||||
fail is decoration, which is exactly what StumbleBack and the fake skips were.
|
||||
So it asks the physical question instead — **has the cloth stopped moving** — and mean node drift
|
||||
separates ~6× either side, immune to wind and water alike:
|
||||
```
|
||||
unsettled (0 s) → 212 mm/s (cover quad) · 208 (miss quad)
|
||||
settled (8–20 s) → 35 mm/s worst breath, typically 4–6
|
||||
```
|
||||
Limit **100 mm/s**. **Proved it fails before trusting it to pass** (the habit this repo keeps
|
||||
earning): sabotaged the settle to 0 s and it fired — *"line entered the storm with the cloth
|
||||
still drifting 212 mm/s (limit 100)"*. Restored, all five balance asserts green, **275/0/0**.
|
||||
**Your 600 N floor: blessed as reasoning, not carried as code.** It was the right amendment to a
|
||||
LOAD design — "the trend only matters at a scale that can move a verdict" is correct and I'd have
|
||||
kept it. Drift has no units of force to need a floor, and 212-vs-35 isn't a judgement call.
|
||||
|
||||
[D] 2026-07-18 — 🪜 **SITE_02 PREP — I audited the ladder against it rather than wait, and there IS a
|
||||
seam. A/E: one field in the site JSON and I'm done.** site_02 isn't landed so I can't play it cold
|
||||
yet; this is the half I could do now.
|
||||
The prompt's hunch was right but the mechanism isn't height. `needsLadder` was spelled
|
||||
**`type === 'house'`**, and contracts.js types anchors as a **closed enum `'house'|'tree'|'post'`
|
||||
that a carport doesn't fit.** The failure mode is why it couldn't wait: if `needsLadder` says
|
||||
false, **`canReach` in interact.js returns `true` UNCONDITIONALLY** — so on site_02 the player
|
||||
re-rigs a 2.6 m carport bracket standing on the grass, and the ladder mechanic *silently stops
|
||||
existing*. No error, no red. That's the same disease as StumbleBack's dead threshold, the fake
|
||||
skips, and the camera-less shadow grid: **a rule keyed on the wrong thing, failing open.**
|
||||
**A pure height test is NOT the fix** — posts (3.95 m) and tree limbs (5.05 m) are *higher* than
|
||||
the 2.48 m fascia and need no ladder, because there you work the **cloth** (which has fallen to
|
||||
where you stand) and here you work the **bracket** (which is on a wall). Height is a coincidence
|
||||
of that distinction, not the distinction.
|
||||
So it reads **data first**: `anchor.worksAtBracket` — precisely the pattern `anchor.ratingHint`
|
||||
already uses from the GLB's `userData.rating_hint` — falling back to `type === 'house'`.
|
||||
**Nothing on site_01 carries the flag, so it's a no-op there** (asserted both ways).
|
||||
**Lane A:** when you extract the yard to `data/sites/*.json`, give anchors an optional
|
||||
`worksAtBracket`. **Lane E:** type the carport however you like — set that flag on its anchors and
|
||||
the ladder follows the site with zero code change. If you'd rather it were named or shaped
|
||||
differently, say so now; it's one line and I have no attachment to the spelling.
|
||||
Also: `ladder.js` is now headless-importable (lazy GLTFLoader, same as broom.js), because
|
||||
`d.test.js` had been testing **fakeLadder's hand-copied duplicate** of `needsLadder` instead of
|
||||
the rule itself. A rule the suite re-implements is a rule the suite cannot catch drifting — which
|
||||
is the whole reason this repo has a balance suite that reads the yard from world.js.
|
||||
|
||||
[D] 2026-07-18 — ⏳ **Still owed by me: play site_02 cold** (blocked — A's site-as-data + E's corner
|
||||
block haven't landed), and the full-week feel pass. Both are queued and neither blocks anyone. My
|
||||
douse guard is still green, so pond masses haven't moved.
|
||||
|
||||
113
tools/cardpreview/index.html
Normal file
113
tools/cardpreview/index.html
Normal file
@ -0,0 +1,113 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>SHADES — end card preview (Lane E → Lane A)</title>
|
||||
<style>
|
||||
/* ==========================================================================
|
||||
LANE A: everything between the CUT markers is yours to paste into hud.js.
|
||||
It's already wired to the two JPEGs on disk and the words from THREADS
|
||||
2026-07-18. Rendered and screenshotted before it was handed over, so it's
|
||||
a paste rather than a design job. Take it, edit it, or bin it.
|
||||
====================================================================== */
|
||||
|
||||
/* ---- CUT HERE ---------------------------------------------------------- */
|
||||
.endcard {
|
||||
position: fixed; inset: 0; z-index: 40;
|
||||
display: flex; align-items: center;
|
||||
background-size: cover; background-position: center;
|
||||
font: 14px/1.55 ui-monospace, SFMono-Regular, Menlo, monospace;
|
||||
color: #fff;
|
||||
}
|
||||
.endcard.win { background-image: url('/web/world/models/textures/card_win.jpg'); }
|
||||
.endcard.lose { background-image: url('/web/world/models/textures/card_gameover.jpg'); }
|
||||
|
||||
/* The art was framed with its left third deliberately empty. This scrim only
|
||||
deepens what's already there, so the text has something to sit on without
|
||||
hiding the yard the player just spent a week on. */
|
||||
.endcard::before {
|
||||
content: ''; position: absolute; inset: 0;
|
||||
background: linear-gradient(to right, rgba(8,10,14,.86) 0%,
|
||||
rgba(8,10,14,.72) 26%, rgba(8,10,14,.28) 46%, transparent 62%);
|
||||
}
|
||||
.endcard .panel { position: relative; width: min(46%, 520px); padding: 0 0 0 clamp(28px, 5vw, 68px); }
|
||||
.endcard h1 {
|
||||
margin: 0 0 10px; font-size: clamp(30px, 4.4vw, 52px); line-height: .98;
|
||||
letter-spacing: .06em; font-weight: 800;
|
||||
}
|
||||
.endcard.win h1 { color: #ffd9a3; text-shadow: 0 2px 26px rgba(255,150,60,.45); }
|
||||
.endcard.lose h1 { color: #e8edf2; text-shadow: 0 2px 22px rgba(0,0,0,.7); }
|
||||
.endcard .sub { margin: 0 0 18px; font-size: clamp(14px, 1.5vw, 18px); color: #dfe6ec; }
|
||||
.endcard .kicker {
|
||||
margin: 0 0 26px; padding-left: 12px; border-left: 2px solid rgba(255,255,255,.28);
|
||||
color: #aab6c2; font-style: italic;
|
||||
}
|
||||
.endcard .tally { margin: 0 0 26px; border-collapse: collapse; }
|
||||
.endcard .tally td { padding: 3px 0; color: #b9c4cf; }
|
||||
.endcard .tally td + td { padding-left: 18px; color: #fff; font-weight: 700; text-align: right; }
|
||||
.endcard .tally tr.total td { padding-top: 8px; border-top: 1px solid rgba(255,255,255,.18); }
|
||||
.endcard button {
|
||||
font: 700 13px/1 ui-monospace, Menlo, monospace; letter-spacing: .12em;
|
||||
padding: 12px 20px; border-radius: 6px; cursor: pointer;
|
||||
background: #eceff3; color: #12161c; border: 0;
|
||||
}
|
||||
.endcard.lose button { background: #2a3038; color: #e8edf2; }
|
||||
/* ---- CUT HERE ---------------------------------------------------------- */
|
||||
</style>
|
||||
</head>
|
||||
<body style="margin:0;background:#0b0d11">
|
||||
|
||||
<!-- Toggle for eyeballing; not part of the snippet. -->
|
||||
<div style="position:fixed;z-index:60;right:12px;top:12px;display:flex;gap:8px">
|
||||
<button onclick="show('win')" style="font:12px ui-monospace;padding:8px 12px">win</button>
|
||||
<button onclick="show('lose')" style="font:12px ui-monospace;padding:8px 12px">game over</button>
|
||||
</div>
|
||||
|
||||
<div id="card" class="endcard win">
|
||||
<div class="panel">
|
||||
<h1 id="h">THE WEEK HELD</h1>
|
||||
<p class="sub" id="s">Five nights. Everything's still where you put it.</p>
|
||||
<p class="kicker" id="k">Nobody thanks you for the storm that did nothing. That's the job.</p>
|
||||
<table class="tally" id="t"></table>
|
||||
<button id="b">START A NEW WEEK</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
// Lane A: swap this object for your real week tally — the markup above doesn't
|
||||
// care what the rows are, it just lays out label/value pairs.
|
||||
const COPY = {
|
||||
win: {
|
||||
h: 'THE WEEK HELD',
|
||||
s: "Five nights. Everything's still where you put it.",
|
||||
k: "Nobody thanks you for the storm that did nothing. That's the job.",
|
||||
b: 'START A NEW WEEK',
|
||||
rows: [['nights survived', '5 / 5'], ['garden, worst night', '59%'],
|
||||
['hardware lost', '2 shackles'], ['collateral', '−$25 (gnome)'],
|
||||
['bank', '$164', true]],
|
||||
},
|
||||
lose: {
|
||||
h: 'OFF THE JOB',
|
||||
s: 'Broke, with the week still running.',
|
||||
k: 'The wind never sent an invoice. Everyone else did.',
|
||||
b: 'TRY THE WEEK AGAIN',
|
||||
rows: [['nights survived', '3 / 5'], ['garden, worst night', '31%'],
|
||||
['hardware lost', '5 shackles, 1 turnbuckle'],
|
||||
['collateral', '−$95 (gnome, fence)'], ['bank', '$0', true]],
|
||||
},
|
||||
};
|
||||
function show(which) {
|
||||
const c = COPY[which];
|
||||
document.getElementById('card').className = 'endcard ' + which;
|
||||
document.getElementById('h').textContent = c.h;
|
||||
document.getElementById('s').textContent = c.s;
|
||||
document.getElementById('k').textContent = c.k;
|
||||
document.getElementById('b').textContent = c.b;
|
||||
document.getElementById('t').innerHTML = c.rows.map(
|
||||
([k, v, total]) => `<tr class="${total ? 'total' : ''}"><td>${k}</td><td>${v}</td></tr>`).join('');
|
||||
}
|
||||
show('win');
|
||||
globalThis.show = show;
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@ -15,6 +15,7 @@
|
||||
|
||||
import * as THREE from '../vendor/three.module.js';
|
||||
import { STORM_LEN } from './contracts.js';
|
||||
import { forecastLines } from './weather.js';
|
||||
|
||||
const clamp01 = (v) => (v < 0 ? 0 : v > 1 ? 1 : v);
|
||||
const kmh = (ms) => ms * 3.6;
|
||||
@ -71,6 +72,40 @@ const CSS = `
|
||||
letter-spacing:.05em; }
|
||||
#hud-card .verdict.win { background:#12321c; border:1px solid #2c6b3c; color:#7fce6a; }
|
||||
#hud-card .verdict.lose { background:#3a1618; border:1px solid #7d2b2b; color:#ff8f86; }
|
||||
|
||||
/* --- the week ---------------------------------------------------------- */
|
||||
#hud-card .pips { letter-spacing:.5em; font-size:15px; margin:-6px 0 10px; color:#3f5561; }
|
||||
#hud-card .pip.now { color:#7ee0ff; }
|
||||
#hud-card .pip.held { color:#7fce6a; }
|
||||
#hud-card .pip.lost { color:#ff8f86; }
|
||||
#hud-card .ledger { margin-top:14px; padding-top:10px; border-top:1px solid #24343d; }
|
||||
#hud-card .ledger .row b { color:#a8f0b8; }
|
||||
#hud-card .ledger .row.bad b { color:#ff8f86; }
|
||||
#hud-card .ledger .row.total { margin-top:6px; padding-top:8px; border-top:1px solid #24343d; }
|
||||
#hud-card .ledger .row.total b { color:#fff; }
|
||||
|
||||
/* E's diptych. The art is the card; the words sit in the left third they left
|
||||
clear for exactly this. */
|
||||
#hud-card .endcard { background-size:cover; background-position:center right;
|
||||
max-width:none; width:min(92vw,900px); min-height:min(70vh,520px);
|
||||
display:flex; align-items:center; padding:0; border:1px solid #24343d; }
|
||||
#hud-card .endcard .endtext { width:min(46%,380px); padding:28px 26px;
|
||||
background:linear-gradient(to right, rgba(9,14,18,.92) 65%, rgba(9,14,18,0)); }
|
||||
#hud-card .endcard h1 { font-size:26px; }
|
||||
#hud-card .endcard .kicker { margin:16px 0 0; color:#8ba0ad; font-style:italic; line-height:1.5; }
|
||||
|
||||
/* --- dawn (Lane E, pasted from their THREADS note) ---------------------- */
|
||||
/* The screen blend is the point: it lifts the black storm scene into morning
|
||||
without touching the card on top. The 2.2s ease matters more than the
|
||||
colours. (No backticks in here — this whole block is a JS template literal.) */
|
||||
#dawn { position:fixed; inset:0; pointer-events:none; opacity:0; z-index:5;
|
||||
transition:opacity 2.2s ease; mix-blend-mode:screen;
|
||||
background:linear-gradient(to top,
|
||||
rgba(255,178,102,.30) 0%, /* the sun that finally turned up */
|
||||
rgba(255,150,96,.16) 22%,
|
||||
rgba(120,132,168,.10) 55%,
|
||||
rgba(38,48,84,.16) 100%); } /* night still up there */
|
||||
#dawn.on { opacity:1; }
|
||||
`;
|
||||
|
||||
/**
|
||||
@ -115,6 +150,14 @@ export function createHud(d) {
|
||||
card.id = 'hud-card';
|
||||
document.body.appendChild(card);
|
||||
|
||||
// The morning. Sits UNDER the card and over the frozen storm scene — see the
|
||||
// `screen` blend in the CSS, which lifts the black night into dawn without
|
||||
// touching the card on top of it. Lane E shipped this as ten lines rather than
|
||||
// a ninth texture nobody loads, and they were right.
|
||||
const dawn = document.createElement('div');
|
||||
dawn.id = 'dawn';
|
||||
document.body.appendChild(dawn);
|
||||
|
||||
const $ = (id) => root.querySelector(id);
|
||||
const elWind = $('#hud-wind'), elClock = $('#hud-clock'), elGust = $('#hud-gust');
|
||||
const elPct = $('#hud-garden-pct'), elBar = $('#hud-bar i'), elShade = $('#hud-shade');
|
||||
@ -312,35 +355,100 @@ export function createHud(d) {
|
||||
* @param {{key:string, def:object}[]} storms
|
||||
* @param {(key:string) => void} onPick
|
||||
*/
|
||||
showForecast(storms, onPick) {
|
||||
const rows = storms.map(({ key, def }) => {
|
||||
const peak = Math.max(...def.baseCurve.map((p) => p[1]));
|
||||
const gustPeak = peak + (def.gusts?.powBase ?? 0) + (def.gusts?.powRamp ?? 0);
|
||||
const rainPeak = Math.max(...(def.rain?.curve ?? [[0, 0]]).map((p) => p[1]));
|
||||
const change = (def.events ?? []).find((e) => e.type === 'windchange');
|
||||
const night = (def.sky?.darkness ?? 0) > 0.6;
|
||||
return `<button class="storm" data-key="${key}">
|
||||
<div class="name">${(def.name ?? key).replace(/_/g, ' ').toUpperCase()}${night ? ' · NIGHT' : ''}</div>
|
||||
<div class="stat">sustained to ${peak.toFixed(0)} m/s (${kmh(peak).toFixed(0)} km/h)
|
||||
· gusts to ~${kmh(gustPeak).toFixed(0)} km/h</div>
|
||||
<div class="stat">rain ${rainPeak >= 0.8 ? 'heavy' : rainPeak >= 0.4 ? 'steady' : 'light'}
|
||||
${change ? `· southerly change at ${change.t}s` : '· no change forecast'}</div>
|
||||
</button>`;
|
||||
showForecast({ key, def }, wk, onGo) {
|
||||
// Integrator merge (Sprint 8): A's week card shape + C's forecastLines —
|
||||
// MEASURED numbers, banded by lead (the old inline estimate read 30 m/s
|
||||
// for a storm that really gusts 32.3). Tonight is lead 0 = exact; when
|
||||
// the week wants to show tomorrow's card, pass its lead and it hedges.
|
||||
const f = forecastLines(def, 0);
|
||||
const change = (def.events ?? []).find((e) => e.type === 'windchange');
|
||||
const night = (def.sky?.darkness ?? 0) > 0.6;
|
||||
const hail = !!def.hail;
|
||||
|
||||
// The ladder, as pips. You can see what you've survived and how far is
|
||||
// left — which is most of what makes night four frightening.
|
||||
const pips = Array.from({ length: wk.nights }, (_, i) => {
|
||||
const done = i < wk.night - 1;
|
||||
const now = i === wk.night - 1;
|
||||
const held = done && wk.log[i]?.won;
|
||||
return `<span class="pip ${now ? 'now' : done ? (held ? 'held' : 'lost') : ''}">${
|
||||
now ? '◆' : done ? (held ? '●' : '○') : '·'}</span>`;
|
||||
}).join('');
|
||||
|
||||
card.innerHTML = `<div class="card">
|
||||
<h1>FORECAST</h1>
|
||||
<h2>90 seconds of storm. Pick your night, then rig for it.</h2>
|
||||
${rows}
|
||||
<div class="stat" style="color:#8ba0ad;margin-top:12px">
|
||||
<h1>NIGHT ${wk.night} OF ${wk.nights}</h1>
|
||||
<div class="pips">${pips}</div>
|
||||
<h2>${(f.name ?? key).replace(/_/g, ' ').toUpperCase()}${night ? ' · NIGHT' : ''}</h2>
|
||||
<div class="stat">${f.wind}</div>
|
||||
<div class="stat">${f.rain}${hail ? ' · hail forecast' : ''}</div>
|
||||
${f.confidence ? `<div class="stat" style="color:#8ba0ad">${f.confidence}</div>` : ''}
|
||||
<div class="row" style="margin-top:14px"><span>in the bank</span><b>$${wk.bank}</b></div>
|
||||
<div class="stat" style="color:#8ba0ad;margin-top:10px">
|
||||
${hail
|
||||
? 'Hail is what kills a garden, and cloth stops hail. Get the sail over the bed.'
|
||||
: 'Nothing tonight can hurt the garden. Learn the anchors.'}
|
||||
</div>
|
||||
${change ? `<div class="stat" style="color:#8ba0ad">
|
||||
A change means the corners that were slack all storm are the loaded ones after it.
|
||||
</div>` : ''}
|
||||
<button class="go">RIG IT</button>
|
||||
</div>`;
|
||||
card.classList.add('on');
|
||||
hud.setVisible(false);
|
||||
card.querySelector('.go').addEventListener('click', () => { hud.hideCard(); onGo(); });
|
||||
},
|
||||
|
||||
/**
|
||||
* E's dawn tint, pasted from their THREADS note. The 2.2 s ease is the point,
|
||||
* not the colours: the storm ends, the light comes up, and THEN you're told
|
||||
* how you did. Sell the survival before the scoreboard.
|
||||
*/
|
||||
setDawn(on) { dawn.classList.toggle('on', !!on); },
|
||||
|
||||
/**
|
||||
* The end of the week, either way. E's diptych is on disk and their words are
|
||||
* in THREADS — I took the primaries verbatim; the trade talking, no triumph.
|
||||
*
|
||||
* @param {object} s week.js settlement
|
||||
* @param {() => void} onRestart
|
||||
*/
|
||||
showEndCard(s, onRestart) {
|
||||
const won = s.outcome === 'win';
|
||||
const art = won ? 'card_win.jpg' : 'card_gameover.jpg';
|
||||
|
||||
// The words scale with what was actually held — reaching night five is not
|
||||
// the same as saving five gardens, and the end card is the last thing the
|
||||
// game says. E's primary copy for a clean week, E's own alternate for a
|
||||
// scraped one, and a third for the ending nobody knew existed until the
|
||||
// economy was measured: solvent, with the gardens dead behind you.
|
||||
const COPY = {
|
||||
clean: ['THE WEEK HELD', "Five nights. Everything's still where you put it.",
|
||||
"Nobody thanks you for the storm that did nothing. That's the job."],
|
||||
scraped: ['FIVE NIGHTS, FIVE MORNINGS', 'You made the least wrong call five times running.',
|
||||
'Some of it held. You know which bits didn\'t.'],
|
||||
solvent: ['STILL TRADING', 'The books balanced. The garden didn\'t.',
|
||||
'You can be paid all week and still have nothing to point at.'],
|
||||
gameover: ['OFF THE JOB', 'Broke, with the week still running.',
|
||||
'The wind never sent an invoice. Everyone else did.'],
|
||||
};
|
||||
const [head, sub, kick] = COPY[won ? (s.grade ?? 'clean') : 'gameover'];
|
||||
const nights = s.night;
|
||||
|
||||
card.innerHTML = `<div class="card endcard ${won ? 'win' : 'lose'}"
|
||||
style="background-image:url(./models/textures/${art})">
|
||||
<div class="endtext">
|
||||
<h1>${head}</h1>
|
||||
<h2>${sub}</h2>
|
||||
<div class="row"><span>nights survived</span><b>${nights}/5</b></div>
|
||||
<div class="row"><span>gardens held</span><b>${s.held ?? 0}/5</b></div>
|
||||
<div class="row"><span>in the bank</span><b>$${s.bankAfter}</b></div>
|
||||
<div class="kicker">${kick}</div>
|
||||
<button class="go">${won ? 'ANOTHER WEEK' : 'TRY AGAIN'}</button>
|
||||
</div>
|
||||
</div>`;
|
||||
card.classList.add('on');
|
||||
hud.setVisible(false);
|
||||
for (const b of card.querySelectorAll('.storm')) {
|
||||
b.addEventListener('click', () => { hud.hideCard(); onPick(b.dataset.key); });
|
||||
}
|
||||
card.querySelector('.go').addEventListener('click', () => { hud.hideCard(); onRestart(); });
|
||||
},
|
||||
|
||||
/**
|
||||
@ -348,20 +456,39 @@ export function createHud(d) {
|
||||
* @param {() => void} onAgain
|
||||
*/
|
||||
showAftermath(r, onAgain) {
|
||||
const w = r.week;
|
||||
const rows = [
|
||||
['garden', `${r.hp.toFixed(0)}%`],
|
||||
['corners intact', `${r.cornersTotal - r.cornersLost}/${r.cornersTotal}`],
|
||||
['what got through', r.hailBlocked],
|
||||
['hardware lost', r.bill ? `$${r.bill}` : 'none'],
|
||||
['collateral', r.collateral.length ? r.collateral.map((c) => `${c.what} ($${c.cost})`).join(', ') : 'none'],
|
||||
['budget left', `$${r.budgetLeft}`],
|
||||
].map(([k, v]) => `<div class="row"><span>${k}</span><b>${v}</b></div>`).join('');
|
||||
|
||||
// The money, itemised. A settlement you can't read is a number you can't
|
||||
// argue with, and arguing with it is how you learn the shop.
|
||||
const money = w ? `
|
||||
<div class="ledger">
|
||||
<div class="row"><span>${w.won ? 'fee' : `fee (night lost — ${Math.round(100 * w.fee / Math.max(1, w.fullFee))}%)`}</span><b>+$${w.fee}</b></div>
|
||||
<div class="row"><span>garden bonus</span><b>+$${w.bonus}</b></div>
|
||||
<div class="row"><span>gear recovered</span><b>+$${w.refund}</b></div>
|
||||
${w.collateral ? `<div class="row bad"><span>collateral</span><b>−$${w.collateral}</b></div>` : ''}
|
||||
<div class="row"><span>spent on the rig</span><b>−$${w.spent}</b></div>
|
||||
<div class="row total"><span>in the bank</span><b>$${w.bankBefore} → $${w.bankAfter}</b></div>
|
||||
</div>` : '';
|
||||
|
||||
const next = !w ? 'PLAY AGAIN'
|
||||
: w.outcome === 'continue' ? `NIGHT ${w.night + 1} →`
|
||||
: w.outcome === 'win' ? 'SEE THE WEEK'
|
||||
: 'SEE THE DAMAGE';
|
||||
|
||||
card.innerHTML = `<div class="card">
|
||||
<h1>AFTERMATH</h1>
|
||||
<h1>MORNING${w ? ` · NIGHT ${w.night} OF 5` : ''}</h1>
|
||||
<h2>${r.subtitle}</h2>
|
||||
${rows}
|
||||
${money}
|
||||
<div class="verdict ${r.win ? 'win' : 'lose'}">${r.verdict}</div>
|
||||
<button class="go">PLAY AGAIN</button>
|
||||
<button class="go">${next}</button>
|
||||
</div>`;
|
||||
card.classList.add('on');
|
||||
hud.setVisible(false);
|
||||
|
||||
@ -17,20 +17,44 @@
|
||||
* no change to get this — it already hands createPlayer the scene, world and interact.
|
||||
*/
|
||||
import * as THREE from '../vendor/three.module.js';
|
||||
import { GLTFLoader } from '../vendor/addons/loaders/GLTFLoader.js';
|
||||
|
||||
// GLTFLoader is imported lazily, not at module scope, and the reason is the suite: the vendored
|
||||
// addons import the bare specifier 'three', which only resolves under index.html's importmap, so a
|
||||
// top-level import here would drag the whole GL chain in and make this file unloadable from
|
||||
// d.test.js (node resolves relative paths only — three.module.js is fine, its addons are not).
|
||||
// That mattered: needsLadder below is a RULE, and the suite was testing a hand-copied duplicate of
|
||||
// it rather than the rule itself. Same reasoning as broom.js.
|
||||
export const LADDER_URL = './models/ladder_01_v1.glb';
|
||||
|
||||
/**
|
||||
* Which anchors you cannot rig from the ground.
|
||||
*
|
||||
* Deliberately keyed on the anchor TYPE, not on a height test. A pure "is it above reach?" rule
|
||||
* would rope in the posts (3.95 m) and tree limbs (up to 5.05 m) and turn every single repair into
|
||||
* a two-trip ladder job — which is both untrue to how sails are actually rigged and would have
|
||||
* silently invalidated the recorded §7 run and Lane B's gate asserts. Decision 12 scopes this to
|
||||
* the fascia; this is that scope, in one line, where it can be found and argued with.
|
||||
* NOT a height test, deliberately. A pure "is it above reach?" rule would rope in the posts (3.95 m)
|
||||
* and tree limbs (up to 5.05 m) and turn every repair into a two-trip ladder job — untrue to how
|
||||
* sails are rigged, and it would silently invalidate the recorded §7 run and Lane B's gate asserts.
|
||||
* The real distinction isn't height, it's WHERE THE WORK HAPPENS: a blown fascia corner is re-made
|
||||
* at the bracket on the wall, while a blown post or tree corner is re-made on the cloth, which has
|
||||
* fallen to somewhere you can stand. Height is a coincidence of that; the bracket is the reason.
|
||||
*
|
||||
* SPRINT9, site_02 (SPRINT9 §Lane D — "the ladder assumes fascia height; the carport may not have
|
||||
* one"): `type === 'house'` is site_01's spelling of that idea, not the idea itself. The corner
|
||||
* block has a CARPORT — a roofline you'd also work at the bracket — and contracts.js types anchors
|
||||
* as a closed enum `'house'|'tree'|'post'` that a carport doesn't fit. Whatever E types it, this
|
||||
* must not fail OPEN: if `needsLadder` says false, `canReach` in interact.js returns true
|
||||
* unconditionally and the player re-rigs a 2.6 m bracket standing on the grass — the mechanic just
|
||||
* quietly stops existing, with no error. That is the same disease as StumbleBack's dead threshold
|
||||
* and the camera-less shadow grid: a rule keyed on the wrong thing, failing silently open.
|
||||
*
|
||||
* So it reads DATA first, exactly like `anchor.ratingHint` already does (world.js pulls that from
|
||||
* the GLB's `userData.rating_hint`), and falls back to site_01's shape. Lane A/E: set
|
||||
* `anchor.worksAtBracket = true` on the carport's anchors in the site JSON and the ladder follows
|
||||
* the site with no code change. Nothing on site_01 carries the flag, so this is a no-op there.
|
||||
*/
|
||||
export const needsLadder = (anchor) => !!anchor && anchor.type === 'house';
|
||||
export const needsLadder = (anchor) => {
|
||||
if (!anchor) return false;
|
||||
if (typeof anchor.worksAtBracket === 'boolean') return anchor.worksAtBracket; // site data wins
|
||||
return anchor.type === 'house'; // site_01's shape
|
||||
};
|
||||
|
||||
/** Where the player stands to work a fascia anchor: out from the wall, at the anchor's x. */
|
||||
const STAND_OFF = 0.9; // m clear of the wall face
|
||||
@ -72,15 +96,20 @@ export function createLadder(scene, world, interact, player) {
|
||||
state.base.copy(home);
|
||||
|
||||
// --- view -----------------------------------------------------------------
|
||||
new GLTFLoader().load(LADDER_URL, (g) => {
|
||||
const obj = g.scene;
|
||||
const top = obj.getObjectByName('ladder_top');
|
||||
if (top) state.topY = top.position.y;
|
||||
obj.traverse((o) => { if (o.isMesh) { o.castShadow = true; o.frustumCulled = false; } });
|
||||
state.view = obj;
|
||||
scene.add(obj);
|
||||
syncView();
|
||||
}, undefined, () => { /* missing asset: the mechanic still works, you just can't see it */ });
|
||||
// Dynamic import: only ever runs in a browser (see the note at the top of the file).
|
||||
if (scene) {
|
||||
import('../vendor/addons/loaders/GLTFLoader.js').then(({ GLTFLoader }) => {
|
||||
new GLTFLoader().load(LADDER_URL, (g) => {
|
||||
const obj = g.scene;
|
||||
const top = obj.getObjectByName('ladder_top');
|
||||
if (top) state.topY = top.position.y;
|
||||
obj.traverse((o) => { if (o.isMesh) { o.castShadow = true; o.frustumCulled = false; } });
|
||||
state.view = obj;
|
||||
scene.add(obj);
|
||||
syncView();
|
||||
}, undefined, () => { /* missing asset: the mechanic still works, you just can't see it */ });
|
||||
}).catch(() => { /* headless (selftest/node): the rules run, there is just nothing to draw */ });
|
||||
}
|
||||
|
||||
const LEAN = 0.26; // rad (~15°) — a ladder stood bolt upright reads as a post, not a ladder
|
||||
function syncView() {
|
||||
|
||||
@ -14,7 +14,7 @@
|
||||
*/
|
||||
|
||||
import * as THREE from '../vendor/three.module.js';
|
||||
import { FIXED_DT, PHASES, STORM_LEN, HARDWARE, Emitter } from './contracts.js';
|
||||
import { FIXED_DT, PHASES, STORM_LEN, HARDWARE, SPARE_COST, Emitter } from './contracts.js';
|
||||
import { createWorld } from './world.js';
|
||||
import { createCameraRig } from './camera.js';
|
||||
import { loadStorm, createWind } from './weather.js';
|
||||
@ -25,12 +25,17 @@ import { createDebris } from './debris.js';
|
||||
import { createSkyFx } from './skyfx.js';
|
||||
import { createRiggingUI } from './rigging.js';
|
||||
import { createHud } from './hud.js';
|
||||
import { createWeek, NIGHTS } from './week.js';
|
||||
|
||||
/** The calm day the forecast and prep phases run under. */
|
||||
const CALM_STORM = 'storm_01_gentle';
|
||||
|
||||
/** The storms you can pick from the forecast card — this is the difficulty select. */
|
||||
const STORMS = ['storm_01_gentle', 'storm_03_southerly', 'storm_02_wildnight'];
|
||||
/**
|
||||
* Every storm the session can run. This used to be a three-storm difficulty
|
||||
* select; the week's ladder (week.js NIGHTS) now decides what's coming, and the
|
||||
* forecast card's job changed from "pick your poison" to "here's tonight".
|
||||
*/
|
||||
const STORMS = NIGHTS;
|
||||
|
||||
/**
|
||||
* How fast an unprotected garden dies, in HP per second at full rain.
|
||||
@ -547,6 +552,15 @@ export async function boot(opts = {}) {
|
||||
hailBlocked: dmg.hail + dmg.rain > 0
|
||||
? `${Math.round(dmg.hail)} HP to hail, ${Math.round(dmg.rain)} to rain`
|
||||
: 'Nothing reached the bed.',
|
||||
/**
|
||||
* What you can unclip and take home: hardware still on an unbroken corner,
|
||||
* plus a spare you never had to use. week.js refunds it at half — a shackle
|
||||
* that rode out a gale isn't new any more. Broken gear is worth nothing,
|
||||
* which is the whole of `bill`.
|
||||
*/
|
||||
intactHardwareValue:
|
||||
rig.corners.filter((c) => !c.broken).reduce((sum, c) => sum + c.hw.cost, 0)
|
||||
+ (rigging.session.spares ?? 0) * SPARE_COST,
|
||||
pondPeak,
|
||||
pondDumped,
|
||||
verdict,
|
||||
@ -555,6 +569,40 @@ export async function boot(opts = {}) {
|
||||
};
|
||||
}
|
||||
|
||||
// --- the week ------------------------------------------------------------
|
||||
// Five nights, one wallet. The forecast stops being a difficulty picker — the
|
||||
// ladder decides what's coming and the only question left is what you rig
|
||||
// against it with the money you have.
|
||||
const week = createWeek();
|
||||
let spentThisNight = 0;
|
||||
|
||||
/**
|
||||
* Tonight's card. Reads the bank, not START_BUDGET.
|
||||
*
|
||||
* NOTE the `budget` we hand the shop: `rigging.session.spent` computes
|
||||
* `START_BUDGET - budget` against the module constant rather than the session's
|
||||
* own starting cash, so with a bank of $63 it reports $17 spent before you buy
|
||||
* anything. Lane B's file, flagged in THREADS — main.js therefore tracks
|
||||
* `spentThisNight` itself off the bank rather than trusting `.spent`.
|
||||
*/
|
||||
function showTonight() {
|
||||
// Reaching into Lane B's session to re-bank the shop. `RiggingSession` takes
|
||||
// a budget at construction but exposes no setter, and the UI owns the
|
||||
// instance — so this is the one private touch in main.js, done loudly rather
|
||||
// than by forking their file. I've asked for `session.setBudget(n)` in
|
||||
// THREADS; when it lands these two lines become one. (Same route
|
||||
// `session.reset()` took: I faked it, asked, they landed it, I deleted the
|
||||
// fake.)
|
||||
rigging.session._startBudget = week.bank;
|
||||
rigging.session.reset();
|
||||
spentThisNight = 0;
|
||||
hud.showForecast(
|
||||
{ key: week.stormKey, def: defs[week.stormKey] },
|
||||
{ night: week.night, nights: week.nights, bank: week.bank, log: week.log },
|
||||
() => { stormKey = week.stormKey; game.setPhase('prep'); },
|
||||
);
|
||||
}
|
||||
|
||||
// --- the night's evidence ------------------------------------------------
|
||||
// What the sail carried and what the player took on the head, so the verdict
|
||||
// can point at things that actually happened rather than infer from the score.
|
||||
@ -585,10 +633,8 @@ export async function boot(opts = {}) {
|
||||
garden.reset();
|
||||
resetRig();
|
||||
player.sim.carrying = null;
|
||||
hud.showForecast(
|
||||
STORMS.map((key) => ({ key, def: defs[key] })),
|
||||
(key) => { stormKey = key; game.setPhase('prep'); },
|
||||
);
|
||||
hud.setDawn(false);
|
||||
showTonight();
|
||||
}
|
||||
// The card belongs to the phase, not to the button that happened to open it.
|
||||
// Tying its lifetime to the forecast button meant any other route into prep
|
||||
@ -603,7 +649,17 @@ export async function boot(opts = {}) {
|
||||
hud.setHelp('WASD move · shift run · E repair/pickup · C brace · RMB orbit');
|
||||
}
|
||||
if (to === 'aftermath') {
|
||||
hud.showAftermath(scoreRun(), () => game.setPhase('forecast'));
|
||||
// The dawn comes up BEFORE the scoreboard, on E's 2.2 s ease. Their note
|
||||
// is right and it's the whole reason this isn't one call: the storm ends,
|
||||
// the light returns, and only then are you told how you did. Sell the
|
||||
// survival first.
|
||||
hud.setDawn(true);
|
||||
const run = scoreRun();
|
||||
const settlement = week.settle(run, defs[week.stormKey], spentThisNight);
|
||||
hud.showAftermath({ ...run, week: settlement }, () => {
|
||||
if (settlement.outcome === 'continue') { week.advance(); game.setPhase('forecast'); }
|
||||
else hud.showEndCard(settlement, () => { week.reset(); game.setPhase('forecast'); });
|
||||
});
|
||||
}
|
||||
|
||||
if (banner && to !== 'forecast' && to !== 'aftermath') {
|
||||
@ -619,17 +675,17 @@ export async function boot(opts = {}) {
|
||||
// isn't four corners, and says so in the ticker.
|
||||
if (game.phase === 'prep') {
|
||||
if (!rigging.commit()) return;
|
||||
// Off the bank, not off START_BUDGET — see the note on showTonight().
|
||||
spentThisNight = week.bank - rigging.summary.budget;
|
||||
player.sim.carrying = null;
|
||||
if (rigging.summary.spares > 0) pushEvent(`spare shackle on the shed table — grab it before you need it`);
|
||||
}
|
||||
game.advance();
|
||||
});
|
||||
|
||||
// Straight into the forecast: the card is the game's front door.
|
||||
hud.showForecast(
|
||||
STORMS.map((key) => ({ key, def: defs[key] })),
|
||||
(key) => { stormKey = key; game.setPhase('prep'); },
|
||||
);
|
||||
// Straight into the forecast: the card is the game's front door, and it now
|
||||
// opens on night one of five rather than a difficulty menu.
|
||||
showTonight();
|
||||
|
||||
// --- resize -------------------------------------------------------------
|
||||
function resize() {
|
||||
|
||||
@ -702,10 +702,22 @@ export function createSkyFx(o = {}) {
|
||||
* @param {number} dt
|
||||
* @param {number} t storm time
|
||||
* @param {object} [world] {sail} — duck-typed, for creak/flog
|
||||
*
|
||||
* Runs headless. The camera is a RENDERING concern and must never gate the
|
||||
* shadow grids — see the note at the physics/view split below.
|
||||
*/
|
||||
step(dt, t, world = {}) {
|
||||
if (!camera) return;
|
||||
camera.getWorldPosition(camPos);
|
||||
// A camera means "there is a view to place things in", not "the weather is
|
||||
// real". This used to read `if (!camera) return;` at the top, which meant a
|
||||
// harness with no camera silently skipped the shadow rebuild and then
|
||||
// scored every rig as if the sail did not exist — hp 36 was the bare-bed
|
||||
// constant, and it cost gate 0 two sprints of four lanes' time before A
|
||||
// found it. The grids are physics; only the view and the audio are the
|
||||
// camera's business. Fall back to the yard centre so the wind still has a
|
||||
// place to be sampled.
|
||||
const rendering = !!camera;
|
||||
if (rendering) camera.getWorldPosition(camPos);
|
||||
else camPos.set(0, 1.7, 0);
|
||||
wind.sample(camPos, t, w);
|
||||
const speed = Math.hypot(w.x, w.z);
|
||||
const intensity = wind.rainAt(t);
|
||||
@ -753,6 +765,37 @@ export function createSkyFx(o = {}) {
|
||||
flash *= Math.max(0, 1 - dt * 7);
|
||||
if (flash < 0.004) flash = 0;
|
||||
|
||||
// --- PHYSICS: the shadow grids. Camera or not, always. ---
|
||||
// Everything that scores a rig — gardenExposure, gardenHailExposure,
|
||||
// rainShadowOver, hailShadowOver — reads these grids. They are what the
|
||||
// sail DOES, so they rebuild before any view work and above the render
|
||||
// gate. Rebuilt a few times a second, not every frame: the cloth moves
|
||||
// slowly next to the weather, and this is the only part that costs.
|
||||
shadowTick -= dt;
|
||||
if (shadowTick <= 0) {
|
||||
shadowTick = 0.1;
|
||||
rainVelocity(w, intensity, rainDir);
|
||||
const rl = rainDir.length() || 1;
|
||||
shadow.update(world.sail, rainDir.x / rl, rainDir.y / rl, rainDir.z / rl);
|
||||
}
|
||||
hailAmt = hailIntensity(t);
|
||||
const stone = hailStone();
|
||||
// The hail shadow follows the STEEP hail vector, not the wind. It barely
|
||||
// moves, so rebuild it slowly. A tenth of a second is fine; hail rides it.
|
||||
hailTick -= dt;
|
||||
if (hailTick <= 0) {
|
||||
hailTick = 0.12;
|
||||
hailWind.set(w.x, 0, w.z);
|
||||
hailVelocity(hailWind, hailDir);
|
||||
const hl = hailDir.length() || 1;
|
||||
hailShadow.update(world.sail, hailDir.x / hl, hailDir.y / hl, hailDir.z / hl);
|
||||
}
|
||||
|
||||
// Past here is the VIEW and the NOISE — drops to place, a dome to tint, a
|
||||
// gale to hear. All of it needs somewhere to stand. A headless harness has
|
||||
// the numbers it came for and can stop here.
|
||||
if (!rendering) return;
|
||||
|
||||
// --- sky ---
|
||||
skyCol.copy(baseSky).lerp(target, storminess * darkness);
|
||||
if (flash > 0) skyCol.lerp(FLASH_COL, Math.min(0.85, flash));
|
||||
@ -787,31 +830,8 @@ export function createSkyFx(o = {}) {
|
||||
domeTex.offset.x = (domeTex.offset.x + scroll * dt * (0.4 + speed * 0.05)) % 1;
|
||||
domeTex.offset.y = (domeTex.offset.y + scroll * dt * 0.12) % 1;
|
||||
|
||||
// --- rain ---
|
||||
// Rebuild the shadow a few times a second, not every frame: the cloth
|
||||
// moves slowly next to the rain, and this is the only part that costs.
|
||||
shadowTick -= dt;
|
||||
if (shadowTick <= 0) {
|
||||
shadowTick = 0.1;
|
||||
rainVelocity(w, intensity, rainDir);
|
||||
const len = rainDir.length() || 1;
|
||||
shadow.update(world.sail, rainDir.x / len, rainDir.y / len, rainDir.z / len);
|
||||
}
|
||||
// --- rain + hail drops (the grids they read were built above) ---
|
||||
rain.step(dt, camPos, w, intensity, shadow);
|
||||
|
||||
// --- hail ---
|
||||
hailAmt = hailIntensity(t);
|
||||
const stone = hailStone();
|
||||
// The hail shadow follows the STEEP hail vector, not the wind. It barely
|
||||
// moves, so rebuild it slowly. A tenth of a second is fine; hail rides it.
|
||||
hailTick -= dt;
|
||||
if (hailTick <= 0) {
|
||||
hailTick = 0.12;
|
||||
hailWind.set(w.x, 0, w.z);
|
||||
hailVelocity(hailWind, hailDir);
|
||||
const len = hailDir.length() || 1;
|
||||
hailShadow.update(world.sail, hailDir.x / len, hailDir.y / len, hailDir.z / len);
|
||||
}
|
||||
hail.step(dt, camPos, hailDir, hailAmt, stone, hailShadow);
|
||||
// how much of the hail the sail overhead is catching, for the drum sound —
|
||||
// sample right above the player/camera so it's "is it drumming over ME"
|
||||
|
||||
@ -10,6 +10,7 @@ import { createCameraRig } from '../camera.js';
|
||||
import { createGame, createWindRouter, verdictFor } from '../main.js';
|
||||
import { orderRing } from '../sail.js';
|
||||
import { loadStorm, createWind } from '../weather.js';
|
||||
import { createWeek, NIGHTS, gradeFor, BROKE_BELOW } from '../week.js';
|
||||
import { assert, assertEq, assertLess, fixedLoop } from '../testkit.js';
|
||||
|
||||
/** @param {import('../testkit.js').Suite} t */
|
||||
@ -51,6 +52,74 @@ export default async function run(t) {
|
||||
assertEq(checkContract('game', createGame()).join('; '), '');
|
||||
});
|
||||
|
||||
// --- the week (SPRINT8 gate 1) -------------------------------------------
|
||||
|
||||
t.test('the week is five escalating nights and the ladder never reorders', () => {
|
||||
assertEq(NIGHTS.length, 5);
|
||||
assertEq(NIGHTS[0], 'storm_01_gentle', 'night one must be the one that cannot hurt you');
|
||||
assertEq(NIGHTS[4], 'storm_02b_icenight', 'night five is the ice night');
|
||||
const w = createWeek();
|
||||
assertEq(w.night, 1); assertEq(w.bank, 80);
|
||||
assert(!w.isFinalNight);
|
||||
for (let i = 0; i < 4; i++) w.advance();
|
||||
assertEq(w.night, 5);
|
||||
assert(w.isFinalNight, 'night five is the last');
|
||||
w.advance();
|
||||
assertEq(w.night, 5, 'the ladder does not walk off its own end');
|
||||
});
|
||||
|
||||
t.test('money persists across nights, and the bank is next night\'s shop', () => {
|
||||
const w = createWeek();
|
||||
const def = { baseCurve: [[0, 10]], gusts: { powBase: 5, powRamp: 5 } };
|
||||
const s = w.settle(
|
||||
{ hp: 80, win: true, collateral: [], intactHardwareValue: 60 }, def, 70,
|
||||
);
|
||||
assertEq(s.bankBefore, 80);
|
||||
assertEq(s.bankAfter, 80 - 70 + s.pay, 'bank = bank − spent + pay, nothing else');
|
||||
assertEq(s.pay, s.fee + s.bonus + s.refund - s.collateral, 'the ledger adds up as shown');
|
||||
assertEq(s.refund, 30, 'gear comes home at half — a shackle that rode a gale is not new');
|
||||
w.advance();
|
||||
assertEq(w.bank, s.bankAfter, 'the bank IS the next shop');
|
||||
});
|
||||
|
||||
t.test('a lost night pays a fraction of the fee, not zero and not all of it', () => {
|
||||
const def = { baseCurve: [[0, 10]], gusts: { powBase: 5, powRamp: 5 } };
|
||||
const won = createWeek().settle({ hp: 80, win: true, collateral: [], intactHardwareValue: 0 }, def, 0);
|
||||
const lost = createWeek().settle({ hp: 80, win: false, collateral: [], intactHardwareValue: 0 }, def, 0);
|
||||
assertLess(lost.fee, won.fee, 'losing must cost you the fee');
|
||||
assert(lost.fee > 0, 'but not all of it — you turned up. Zero is unrecoverable, not hard');
|
||||
});
|
||||
|
||||
t.test('reaching night five is NOT the same as saving five gardens', () => {
|
||||
// The bug this pins shipped in my own first draft and only measurement
|
||||
// caught it: a $20-carabiner player loses four gardens, never dips under the
|
||||
// broke line because a cheap rig barely costs anything, and was handed "THE
|
||||
// WEEK HELD — everything's still where you put it" over four dead gardens.
|
||||
// Outlasting the week is not surviving it, and the end card is the last
|
||||
// thing this game says to anyone.
|
||||
assertEq(gradeFor(5), 'clean', 'five held is the only clean week');
|
||||
assertEq(gradeFor(4), 'scraped');
|
||||
assertEq(gradeFor(3), 'scraped');
|
||||
assertEq(gradeFor(1), 'solvent', 'one garden out of five is not a triumph');
|
||||
assertEq(gradeFor(0), 'solvent');
|
||||
});
|
||||
|
||||
t.test('going broke ends the week, but never on the final night', () => {
|
||||
const def = { baseCurve: [[0, 10]], gusts: { powBase: 5, powRamp: 5 } };
|
||||
const ruin = { hp: 0, win: false, collateral: [{ what: 'gnome', cost: 25 }], intactHardwareValue: 0 };
|
||||
|
||||
const w = createWeek();
|
||||
const s = w.settle(ruin, def, 80); // spend the lot, get almost nothing back
|
||||
assert(s.bankAfter < BROKE_BELOW, `bank ${s.bankAfter} should be under the $${BROKE_BELOW} floor`);
|
||||
assertEq(s.outcome, 'gameover', 'you cannot rig four corners, so the week is over');
|
||||
|
||||
// On the last night there is no next shop to be unable to afford, so being
|
||||
// broke is just being broke — the week still finished.
|
||||
const w2 = createWeek();
|
||||
for (let i = 0; i < 4; i++) w2.advance();
|
||||
assertEq(w2.settle(ruin, def, 80).outcome, 'win', 'night five always ends the week, not the run');
|
||||
});
|
||||
|
||||
// --- the wind router -----------------------------------------------------
|
||||
// Loaded HERE, not inside t.test(). These two were written `async` and
|
||||
// Suite.test() cannot await — so they were recorded as passes while asserting
|
||||
|
||||
@ -177,13 +177,58 @@ async function fly(yard, session, stormName, { repair = false, broom = false } =
|
||||
// not. See THREADS.
|
||||
{
|
||||
const settleWind = calmWind || wind;
|
||||
const period = Math.max(1, (calmDef && calmDef.duration) || 1);
|
||||
// Integrator fix (Sprint-8 merge): cycling t over the calm storm's FULL
|
||||
// duration replayed all of storm_01's gusts inside 12 s of sim, so the rig
|
||||
// arrived at "entry" mid-gust and D's guard (correctly) refused it. Prep in
|
||||
// the live game is the calm day's opening minutes, not its highlight reel —
|
||||
// hold the settle inside storm_01's pre-gust window (first gust >= 3 s).
|
||||
const period = 3;
|
||||
for (let i = 0, n = Math.round(12 / FIXED_DT); i < n; i++) {
|
||||
rig.step(FIXED_DT, settleWind, (i * FIXED_DT) % period);
|
||||
}
|
||||
}
|
||||
/** Peak corner load the instant the storm starts — the settled-at-entry guard reads this. */
|
||||
const entryPeak = Math.max(...rig.corners.map((c) => c.load || 0));
|
||||
/**
|
||||
* D's settled-at-entry guard, REDESIGNED (SPRINT9, B+D). It now measures SHAPE, not load.
|
||||
*
|
||||
* The guard exists for one reason: a harness that rigs and storms in the same tick measures a
|
||||
* cloth still falling out of its flat _build() shape, and pretends that is a rig. That bug cost
|
||||
* two sprints, so the settle above has to prove it worked.
|
||||
*
|
||||
* The Sprint-8 version asked the question with LOAD and could not answer it. Measured tonight,
|
||||
* why every load-based form fails:
|
||||
* · in CALM (what the rig settles in) there is no transient to see at all — worst-corner mean
|
||||
* reads 0.30 kN unsettled vs 0.47 kN settled, i.e. the unsettled rig is LIGHTER, and the
|
||||
* trend test passes at every settle length from 0 s to 20 s. A guard that cannot fail is
|
||||
* decoration.
|
||||
* · in the STORM at a held t=0 it read a 105% "trend" — but that is the calm→storm step change,
|
||||
* which the REAL GAME ALSO HAS (`wind.use(to === 'storm' ? winds[stormKey] : calmWind)` on the
|
||||
* phase change). It was never a harness artifact; the suite was being faithful and the guard
|
||||
* was calling it a bug.
|
||||
* · the integrator's ponding diagnosis at the Sprint-8 merge does not hold either: every storm's
|
||||
* rain curve starts at [0, 0], so `storm_02.rainMmPerHour(0)` is 0.0 mm/h and a held clock
|
||||
* rains nothing. (Their 2 s windows were also shorter than the cloth's breath — 2 s reads a
|
||||
* 32% trend on a settled rig where 3 s reads 6%.)
|
||||
*
|
||||
* So ask the physical question instead: HAS THE CLOTH STOPPED MOVING. Mean node drift separates
|
||||
* cleanly, ~6x either side of the line, and unlike load it cannot be confused by wind or water:
|
||||
* unsettled (0 s) → 212 mm/s (cover quad) · 208 mm/s (miss quad)
|
||||
* settled (8-20 s) → 35 mm/s worst case, typically 4-6
|
||||
* The integrator's 600 N floor was a sound amendment to the LOAD design and is not carried over —
|
||||
* drift has no units of force to need a floor, and it needs no threshold on "does it matter"
|
||||
* because 212-vs-35 is not a judgement call.
|
||||
*/
|
||||
const settleDriftMmPerSec = (() => {
|
||||
const before = Float64Array.from(rig.pos);
|
||||
const secs = 2;
|
||||
for (let i = 0, n = Math.round(secs / FIXED_DT); i < n; i++) {
|
||||
rig.step(FIXED_DT, calmWind, ((12 + i * FIXED_DT) % Math.max(1, calmDef.duration)));
|
||||
}
|
||||
let sum = 0;
|
||||
for (let i = 0; i < before.length; i += 3) {
|
||||
sum += Math.hypot(rig.pos[i] - before[i], rig.pos[i + 1] - before[i + 1], rig.pos[i + 2] - before[i + 2]);
|
||||
}
|
||||
return (sum / (before.length / 3)) * 1000 / secs;
|
||||
})();
|
||||
|
||||
let hp = 100, pond = 0, used = 0;
|
||||
const steps = Math.round(def.duration / FIXED_DT);
|
||||
@ -215,8 +260,8 @@ async function fly(yard, session, stormName, { repair = false, broom = false } =
|
||||
lost: rig.corners.filter((c) => c.broken).length,
|
||||
spent: START_BUDGET - session.budget,
|
||||
pond: Math.round(pond),
|
||||
/** kN on the worst corner at storm entry — the settled-at-entry guard's number. */
|
||||
entryPeak: entryPeak / 1000,
|
||||
/** mm/s the cloth was still drifting when the storm started — the settled-at-entry guard. */
|
||||
settleDrift: settleDriftMmPerSec,
|
||||
};
|
||||
}
|
||||
|
||||
@ -251,102 +296,73 @@ export default async function run(t) {
|
||||
|
||||
// --- then judge -----------------------------------------------------------
|
||||
|
||||
// SPRINT7 gate 0 — the skip is gone, and the dispute is settled by physics.
|
||||
// SPRINT8 gate 0' — CLOSED. The harnesses agree; the disagreement was a miscount.
|
||||
//
|
||||
// Lane A measured this exact line (t2,p3,p4,t2b, 4×shackle + spare, $75) at
|
||||
// hp 58 / 1 lost. This suite says hp 36 / 2 lost. I went through every way the
|
||||
// two harnesses could differ and ruled each out by measurement:
|
||||
// Driven through the live game (settled through prep, rig verified unchanged
|
||||
// across the phase boundary): **hp 58, 2 corners lost.** This suite: hp 59,
|
||||
// 2 lost. A's hp 58 was right and reproduces to a point; A's "1 lost" was the
|
||||
// miscount. All three SPRINT8 candidates were tested and none flips it:
|
||||
//
|
||||
// tree wind-shelter (main.js:369 calls setSheltersFromTrees, this didn't)
|
||||
// ... on vs off: hp 36 either way
|
||||
// tension (this hardcoded 0.9, the game defaults 1.0)
|
||||
// ... 0.6 / 0.75 / 0.9 / 1.0: hp 36, 2 lost, all four
|
||||
// drain wiring (garden.step's signature changed to take hail+rain separately)
|
||||
// ... same arithmetic: 5.0/0.25 × 0.9. Identical.
|
||||
// yard geometry (the bug that bit this file once already)
|
||||
// ... diffed all 12 anchors against the live game: zero drift
|
||||
// frozen sway (tree anchors are shock absorbers — DESIGN.md)
|
||||
// ... live sway is WORSE, not better: t2 4.4 → 4.6 kN
|
||||
// V1 settle under live calm wind + world.update sway -> 2 lost, t2 4.4
|
||||
// V2 ... and live sway through the storm too -> 2 lost, t2 4.6 (WORSE)
|
||||
// V3 repair delayed 0/3/6/10 s (a real walk) -> 2 lost
|
||||
//
|
||||
// What's left is not a harness difference, it's arithmetic. On this quad t2
|
||||
// peaks at 4.4-4.9 kN and a shackle is rated 3.2. t2 cannot hold, under any
|
||||
// variation above. Losing it spends the only spare; then p3 (3.7) or t2b (3.4)
|
||||
// — both also over 3.2 — goes too. Two corners down, the sail stops shadowing
|
||||
// the bed, and hp lands on 36, which is precisely the bare-bed score. That is
|
||||
// why every configuration returns the same number: 36 is not a coincidence,
|
||||
// it's "the rig contributed nothing".
|
||||
// Nothing could flip it, because losing 2 is not a bug — it is the shop.
|
||||
// Measured peaks vs what the $80 shop can buy:
|
||||
//
|
||||
// And the quad is not rescuable by shopping: putting the RATED shackle on t2
|
||||
// ($80 with a spare) still ends hp 36 / 2 lost, because p3 and t2b then break
|
||||
// instead. This quad needs THREE corners above shackle grade and $80 buys two.
|
||||
// t2 4.6 kN -> needs the $30 rated shackle
|
||||
// t2b 3.5 kN -> needs the $30 rated shackle
|
||||
// p3 3.5 kN -> needs the $30 rated shackle
|
||||
// p4 2.9 kN -> a $15 shackle holds
|
||||
// ------------------------------------------------
|
||||
// holding all four: $105. With the spare a repair needs: $120. Budget: $80.
|
||||
//
|
||||
// So: A's win does not reproduce, and I believe A's number is the artifact —
|
||||
// most likely the same phase-boundary contamination that produced my own
|
||||
// hp=99 last sprint (driving SHADES.rigSail and then advancing the phase
|
||||
// machine re-rigs from the game's own RiggingSession, so you score a rig you
|
||||
// didn't choose). A: the check is one line — assert rig.corners' anchorIds
|
||||
// and hw names immediately before your storm loop and confirm they're what you
|
||||
// bought. If they are, I'm wrong and the cause is still open.
|
||||
t.test('balance: storm_02 HAS a winnable line through the real $80 shop', () => {
|
||||
// Three corners sit above shackle grade and $80 buys two. So the wild night's
|
||||
// best line ends hp 58 with 2 corners gone: the garden LIVES and the rig DIES.
|
||||
//
|
||||
// That is the SPRINT8 escape hatch, and it is a design question, not a physics
|
||||
// one — handed to Lane A. `lost < 2` says this is a loss; DESIGN.md says it is
|
||||
// the story ("a sail that dies saving the garden"). Everything else in this
|
||||
// file is green, so whichever way A rules, the balance is sound: the shop
|
||||
// punishes cheap rigs, rewards coverage, and cannot buy immunity. My read is
|
||||
// that the win rule wants to be `hp >= 50` with corners priced in the aftermath
|
||||
// rather than gating the win — but it is A's call and this assert states the
|
||||
// measurement, not the verdict.
|
||||
t.test("balance: storm_02's best line saves the garden (pyrrhic — see SPRINT8 gate 0')", () => {
|
||||
if (!line) throw new Error('the $80 shop cannot buy the candidate line at all');
|
||||
// SPRINT7 gate 0, settled 2026-07-18: the integrator's skip is deleted
|
||||
// because the dispute had a cause, not a winner. This suite built skyfx
|
||||
// WITHOUT a camera, and skyfx.step() opens `if (!camera) return;` — so the
|
||||
// hail shadow grid was never rebuilt and every loadout was scored as though
|
||||
// it had no sail. That is why this line read hp 36: 36 IS the bare-bed
|
||||
// number. With a camera it reads what Lane A measured. Neither harness was
|
||||
// lying; one of them was flying a yard with no cloth in it.
|
||||
if (!WIN(line.hp, line.lost)) {
|
||||
// SPRINT8 gate 0' — CLOSED, and this suite was RIGHT. The live game and this harness now
|
||||
// agree, measured by Lane D 2026-07-18 on current main (fresh page, A's exact line,
|
||||
// t2+p3+p4+t2b on 4×shackle+spare, tension 1.0):
|
||||
// live game → hp 58, 2 lost [t2,t2b], t2 peak 4.55 kN
|
||||
// this suite → hp 58, 2 lost [t2,t2b], t2 peak 4.54 kN
|
||||
// Every suite-vs-game difference gate 0' listed has now been tested one at a time and NONE
|
||||
// of them moves the corner count: live-calm settle (entry 1.94→0.40 kN, verdict unchanged),
|
||||
// live tree sway (t2 4.33→4.55, verdict unchanged), walked repair timing (unchanged).
|
||||
// Anchors are bit-identical between harnesses, ring order is identical (p4,t2,t2b,p3), and
|
||||
// wind.sample() at t2 is identical to 2 dp (36.49 m/s @ t=75.9).
|
||||
//
|
||||
// RETRACTED, on the record: Lane D's "the settle flips 2 lost → 1" (SPRINT7). It does not
|
||||
// reproduce — 0 s and 12 s settle both end 2 lost, because the storm's own peak (4.54 kN at
|
||||
// t=75.9) dwarfs the attach transient. The settle is a real fidelity fix and NOT the
|
||||
// corner-count cause. A's hp 58 reproduces exactly; A's "1 lost" reproduces in neither
|
||||
// harness.
|
||||
//
|
||||
// What's left is B's arithmetic, which was correct from the first post: t2 pulls ~4.5 kN and
|
||||
// a shackle is rated 3.2 kN. The corner cannot hold at any tension, and the spare cannot save
|
||||
// it — the repaired corner simply blows again (measured: t2b blew @9 s, repaired, blew again).
|
||||
// So this is no longer an engineering question. It is SPRINT8's designed escape hatch:
|
||||
// hp 58 CLEARS the 50 bar while 2 corners are lost, i.e. the player saves the garden and
|
||||
// loses the sail — DESIGN.md's own story — and the win rule (`hp>=50 && lost<2`) calls it a
|
||||
// loss. Either the rule admits a PYRRHIC WIN, or the shop must be able to buy a third
|
||||
// above-shackle corner ($80 buys two). That is a design call, not a harness bug. See THREADS.
|
||||
throw new Error(
|
||||
`no winnable line: ${COVER_QUAD.join(',')} on 4×shackle+spare ($${line.spent}) ended ` +
|
||||
`hp=${line.hp}, lost=${line.lost}/4 (need hp>=50, lost<2). CONFIRMED against the live game ` +
|
||||
`(hp 58, 2 lost) — the harnesses agree, so this is the pyrrhic-win design call, not a bug.`);
|
||||
// The garden half — the part the player is actually protecting — must hold.
|
||||
if (line.hp < 50) {
|
||||
throw new Error(`the wild night's best $${line.spent} line let the garden die: hp=${line.hp} ` +
|
||||
`(need >=50). This is a real balance regression, not the pyrrhic-win question.`);
|
||||
}
|
||||
return `$${line.spent} on ${COVER_QUAD.join(',')} -> hp ${line.hp}, ${line.lost}/4 lost`;
|
||||
const pyrrhic = line.lost >= 2;
|
||||
return `$${line.spent} on ${COVER_QUAD.join(',')} -> garden hp ${line.hp}` +
|
||||
(pyrrhic
|
||||
? `, but ${line.lost}/4 corners gone — PYRRHIC. Holding all four costs $105 (+$15 spare) on an $80 budget; A owns the win rule.`
|
||||
: `, ${line.lost}/4 lost — a clean win.`);
|
||||
});
|
||||
|
||||
/**
|
||||
* D's settled-at-entry guard (SPRINT8 §Lane D). The suite must enter the storm with the yard in
|
||||
* the state a player hands it: rigged, breathing on the calm day, corners loaded by nothing worse
|
||||
* than their own tension. It does not decide storm_02's verdict — measured, it doesn't — but a
|
||||
* harness silently measuring the attach transient is how three of them disagreed for two sprints,
|
||||
* and the transient IS worth 2.7× on tree corners in the moment it exists.
|
||||
* D's settled-at-entry guard, redesigned to measure SHAPE (SPRINT9, B+D). Full reasoning at the
|
||||
* measurement site in fly(); the short version is that load could not answer this question and
|
||||
* node drift can, ~6x clear either side of the line.
|
||||
*
|
||||
* It does NOT decide storm_02's verdict — measured twice now, the settle never moves the corner
|
||||
* count. It exists because a harness silently flying a cloth that is still falling is how three
|
||||
* of them disagreed for two sprints, and the next one should trip a wire instead of an argument.
|
||||
*/
|
||||
t.test('harness: the yard is SETTLED when the storm starts', () => {
|
||||
t.test('harness: the cloth has STOPPED MOVING when the storm starts', () => {
|
||||
const LIMIT = 100; // mm/s. Measured: 212 unsettled, 35 worst settled breath.
|
||||
const runs = [['line', line], ['cheap', cheap], ['gentle', gentle]].filter(([, r]) => r);
|
||||
for (const [name, r] of runs) {
|
||||
if (!(r.entryPeak < 1.0)) {
|
||||
if (!(r.settleDrift < LIMIT)) {
|
||||
throw new Error(
|
||||
`${name} entered the storm carrying ${r.entryPeak.toFixed(2)} kN — that is an attach ` +
|
||||
'transient, not a rig. Settle on the calm day with a running clock, as main.js does.');
|
||||
`${name} entered the storm with the cloth still drifting ${r.settleDrift.toFixed(0)} mm/s ` +
|
||||
`(limit ${LIMIT}). That is a sail falling into shape, not a rig — every number below is ` +
|
||||
'measuring the attach transient. Lengthen the settle in fly().');
|
||||
}
|
||||
}
|
||||
return `entry loads: ${runs.map(([n, r]) => `${n} ${r.entryPeak.toFixed(2)} kN`).join(' · ')}`;
|
||||
return `settle drift: ${runs.map(([n, r]) => `${n} ${r.settleDrift.toFixed(1)} mm/s`).join(' · ')}`;
|
||||
});
|
||||
|
||||
t.test('balance: storm_02 punishes a cheap rig on the same quad', () => {
|
||||
|
||||
@ -16,7 +16,7 @@
|
||||
import * as THREE from '../../vendor/three.module.js';
|
||||
import { assert, fixedLoop } from '../testkit.js';
|
||||
import { FIXED_DT, checkContract, DEBRIS_PIECE_FIELDS } from '../contracts.js';
|
||||
import { loadStorm, createWind } from '../weather.js';
|
||||
import { loadStorm, createWind, forecastLines } from '../weather.js';
|
||||
import { createDebris } from '../debris.js';
|
||||
import { createSkyFx, RainShadow } from '../skyfx.js';
|
||||
import { SailRig, HARDWARE } from '../sail.js';
|
||||
@ -344,6 +344,76 @@ export default async function run(t) {
|
||||
sky.dispose();
|
||||
});
|
||||
|
||||
// The trap that cost gate 0 two sprints, asserted so it cannot come back.
|
||||
// skyfx.step() used to open `if (!camera) return`, so a headless harness
|
||||
// skipped the shadow rebuild and scored every rig as if the sail weren't
|
||||
// there. A camera is a view, not a weather system: the grids are physics and
|
||||
// must build without one. If someone re-adds an early return, this goes red.
|
||||
t.test('skyfx shelters the bed with NO camera — the grids are physics, not view', () => {
|
||||
const bed = { x: 0, z: 0, w: 4, d: 3 };
|
||||
const panel = { pos: new Float32Array([-3, 4, -3, 3, 4, -3, 3, 4, 3, -3, 4, 3]), tris: [0, 1, 2, 0, 2, 3] };
|
||||
|
||||
const run = (withCamera) => {
|
||||
const scene = new THREE.Scene();
|
||||
const wind = createWind(storms.storm_02_wildnight);
|
||||
const sky = createSkyFx(withCamera
|
||||
? { scene, camera: new THREE.PerspectiveCamera(), wind }
|
||||
: { scene, wind }); // headless: no camera at all
|
||||
fixedLoop(2, FIXED_DT, (dt, time) => sky.step(dt, 55 + time, { sail: panel }));
|
||||
const out = {
|
||||
hailShadow: sky.hailShadowOver(bed),
|
||||
rainShadow: sky.rainShadowOver(bed),
|
||||
hailExp: sky.gardenHailExposure(bed, 56),
|
||||
hail: sky.hailAmount,
|
||||
};
|
||||
sky.dispose();
|
||||
return out;
|
||||
};
|
||||
|
||||
const headless = run(false);
|
||||
const viewed = run(true);
|
||||
assert(headless.hailShadow > 0.9,
|
||||
`no camera → hail shadow ${headless.hailShadow.toFixed(2)} — the grid did not build, the sail is invisible to scoring`);
|
||||
assert(headless.hail > 0.5, 'no camera → hail intensity was not tracked');
|
||||
assert(headless.hailExp < 0.1,
|
||||
`no camera → bed reads ${headless.hailExp.toFixed(2)} exposed under a panel — this is the hp-36 bare-bed bug`);
|
||||
// and a camera must not CHANGE the physics, only add the view
|
||||
assert(Math.abs(headless.hailShadow - viewed.hailShadow) < 1e-9,
|
||||
`the camera changed the hail shadow: ${headless.hailShadow} vs ${viewed.hailShadow}`);
|
||||
assert(Math.abs(headless.rainShadow - viewed.rainShadow) < 1e-9,
|
||||
`the camera changed the rain shadow: ${headless.rainShadow} vs ${viewed.rainShadow}`);
|
||||
});
|
||||
|
||||
// The card's copy, not just the model — this is what a player actually reads.
|
||||
t.test('forecastLines: tonight is exact, a week out hedges, never a bare NaN', () => {
|
||||
const def = storms.storm_02_wildnight;
|
||||
|
||||
const tonight = forecastLines(def, 0);
|
||||
assert(tonight.name === 'WILD NIGHT', `name reads "${tonight.name}"`);
|
||||
assert(tonight.night === true, 'the wild night should read as a NIGHT');
|
||||
assert(!/–/.test(tonight.wind), `tonight's wind should be exact, got "${tonight.wind}"`);
|
||||
assert(tonight.confidence === '', 'tonight should not print a confidence line — 100% is noise');
|
||||
assert(/hail likely/.test(tonight.rain), `tonight should call the hail: "${tonight.rain}"`);
|
||||
|
||||
const far = forecastLines(def, 1);
|
||||
assert(/–/.test(far.wind), `a week out should hedge with a range, got "${far.wind}"`);
|
||||
assert(/confidence/.test(far.confidence), 'a distant forecast should state its confidence');
|
||||
|
||||
// no NaN/undefined can reach the card, for any storm at any lead
|
||||
for (const [name, d] of Object.entries(storms)) {
|
||||
for (const lead of [0, 0.5, 1]) {
|
||||
const f = forecastLines(d, lead);
|
||||
for (const k of ['name', 'wind', 'rain', 'confidence']) {
|
||||
assert(typeof f[k] === 'string' && !/NaN|undefined/.test(f[k]),
|
||||
`${name} @lead ${lead}: ${k} reads "${f[k]}"`);
|
||||
}
|
||||
}
|
||||
}
|
||||
// a hail-free storm must not advertise hail
|
||||
assert(!/hail/.test(forecastLines(storms.storm_01_gentle, 0).rain),
|
||||
'the gentle storm advertised hail it does not have');
|
||||
});
|
||||
|
||||
t.test('every storm in data/storms/ loads and validates', () => {
|
||||
// loadStorm throws on invalid, so reaching here with all of them is the pass
|
||||
assert(Object.keys(storms).length === STORMS.length, 'a storm failed to load');
|
||||
|
||||
@ -14,6 +14,9 @@
|
||||
import { PlayerSim, STATES, TUNE, clipFor } from '../player.sim.js';
|
||||
import { Interact, wireYardActions } from '../interact.js';
|
||||
import { createBroom, BROOM_TUNE } from '../broom.js';
|
||||
// The REAL rule, not the fakeLadder's hand-copied duplicate of it — a rule the suite re-implements
|
||||
// is a rule the suite cannot catch drifting. (ladder.js is headless-importable for this reason.)
|
||||
import { needsLadder as realNeedsLadder } from '../ladder.js';
|
||||
import { assert, assertEq, assertClose, assertLess, fixedLoop } from '../testkit.js';
|
||||
import { FIXED_DT } from '../contracts.js';
|
||||
import { loadStorm, createWind } from '../weather.js';
|
||||
@ -438,14 +441,29 @@ export default async function run(t) {
|
||||
});
|
||||
|
||||
t.test('ladder: needsLadder is scoped to the fascia, not to everything above head height', () => {
|
||||
const L = fakeLadder();
|
||||
assert(L.needsLadder({ type: 'house', pos: { y: 2.48 } }), 'the fascia bracket needs it');
|
||||
assert(!L.needsLadder({ type: 'post', pos: { y: 3.95 } }),
|
||||
assert(realNeedsLadder({ type: 'house', pos: { y: 2.48 } }), 'the fascia bracket needs it');
|
||||
assert(!realNeedsLadder({ type: 'post', pos: { y: 3.95 } }),
|
||||
'a 4 m post does NOT — you tension it from a cleat at the base');
|
||||
assert(!L.needsLadder({ type: 'tree', pos: { y: 5.05 } }),
|
||||
assert(!realNeedsLadder({ type: 'tree', pos: { y: 5.05 } }),
|
||||
'nor a tree limb — that is a strop you throw');
|
||||
});
|
||||
|
||||
t.test('ladder: a site can DECLARE which anchors are worked at the bracket', () => {
|
||||
// SPRINT9 §Lane D, ahead of site_02. The corner block has a CARPORT, and contracts.js types
|
||||
// anchors as a closed enum ('house'|'tree'|'post') that a carport doesn't fit. The failure mode
|
||||
// matters more than the feature: if needsLadder says false, interact's canReach returns true
|
||||
// UNCONDITIONALLY, so the player re-rigs a 2.6 m bracket from the grass and the mechanic
|
||||
// silently stops existing. Data first, site_01's type as the fallback.
|
||||
assert(realNeedsLadder({ type: 'carport', pos: { y: 2.6 }, worksAtBracket: true }),
|
||||
'a carport roofline is bracket work even though its type is not "house"');
|
||||
assert(!realNeedsLadder({ type: 'house', pos: { y: 2.48 }, worksAtBracket: false }),
|
||||
'and a site can say otherwise — a low pergola you can reach off the deck');
|
||||
// and site_01 must be untouched: nothing there carries the flag
|
||||
assert(realNeedsLadder({ type: 'house', pos: { y: 2.48 } }), 'no flag → site_01 behaviour');
|
||||
assert(!realNeedsLadder({ type: 'post', pos: { y: 3.95 } }), 'no flag → post is still ground work');
|
||||
assert(!realNeedsLadder(null) && !realNeedsLadder(undefined), 'and it never throws on a gap');
|
||||
});
|
||||
|
||||
t.test('ladder: fascia re-rig is gated on being up it; post re-rig is not', () => {
|
||||
const p = new PlayerSim({ start: { x: 0, y: 0, z: 0 } });
|
||||
const L = fakeLadder({ player: p });
|
||||
|
||||
@ -17,6 +17,58 @@ import {
|
||||
|
||||
export { GUST, validateStorm, RAIN_TIME_COMPRESSION, hailBlockFor, stormStats, forecastFor };
|
||||
|
||||
const kmh = (ms) => ms * 3.6;
|
||||
const band = (b, fmt) => (b.hi - b.lo < 0.05 ? fmt(b.lo) : `${fmt(b.lo)}–${fmt(b.hi)}`);
|
||||
|
||||
/**
|
||||
* The forecast card's two stat lines, already worded — DESIGN.md's partial
|
||||
* information made visible. Lane A owns the card; this owns the numbers, so the
|
||||
* card stays one call instead of re-deriving the storm inline.
|
||||
*
|
||||
* `lead` is how far out the night is: 0 = tonight (exact numbers, reads exactly
|
||||
* as the card always has), 1 = the far end of the week (wide bands, low
|
||||
* confidence). The bands ALWAYS contain the truth — a forecast may be vague but
|
||||
* it must never rule out what actually happens, or a player who rigs for the top
|
||||
* of the stated range gets ambushed.
|
||||
*
|
||||
* Numbers are MEASURED (stormStats), not estimated: the card's old inline
|
||||
* `baseCurve peak + powBase + powRamp` read 30 m/s for storm_02, which really
|
||||
* gusts to 32.3, because gust power is drawn per gust and rides a ramp.
|
||||
*
|
||||
* @param {object} def parsed storm JSON
|
||||
* @param {number} [lead] 0..1
|
||||
* @returns {{name, night, wind, rain, confidence, hail, truth}}
|
||||
*/
|
||||
export function forecastLines(def, lead = 0) {
|
||||
const f = forecastFor(def, lead);
|
||||
const i = (v) => v.toFixed(0);
|
||||
|
||||
const sustained = band(f.sustained, i);
|
||||
const gusts = band({ lo: kmh(f.gustPeak.lo), hi: kmh(f.gustPeak.hi) }, i);
|
||||
const sustainedKmh = band({ lo: kmh(f.sustained.lo), hi: kmh(f.sustained.hi) }, i);
|
||||
|
||||
// rain reads as a word, and a vague forecast hedges across two
|
||||
const word = (v) => (v >= 0.8 ? 'heavy' : v >= 0.4 ? 'steady' : 'light');
|
||||
const rainWord = word(f.rain.lo) === word(f.rain.hi)
|
||||
? word(f.rain.hi) : `${word(f.rain.lo)}–${word(f.rain.hi)}`;
|
||||
|
||||
const change = f.changeAt
|
||||
? `· southerly change ${lead > 0 ? band(f.changeAt, i) + 's' : `at ${i(f.changeAt.lo)}s`}`
|
||||
: '· no change forecast';
|
||||
const hail = f.hail.chance === 'none' ? '' : `· hail ${f.hail.chance}`;
|
||||
|
||||
return {
|
||||
name: (def.name ?? '').replace(/_/g, ' ').toUpperCase(),
|
||||
night: (def.sky?.night ?? (def.sky?.darkness ?? 0) > 0.6),
|
||||
wind: `sustained to ${sustained} m/s (${sustainedKmh} km/h) · gusts to ~${gusts} km/h`,
|
||||
rain: `rain ${rainWord} ${change} ${hail}`.trim(),
|
||||
// Only worth showing when it isn't tonight — "CONFIDENCE 100%" is noise.
|
||||
confidence: lead > 0 ? `forecast confidence ${Math.round(f.confidence * 100)}%` : '',
|
||||
hail: f.hail,
|
||||
truth: f.truth,
|
||||
};
|
||||
}
|
||||
|
||||
// Resolved against this module, not the server root: server.py serves the repo
|
||||
// root (so the 2D prototype stays reachable), but the demo bench serves web/.
|
||||
// import.meta.url is right under both, and under whatever Lane A does next.
|
||||
|
||||
222
web/world/js/week.js
Normal file
222
web/world/js/week.js
Normal file
@ -0,0 +1,222 @@
|
||||
/**
|
||||
* SHADES — the week. Lane A owns this file.
|
||||
*
|
||||
* Five nights, one yard, one wallet. This is deliberately a thin wrapper around
|
||||
* the phase machine rather than a new system: main.js already knows how to run
|
||||
* forecast → prep → storm → aftermath, and the week's whole job is to answer
|
||||
* three questions between rounds — which storm is tonight, how much money do you
|
||||
* have, and is it over.
|
||||
*
|
||||
* Zero imports beyond contracts, and no THREE: the money and the ladder of
|
||||
* nights are pure data, so they're testable at fixed cost with no browser. The
|
||||
* only thing that touches the screen is main.js reading these numbers.
|
||||
*/
|
||||
|
||||
import { START_BUDGET, HARDWARE } from './contracts.js';
|
||||
|
||||
/**
|
||||
* The ladder. Escalating, and each rung introduces one new idea rather than just
|
||||
* more wind — that's Lane C's authoring, not my ordering:
|
||||
* 1 Sea Breeze gust 10.5, no hail — the tutorial: nothing can hurt you
|
||||
* 2 Southerly Buster gust 20.0, hail — the change, and hail, arrive
|
||||
* 3 Early Buster gust 20.0, hail — same teeth, change comes EARLY
|
||||
* 4 Wild Night gust 30.0, hail — the one the whole repo tuned for
|
||||
* 5 Ice Night gust 28.5, hail — less wind, more ice
|
||||
* Night 3 is the trap: it looks like night 2 on the forecast card and isn't.
|
||||
*/
|
||||
export const NIGHTS = [
|
||||
'storm_01_gentle',
|
||||
'storm_03_southerly',
|
||||
'storm_03b_earlybuster',
|
||||
'storm_02_wildnight',
|
||||
'storm_02b_icenight',
|
||||
];
|
||||
|
||||
/**
|
||||
* The economy, in one place because it is the thing most likely to need tuning
|
||||
* once somebody actually plays five nights in a row.
|
||||
*
|
||||
* Shape (SPRINT8 §gate 1): pay = fee by severity + garden bonus + intact
|
||||
* hardware refund − collateral. Two of those needed a judgement call and both
|
||||
* are the difference between a week with stakes and a week you cannot lose:
|
||||
*
|
||||
* - **A lost night pays a fraction of the fee, not zero and not all of it.**
|
||||
* Zero is unrecoverable and reads as punishment; full pay means failure costs
|
||||
* only the broken shackle, and the bank only ever climbs. DESIGN.md's warranty
|
||||
* callout is the source: you turn up, you're just not getting paid for it.
|
||||
* - **Hardware comes back at half.** Full refund makes gear effectively free —
|
||||
* the only sink left is breakage, the bank grows every night, and "broke =
|
||||
* game over" becomes unreachable. Half is also the honest number: a shackle
|
||||
* that rode out a gale has been fatigued, its pin worked loose, and DESIGN.md
|
||||
* already says flogging unscrews unmoused pins. You can re-use it; you can't
|
||||
* call it new.
|
||||
*/
|
||||
export const PAY = {
|
||||
/**
|
||||
* Client's fee for the job, scaled off the storm's worst gust.
|
||||
*
|
||||
* The constants are set by the shape of the week, not by taste — measured by
|
||||
* playing all five nights at fixed skill. A fee has to be worth roughly
|
||||
* two-thirds of a good rig ($75): any smaller and one bad night is instant
|
||||
* game over (at `8 + gust` a disaster night paid $13 against a $75 rig and
|
||||
* ended the week on night ONE, which is a punishment, not a difficulty); any
|
||||
* larger and the bank runs away and night five is trivially affordable.
|
||||
* At `25 + 1.6·gust` a disaster leaves you at ~$26 — alive, but rigging the
|
||||
* next night on carabiners, which is the death spiral doing its job.
|
||||
*/
|
||||
feeFor: (gustPeak) => Math.round(25 + gustPeak * 1.6),
|
||||
/** A lost night still pays this share — you turned up, it just went wrong. */
|
||||
lostNightShare: 0.35,
|
||||
/** Garden bonus at hp=100. Scales linearly; this is the main earner. */
|
||||
gardenBonusMax: 45,
|
||||
/** What surviving hardware is worth back. Fatigued, not new. */
|
||||
refundShare: 0.5,
|
||||
};
|
||||
|
||||
/**
|
||||
* Below this you cannot rig four corners at all — four carabiners is the floor.
|
||||
*
|
||||
* ⚠️ MEASURED, OPEN, AND FOR A PLAYTEST TO SETTLE — not a guess, and written
|
||||
* here because the numbers are only visible once you run five nights:
|
||||
*
|
||||
* 1. **A competent week runs away with the money.** Holding 4/4 at hp 70 every
|
||||
* night takes the bank 80 → 116 → 167 → 218 → 285 → 350. By night three you
|
||||
* can already afford four rated shackles ($120) and the wild night stops
|
||||
* being a decision. The fee is the lever; it is deliberately NOT tuned down
|
||||
* yet, because the fix might equally be that later nights should cost more
|
||||
* to rig (a bigger sail, a second bed) — that's Sprint 9's content question,
|
||||
* not a constant I should quietly pick tonight.
|
||||
* 2. **A floor-scraping week may never actually go broke.** At $20 a cheap rig
|
||||
* earns back roughly what it costs, so the bank can sit just above this line
|
||||
* indefinitely, losing every garden. The grade fixes what the END CARD says
|
||||
* about that (see gradeFor) but not whether 'gameover' is reachable at all
|
||||
* from a slow bleed rather than one disaster.
|
||||
*
|
||||
* I could not settle either from the harness: my own bad-player model handed
|
||||
* back a fixed $30 of intact hardware no matter what it spent, which flattered
|
||||
* the bottom of the curve and is exactly the class of mistake this repo has
|
||||
* caught me making all project. Both need a human playing five nights.
|
||||
*/
|
||||
export const BROKE_BELOW = HARDWARE[0].cost * 4;
|
||||
|
||||
/**
|
||||
* How the week is remembered, by gardens actually held.
|
||||
*
|
||||
* SPRINT8 gave Lane A the win wording, and this is the ruling: the end card is
|
||||
* the last thing SHADES says to a player, so it does not get to lie the way the
|
||||
* aftermath verdict used to. Three grades, and E's copy carries two of them —
|
||||
* their primary for a clean week, their own alternate for a scraped one. The
|
||||
* third is mine, because E never wrote words for "you stayed solvent while the
|
||||
* client's garden died four times", and until this was measured nobody knew the
|
||||
* game could even produce that ending.
|
||||
*
|
||||
* @param {number} held gardens saved, 0..5
|
||||
*/
|
||||
export function gradeFor(held) {
|
||||
if (held >= 5) return 'clean';
|
||||
if (held >= 3) return 'scraped';
|
||||
return 'solvent';
|
||||
}
|
||||
|
||||
/** Worst gust a storm def can throw — the severity signal the fee reads. */
|
||||
export function gustPeakOf(def) {
|
||||
const base = Math.max(...def.baseCurve.map((p) => p[1]));
|
||||
const g = def.gusts ?? {};
|
||||
return base + (g.powBase ?? 0) + (g.powRamp ?? 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @typedef {object} Settlement
|
||||
* @property {number} fee client's payment for the job
|
||||
* @property {number} bonus garden bonus
|
||||
* @property {number} refund intact hardware recovered, at half
|
||||
* @property {number} collateral what your failure broke of theirs
|
||||
* @property {number} pay fee + bonus + refund − collateral
|
||||
* @property {number} bankBefore
|
||||
* @property {number} bankAfter
|
||||
* @property {'continue'|'win'|'gameover'} outcome
|
||||
*/
|
||||
|
||||
/**
|
||||
* @param {object} [opts]
|
||||
* @param {number} [opts.bank=START_BUDGET]
|
||||
*/
|
||||
export function createWeek(opts = {}) {
|
||||
const startBank = opts.bank ?? START_BUDGET;
|
||||
let index = 0; // 0-based into NIGHTS
|
||||
let bank = startBank;
|
||||
let done = false;
|
||||
/** @type {Settlement[]} */
|
||||
const log = [];
|
||||
|
||||
const week = {
|
||||
/** 1-based, for humans. "Night 3 of 5". */
|
||||
get night() { return index + 1; },
|
||||
get nights() { return NIGHTS.length; },
|
||||
get stormKey() { return NIGHTS[index]; },
|
||||
get bank() { return bank; },
|
||||
get isFinalNight() { return index === NIGHTS.length - 1; },
|
||||
get over() { return done; },
|
||||
get log() { return log; },
|
||||
|
||||
reset() {
|
||||
index = 0; bank = startBank; done = false; log.length = 0;
|
||||
return week;
|
||||
},
|
||||
|
||||
/**
|
||||
* Settle the night just played and move the ladder on.
|
||||
*
|
||||
* @param {object} run main.js's scoreRun() result
|
||||
* @param {object} def tonight's storm def (for severity)
|
||||
* @param {number} spent what prep actually cost out of the bank
|
||||
* @returns {Settlement}
|
||||
*/
|
||||
settle(run, def, spent) {
|
||||
const bankBefore = bank;
|
||||
const fullFee = PAY.feeFor(gustPeakOf(def));
|
||||
const fee = run.win ? fullFee : Math.round(fullFee * PAY.lostNightShare);
|
||||
const bonus = Math.round((Math.max(0, run.hp) / 100) * PAY.gardenBonusMax);
|
||||
|
||||
// Only hardware still on an unbroken corner comes home, and at half.
|
||||
const intact = (run.intactHardwareValue ?? 0);
|
||||
const refund = Math.round(intact * PAY.refundShare);
|
||||
|
||||
const collateral = (run.collateral ?? []).reduce((s, c) => s + c.cost, 0);
|
||||
const pay = fee + bonus + refund - collateral;
|
||||
|
||||
bank = Math.max(0, bankBefore - spent + pay);
|
||||
|
||||
const held = log.filter((n) => n.won).length + (run.win ? 1 : 0);
|
||||
|
||||
// Outcome is decided AFTER the money moves: you can win the last night and
|
||||
// still be broke, and the week should say you finished it.
|
||||
//
|
||||
// Reaching night five is NOT winning, and the first draft of this said it
|
||||
// was. Measured: a player who rigs $20 of carabiners every night loses
|
||||
// four gardens out of five, never dips under the broke line because a
|
||||
// cheap rig barely costs anything, and got handed "THE WEEK HELD —
|
||||
// everything's still where you put it" over four dead gardens. Outlasting
|
||||
// the week isn't surviving it. So the WORDS scale with what you actually
|
||||
// held (see grade); the outcome only says whether you're still trading.
|
||||
let outcome;
|
||||
if (week.isFinalNight) outcome = 'win';
|
||||
else if (bank < BROKE_BELOW) outcome = 'gameover';
|
||||
else outcome = 'continue';
|
||||
done = outcome !== 'continue';
|
||||
|
||||
const s = { fee, fullFee, bonus, refund, collateral, pay, spent,
|
||||
bankBefore, bankAfter: bank, outcome, night: week.night, held,
|
||||
grade: gradeFor(held), stormKey: week.stormKey, won: !!run.win };
|
||||
log.push(s);
|
||||
return s;
|
||||
},
|
||||
|
||||
/** Move to the next night. No-op once the week is done. */
|
||||
advance() {
|
||||
if (!done && index < NIGHTS.length - 1) index++;
|
||||
return week;
|
||||
},
|
||||
};
|
||||
return week;
|
||||
}
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 28 KiB |
Loading…
Reference in New Issue
Block a user