Add Idol Deck Sorter tool - #58
Open
12problems wants to merge 2 commits into
Open
Conversation
Lets a user build an arbitrary deck (visual card grid, kept in sync with a text box that accepts a new hand-typeable shorthand or the site's existing canonical deck string) and see how the modded Idol joker's algorithm would score, sort, and weight it, including an interactive roll and a full per-card score breakdown with the equations plugged in. - src/lib/idol-sort.ts: TypeScript port of reset_idol_card() from Balatro-Multiplayer's TheOrder.lua, built against PR #527's proposed weight changes (not yet merged, confirmed to land). Every coefficient is bundled into an IdolSortWeights object so it can be overridden and re-simulated against the same deck (currently wired through but the tuning UI is hidden — see below). - Extracted src/components/idol-roll-track.tsx out of the log parser's idol-hit.tsx (previously private) so both features share one implementation of the felt-track visualization instead of duplicating it. - Extracted src/shared/cards.ts and src/shared/card-sprite.ts (rank/suit ordering and sprite-atlas positioning) so the new deck grid renders identically to the log parser's deck viewer without a second copy. - New route at /idol-deck-sorter, linked from the Tools nav menu. The scoring-weights tuning panel is fully implemented (state, UI, and the equation breakdown all read live weights) but hidden behind a SHOW_WEIGHTS_PANEL flag in page.tsx for now — flip it to re-enable, no other changes needed. 140 tests added/passing, typecheck and biome clean. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
FACE_RANKS in shared/cards.ts wrongly included 'A'. Checked against
Steamodded's actual rank registrations (src/game_object.lua in
Steamodded/smods): Jack, Queen, and King are registered with `face = true`;
Ace gets `nominal = 11` and `face_nominal = 0.4` (sort-order tiebreaking
only) but no `face` flag, so TheOrder.lua's `if rank_obj.face then ...`
check is false for it. Both the ported algorithm and the tool's UI copy
("face (J/Q/K/A)") assumed otherwise.
- FACE_RANKS is now ['J', 'Q', 'K'], with a comment pointing at the source
so it doesn't regress.
- Fixed the two UI strings that said "(J/Q/K/A)".
- Fixed the hand-verified idol-sort.test.ts fixture, which had an Ace-heavy
deck and was asserting the buggy 0.055 face bonus / 2.555 total score for
it — corrected to 0 / 2.5 (the sort order and every other entry's numbers
were unaffected).
- Added regression coverage: an Ace-skewed deck gets no face bonus, the
identical shape with Jacks does, Queens/Kings also do, plus a direct
cards.test.ts asserting FACE_RANKS' exact contents.
Verified live: the same 5x A♠ deck that scored 2.555 now scores 2.500, and
the score breakdown correctly reads "not a face rank (J/Q/K) -> 0" for it.
148 tests passing, typecheck and biome clean.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
New tool at
/idol-deck-sorter(linked from Tools in the nav): build an arbitrary deck — via a visual card grid or a text box — and see how the modded Idol joker's algorithm would score, sort, and weight it, without needing a real game/seed.4x KH-steel-foil,10H-goldseal, etc.) or the site's existing canonicalsuit-rank-enh-edition-sealdeck string — so a deck copied from a parsed log'sView deckcan be pasted straight in.IdolRollTrackcomponent so both features stay in sync), plus an interactive roll slider since there's no real seed to draw from, plus a full per-card score table with an expandable breakdown showing every term's equation with the actual numbers plugged in.src/lib/idol-sort.tsis a TypeScript port ofreset_idol_card()fromTheOrder.lua, built against PR #527's proposed weight changes rather than currentdev, since that's confirmed to land. Every weight constant is a single named export with a comment on what PR527 changed, so a future mod tweak is a one-line edit. The algorithm also accepts a full override of every coefficient (IdolSortWeights) so the same deck can be re-simulated against different values — the UI for that is built (weights-panel.tsx) but hidden behind aSHOW_WEIGHTS_PANELflag inpage.tsxfor now.Why the log parser also changed
Two small shared-code extractions so the new tool doesn't duplicate existing logic:
idol-hit.tsx's previously-private felt-track components moved tosrc/components/idol-roll-track.tsx(pure relocation, no behavior change) — both the log parser and the new tool render from the same place now.deck-view.tsx's sprite-atlas positioning moved tosrc/shared/card-sprite.ts(also pure relocation) so the new deck grid renders pixel-identical card art.deck-utils.ts'sENHANCEMENT_NAMES/EDITION_NAMES/SEAL_NAMESare now exported (were already there, just not exported) so the new deck grid and weights panel can reuse the same display names.Testing
bun run typecheckandbunx biome check .clean on every file this PR touches.🤖 Generated with Claude Code