* The tooltip mis-taught every pure enabler. JCA.explain used a cluster tag's `both` text whenever EITHER side was a full member, so Four Fingers next to Runner claimed "both reward Straights" -- Four Fingers does not reward Straights, it makes them reachable. `both` now requires both sides, and every cluster tag carries give/want phrasings. * Blue Joker and Abstract Joker scored 0 against all 150 jokers. Blue Joker scales on #G.deck.cards, so it wants card_gen (DNA, Marble, Certificate); Abstract scales on #G.jokers.cards, so it wants joker_gen (Riff-Raff is +6 Mult on its own). Both verified in card.lua. Steel and Glass Joker look like the same fix but are NOT: they need Steel/Glass specifically, and the only enhance_gen givers make Gold and Stone, so tagging them would invent a synergy that does not exist. * Copy jokers are positional and the board order was there all along. JCA.copy_source reports what an owned Blueprint/Brainstorm is actually copying, including when the target is one of the 29 centers vanilla refuses to copy (blueprint_compat = false), or when it is copying nothing at all. * The sell advisor now counts clashes when ranking what to cut. JCA.score stays pure -- a trap must never make a card look like a combo -- but a joker eating another one's payoff is exactly the one to sell. The suite caught a real bug while writing this: `(mode == 'right') and cards[idx+1] or cards[1]` falls through to the LEFTMOST joker when the right-hand slot is nil, so a rightmost Blueprint would have named the wrong card. 673 pass here, 9 in-game via the smoke harness. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
14 KiB
CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Project
"Joker Combo Advisor" — a Steamodded (SMODS) mod for Balatro that scores shop/pack jokers against the player's current jokers, shows a "Combo Advisor" tooltip on hover, and pulses strongly recommended cards. Pure Lua, no build step.
Commands
Syntax check, then run the test suite — always both, after every edit:
luac -p main.lua synergies.lua config.lua test.lua
lua test.lua
test.lua stubs the handful of game globals main.lua touches (the game cannot be
launched headlessly here) and then exercises the real engine, the real database and
the real catalog tab builders. It is the only safety net; there is no other harness.
It enforces, among other things:
- Score tiers: famous explicit pair + tags = 6, hand-type/suit cluster = 4, single tag match = 2, generic mult+xmult complement = +1 on top, unrelated = 0.
- No orphan wants — a
wantstag nothing gives is a payoff with no enabler. - No dead gives — a non-engine tag given but never wanted can never change a
score, so it is invisible dead weight. (This caught
hand_level, given by Space and Burnt Joker and wanted by nobody.) - Every theme is discoverable — theme discovery needs a giver and a wanter on two
different fielded jokers, so a theme with fewer than two members is an
achievement no player can ever earn and pins the Progress tab under 100% forever.
(This caught
four_kind, whose only member was The Family.) theme_infoandTHEME_TABScover exactly the same tag set.- Pair/clash/caution keys all exist; every blurb fits its ~34-char row.
- Every card the catalog pages emplace is materialized (see the UI notes below).
- Jokers with no tags at all are listed in
EXPECTED_INERTon purpose — a joker landing there by accident scores 0 against the entire game and says nothing.
To poke at the engine by hand, copy the stub block from the top of test.lua.
In-game verification (this machine)
- The mod is symlinked into the live Mods folder:
~/.local/share/Balatro/Mods/JokerComboAdvisor -> ~/Documents/JokerComboAdvisor(this repo). Edits here go live on next game launch — do not copy files anywhere. Lovely reads that folder asC:\users\steamuser\AppData\Roaming\Balatro\Mods. - Game: Steam/Proton at
~/.local/share/Steam/steamapps/common/Balatro. Lovely injector + Steamodded 1.0.0-beta are already installed; mods are managed via Balatro Mod Manager. - Crash/load logs:
~/.local/share/Balatro/Mods/lovely/log/(newest file). - Remote:
https://git.aleshym.co/funman300/JokerComboAdvisor(private, user's Gitea).git pushjust works: it authenticates through the global libsecret credential helper (credential.helper=/usr/lib/git-core/git-credential-libsecret). Never copy a token into the repo or the remote URL. Commit per feature. - The
teaCLI is installed and logged in asfunman300, but its stored login hasauth_method: oauthand no token, soteacannot create repos or call the API — it is not the thing that authenticates pushes, despite what this file used to say. Creating a new remote repo needs the web UI (or a token added totea).
Architecture
Three-layer split; JCA is the single global namespace:
synergies.lua— data only. Returns{ jokers = {...}, pairs = {...} }. Each of the 150 vanilla jokers getsgives(capabilities it adds) andwants(capabilities that strengthen it) tag lists, converted to sets at the bottom of the file.PAIRSlists famous explicit combos worth a flat +4.main.lua— engine + game integration:- Scoring:
JCA.score(a, b)= explicit pair bonus (+4) + 2 per give→want tag match in each direction + 1 for the generic "+Mult/+Chips source with an ×Mult joker" complement (second return value flags when that +1 applied).JCA.partners_for(card)aggregates overG.jokers.cards; total ≥JCA.config.threshold⇒ recommended. The generic +1 counts toward the total once per candidate, not per owned joker — since tag/pair scores are even and the threshold is 4, the generic bonus alone can never trigger a recommendation, so a pulsing card always has a nameable partner. Jokers whose multiplier the generic rule misreads opt out with{no_generic = true}insynergies.lua(Joker Stencil: its ×Mult grows with empty slots, so "+Mult jokers feed it" is backwards). - UI hooks: wraps
Card:generate_UIBox_ability_tableto append a tooltip entry toaut.info(format: array of rows-of-UIT-nodes plus a.namestring — must match what vanillainfo_tip_from_rowsexpects), and wrapsCard:updatefor the ~2.5s pulse on recommended shop cards and the partner highlight (hovering a joker juices its owned partners ~0.9s; partner set cached on the card asjca_hl, dropped when hover ends). All hook bodies are pcall-wrapped so a scoring bug can never crash a run — keep it that way. - Sell advisor:
JCA.weakest_link()(full board + ≥3 jokers + a strict minimum required, else nil) flags the lowest-scoring owned joker with a red verdict row; suppressed by learning mode, toggled byconfig.sell_advisor. Its ranking subtractsCLASH_PENALTY(odd, so it always breaks a tie) per clash with an owned joker — the joker eating another one's payoff is the one you want to cut. This is the only place a clash changes a number;JCA.scorestays pure, because a trap must never make a card look like a combo. - Copy advisor:
JCA.copy_source(card)returns what an owned Blueprint or Brainstorm is actually copying, from the live board order — Blueprint takes the joker to its right, Brainstorm the leftmost — plus whether vanilla will copy it at all (29 centers carryblueprint_compat = false). The tooltip names the target, or says it is copying nothing. Do not rebuild this with thea and b or cidiom: for a rightmost Blueprint the right-hand slot is nil and the idiom falls through to the leftmost joker, confidently reporting the wrong card. - Public API for other mods:
JCA.register(key, gives, wants, opts),JCA.register_pair(a, b, blurb)(setsJCA._pairs_dirtyso the Combos tab re-sorts),JCA.register_clash(a, b, warning). Unknown tags are dropped with a log line, never an error. - Config tab: registered on
SMODS.current_mod.config_tab, guarded byif SMODS.current_modso standalone tests don't need full stubs. - Synergy catalog:
SMODS.current_mod.extra_tabsadds Combos/Engine/ Economy/Hands tabs (plus a text-only Progress tab with discovery completion bars) that render realCardobjects inCardAreas (collection-style, so hover shows each joker's own tooltip). One theme per page; pagers swap thetab_contentsUIBox from an option-cycle callback — the same pattern as SMODS's achievements tab. Because pages contain live Card/CardArea objects, tab definitions must be rebuilt on every call — never cache the node trees. Cards must bestart_materialized as they are emplaced (card_row_node), exactly as every vanilla collection page does — that call is the appear animation, and without it cards pop in with no animation on tab open and page switch. Only the first card of a page build plays the sound (vanilla'si>1 or j>1silence flag); tab defs callbegin_page()so the counter spans the page, not one row. The same tabs open in-run via a "Combos" HUD button (wrappedcreate_UIBox_HUD, injected into thebutton_areanode under Run Info/Options); the pagers work there because vanillacreate_tabsalso names its bodytab_contents. - Discovery:
CardArea:emplacehook callsJCA.check_discoverieswhen a joker lands inG.jokers; famous pairs fielded together persist inconfig.discovered(saved immediately viaSMODS.save_mod_config) and per-run inG.GAME.jca_run_combos. Undiscovered pairs render face-down with a???caption in the Combos tab; blurb replaces it once fielded. Themes (everytheme_infotag) persist inconfig.themes_foundonce two DIFFERENT jokers connect the tag (giver + wanter; a joker carrying both sides needs a second joker). One toast per emplacement, famous pair outranking theme. Badge/progress render intheme_tab_def; toast names come fromJCA.theme_names(filled after THEME_TABS, used only at gameplay time). - Post-run recap: wraps
create_UIBox_game_over/create_UIBox_winand inserts a "Combos fielded this run" row (fromG.GAME.jca_run_combos) relative to vanilla button ids (from_game_over;from_game_wonorwin_cta) via a parent-trail walk — anchor depths differ per screen. - Learning mode (
config.learning_mode): suppresses the pulse and the "Strong pick!" line but never the explanations. No-synergy buy-area tooltips show "Looking for:"/"Offers:" hints fromTAG_LABEL.synergies.luaalso exportstheme_info(one teaching sentence per catalog tag — keep ≤ ~90 chars and cover every THEME_TABS tag). - The real (Lovely-patched) game source is readable at
~/.local/share/Balatro/Mods/lovely/dump/— check it before assuming what a vanilla function returns or expects.
- Scoring:
config.lua— default settings (pulse,owned_tooltip,threshold). Steamodded loads and persists this table itself; read it only viaSMODS.current_mod.config(exposed asJCA.config).
Conventions and gotchas
- Cluster tags (hand types
pair/straight/flush/…, suits,planet,spectral_gen): put the same tag in bothgivesandwantsof every member so members mutually reinforce (2+2 = 4). Pure enablers (e.g. Four Fingers, Smeared, Pareidolia, DNA) onlygive; pure payoffs onlywant. A cluster tag needs all threeTAG_TEXTphrasings, not justboth:bothis only true when both jokers sit on both sides of the tag, andJCA.explainrequires that before using it. Four Fingers does not "reward Straights" — it makes them reachable. The suite enforces the three phrasings. - A tag needs both sides to exist, on at least two different jokers: something
must give it, something must want it, or it is dead data that can never change a
score — and if it is also a theme, an achievement nobody can earn.
lua test.luaenforces both directions; run it after everysynergies.luaedit. - Tooltips teach:
JCA.explain(hovered, partner)picks one reason per partner — famous-pair blurb (third element of eachPAIRSentry), else the firstTAG_ORDERmatch phrased fromTAG_TEXT(give/want/both variants), else the generic mult×xmult line. Every non-engine tag (anything besides mult/chips/xmult) MUST have aTAG_TEXTentry; newPAIRSentries need a blurb under ~34 chars so name + blurb fits one tooltip row. - Vanilla center keys contain intentional misspellings/abbreviations — do not
"fix" them:
j_gluttenous_joker,j_selzer,j_ticket(Golden Ticket),j_trousers(Spare Trousers),j_ring_master(Showman),j_caino(Canio),j_delayed_grat,j_todo_list. - Unknown joker keys (from other mods) must keep scoring 0 — never index
JCA.db[key]without a nil guard. - Display names go through
localize{type='name_text', set='Joker', ...}with a pcall +center.namefallback. - Anti-synergies never affect scores. Known traps are warning-only data:
CLASHES(pairwise, red "Clashes -" tooltip line vs owned jokers) andCAUTIONS(per-joker, buy-area "Caution:" line) insynergies.lua, same ~34-char blurb budget asPAIRS. Learning mode keeps warnings visible. Verify every new trap against the dump before adding it — a warning that is merely plausible is worse than none. The mod once shipped aj_smeared+j_flower_potclash that was exactly backwards: Flower Pot fills its four suit slots with a greedyif/elseifchain (card.lua:4256) and Smeared makes Hearts answer for Diamonds, so any two red + two black cards fill the pot. It is one of the best combos in the game, and the mod was warning players off it. Most traps hinge on the scoring-pipeline order infunctions/state_events.lua(before→ per-cardindividual→joker_main): Vampire strips enhancements inbefore, so every enhancement payoff that reads them inindividual— Golden Ticket, Glass, Stone, Driver's License — is looking at cards it has already eaten. - The UI hooks used to be the untested surface. They are now covered in the real
game by the smoke harness (see below). If a tooltip regression is reported,
run it, then suspect the
aut.infoentry format and check the lovely log.
In-game smoke tests
lua test.lua stubs the game, so it cannot tell you that vanilla accepted the
tooltip format or that a card is actually animating. The smoke harness runs the
real engine — real Card objects, the real Card:generate_UIBox_ability_table
pipeline, a real overlay UIBox — with no clicking:
~/Documents/BalatroSmoke/run.sh JokerComboAdvisor
It boots the game, runs scenarios/JokerComboAdvisor.lua, quits, and prints a
pass/fail report (non-zero exit on failure). Close Balatro first; it needs a clean
boot. Scenarios live in the harness repo, not here.
It covers the surfaces this repo's tests cannot reach: the hover tooltip naming a
partner, the clash and caution lines, discovery on emplace, and — the reason it
exists — that catalog cards really do start_materialize on tab build and on
page switch (asserted via card.dissolve > 0 in the live UIBox).
The harness suppresses every save path and verifies from outside that no discovery state leaked, so running it can never spoil the catalog. Do not "fix" that by reversing writes after the fact — a crashed scenario would skip the reversal.