From 6513f96a42bc48020e2acec0c703b3f054899b2f Mon Sep 17 00:00:00 2001 From: Richard Halsall <–richard-glyn.halsall@informatik.hs-fulda.e> Date: Wed, 1 Feb 2023 18:32:31 +0100 Subject: [PATCH] =?UTF-8?q?movePlayer-funktion=20hinzugef=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- schlangen_und_leitern/js/playerHandling.js | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/schlangen_und_leitern/js/playerHandling.js b/schlangen_und_leitern/js/playerHandling.js index 610152b..ea605c0 100644 --- a/schlangen_und_leitern/js/playerHandling.js +++ b/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) console.log("player added to array!") } - + return playerArray; +} + +function movePlayer(player, roll){ + +player.position += roll; +if(player.position >= 99){ + player.position = 99; +} +console.log(player.position); + } \ No newline at end of file