Skip to content

fix: Use kan tile as winning tile for chankan ron in end_kyoku modal - #165

Merged
smly merged 4 commits into
mainfrom
fix/ui-chankan-ron-tile
Mar 10, 2026
Merged

fix: Use kan tile as winning tile for chankan ron in end_kyoku modal#165
smly merged 4 commits into
mainfrom
fix/ui-chankan-ron-tile

Conversation

@smly

@smly smly commented Mar 10, 2026

Copy link
Copy Markdown
Owner
  • Fix incorrect winning tile display in the end_kyoku modal for chankan (robbing a kan) ron
  • The winning tile inference only searched for dahai events from the target player, so for chankan ron the previous discard was incorrectly shown as the winning tile
  • Now also searches kakan and ankan events (with fallback to consumed[0] for ankan which has no pai field)

Thanks for the bug report! @Apricot-S

@smly smly added this to the v0.5.0 milestone Mar 10, 2026
@smly smly self-assigned this Mar 10, 2026
@smly smly added bug Something isn't working ui labels Mar 10, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Fixes winning-tile inference for chankan ron in the UI’s end_kyoku result enrichment, so the end-of-hand modal shows the kan tile (kakan/ankan) instead of incorrectly falling back to the previous discard.

Changes:

  • Extend ron winning-tile inference to also consider kakan and ankan events from the target (chankan).
  • Add a fallback to consumed[0] when ankan events lack pai.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread riichienv-ui/src/game_state.ts
Comment thread riichienv-ui/src/game_state.ts Outdated
Comment thread riichienv-ui/src/game_state.ts Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 3 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread riichienv-ui/src/__tests__/game_state.test.ts Outdated
Comment thread riichienv-ui/src/__tests__/game_state.test.ts Outdated
Comment thread riichienv-ui/src/__tests__/game_state.test.ts Outdated
Comment on lines +650 to +666
it('should not mark found when neither pai nor consumed is available', () => {
const events: MjaiEvent[] = [
makeStartKyoku(),
{ type: 'tsumo', actor: 0, pai: '1s' },
{ type: 'dahai', actor: 0, pai: '1m' },
// Malformed hora with no pai and no prior matching event
{ type: 'hora', actor: 1, target: 0, deltas: [0, 8000, -8000, 0], ura_markers: [] },
{ type: 'end_kyoku' },
];
const gs = new GameState(events);
gs.jumpTo(events.length);
const state = gs.getState();
const results = state.lastEvent?.meta?.results;
expect(results).toBeDefined();
// Should find the dahai from player 0 (target)
expect(results[0].winningTile).toBe('1m');
});

Copilot AI Mar 10, 2026

Copy link

Choose a reason for hiding this comment

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

This test name says it verifies the “neither pai nor consumed is available” case, but the event sequence doesn’t include a kakan/ankan without pai/consumed; it asserts the normal ron inference from a dahai. Renaming the test (or adjusting the events + assertions to actually cover the missing-tile case, e.g. via a spy on console.warn) would make the intent clear.

Copilot uses AI. Check for mistakes.

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.

Agreed. Renamed the test to "should infer winning tile from dahai for normal ron" to accurately reflect what it covers.

@smly
smly merged commit ce9ca03 into main Mar 10, 2026
7 checks passed
@smly
smly deleted the fix/ui-chankan-ron-tile branch March 10, 2026 15:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working ui

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants