-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcombat.html
27 lines (27 loc) · 846 Bytes
/
combat.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Combat</title>
<link rel="stylesheet" href="css/style.css">
<script>
function rollDice() {
const roll = Math.floor(Math.random() * 6) + 1;
const resultText = roll >= 4
? "You defeated the goblin!"
: "The goblin defeated you!";
document.getElementById('result').textContent = `You rolled a ${roll}. ${resultText}`;
}
</script>
</head>
<body>
<h1>Combat</h1>
<p>Roll the dice to see if you defeat the goblin:</p>
<button onclick="rollDice()">Roll Dice</button>
<p id="result"></p>
<ul>
<li><a href="index.html">Return to the entrance</a></li>
</ul>
</body>
</html>