generated from nhcarrigan/template
fix: turn off auto-boss/auto-quest on failure and surface status (#46)
## Summary - Auto-boss now turns itself **off** when a boss fight is **lost**, so the player can reassess rather than the system silently looping. A "🤖 Last fight: [Boss] — ❌ Lost" status line appears in the boss panel. - Auto-boss also turns off (with an ⚠️ error message) when the API call fails outright (e.g. party has no adventurers), replacing the previous behaviour of silently hammering the API every animation frame. - Auto-quest now turns itself **off** whenever a quest fails the random-chance check, detected inside the tick's `setState` callback immediately after `applyTick`. - `autoBoss: false` and `autoQuest: false` are now part of `initialGameState`, so these fields persist through save/load cycles from the very first session — preventing a race window where the boss-route DB write could strip them before the first auto-save. - `toggleAutoBoss` clears both `autoBossLastResult` and `autoBossError` on each toggle so the panel always reflects the current session cleanly. ## Test plan - [x] `pnpm lint` — 0 errors, 0 warnings - [x] `pnpm build` — all packages clean - [x] `pnpm test` — 100% coverage maintained across the board Closes #40 ✨ This issue was created with help from Hikari~ 🌸 Reviewed-on: #46 Co-authored-by: Hikari <hikari@nhcarrigan.com> Co-committed-by: Hikari <hikari@nhcarrigan.com>
This commit was merged in pull request #46.
This commit is contained in:
@@ -226,7 +226,14 @@ const computePartyStats = (
|
||||
* @returns The JSX element.
|
||||
*/
|
||||
const BossPanel = (): JSX.Element => {
|
||||
const { state, challengeBoss, formatNumber, toggleAutoBoss } = useGame();
|
||||
const {
|
||||
state,
|
||||
challengeBoss,
|
||||
formatNumber,
|
||||
toggleAutoBoss,
|
||||
autoBossLastResult,
|
||||
autoBossError,
|
||||
} = useGame();
|
||||
const [ challengingBossId, setChallengingBossId ] = useState<string | null>(
|
||||
null,
|
||||
);
|
||||
@@ -346,6 +353,23 @@ const BossPanel = (): JSX.Element => {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{autoBossError === null
|
||||
? null
|
||||
: <p className="auto-boss-error">
|
||||
{"⚠️ Auto-boss stopped: "}
|
||||
{autoBossError}
|
||||
</p>
|
||||
}
|
||||
{autoBossLastResult !== null && autoBossError === null
|
||||
? <p className="auto-boss-status">
|
||||
{"🤖 Last fight: "}
|
||||
{autoBossLastResult.bossName}
|
||||
{autoBossLastResult.won
|
||||
? " — ✅ Won"
|
||||
: " — ❌ Lost"}
|
||||
</p>
|
||||
: null}
|
||||
|
||||
<ZoneSelector
|
||||
activeZoneId={activeZoneId}
|
||||
onSelectZone={setActiveZoneId}
|
||||
|
||||
Reference in New Issue
Block a user