diff --git a/schlangen_und_leitern/js/playerHandling.js b/schlangen_und_leitern/js/playerHandling.js index 301e439..f8da9ea 100644 --- a/schlangen_und_leitern/js/playerHandling.js +++ b/schlangen_und_leitern/js/playerHandling.js @@ -33,44 +33,26 @@ function movePlayer(player, roll){ player.newPosition = player.position + roll; if(player.newPosition >= 100){ player.newPosition = 100; - //TODO gewinn aufrufen. } - //TODO Schlange oder Leiter fehlschalg. + } + + function initialise(count, playerArray){ + //player id ie. count 0 = + var id = count +1; + var Token = document.createElement("div") + let position = playerArray[count].position + var boardPostition = boardLocation(position); + Token.classList.add("p"+ id); + Token.id = "p" + id; + document.getElementById(boardPostition).appendChild(Token) + + } + //Draw Spieler bei Spiele init function playerInit(playerArray){ for(let i = 0; i < playerArray.length; i++){ - var Token = document.createElement("div") - if(i == 0){ - let position = playerArray[i].position - var boardPostition = boardLocation(position); - Token.classList.add("p1"); - Token.id = "p1"; - document.getElementById(boardPostition).appendChild(Token) - } - else if(i == 1){ - let position = playerArray[i].position - var boardPostition = boardLocation(position); - Token.classList.add("p2"); - Token.id = "p2"; - document.getElementById(boardPostition).appendChild(Token) - } - else if(i == 2){ - let position = playerArray[i].position - var boardPostition = boardLocation(position); - Token.classList.add("p3"); - Token.id = "p3"; - document.getElementById(boardPostition).appendChild(Token) - } - else if(i == 3){ - let position = playerArray[i].position - var boardPostition = boardLocation(position); - Token.classList.add("p4"); - Token.id = "p4"; - document.getElementById(boardPostition).appendChild(Token) - } - - + initialise(i,playerArray) } }