Skip to content

fix : move victory check before game-over check in Minesweeper game loop #1873

Description

@tmdeveloper007

Summary of What Needs to be Done

Fix the game loop in games/Minesweeper/minesweeper.py. The check_victory() method is called after the user action (dig or flag) and the result is stored in game.victory. However, since the while loop checks not game.victory as its condition (along with not game.game_over), if a player wins by revealing all non-mine cells on their move, game.victory becomes True but the loop condition not game.game_over and not game.victory immediately becomes False, exiting the loop WITHOUT displaying the victory banner. The next action (hitting a mine) then shows the game-over banner instead.

Changes that Need to be Made

Move the check_victory() call to be evaluated as part of the loop condition itself, or restructure the win detection so that winning is handled before the next prompt is shown. The simplest fix is to check check_victory() immediately after each action (dig or flag), BEFORE the next iteration of the prompt loop.

Impact that it would Provide

Players who win by revealing all non-mine cells will see the victory banner and board, rather than the game over screen from their next (accidental) mine hit.

Note: please assign this issue to the tmdeveloper007 account.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions