check_win only counts 13 cards per foundation — corrupt save permanently locks game #22
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_core/src/game_state.rslines 420–426Description
check_winreturnstruewhen each foundation pile has exactly 13 cards, without verifying card order or suit uniqueness. Under normal play this is safe becausecan_place_on_foundationenforces correctness. However, if a deserializedGameStatefrom a corrupt or edited save file has 13 cards per foundation but they are not a valid A→K sequence,is_wonbecomestrueand theGameAlreadyWonguard permanently blocks all further actions (draw,move_cards,undo) with no recovery path except deleting the save.Fix
In
check_win, additionally verify that each foundation pile's cards form a valid A–K sequence of a single suit, or add avalidate()method onGameStatethat is called after deserialization.