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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!DOCTYPE html>
|
2 |
+
<html lang="en">
|
3 |
+
<head>
|
4 |
+
<meta charset="UTF-8">
|
5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6 |
+
<title>๐ฒ D20 Dungeon Crawler ๐ฐ</title>
|
7 |
+
<style>
|
8 |
+
body {
|
9 |
+
font-family: Arial, sans-serif;
|
10 |
+
display: flex;
|
11 |
+
justify-content: center;
|
12 |
+
align-items: center;
|
13 |
+
min-height: 100vh;
|
14 |
+
margin: 0;
|
15 |
+
background-color: #2c3e50;
|
16 |
+
color: #ecf0f1;
|
17 |
+
}
|
18 |
+
#game-container {
|
19 |
+
background-color: #34495e;
|
20 |
+
padding: 20px;
|
21 |
+
border-radius: 10px;
|
22 |
+
box-shadow: 0 0 20px rgba(0,0,0,0.3);
|
23 |
+
max-width: 800px;
|
24 |
+
width: 100%;
|
25 |
+
}
|
26 |
+
button {
|
27 |
+
margin: 5px;
|
28 |
+
padding: 10px 15px;
|
29 |
+
background-color: #3498db;
|
30 |
+
color: white;
|
31 |
+
border: none;
|
32 |
+
border-radius: 5px;
|
33 |
+
cursor: pointer;
|
34 |
+
transition: background-color 0.3s;
|
35 |
+
}
|
36 |
+
button:hover {
|
37 |
+
background-color: #2980b9;
|
38 |
+
}
|
39 |
+
select {
|
40 |
+
margin: 5px;
|
41 |
+
padding: 5px 10px;
|
42 |
+
}
|
43 |
+
#dungeon-image {
|
44 |
+
width: 100%;
|
45 |
+
height: 200px;
|
46 |
+
background-color: #2c3e50;
|
47 |
+
margin-bottom: 20px;
|
48 |
+
display: flex;
|
49 |
+
justify-content: center;
|
50 |
+
align-items: center;
|
51 |
+
font-size: 24px;
|
52 |
+
text-align: center;
|
53 |
+
}
|
54 |
+
#choices {
|
55 |
+
display: grid;
|
56 |
+
grid-template-columns: 1fr 1fr;
|
57 |
+
gap: 10px;
|
58 |
+
}
|
59 |
+
#combat-log {
|
60 |
+
max-height: 200px;
|
61 |
+
overflow-y: auto;
|
62 |
+
background-color: #2c3e50;
|
63 |
+
padding: 10px;
|
64 |
+
border-radius: 5px;
|
65 |
+
margin-top: 20px;
|
66 |
+
}
|
67 |
+
#monster-trophies {
|
68 |
+
display: flex;
|
69 |
+
flex-wrap: wrap;
|
70 |
+
margin-top: 10px;
|
71 |
+
}
|
72 |
+
.monster-trophy {
|
73 |
+
font-size: 24px;
|
74 |
+
margin-right: 5px;
|
75 |
+
}
|
76 |
+
</style>
|
77 |
+
</head>
|
78 |
+
<body>
|
79 |
+
<div id="game-container">
|
80 |
+
<h1>๐ฒ D20 Dungeon Crawler ๐ฐ</h1>
|
81 |
+
<div id="character-creation">
|
82 |
+
<h2>๐ค Character Creation</h2>
|
83 |
+
<select id="race">
|
84 |
+
<option value="human">๐จ Human</option>
|
85 |
+
<option value="elf">๐งโโ๏ธ Elf</option>
|
86 |
+
<option value="dwarf">๐ง Dwarf</option>
|
87 |
+
<option value="halfling">๐ง Halfling</option>
|
88 |
+
</select>
|
89 |
+
<select id="class">
|
90 |
+
<option value="warrior">โ๏ธ Warrior</option>
|
91 |
+
<option value="mage">๐งโโ๏ธ Mage</option>
|
92 |
+
<option value="rogue">๐ก๏ธ Rogue</option>
|
93 |
+
<option value="cleric">โจ Cleric</option>
|
94 |
+
</select>
|
95 |
+
<button onclick="createCharacter()">๐ญ Create Character</button>
|
96 |
+
</div>
|
97 |
+
<div id="game-area" style="display: none;">
|
98 |
+
<div id="dungeon-image"></div>
|
99 |
+
<div id="encounter-description"></div>
|
100 |
+
<div id="choices"></div>
|
101 |
+
<div id="player-stats"></div>
|
102 |
+
<div id="combat-log"></div>
|
103 |
+
<div id="monster-trophies"></div>
|
104 |
+
</div>
|
105 |
+
</div>
|
106 |
+
<svg id="d20" width="100" height="100" viewBox="0 0 100 100" style="display: none;">
|
107 |
+
<polygon points="50,5 95,75 5,75" fill="#f3f3f3" stroke="#000" stroke-width="2"/>
|
108 |
+
<text x="50" y="55" font-size="24" text-anchor="middle" id="roll-result"></text>
|
109 |
+
</svg>
|
110 |
+
<script>
|
111 |
+
let player, currentEncounter, score = 0, monsterTrophies = [];
|
112 |
+
|
113 |
+
const settingsData = `
|
114 |
+
๐๏ธ๐ฎ,Ancient Temple,A crumbling temple with flickering torches and moss-covered statues
|
115 |
+
๐ณ๐,Enchanted Forest,A mystical forest filled with glowing mushrooms and whispering trees
|
116 |
+
๐๏ธโ๏ธ,Frozen Peaks,Treacherous icy mountains with howling winds and hidden crevasses
|
117 |
+
๐๏ธ๐ซ,Desert Ruins,Sun-baked ruins half-buried in shifting sands
|
118 |
+
๐๐ฅ,Volcanic Cavern,A scorching cave system with rivers of lava and sulfurous air
|
119 |
+
๐๐,Sunken City,The remains of an ancient city submerged beneath crystal-clear waters
|
120 |
+
๐ฏ๏ธ๐,Arcane Library,Towering bookshelves filled with magical tomes and floating candles
|
121 |
+
โฐ๏ธ๐,Haunted Crypt,A chilling burial chamber echoing with unseen whispers
|
122 |
+
๐ฟ๐ฆ,Fairy Glade,A serene clearing shimmering with magical butterflies and flower petals
|
123 |
+
๐ฐ๏ธโ๏ธ,Clockwork Maze,An intricate labyrinth of gears, pistons, and ticking mechanisms
|
124 |
+
๐๐บ,Shadowy Woods,Dark and foreboding forest where eyes seem to watch from every shadow
|
125 |
+
๐ฎ๐ญ,Illusory Palace,A grand castle where nothing is as it seems, constantly shifting
|
126 |
+
๐ณ๏ธ๐ฆ,Abyssal Chasm,A deep, dark pit with strange echoes and unseen terrors
|
127 |
+
๐๐ฆ,Crystal Cavern,A dazzling cave system filled with luminous, multi-colored crystals
|
128 |
+
๐ช๐ญ,Carnival of Souls,An eerie, abandoned fairground with a sinister undercurrent
|
129 |
+
๐ฟ๐ด,Primal Jungle,A dense, primordial jungle teeming with ancient creatures and ruins
|
130 |
+
๐๐,Astral Plane,A surreal realm of floating islands and swirling cosmic energies
|
131 |
+
๐ดโโ ๏ธ๐ฆ,Ghost Ship,A decrepit vessel sailing through mists, crewed by spectral pirates
|
132 |
+
๐๐ถ,Harmonic Sanctuary,A tranquil temple where magical music fills the air
|
133 |
+
๐ญ๐พ,Alien Hive,A bizarre, organic structure pulsing with otherworldly life
|
134 |
+
`;
|
135 |
+
|
136 |
+
const monstersData = `
|
137 |
+
๐น๐ก๏ธ,Goblin,A small, green-skinned creature with a wicked grin and rusty dagger
|
138 |
+
๐๐น,Skeleton Archer,A reanimated skeleton wielding a creaky bow with surprising accuracy
|
139 |
+
๐บ๐,Dire Wolf,A massive wolf with glowing eyes and razor-sharp fangs
|
140 |
+
๐ท๏ธ๐ธ๏ธ,Giant Spider,A hairy arachnid the size of a horse, with venom dripping from its fangs
|
141 |
+
๐งโโ๏ธ๐,Zombie,A shambling corpse with rotting flesh, driven by an insatiable hunger
|
142 |
+
๐งโโ๏ธ๐ฎ,Evil Witch,A cackling hag with gnarled fingers and a bubbling cauldron of curses
|
143 |
+
๐๐ฅ,Young Dragon,A scaled wyrm with smoke curling from its nostrils, hungry for treasure
|
144 |
+
๐ฆ๐งโโ๏ธ,Vampire,A pale, aristocratic figure with razor-sharp fangs and hypnotic eyes
|
145 |
+
๐ฟ๐,Treant,An ancient tree come to life, with bark-covered limbs and mossy beard
|
146 |
+
๐ฆ๐ฑ,Lizardfolk Warrior,A scaly humanoid with sharp claws and primitive weapons
|
147 |
+
๐ป๐,Poltergeist,An invisible spirit that delights in chaos and flying objects
|
148 |
+
๐๐,Kraken Spawn,A mass of writhing tentacles emerging from dark waters
|
149 |
+
๐ฆ
๐ฆ,Griffin,A majestic creature with the head and wings of an eagle and body of a lion
|
150 |
+
๐ฟ๐จ,Stone Golem,A hulking figure carved from living rock, nearly impervious to harm
|
151 |
+
๐ฆ๐,Corrupted Unicorn,Once pure, now twisted by dark magic with a deadly horn
|
152 |
+
๐งโโ๏ธ๐ถ,Siren,A hauntingly beautiful creature with an alluring, deadly song
|
153 |
+
๐ฒโ๏ธ,Cloud Giant,A towering humanoid wreathed in mists, with storm-powered magic
|
154 |
+
๐ฆ๐ฅ,Infernal Scorpion,A massive scorpion with a carapace of smoldering coals
|
155 |
+
๐ง ๐๏ธ,Mind Flayer,A tentacle-faced horror with powerful psionic abilities
|
156 |
+
๐๐บ,Shadow Wolf,A beast made of living darkness with glowing red eyes
|
157 |
+
`;
|
158 |
+
|
159 |
+
const settings = parseCSV(settingsData);
|
160 |
+
const monsters = parseCSV(monstersData);
|
161 |
+
|
162 |
+
function parseCSV(data) {
|
163 |
+
return data.trim().split('\n').map(line => {
|
164 |
+
const [emoji, name, description] = line.split(',');
|
165 |
+
return { emoji, name, description };
|
166 |
+
});
|
167 |
+
}
|
168 |
+
|
169 |
+
function createCharacter() {
|
170 |
+
const race = document.getElementById('race').value;
|
171 |
+
const characterClass = document.getElementById('class').value;
|
172 |
+
player = {
|
173 |
+
race,
|
174 |
+
class: characterClass,
|
175 |
+
maxHp: 50,
|
176 |
+
hp: 50,
|
177 |
+
attack: 10,
|
178 |
+
defense: 5,
|
179 |
+
magic: 8
|
180 |
+
};
|
181 |
+
document.getElementById('character-creation').style.display = 'none';
|
182 |
+
document.getElementById('game-area').style.display = 'block';
|
183 |
+
updateStats();
|
184 |
+
nextEncounter();
|
185 |
+
}
|
186 |
+
|
187 |
+
function updateStats() {
|
188 |
+
document.getElementById('player-stats').innerHTML = `
|
189 |
+
๐ค Player: โค๏ธ HP ${player.hp}/${player.maxHp}, โ๏ธ ATK ${player.attack}, ๐ก๏ธ DEF ${player.defense}, ๐ฎ MAG ${player.magic}
|
190 |
+
<br>๐ Score: ${score}
|
191 |
+
`;
|
192 |
+
}
|
193 |
+
|
194 |
+
function nextEncounter() {
|
195 |
+
const setting = settings[Math.floor(Math.random() * settings.length)];
|
196 |
+
const monster = monsters[Math.floor(Math.random() * monsters.length)];
|
197 |
+
currentEncounter = {
|
198 |
+
setting,
|
199 |
+
monster,
|
200 |
+
monsterHp: 30,
|
201 |
+
description: `${setting.emoji} You find yourself in ${setting.name}. ${setting.description}
|
202 |
+
<br><br>${monster.emoji} Suddenly, a ${monster.name} appears! ${monster.description}`,
|
203 |
+
choices: generateChoices()
|
204 |
+
};
|
205 |
+
document.getElementById('dungeon-image').innerHTML = setting.emoji;
|
206 |
+
document.getElementById('encounter-description').innerHTML = currentEncounter.description;
|
207 |
+
displayChoices();
|
208 |
+
}
|
209 |
+
|
210 |
+
function generateChoices() {
|
211 |
+
return [
|
212 |
+
{ text: "โ๏ธ Attack with your weapon", successRate: 0.7, statUsed: "attack" },
|
213 |
+
{ text: "๐ฎ Cast a spell", successRate: 0.6, statUsed: "magic" },
|
214 |
+
{ text: "๐ต๏ธ Try to sneak past", successRate: 0.5, statUsed: "defense" },
|
215 |
+
{ text: "๐ฃ๏ธ Attempt to communicate", successRate: 0.3, statUsed: "magic" }
|
216 |
+
];
|
217 |
+
}
|
218 |
+
|
219 |
+
function displayChoices() {
|
220 |
+
const choicesDiv = document.getElementById('choices');
|
221 |
+
choicesDiv.innerHTML = "";
|
222 |
+
currentEncounter.choices.forEach((choice, index) => {
|
223 |
+
const button = document.createElement('button');
|
224 |
+
button.textContent = `${String.fromCharCode(65 + index)}. ${choice.text}`;
|
225 |
+
button.onclick = () => makeChoice(index);
|
226 |
+
choicesDiv.appendChild(button);
|
227 |
+
});
|
228 |
+
}
|
229 |
+
|
230 |
+
async function makeChoice(index) {
|
231 |
+
const choice = currentEncounter.choices[index];
|
232 |
+
const roll = await rollD20();
|
233 |
+
const success = roll / 20 <= choice.successRate;
|
234 |
+
const statBonus = player[choice.statUsed] / 10;
|
235 |
+
const totalSuccessRate = Math.min(choice.successRate + statBonus, 1);
|
236 |
+
|
237 |
+
if (success) {
|
238 |
+
const damage = Math.floor(roll * totalSuccessRate);
|
239 |
+
currentEncounter.monsterHp -= damage;
|
240 |
+
score += damage;
|
241 |
+
log(`โ
Success! ${choice.text} (๐ฒ Roll: ${roll}, ๐ Success Rate: ${(totalSuccessRate * 100).toFixed(1)}%, ๐ฅ Damage: ${damage}, ๐ Score: +${damage})`);
|
242 |
+
} else {
|
243 |
+
player.hp -= 5;
|
244 |
+
log(`โ Failure... ${choice.text} (๐ฒ Roll: ${roll}, ๐ Success Rate: ${(totalSuccessRate * 100).toFixed(1)}%, โค๏ธ HP: -5)`);
|
245 |
+
}
|
246 |
+
|
247 |
+
updateStats();
|
248 |
+
|
249 |
+
if (player.hp <= 0) {
|
250 |
+
log("๐ Game over! You have been defeated.");
|
251 |
+
return;
|
252 |
+
}
|
253 |
+
|
254 |
+
if (currentEncounter.monsterHp <= 0) {
|
255 |
+
log(`๐ Victory! You defeated the ${currentEncounter.monster.name}!`);
|
256 |
+
monsterTrophies.push(currentEncounter.monster.emoji);
|
257 |
+
updateMonsterTrophies();
|
258 |
+
player.hp = player.maxHp; // Heal to full after battle
|
259 |
+
updateStats();
|
260 |
+
nextEncounter();
|
261 |
+
} else {
|
262 |
+
log(`The ${currentEncounter.monster.name} has ${currentEncounter.monsterHp} HP remaining.`);
|
263 |
+
}
|
264 |
+
}
|
265 |
+
|
266 |
+
function updateMonsterTrophies() {
|
267 |
+
const trophiesDiv = document.getElementById('monster-trophies');
|
268 |
+
trophiesDiv.innerHTML = monsterTrophies.map(emoji => `<span class="monster-trophy">${emoji}</span>`).join('');
|
269 |
+
}
|
270 |
+
|
271 |
+
function rollD20() {
|
272 |
+
return new Promise(resolve => {
|
273 |
+
const d20 = document.getElementById('d20');
|
274 |
+
d20.style.display = 'block';
|
275 |
+
const result = Math.floor(Math.random() * 20) + 1;
|
276 |
+
document.getElementById('roll-result').textContent = result;
|
277 |
+
d20.animate([
|
278 |
+
{ transform: 'rotate(0deg)' },
|
279 |
+
{ transform: 'rotate(360deg)' }
|
280 |
+
], {
|
281 |
+
duration: 1000,
|
282 |
+
iterations: 1
|
283 |
+
}).onfinish = () => {
|
284 |
+
d20.style.display = 'none';
|
285 |
+
resolve(result);
|
286 |
+
};
|
287 |
+
});
|
288 |
+
}
|
289 |
+
|
290 |
+
function log(message) {
|
291 |
+
const combatLog = document.getElementById('combat-log');
|
292 |
+
combatLog.innerHTML += `<p>${message}</p>`;
|
293 |
+
combatLog.scrollTop = combatLog.scrollHeight;
|
294 |
+
}
|
295 |
+
</script>
|
296 |
+
</body>
|
297 |
+
</html>
|