Stats double-counted on game forfeit — record_abandoned() fires twice #21
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
File
solitaire_engine/src/stats_plugin.rslines 596–613 (update_stats_on_new_game), 620–645 (handle_forfeit)Description
handle_forfeitcallsstats.0.record_abandoned()then writes aNewGameRequestEvent. Bothhandle_forfeitandupdate_stats_on_new_gameare registered.before(GameMutation)with no ordering between them. When Bevy scheduleshandle_forfeitfirst,update_stats_on_new_gamereads theNewGameRequestEventin the same frame, checksgame.0.move_count > 0 && !game.0.is_won(still true —GameMutationhasn't run yet), and callsrecord_abandoned()a second time. Every forfeit doublesgames_playedandgames_lost.Fix
Add
.before(update_stats_on_new_game)tohandle_forfeit's system registration soupdate_stats_on_new_gamecannot observe the forfeit'sNewGameRequestEventin the same frame.