Refuel-for-flight buys 150% of requirement; wind adjusts per-leg burn ±20% (ISS-071, ISS-070, v0.36.0) #74

Merged
kamilkrzywda merged 1 commits from feat/weather-fuel-burn into master 2026-09-21 11:03:03 +02:00
Owner

Fixes #71
Fixes #70

Two changes to the same fuel-math code, shipped together:

ISS-071 — refuel margin. The per-leg "Refuel for flight" action now tops up to 150% of the required fuel for the loaded package's leg (capped at tank capacity) instead of exactly the requirement, so burn variance from weather/maintenance doesn't strand planes.

ISS-070 — wind affects burn. Per-leg fuel burn is adjusted by a deterministic factor derived from the departure airport's weather vs the route heading: factor = 1 + headwindKt/150 → exactly ±20% over the 2–30 kt wind range (headwind burns more, tailwind less). New pure helpers: initialBearingDeg() in lib/geo.ts, windBurnFactor() in lib/sim/movement.ts. Applied consistently at all five burn call sites (dispatch feasibility, refuel requirement, landing burn, auto-chain check, live fuel display) — no signature changes to the existing movement functions.

Unit: +12 tests (bearing, factor bounds 0.8/1.2 exact, scaled math; refuel/engine expectations recomputed in-test via the same helpers). E2e: specs now import the real lib helpers instead of mirroring them; "farthest flyable" pickers require both legs to fit a full tank under wind. OpenAPI: description-only updates (no schema change — snapshot shape unchanged, live display recomputes server-side).

Fixes #71 Fixes #70 Two changes to the same fuel-math code, shipped together: **ISS-071 — refuel margin.** The per-leg "Refuel for flight" action now tops up to **150% of the required fuel** for the loaded package's leg (capped at tank capacity) instead of exactly the requirement, so burn variance from weather/maintenance doesn't strand planes. **ISS-070 — wind affects burn.** Per-leg fuel burn is adjusted by a deterministic factor derived from the **departure airport's** weather vs the route heading: `factor = 1 + headwindKt/150` → exactly ±20% over the 2–30 kt wind range (headwind burns more, tailwind less). New pure helpers: `initialBearingDeg()` in `lib/geo.ts`, `windBurnFactor()` in `lib/sim/movement.ts`. Applied consistently at all five burn call sites (dispatch feasibility, refuel requirement, landing burn, auto-chain check, live fuel display) — no signature changes to the existing movement functions. Unit: +12 tests (bearing, factor bounds 0.8/1.2 exact, scaled math; refuel/engine expectations recomputed in-test via the same helpers). E2e: specs now import the real lib helpers instead of mirroring them; "farthest flyable" pickers require both legs to fit a full tank under wind. OpenAPI: description-only updates (no schema change — snapshot shape unchanged, live display recomputes server-side).
kamilkrzywda added 1 commit 2026-09-21 10:52:25 +02:00
kamilkrzywda scheduled this pull request to auto merge when all checks succeed 2026-09-21 11:02:40 +02:00
kamilkrzywda merged commit 718e3a0177 into master 2026-09-21 11:03:03 +02:00
Sign in to join this conversation.