-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathknp.html
173 lines (150 loc) · 4.91 KB
/
knp.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
<!DOCTYPE html>
<html>
<style>
@font-face {
font-family: "Exo 2";
src: url("Exo2-VariableFont_wght.ttf");
}
body {
font-family: "Exo 2";
animation: pulse 15s infinite;
}
.button {
background-color: white;
color: black;
padding: 5px; /* Adjust the height of the button here */
margin-right: 10px;
border-radius: 5px;
box-shadow: none; /* Remove the black border */
transition-duration: 0.4s;
width: 60px; /* Adjust the width of the button here */
cursor: pointer; /* Change the cursor to a pointer when hovering over the button */
}
.resetButton {
background-color: white;
color: black;
padding: 5px; /* Adjust the height of the button here */
margin-right: 10px;
border-radius: 5px;
box-shadow: none; /* Remove the black border */
transition-duration: 0.4s;
width: 80px; /* Adjust the width of the button here */
cursor: pointer; /* Change the cursor to a pointer when hovering over the button */
}
.button:hover, .resetButton:hover {
background-color: darkslateblue;
color: white;
}
@keyframes pulse {
0% {
background-color: white;
}
50% {
background-color: #3ead85;
}
100% {
background-color: white;
}
}
#scoreboard {
position:absolute;
top:10px;
right:10px;
border-radius:15px; /* Increase the border radius here */
padding:10px;
background-color:#f8f8f8;
border:1px solid #ddd;
}
</style>
<head>
<title>Kámen, nůžky, papír</title>
</head>
<body>
<audio id="winSound" src="win.mp3" preload="auto"></audio>
<audio id="drawSound" src="draw.mp3" preload="auto"></audio>
<audio id="loseSound" src="lose.mp3" preload="auto"></audio>
<audio id="resetSound" src="reset.mp3" preload="auto"></audio>
<h1>Kámen, nůžky, papír</h1>
<button class="button" onclick="hraj('kámen')" title="Kámen">🪨</button>
<button class="button" onclick="hraj('nůžky')" title="Nůžky">✂️</button>
<button class="button" onclick="hraj('papír')" title="Papír">📑</button>
<p id="vysledek"></p>
<a href="index.html" style="position:absolute; bottom:10px; right:10px;">Hlavní strana</a>
<div id="scoreboard">
<h2>Skóre 📊</h2>
<hr/>
<p>Výhry 🏆: <span id="wins">0</span></p>
<p>Remízy 😐: <span id="draws">0</span></p>
<p>Prohry ☄️: <span id="losses">0</span></p>
<hr/>
<p>Celkové skóre 🎉: <span id="total">0</span></p>
<hr/>
<p>Celkový počet tahů 🔄: <span id="totalMoves">0</span></p>
<button class="resetButton" onclick="confirmReset()" title="Vyresetovat všechny hodnoty na 0">🔁 Resetovat skóre</button>
</div>
<script>
var wins = parseInt(localStorage.getItem('wins')) || 0,
draws = parseInt(localStorage.getItem('draws')) || 0,
losses = parseInt(localStorage.getItem('losses')) || 0,
totalMoves = parseInt(localStorage.getItem('totalMoves')) || 0;
function playSound(soundId) {
var sound = document.getElementById(soundId);
sound.play();
}
function hraj(hrac) {
var moznosti = ['kámen', 'nůžky', 'papír'];
var pocitac = moznosti[Math.floor(Math.random() * moznosti.length)];
totalMoves++;
localStorage.setItem('totalMoves', totalMoves);
if (hrac === pocitac) {
document.getElementById("vysledek").style.color = "yellow";
document.getElementById("vysledek").textContent = "Remíza!";
draws++;
localStorage.setItem('draws', draws);
playSound('drawSound');
} else if ((hrac === 'kámen' && pocitac === 'nůžky') || (hrac === 'nůžky' && pocitac === 'papír') || (hrac === 'papír' && pocitac === 'kámen')) {
document.getElementById("vysledek").style.color = "green";
document.getElementById("vysledek").textContent = "GG, vyhrál jsi 🎉!";
wins++;
localStorage.setItem('wins', wins);
playSound('winSound');
} else {
document.getElementById("vysledek").style.color = "red";
document.getElementById("vysledek").textContent = "Bohužel, bot vyhrál ☄️.";
losses++;
localStorage.setItem('losses', losses);
playSound('loseSound');
}
// Update the scoreboard
updateScoreboard();
}
function updateScoreboard() {
document.getElementById("wins").textContent = wins;
document.getElementById("draws").textContent = draws;
document.getElementById("losses").textContent = losses;
document.getElementById("total").textContent = wins - losses;
document.getElementById("totalMoves").textContent = totalMoves;
}
function resetScore() {
wins = 0;
draws = 0;
losses = 0;
totalMoves = 0;
localStorage.setItem('wins', wins);
localStorage.setItem('draws', draws);
localStorage.setItem('losses', losses);
localStorage.setItem('totalMoves', totalMoves);
updateScoreboard();
alert("Skóre resetováno!");
playSound('resetSound');
}
function confirmReset() {
if (confirm("Opravdu chcete resetovat skóre?")) {
resetScore();
}
}
// Update the scoreboard when the page loads
updateScoreboard();
</script>
</body>
</html>