Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
krisb1220 opened this issue Feb 17, 2020 · 1 comment
Closed
Assignees
Labels
bug Something isn't working Functionality Issues related to the functionality GUI Issues related to the GUI
Milestone

Comments

@krisb1220
Copy link
Owner

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.

@krisb1220 krisb1220 self-assigned this Feb 17, 2020
@krisb1220 krisb1220 added bug Something isn't working GUI Issues related to the GUI Functionality Issues related to the functionality labels Feb 17, 2020
@krisb1220 krisb1220 added this to Issues in Minesweeper Game via automation Feb 17, 2020
@krisb1220 krisb1220 added this to the GUI milestone Feb 17, 2020
@krisb1220
Copy link
Owner Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Functionality Issues related to the functionality GUI Issues related to the GUI
Projects
Minesweeper Game
  
Issues
Development

No branches or pull requests

1 participant