Spaces:
Running
Running
Update index.html
Browse files- index.html +77 -16
index.html
CHANGED
@@ -1,19 +1,80 @@
|
|
1 |
<!DOCTYPE html>
|
2 |
<html>
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
</html>
|
|
|
1 |
<!DOCTYPE html>
|
2 |
<html>
|
3 |
+
<head>
|
4 |
+
<title>Dungeons & Dragons</title>
|
5 |
+
<style>
|
6 |
+
body {
|
7 |
+
font-family: Arial, sans-serif;
|
8 |
+
}
|
9 |
+
#output {
|
10 |
+
white-space: pre-wrap;
|
11 |
+
background-color: #f0f0f0;
|
12 |
+
padding: 10px;
|
13 |
+
margin-top: 10px;
|
14 |
+
border-radius: 5px;
|
15 |
+
}
|
16 |
+
</style>
|
17 |
+
</head>
|
18 |
+
<body>
|
19 |
+
<h1>Dungeons & Dragons: Adventure Awaits</h1>
|
20 |
+
<button id="createCharacter">Create Character</button>
|
21 |
+
<button id="startAdventure">Start Adventure</button>
|
22 |
+
<button id="attack">Attack</button>
|
23 |
+
<button id="castSpell">Cast Spell</button>
|
24 |
+
<div id="output"></div>
|
25 |
+
|
26 |
+
<script>
|
27 |
+
let character = {};
|
28 |
+
|
29 |
+
document.getElementById("createCharacter").addEventListener("click", createCharacter);
|
30 |
+
document.getElementById("startAdventure").addEventListener("click", startAdventure);
|
31 |
+
document.getElementById("attack").addEventListener("click", attack);
|
32 |
+
document.getElementById("castSpell").addEventListener("click", castSpell);
|
33 |
+
|
34 |
+
function createCharacter() {
|
35 |
+
character = {
|
36 |
+
name: "Hero",
|
37 |
+
class: "Warrior",
|
38 |
+
level: 1,
|
39 |
+
health: 100,
|
40 |
+
magic: 50,
|
41 |
+
strength: 10,
|
42 |
+
intelligence: 5
|
43 |
+
};
|
44 |
+
display(`Character Created: ${character.name}, the ${character.class}`);
|
45 |
+
}
|
46 |
+
|
47 |
+
function startAdventure() {
|
48 |
+
const encounters = ["a wild beast", "a mysterious traveler", "a hidden treasure"];
|
49 |
+
const encounter = encounters[Math.floor(Math.random() * encounters.length)];
|
50 |
+
display(`You encounter ${encounter} on your adventure.`);
|
51 |
+
}
|
52 |
+
|
53 |
+
function attack() {
|
54 |
+
if (!character.name) {
|
55 |
+
display("You need to create a character first!");
|
56 |
+
return;
|
57 |
+
}
|
58 |
+
|
59 |
+
const damage = Math.floor(Math.random() * character.strength);
|
60 |
+
display(`You attack dealing ${damage} damage.`);
|
61 |
+
}
|
62 |
+
|
63 |
+
function castSpell() {
|
64 |
+
if (!character.name) {
|
65 |
+
display("You need to create a character first!");
|
66 |
+
return;
|
67 |
+
}
|
68 |
+
|
69 |
+
const spells = ["Fireball", "Healing Light", "Shadow Strike"];
|
70 |
+
const spell = spells[Math.floor(Math.random() * spells.length)];
|
71 |
+
display(`You cast ${spell}! It uses 10 magic points.`);
|
72 |
+
character.magic -= 10;
|
73 |
+
}
|
74 |
+
|
75 |
+
function display(message) {
|
76 |
+
document.getElementById("output").textContent += message + "\n";
|
77 |
+
}
|
78 |
+
</script>
|
79 |
+
</body>
|
80 |
</html>
|