Skip to content

Add target card - #3

Merged
zxpower merged 1 commit into
mainfrom
add_target_card
Aug 15, 2026
Merged

zxpower merged 1 commit into
mainfrom
add_target_card

Conversation

@zxpower

@zxpower zxpower commented Aug 15, 2026 •

Copy link
Copy Markdown
Owner

What

Adds a third card — Target Card — for building a dial-up card for a set of known targets, instead of the even range ladder the trajectory table produces.

  • Starts with one row (A); + Add target appends B, C, D, … (spreadsheet-style, so it continues Z → AA → AB). The × deletes a row and relabels the rest, and is disabled when only one row is left, enforcing the one-row minimum.
  • Each row is a distance in metres. Calculate corrections renders a table (with the existing mobile tcard fallback) giving per target: drop cm, elevation in MRAD/MOA, elevation clicks to dial UP, drift cm with the side it pushes to, windage in MRAD/MOA, windage clicks with the direction to dial, ToF and remaining velocity.
  • Targets stay in the order entered — the solver needs ascending samples, so it sorts internally and maps results back. Duplicates are fine. A distance the bullet cannot reach shows – and is named in a note rather than being estimated.
  • Rows and distances persist in localStorage with the rest of the state. Once a card is on screen it re-runs automatically when turret settings or the unit/drag/twist toggles change — matching how the trajectory table already behaves.

The card reuses the bullet / rifle / atmosphere / wind inputs from the Full Trajectory Calculator and the turret settings from card 1, so its numbers agree with the trajectory table exactly.

Refactor

The solver setup was pulled out of runTrajectory into trajectoryContext(), deriveShot(), solveShots(), turretSettings(), clicksFor(), fmtClicks() and renderStability(), and runTrajectory was rewired onto them — both cards now share one code path rather than duplicating the physics. Existing behaviour is unchanged.

Row values round-trip through localStorage and are rendered via innerHTML, so they are HTML-escaped into the value attribute. Everything else in those templates is numeric solver output.

Tests

node test.js → 38 passed, 0 failed (all 28 original assertions still pass; 10 new cover row labels, click formatting, a single row, order preservation, duplicates, unreachable/missing → null, monotonic elevation, spin drift folded into drift, and crosswind side).

Also driven through a stub-DOM harness exercising the real add/type/delete/calculate wiring, confirming relabeling, the persistence round-trip, the one-row minimum, and the error paths.

@zxpower zxpower self-assigned this Aug 15, 2026
@zxpower
zxpower merged commit cd26151 into main Aug 15, 2026
2 checks passed
@zxpower
zxpower deleted the add_target_card branch August 15, 2026 16:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant