Skip to content

Planning

AlyxMoon edited this page Jul 6, 2021 · 1 revision

Gameplay modes, aspects?

  • difficulty modes
    • what does difficulty set
      • size of board
      • number of bombs
      • visibility of counters
    • possible options:
      • easy
        • dimensions: 10x10
        • bombs: 10
      • medium
        • dimensions: 15x15
        • bombs: 40
      • hard
        • dimensions: 20x30
        • bombs: 100
        • extras!
          • do not show bomb counter

What's the Game Loop?

  1. User selects mode to play (at any time)
  2. Create game board based on options
  3. Start timer and show counters
  4. Game has begun, run loop!
    1. User clicks on a cell
    2. Run game logic to check what happens
    3. Show current board state to the user
    4. if win/lose, do whatever and exit loop
  5. timer stops
  6. Present options, go back to step 1

What's needed for business logic

class Cell

  • properties:
    • isBomb: bomb or not (boolean)
    • hasFlag: (boolean)
    • hasQuestionMark: (boolean)
    • adjacentBombs: (0-8)
    • isVisible (boolean)

class GameBoard

  • properties:

    • board (2D array of cell objects)
    • bombNum
    • flagsPlanted
    • complete (boolean)
    • numOfOpenCells
  • methods:

    • constructor(rowNum, colNum, bombNum)

    • generateBoard()

      • create the array with right row/col count
      • place bombs in
        • placeBomb() method
      • calculate for each cell how many bombs are around them
    • clearing()

      • when you click on a cell w/ a value of 0, it will open up all 8 adjacent cells. Additionally, any cells that are opened w/ a value of 0 will also call on clearing().
    • checkCell()

      • if isVisible is true or hasFlag is true, do nothing

      • call checkWinGame() and checkLoseGame()

        • act accordingly with the related displays if true
      • check for number (call clearing() if value is 0)

      • make cell visible

    • markCell()

      • if isVisible is true, do nothing

      • check property of cell being clicked, based on that:

        • place flag or question mark
    • checkWinGame()

      • when all non-bomb cells are open to win
    • checkLoseGame()

      • when a bomb in clicked (lose)
    • winDisplay()

      • stop and display "win"
      • play again
    • loseDisplay()

      • Unsmile
      • show all bombs locations
      • "go back to menu" button

What's needed for UI logic

  • draw the playing board

    • have some icon/whatever for a unidentified cell
    • have an icon/whatever for the flag
    • have an icon/whatever for the question marks
    • have an icon/whatever for a number (adjecent bombs)
    • have an icon/whatever for a blank square
    • have an icon/whatever for a bomb
  • show number of bombs

  • counters, what to show:

    • number of bombs remaining (based on flags marked)
    • timer since first click
    • (extra if time) number of moves
    • (extra if time) number of cells visible/not visible
  • put smiley face

  • add event listener for when cell is left clicked

    • call checkCell()
  • add event listener for when cell is right clicked

    • call markCell()
  • add event listener for dropdown for new game based on difficulty of (easy, medium, hard)

  • add event listener for pause button (maybe, if we include pause button?)

  • possible convenience thing: right click on open cell to auto open adjacent ones (if bombs around have been found)

Clone this wiki locally