Closed ItsAlbi007 closed 9 months ago
Can you list out what some of the bugs are here, so we can have them in a list, from there we can systematically approach them one by one.
well all my bugs are the EvnetListners to many of them and they are somehow getting mixed up with one another when i play the game and i wanna clean it up
There's not too many of them to at least start a list. I'm doing this to force you into being able to write about your code. So write about your code. What's going on with the event listeners? What's the expected behavior and what is the actual behavior? How are they getting mixed up with one another? Why do you think it's happening?
okay hi i was breaking down some stuff and i think im repeating the diagonalOne and digonalTwo into doing the backgroundcolor Yellow on a few spots and im guessing thats wats throwing my code off its just a guess but i think that could be it ??
possibly! If you have an idea of which code is causing the bugs, share them as separate code blocks, with a brief explanation of each, here as a reply.
function resetLastColor(color){
if(firstChecker) {
const col = parseInt(firstSquare.id[1])
const row = parseInt(firstSquare.id[3])
if (color === "red"){
diagonalOne = document.querySelector(`#c${col - 1}r${row + 1}`)
diagonalTwo = document.querySelector(`#c${col - 1}r${row - 1}`)
} else if (color === "blue") {
diagonalOne = document.querySelector(`#c${col + 1}r${row + 1}`)
diagonalTwo = document.querySelector(`#c${col + 1}r${row - 1}`)
}
if (diagonalOne) {
diagonalOne.style.backgroundColor = ""
diagonalOne.removeEventListener("click",function handler(){moveChecker(diagonalOne,checker)})
}
if (diagonalTwo){
diagonalTwo.removeEventListener("click",function handler(){moveChecker(diagonalTwo,checker)})
diagonalTwo.style.backgroundColor = ""
}
}
}
if (diagonalOne && diagonalOne.innerHTML === ""){
diagonalOne.style.backgroundColor = "yellow"
diagonalOne.addEventListener("click",function handler(){moveChecker(diagonalOne)})
// the purpose for diagonalone and two EvenetListner is to highlight yellow when the movechecker function is being called and highlight square are clicked
} else if(diagonalOne && diagonalOne.children[0]) {
checkForSkip(diagonalOne)
}
if (diagonalTwo && diagonalTwo.innerHTML === "") {
diagonalTwo.style.backgroundColor = "yellow"
diagonalTwo.addEventListener("click",function handler(){moveChecker(diagonalTwo)})
// the purpose for diagonalone and two EventListner is to highlight yellow when the movechecker function is being called and highlight square are clicked
these two are doing the same thing first one is in function resetLastColor and second one is function handleClick are these two overriding eachother in some type of way
wait im wrong hold up
okay so i went one by one and commented them out they are all where they are supposed to be but the issue im having is sometimes the squares dont lose the highlighted spot im just very confused right now to be honest
okay so i went one by one and commented them out they are all where they are supposed to be but the issue im having is sometimes the squares dont lose the highlighted spot im just very confused right now to be honest
i figured something out every time i take out a checker that's spot gets highlighted and it doesn't move
resolved with console logs and elbow grease
What's the problem you're trying to solve?
i kinda hit MVP i think but i have to just a lil to many bugs on my codes and i wanna clean it up
Post any code you think might be relevant (one fenced block per file)
If you see an error message, post it here. If you don't, what unexpected behavior are you seeing?
What is your best guess as to the source of the problem?
my best guess is to clean up all the eventListners
What things have you already tried to solve the problem?
me and tylus tried but we couldnt and he said he is going to talk to you guys today Timm and Neb on how you would go on cleaning up my project with all the eventListeners and stuff thats all i know
Paste a link to your repository here
https://github.com/ItsAlbi007/G-Project