Giter VIP home page Giter VIP logo

minesweeper's People

Contributors

krisb1220 avatar

Stargazers

 avatar  avatar

Watchers

 avatar

minesweeper's Issues

Code needs to be refactored to delete padding cells + add logic for detecting mines in tile 1, x, last, and last-x

Padding cells are no longer needed after the implementation of the following code. Logic for tile 1, tile x, last cell, and last cell - x is needed before padding cells can be deleted.

      //right
      if(field.fieldObject[value.integerLocation + 1].hasBomb && value.integerLocation % field.x != 2 ) {
        bombsInCell++;
      } 

      //left
     if(field.fieldObject[value.integerLocation - 1].hasBomb && value.integerLocation % field.x != 3) {
        bombsInCell++;
      }      


      //top
      if(field.fieldObject[value.integerLocation - field.x].hasBomb) { 
        bombsInCell++;
      } 

      //top right
      if(field.fieldObject[(value.integerLocation - field.x)+1].hasBomb && value.integerLocation % field.x != 2 ) {
        bombsInCell++;
      } 

      //top left
      if(field.fieldObject[(value.integerLocation - field.x)-1].hasBomb  && value.integerLocation % field.x != 3) {
        
        bombsInCell++;
      }       

      //bottom
      if(field.fieldObject[value.integerLocation + field.x].hasBomb) {
        bombsInCell++;
      } 

      //bottom right
      if(field.fieldObject[(value.integerLocation + field.x)+1].hasBomb && value.integerLocation % field.x != 2 ) {
        bombsInCell++;
      } 

      //bottom left
      if(field.fieldObject[(value.integerLocation + field.x)-1].hasBomb  && value.integerLocation % field.x != 3 ) {
        bombsInCell++;
      }       

Wrong number calculation (on edge?)

Numbers on the edge are not calculating correctly. Calculating the last 2 cells. Fix by adding an extra cell before & after each row.

Right on Edge

image

1 over

image

?

image

When you click a mined cell's number it returns an error in the console

The error is happening because of the following code in game.js:

function detectClicks() {

  let tiles = document.querySelectorAll(".tile") 

  forEach(tiles, function(tile){
    tile.addEventListener("click", function(event){

      clicked = field.fieldObject[event.target.id]

       if(event.shiftKey) {
         placeFlag(clicked);
       }

       else if(!event.shiftKey){
        clicked.hasBomb ? lose() : mineTile(clicked);
       }
  });
});

and the following code in game-helpers.js from line 128 - 131

	if(!tile.isMined) {
		document.getElementById(tile.integerLocation).innerHTML = "<p class='number'>" + tile.bombsInCell + "</p>";
		document.getElementById(tile.integerLocation).classList.add("tile-mined");
	} 

This can be fixed by changing the tile numbering from an ID to a class, then appending the classname to the paragraph holding the number.

Append numbers to page AFTER button click

The current procedure appends the numbers to each element BEFORE the buttons are clicked. For both cheating & general flow reasons, it should be AFTER the click.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.