sei-ec-remote / project-1-issues

Open new issues here
1 stars 2 forks source link

"flag" button #240

Closed RyanCLuis closed 11 months ago

RyanCLuis commented 11 months ago

What's the problem you're trying to solve?

i am trying to get it to where when i click a tile to place a "head", i can click the same tile to remove the "head"

Post any code you think might be relevant (one fenced block per file)

function tileClicked() {
    let tile = this
    console.log("tile clicked!", tile.id)
    console.log("tile innerText:", tile.innerText)
    // this statement will happen === true then the rest wont happen
    if (gameOver || this.classList.contains("tile-clicked") || this.innerText === "🥴") {
        return
    }
    // this is to place the "flag" on the tiles
    if (headEn) {
        if (tile.innerText === "") {
            tile.innerText = "🥴"
        } else if (tile.innerText === "🥴") {
            tile.innerText = ""
        }
        // putting return so I don't hit a mind when I set a head
        return
    }

If you see an error message, post it here. If you don't, what unexpected behavior are you seeing?

there are no error message, just cant click the "head" that i've placed

What is your best guess as to the source of the problem?

What things have you already tried to solve the problem?

as you see, i added console.logs to see me actually clicking the tiles etc. i tried rewriting the else statement to see if it works.

Paste a link to your repository here

https://github.com/RyanCLuis/Minesweeper

nayaba commented 11 months ago

Try changing 🥴 to a character like X - I suspect javascript is not able to read 🥴 as anything....

Might need to do some deep diving to find out how to continue to use emojis 🥴

RyanCLuis commented 11 months ago

i just change all my 🥴 to "x" and it still doesnt allow me to remove the x

RyanCLuis commented 11 months ago

I fixed it, when going thru my code, i want it to return if it sees a 🥴. so i added an additional line to the code to return and do nothing if it sees 🥴.