BattleOfAI icon indicating copy to clipboard operation
BattleOfAI copied to clipboard

The website shows "undefined" instead of "X" and "O".

Open ndsvw opened this issue 6 years ago • 1 comments

Describe the bug The website shows "undefined" instead of "X" and "O" when I want to comprehend a match. bildschirmfoto 2018-09-29 um 08 38 40

To Reproduce Just open https://battleofai.net/game.html?id=62 for example and click the ">" button multiple times.

Expected behavior I would expect "X"s and "O"s instead of "undefined"s.

Desktop (please complete the following information): It's OS-independent and browser-independent.

ndsvw avatar Sep 29 '18 06:09 ndsvw

I think I found the bug:

if (parseInt(getCookie("userid")) === data["players"][0]["id"]){
    var white = "<div style='width: 40px; height: 40px; background-color: white; border-radius: 25px; border: 1px solid red'></div>";
    var black = "<div style='width: 40px; height: 40px; background-color: black; border-radius: 25px; border: 1px solid white'></div>";
}
if (parseInt(getCookie("userid")) === data["players"][1]["id"]){
    var white = "<div style='width: 40px; height: 40px; background-color: white; border-radius: 25px; border: 1px solid black'></div>";
    var black = "<div style='width: 40px; height: 40px; background-color: black; border-radius: 25px; border: 1px solid red'></div>";
}

getCookie("userid") returns undefined and parsed as int NaN which doesn't strictly equal a number, which results in white and black being undefined too. After that white and black are anyways used to "fill" the grid:

if (board[x][y] === "X") {
    newelement = newelement.replace("#", white);
} else if(board[x][y] === "O") {
    newelement = newelement.replace("#", black);
}

I don't know if its just me, but for some reason, I do not have to be logged in to get to the "member" area, therefore have no cookie userid, and can't view and games (technically I can, but that's not how it should be).

Temporary solution

Go to the "root"-page, aka https://battleofai.net/, and (logout and re-)login.

ghost avatar Sep 29 '18 10:09 ghost