Browse Source

movePlayer-funktion hinzugefügt

main
Richard Halsall 2 years ago
parent
commit
6513f96a42
  1. 18
      schlangen_und_leitern/js/playerHandling.js

18
schlangen_und_leitern/js/playerHandling.js

@ -1,12 +1,10 @@
function PlayerBuilder(id, boardArr){
function PlayerBuilder(){
this.id = id;
this.location = boardArr;
this.position = 1;
console.log("player" + id + "built");
} }
@ -21,7 +19,17 @@ function buildPlayerArray(playerCount, boardArr){
playerArray.push(player) playerArray.push(player)
console.log("player added to array!") console.log("player added to array!")
} }
return playerArray; return playerArray;
}
function movePlayer(player, roll){
player.position += roll;
if(player.position >= 99){
player.position = 99;
}
console.log(player.position);
} }
Loading…
Cancel
Save