Skip to content

Max Lair: test the current boss inference (no behavior change) - #171

Closed
dayfine wants to merge 12 commits into
mainfrom
swsh/maxlair-boss-tests
Closed

dayfine wants to merge 12 commits into
mainfrom
swsh/maxlair-boss-tests

Conversation

@dayfine

@dayfine dayfine commented Nov 2, 2026 •

Copy link
Copy Markdown
Owner

Base: main; no parent PRs. Test-only prep for the Max Lair boss fix in #172; no behavior change.

Moves the Max Lair boss-stage check and boss inference into GlobalState helpers and pins today's results with native tests, so the fix PR shows only the changed behavior and the test expectations it flips.

  • GlobalState::accept_opponent() holds the check and inference that read_battle_menu() ran after the summary read, unchanged (with an internal is_boss_battle() helper); it returns false when the read doesn't fit the battle stage so the caller retries. The header-read check stays where it was.
  • GlobalState::boss_if_caught() returns the boss passed to end_adventure_action() on the caught screen; today that is the identified boss whatever happened. It takes no catch count: "caught" is to be decided from the battles won (wins; the boss is the fourth battle), not from how many Pokemon were caught. Comments on it and on the boss field tell apart the boss known all adventure long from the boss only when caught.
  • Ten PokemonSwSh::MaxLairBossState cases in PokemonSwSh_MaxLair_State_Tests.{h,cpp} record current results, including the ones the fix changes, marked TODO: to be fixed (a rental read at the boss stage becomes the boss; a lost adventure still reports the boss).

How to review: the lines removed from read_battle_menu() reappear in PokemonSwSh_MaxLair_State.cpp with renames (state. dropped, the opponent local becomes opponent_slug), so compare them by eye; then read PokemonSwSh_MaxLair_State_Tests.cpp, which sets wins on the caught screen.

Move the boss-stage check and boss inference that read_battle_menu() runs
after the summary read into GlobalState::infer_boss_from_opponent(), and
the boss passed to end_adventure_action() into GlobalState::caught_boss().
No behavior change. Add native tests that pin down today's results,
including the cases a later fix changes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E
dayfine and others added 2 commits November 2, 2026 11:14
…ught()

Comment the boss field and boss_if_caught() so the two are told apart:
the boss known all adventure long versus the boss only when the
adventure caught it, for the end-of-adventure decision. No behaviour
change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E
boss_if_caught() no longer takes the caught count: whether the boss was
caught is decided from GlobalState::wins (the boss is the fourth battle),
so it stays right if non-boss catches are ever skipped. It still returns
the boss whatever the battles won; the tests set wins on the caught
screen instead of passing a count.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E
dayfine and others added 2 commits November 2, 2026 11:43
Comments on the MaxLairBossState cases that record main's wrong
behaviour, and a blank line between accept_opponent() and
boss_if_caught().

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E
@dayfine
dayfine added this pull request to stack #225 November 4, 2026 04:58



namespace{

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

namespace{ -> move it to line 23

@dayfine dayfine Nov 4, 2026 •

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved to PokemonSwSh_MaxLair_State_Tests.cpp in f6b95cd with namespace{ placed directly under namespace MaxLairInternal{ (merged into #172 in e9c9af2).



namespace{
using MaxLairInternal::GlobalState;

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this necessary?

@dayfine dayfine Nov 4, 2026 •

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dropped in f6b95cd now that the tests live inside namespace MaxLairInternal in PokemonSwSh_MaxLair_State_Tests.cpp.

namespace{
using MaxLairInternal::GlobalState;

struct BossStateCase{

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe

BossStateTestCaseInput

BossStateTestCaseExpectation

and then using BossStateTestCase = std::pair<BossStateTestCaseInput, BossStateTestCaseExpectation>?

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated in f6b95cd to BossStateTestCaseInput, BossStateTestCaseExpectation, and using BossStateTestCase = std::pair<BossStateTestCaseInput, BossStateTestCaseExpectation>; (and merged into #172 in e9c9af2).

}

void add_tests(UnitTestDatabase& database){
add_tests_MaxLairBossState(database);

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this intrusion means we should add a new test file

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extracted to SerialPrograms/Source/VideoGames/PokemonSwSh/MaxLair/Framework/PokemonSwSh_MaxLair_State_Tests.{h,cpp} in f6b95cd (and merged into #172 in e9c9af2), keeping PokemonSwSh_Tests.cpp as pure add_tests_* calls.

@dayfine
dayfine marked this pull request as ready for review November 4, 2026 05:24
std::string boss_if_caught;
};

using BossStateTestCase = std::pair<BossStateTestCaseInput, BossStateTestCaseExpectation>;

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually let's make this a struct so cases[] can have field names

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated in aab7407 to struct BossStateTestCase { BossStateTestCaseInput input; BossStateTestCaseExpectation expectation; }; with .input = ... / .expectation = ... designated initializers (merged into #172 in 974345107).

@dayfine dayfine closed this Nov 6, 2026
@dayfine
dayfine removed this pull request from stack #225 November 11, 2026 03:20
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