coder / coder/balatrobot

fix!(lua.settings): force unlock-all on BalatroBot profile

Open
#220 1 comment 0 reactions 1 assignee Claimed by @S1M0N38 View on GitHub
completed-in-dev
Dominant language
Python
Stars
72
Forks
18
PR merge metrics
No merged PRs in 30d

Description

## Problem

Fixtures aren't portable across hosts. The same seed produces **different tags, shop contents, and card `effect` text** on a dev Mac vs a fresh `balatrobox` container, so `.jkr` fixtures (gitignored, regenerated per host) diverge and cross-host test runs fail.

## Root cause

`G.P_CENTERS[*].discovered` is per-host: it's loaded from `meta.jkr` in each host's LÖVE save dir (`game.lua:740`). A dev's played profile (~325 discovered) ≠ a fresh container (`{j_joker, b_red}`).

The balatrobot gate already sets `G.PROFILES[n].all_unlocked = true` (`src/lua/settings.lua`), but `all_unlocked` only bypasses stake/challenge/deck **locks** + disables achievements — it never sets `discovered`. Verified: `all_unlocked` is read in ~12 places (`unlock_achievement`, `set_challenge_unlock`, stake/deck UI gates…), none flip `discovered`.

That `discovered` gap is load-bearing in two paths:

- `get_current_pool("Tag")` (`functions/common_events.lua:1974`) gates on `G.P_CENTERS[v.requires].discovered`. `tag_polychrome.requires = "e_polychrome"` (`game.lua:230`), so it's excluded from the pool when undiscovered → a different tag is drawn.
- Card effect-text rendering shows `center.unlock` ("Reduce hand size down to 5 cards") instead of `center.text` ("+1 hand size") when undiscovered.

The only thing that flips `discovered` is `G.FUNCS.unlock_all` (`functions/button_callbacks.lua:328`), which loops `G.P_CENTERS`/`G.P_BLINDS`/`G.P_TAGS` forcing `discovered = unlocked = alerted = true`.

Empirical, seed `TEST123`: Mac small-blind tag `tag_polychrome`, Docker `tag_investment`; after the fix both match.

## Fix

In `src/lua/settings.lua`, inside the existing `name == "BalatroBot"` gate, replicate `G.FUNCS.unlock_all`:

- force `discovered/unlocked/alerted = true` over `G.P_CENTERS` / `G.P_BLINDS` / `G.P_TAGS`;
- run **immediately** in `setup()` — SMODS loads the mod *after* `Game:init_item_prototypes`, so prototypes are already populated (confirmed: a deferred-only wrapper logged 0 fires; the immediate call fires) — **and** via an `init_item_prototypes` wrapper for profile reloads.

**Safety:** the gate already returns early (mod fully inactive) unless the active profile is named `BalatroBot`; the wrapper re-checks the name on each call, so a non-BalatroBot profile can never be mutated.

## Verification

Mac-generate → Docker-run: `614 passed, 2 skipped, 0 failed` (was 3→17 failures before the fix). Fixtures byte-identical across hosts (checksums unchanged after the Docker run).

Sibling of the `balatrobox` profile/settings work.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.