Browse Source

Refactoring: Die Rolltaste ruft nun die Hauptspielschleife auf, anstatt von der Hauptspielschleife aufgerufen zu werden

main
Richard Halsall 2 years ago
parent
commit
6b8ff0b18f
  1. 9
      schlangen_und_leitern/HTML.html
  2. 30
      schlangen_und_leitern/js/Bridge.js

9
schlangen_und_leitern/HTML.html

@ -8,6 +8,7 @@
<script type="text/javascript" src="js/diceHandling.js"></script>
<script type= "text/javascript" src="js/makeBoard.js"></script>
<script type= "text/javascript" src="js/Bridge.js"></script>
<script type= "text/javascript" src="js/playerHandling.js"></script>
<title>Document</title>
@ -19,9 +20,9 @@
<body>
<div class = playerSelect>
<input type="button" class = "playerButton" id="2Player" onclick="mainGame(2)" value="2 Spieler"></input>
<input type="button" class = "playerButton" id="3Player" onclick="mainGame(3)" value ="3 Spieler"></input>
<input type="button" class = "playerButton" id="4Player" onclick="mainGame(4)" value = "4 Spieler"></input>
<input type="button" class = "playerButton" id="2Player" onclick="init(2)" value="2 Spieler"></input>
<input type="button" class = "playerButton" id="3Player" onclick="init(3)" value ="3 Spieler"></input>
<input type="button" class = "playerButton" id="4Player" onclick="init(4)" value = "4 Spieler"></input>
</div>
@ -29,7 +30,7 @@
<table id = "board"></table>
<div class = container id="würfelBereich" style="display: none;" >
<img src="/img/wurfle/f(1).png" id="face">
<input type = "button" id="rollButton" onclick = "changeFace();" value = "Würfeln">
<input type = "button" id="rollButton" value = "Würfeln">
</div>
</div>

30
schlangen_und_leitern/js/Bridge.js

@ -1,7 +1,7 @@
let turnCount = 1;
function mainGame(playerCount){
function init(playerCount){
//playerselect versctecken
document.getElementById("2Player").style.display = "none";
document.getElementById("3Player").style.display = "none";
@ -11,22 +11,17 @@ function mainGame(playerCount){
document.getElementById("würfelBereich").style.display = "grid";
// build/show board + get board array
boarArr = buildBoard();
drawBoard(boarArr);
boardArr = buildBoard();
drawBoard(boardArr);
// make x "player" structures and add them to array
let playerArray = buildPlayerArray(playerCount);
let rollresult = rollDice();
console.log("roll result =" + rollresult);
//miain game loop dictated by the pression of the dice roll button
document.getElementById("rollButton").addEventListener("click", function(){gameloop(boardArr,playerArray, playerCount);});
// make x "player" structures and add them to array
//Haupt game loop
//select player
@ -37,16 +32,11 @@ function mainGame(playerCount){
// victory condition
//if boardArr + roll => 99 player n wins
//new game
}
function gameloop (boardArr, playerArray, playerCount){
let roll = rollDice();
}
Loading…
Cancel
Save