Skip to content

Commit

Permalink
show settings #11
Browse files Browse the repository at this point in the history
  • Loading branch information
michivonah committed Jan 23, 2023
1 parent 13b62a7 commit 3743b9a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 8 deletions.
15 changes: 14 additions & 1 deletion game.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ let player3 = []; // Cards of CPU Player 3
let trump; // The current trump
let currentTurn; // Which player is in turn
let givenCards = 0; // total given cards in this game
let speed = 1000; // Speed of the CPU Players in ms
let scores = [ // The scoreboard
{
"score": "0"
Expand Down Expand Up @@ -573,7 +574,7 @@ function cpuPlayer(playerNumber){
}
}
giveCard(cardToGive, playerNumber);
}, 1000);
}, speed);
}

function countPoints(){
Expand Down Expand Up @@ -742,4 +743,16 @@ function toggleMusic(){
else{
player.muted = true;
}
}

function saveSettings(){
speed = document.getElementById("playerSpeed").value;
localStorage.setItem("speed", speed);
localStorage.setItem("playerNames", document.getElementById("playerNames").value);
}

function loadSettings(){
speed = parseInt(localStorage.getItem("speed"));
document.getElementById("playerSpeed").value = speed;
document.getElementById("playerNames").value = localStorage.getItem("playerNames");
}
15 changes: 8 additions & 7 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ <h1>Jassen by Michi</h1>
<button onclick="toggleSection('tutorial', 'block')" style="display:none;">Anleitung/Regeln</button>
<button onclick="toggleSection('copyright', 'block')">Copyright</button>
<button onclick="toggleSection('imprint', 'block')">Impressum</button>
<button onclick="toggleSection('settings', 'block')" style="display:none;">Einstellungen</button>
<button onclick="toggleSection('settings', 'block')">Einstellungen</button>
<p>Kontakt: <a href="mailto:[email protected]" alt="Kontakt per Mail" title="Kontakt per Mail">[email protected]</a></p>
<div id="copyright" class="hiddenSection">
<h2>Copyright</h2>
Expand All @@ -93,17 +93,16 @@ <h2>Anleitung/Regeln</h2>
</div>
<div id="settings" class="hiddenSection">
<h2>Einstellungen</h2>
<label for="cardSet">Kartendesign</label>
<select id="cardSet" name="cardSet">
<label for="cardSet" style="display: none;">Kartendesign</label>
<select id="cardSet" name="cardSet" onchange="saveSettings()" style="display: none;">
<option value="jassverzeichnis" selected>jassverzeichnis.ch</option>
<option value="michivonah" disabled>jass.von-ah.me</option>
<option value="yourown" disabled>Custom</option>
</select>
<label for="playerNames">Namen der Mitspieler (durch Komma getrennt)</label>
<input id="playerNames" name="playerNames" type="text" placeholder="Sepp, Kari, Heidi" value="Sepp, Kari, Heidi">
<input id="playerNames" name="playerNames" type="text" placeholder="Sepp, Kari, Heidi" value="Sepp, Kari, Heidi" onchange="saveSettings()">
<label for="playerSpeed">Geschwindigkeit der Gegner (in Millisekunden)</label>
<input id="playerSpeed" name="playerSpeed" type="number" placeholder="1000ms" value="1000">
<button>Speichern</button>
<input id="playerSpeed" name="playerSpeed" type="number" placeholder="1000ms" value="1000" onchange="saveSettings()">
</div>
<div id="changelog" class="hiddenSection">
<h2>Changelog</h2>
Expand All @@ -112,6 +111,7 @@ <h2>Changelog</h2>
<li>Fehler beim Punktez&auml;hlen nun behoben</li>
<li>Algorithmus der Gegner komplett &uuml;berarbeitet</li>
<li>Arbeit an den Einstellungen begonnen</li>
<li>Gegner-Spielgeschwindigkeit kann nun angepasst werden</li>
</ul>
<p>22. Januar 2023</p>
<ul>
Expand Down Expand Up @@ -236,8 +236,9 @@ <h2>Changelog</h2>
// Loading
window.addEventListener('load', () => {
setTimeout(function(){
loadSettings()
document.getElementById('loadingScreen').style.display = "none";
}, 1500);
}, 1000);
});

window.addEventListener('blur', () =>{
Expand Down

0 comments on commit 3743b9a

Please sign in to comment.