Skip to content

Commit

Permalink
fix bug in play againstcomputer.is
Browse files Browse the repository at this point in the history
  • Loading branch information
ruiwenge2 committed Aug 31, 2021
1 parent b16b38a commit 8da8d64
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions public/js/game/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@ function sleep(number){
});
}
function print(text){
document.getElementById("allmoves").innerHTML += text + "<br><br>";
document.getElementById("allmoves").innerText += text;
document.getElementById("allmoves").innerHTML += "<br><br>";
focusMoves();
}
function clear(){
document.getElementById("allmoves").innerHTML = "";
document.getElementById("allmoves").innerText = "";
}
function showWinner(character, username, character2, username2){
setTimeout(function(){alertmodal("Game Ended!", `Because ${character2.name} (${username2}) has no more health, ${character.name} (${username}) has won the game!`).then(() => location.href = "/join")}, 1500);
Expand Down
5 changes: 3 additions & 2 deletions public/js/game/playagainstcomputer.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
var otherchar, othermove;
const otheruser = "Computer";
const characterslist = ["Spiderman", "Pikachu", "Hercules", "Jedi", "Voldemort", "Thanos", "Medusa"];
const othercharacter = characterslist[randint(0, characterslist.length)];
const othercharacter = characterslist[random(0, characterslist.length - 1)];
switch(othercharacter){
case "Spiderman":
otherchar = new Spiderman();
Expand All @@ -23,9 +24,9 @@ switch(othercharacter){
case "Medusa":
otherchar = new Medusa();
break;
}
document.getElementById("player2").style.display = "block";
document.getElementById("allmoves-h1").style.display = "block";
otheruser = username;
updateStatus();
showMoves();

Expand Down

0 comments on commit 8da8d64

Please sign in to comment.