Hacker News new | ask | show | jobs
by anonymfus 2080 days ago
It seems like end game condition here requires for all mines to be flagged. In classical minesweeper opening all the clean cells is enough for a win. That difference removes the fun and speed advantage of playing without flagging.
1 comments

Hm. I'll make the end condition configurable so you can pick that as an option. Right now I'm stuck at a second refactoring but the idea is to give the player flexibility on structuring the game when they start it. Right now the end-game routine is a very dumb implementation.

    // meaning all tiles are touched or marked
    // and guesses are correct
    is_board_solved() {
        for( var k in this.board.public ) {
            
            // takes a single unguessed, unrevealed tile
            if(
                this.board.public[k].state === "unknown" &&
                this.board.public[k].guess === false
            ) {
                return( false );
            }

            // or one wrong mine guess
            if(
                this.board.public[k].guess === true &&
                this.board.private[k].mine === false
            ) {
                return( false );
            }
        }
        return( true );
    }