|
|
|
@ -19,10 +19,17 @@ let turnTotal = 0;
|
|
|
|
|
let turnPlayer;
|
|
|
|
|
let piecesX;
|
|
|
|
|
let piecesO;
|
|
|
|
|
let scoreX = 0;
|
|
|
|
|
let scoreCounterX = 100;
|
|
|
|
|
let scoreO = 0;
|
|
|
|
|
let scoreCounterO = 100;
|
|
|
|
|
let gameOver = false;
|
|
|
|
|
let winner;
|
|
|
|
|
let somethingIsSelected = false;
|
|
|
|
|
|
|
|
|
|
document.getElementById("scoreCounter").innerText = "Score counter: 100";
|
|
|
|
|
document.getElementById("scoreX").innerText = "Score X: 0";
|
|
|
|
|
document.getElementById("scoreO").innerText = "Score O: 0";
|
|
|
|
|
for(let i = 0; i < 64; i++){
|
|
|
|
|
fieldId = i.toString();
|
|
|
|
|
document.getElementById("field"+fieldId).selected = 0; //Sorgt dafür dass alle Felder die selected variable haben und diese 0 ist
|
|
|
|
@ -82,6 +89,7 @@ function selectField(field){
|
|
|
|
|
somethingIsSelected = false;
|
|
|
|
|
resetValidMoves();
|
|
|
|
|
} else if (field.validMove !== 0){
|
|
|
|
|
score(field);
|
|
|
|
|
field.piece = movePiece(field, selectedPiece);
|
|
|
|
|
selectedPiece.piece = 0;
|
|
|
|
|
drawPieces();
|
|
|
|
@ -423,3 +431,29 @@ function checkWinCondition(){
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
function score (field){
|
|
|
|
|
if(field.piece === 0 && turnPlayer === "Player-Turn: X" && scoreCounterX > 10){
|
|
|
|
|
scoreCounterX -= 10;
|
|
|
|
|
} else if(field.piece === 0 && turnPlayer === "Player-Turn: O" && scoreCounterO > 10){
|
|
|
|
|
scoreCounterO -= 10;
|
|
|
|
|
} else if (field.piece === 1){
|
|
|
|
|
scoreO += scoreCounterO;
|
|
|
|
|
scoreCounterO = 100;
|
|
|
|
|
} else if (field.piece === 11){
|
|
|
|
|
scoreO += ((scoreCounterO + 50) * 2)
|
|
|
|
|
scoreCounterO = 100;
|
|
|
|
|
} else if (field.piece === 2){
|
|
|
|
|
scoreX += scoreCounterX;
|
|
|
|
|
scoreCounterX = 100;
|
|
|
|
|
} else if (field.piece === 2){
|
|
|
|
|
scoreX += ((scoreCounterX + 50) * 2)
|
|
|
|
|
scoreCounterX = 100;
|
|
|
|
|
}
|
|
|
|
|
if(turnPlayer === "Player-Turn: X"){
|
|
|
|
|
document.getElementById("scoreCounter").innerText = "Score counter: " + scoreCounterO;
|
|
|
|
|
} else if (turnPlayer === "Player-Turn: O"){
|
|
|
|
|
document.getElementById("scoreCounter").innerText = "Score counter: " + scoreCounterX;
|
|
|
|
|
}
|
|
|
|
|
document.getElementById("scoreO").innerText = "Score O: " + scoreO;
|
|
|
|
|
document.getElementById("scoreX").innerText = "Score X: " + scoreX;
|
|
|
|
|
}
|