-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
41 lines (35 loc) · 1.33 KB
/
index.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>playful-duel-game</title>
<meta name="description" content="Lovable Generated Project" />
<meta name="author" content="Lovable" />
<meta property="og:image" content="/og-image.png" />
<script src="/socket.io/socket.io.js"></script>
</head>
<body>
<div id="root"></div>
<script src="https://cdn.gpteng.co/gptengineer.js" type="module"></script>
<script type="module" src="/src/main.tsx"></script>
<h1>Rock Paper Scissors</h1>
<button onclick="makeChoice('rock')">Rock</button>
<button onclick="makeChoice('paper')">Paper</button>
<button onclick="makeChoice('scissors')">Scissors</button>
<h2>Opponent's Choice: <span id="opponent-choice">Waiting...</span></h2>
<h2>Round Results: <span id="round-results">Waiting...</span></h2>
<script>
const socket = io();
function makeChoice(choice) {
socket.emit('choice', choice);
}
socket.on('roundResults', (results) => {
const resultText = results.isTie
? 'It\'s a tie!'
: `Winners: ${results.winners.join(', ')}`;
document.getElementById('round-results').textContent = resultText;
});
</script>
</body>
</html>