From da0f30e3cd9e5c9917cf764a91f0b597c1870d07 Mon Sep 17 00:00:00 2001 From: Richard Halsall <–richard-glyn.halsall@informatik.hs-fulda.e> Date: Thu, 2 Feb 2023 17:56:24 +0100 Subject: [PATCH] =?UTF-8?q?cellFinder-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 | 29 +++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/schlangen_und_leitern/js/playerHandling.js b/schlangen_und_leitern/js/playerHandling.js index ea605c0..4a51084 100644 --- a/schlangen_und_leitern/js/playerHandling.js +++ b/schlangen_und_leitern/js/playerHandling.js @@ -4,6 +4,7 @@ function PlayerBuilder(){ this.position = 1; + this.newPosition; } @@ -24,6 +25,8 @@ function buildPlayerArray(playerCount, boardArr){ } + + function movePlayer(player, roll){ player.position += roll; @@ -32,4 +35,28 @@ if(player.position >= 99){ } console.log(player.position); -} \ No newline at end of file +} + +//wandelt Zellennummer in html-Element um +function boardLocation(cellNumber){ +var table = document.getElementById('board'); +var found = false; +var tableId; +for(let i = 0; i < 10; i++){ + for(let j = 0; j < 10; j++){//findet der zelle ID von Stellenummer + if(table.rows[i].cells[j].innerHTML == cellNumber){ + found = 1; + tableId = table.rows[i].cells[j].id; + break; + } + } + } + if(found == true){ + + return tableId; + } + else{ + + log.console("Error: Zellenummer nicht gefunden"); //Druckt Errror auf dem console wenn unerfolgereich + } +}