Raphael Elström
2 years ago
5 changed files with 80 additions and 52 deletions
-
4vier_gewinnt/JS/steinSetzen.js
-
20vier_gewinnt/JS/steineInSpalte.js
-
13vier_gewinnt/JS/vierInSpalte.js
-
7vier_gewinnt/tests/test_vierGewint.test.js
-
84vier_gewinnt/vierGewinnt.html
@ -1,20 +1,28 @@ |
|||
|
|||
|
|||
|
|||
|
|||
function steinInSpalte(spalte) { |
|||
// Feld mit Steinen in Zeile
|
|||
// O = kein Stein
|
|||
// 1 = gruener Stein
|
|||
// 2 = roter Stein
|
|||
var zeile = []; |
|||
var zeile1 = []; |
|||
|
|||
for (let i = 1; i <= 6; i++) { |
|||
var color = document.getElementById(i + "/" + spalte).style.backgroundColor; |
|||
|
|||
if (document.getElementById( i +"/"+ spalte).style.backgroundColor == "red") { |
|||
zeile.push(2); |
|||
}if (document.getElementById(i + "/"+ spalte).style.backgroundColor == "green") { |
|||
zeile.push(1); |
|||
if (color == "red") { |
|||
zeile1.push(2); |
|||
}else if (color == "green") { |
|||
zeile1.push(1); |
|||
} else { |
|||
zeile.push(0); |
|||
zeile1.push(0); |
|||
} |
|||
} |
|||
|
|||
return zeile1; |
|||
|
|||
|
|||
} |
|||
//module.exports = steinInSpalte;
|
@ -0,0 +1,13 @@ |
|||
function vierInSpalte(spalte){ |
|||
if(spalte == [0, 0, 1, 1, 1, 1] || spalte == [0, 1, 1, 1, 1, 0] || spalte == [1, 1, 1, 1, 0, 0]|| spalte == [1, 1, 1, 1, 1, 0]|| spalte == [0, 1, 1, 1, 1, 1]|| spalte == [1, 1, 1, 1, 1, 1] || spalte == [2, 2, 1, 1, 1, 1] || spalte == [2, 1, 1, 1, 1, 2] || spalte == [1, 1, 1, 1, 2, 2]|| spalte == [1, 1, 1, 1, 1, 2]|| spalte == [2, 1, 1, 1, 1, 1]){ |
|||
//Spieler Gruen
|
|||
return 1; |
|||
} |
|||
else if(spalte == [0, 0, 2, 2, 2, 2] || spalte == [0, 2, 2, 2, 2, 0] || spalte == [2, 2, 2, 2, 0, 0]|| spalte == [2, 2, 2, 2, 2, 0]|| spalte == [0, 2, 2, 2, 2, 2]|| spalte == [2, 2, 2, 2, 2, 2] || spalte == [1, 1, 2, 2, 2, 2] || spalte == [1, 2, 2, 2, 2, 1] || spalte == [2, 2, 2, 2, 1, 1]|| spalte == [2, 2, 2, 2, 2, 1]|| spalte == [1, 2, 2, 2, 2, 2]){ |
|||
//Spieler Rot
|
|||
return 2; |
|||
} else { |
|||
return 0; |
|||
} |
|||
} |
|||
module.exports = vierInSpalte; |
Write
Preview
Loading…
Cancel
Save
Reference in new issue