changed code -> If you win, you can no longer keep moving pieces. Pieces of the winner are marked green, pieces of the loser are marked red

master
ElGurkus 4 years ago
parent 5afbf52dde
commit c9bd677e04

@ -65,7 +65,7 @@ function selectField(field){
somethingIsSelected = true;
}
}
if(!somethingIsSelected && (((field.piece === 1 || field.piece === 11) && turnTotal%2 === 1)||((field.piece === 2 || field.piece === 22) && turnTotal%2 === 0))) {
if(!somethingIsSelected && !gameOver && (((field.piece === 1 || field.piece === 11) && turnTotal%2 === 1)||((field.piece === 2 || field.piece === 22) && turnTotal%2 === 0))) {
field.style.backgroundColor = "rgb(16,43,202, 0.3)";
field.selected = 1;
if(field.piece === 1 || field.piece === 11){
@ -307,4 +307,21 @@ function checkWinCondition(){
document.getElementById("turnTotal").innerText = "Game Over!";
document.getElementById("turnPlayer").innerText = "O Won!";
}
if(gameOver){
for(let i = 0; i < 64; i++){
fieldId = i.toString();
if((document.getElementById("field"+fieldId).piece === 1 || document.getElementById("field"+fieldId).piece === 11) && winner === 1){
document.getElementById("field"+fieldId).style.backgroundColor = "rgb(33,157,35, 0.3)"
}
if((document.getElementById("field"+fieldId).piece === 1 || document.getElementById("field"+fieldId).piece === 11) && winner === 2){
document.getElementById("field"+fieldId).style.backgroundColor = "rgb(227,8,8, 0.3)"
}
if((document.getElementById("field"+fieldId).piece === 2 || document.getElementById("field"+fieldId).piece === 22) && winner === 1){
document.getElementById("field"+fieldId).style.backgroundColor = "rgb(227,8,8, 0.3)"
}
if((document.getElementById("field"+fieldId).piece === 2 || document.getElementById("field"+fieldId).piece === 22) && winner === 2){
document.getElementById("field"+fieldId).style.backgroundColor = "rgb(33,157,35, 0.3)"
}
}
}
}
Loading…
Cancel
Save