-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathemojiquest.html
More file actions
721 lines (687 loc) · 30.3 KB
/
Copy pathemojiquest.html
File metadata and controls
721 lines (687 loc) · 30.3 KB
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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<title>Emoji Quest</title>
<link href="https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap" rel="stylesheet">
<style>
body {
font-family: 'Press Start 2P', cursive;
background: #000000;
color: #00ffcc;
margin: 0;
padding: 0;
overflow-x: hidden;
overflow-y: auto;
height: 100vh;
display: flex;
justify-content: center;
align-items: flex-start;
}
#game {
width: 100vw;
max-width: 100%;
padding: 1.5vh;
background: rgba(0, 0, 0, 0.9);
box-shadow: 0 0 8px #ff00ff;
text-shadow: 1px 1px 2px #ff00ff;
box-sizing: border-box;
}
h1 {
font-size: 3.5vw;
color: #ff00ff;
text-shadow: 2px 2px 0 #00ffcc, 0 0 8px #ffffff;
margin: 1.5vh 0;
animation: glow 1.5s infinite alternate;
}
#status, #mission {
font-size: 2vw;
color: #ffff00;
text-shadow: 1px 1px 2px #ff00ff;
margin: 1vh 0;
}
.entity, #stats, #skills {
margin: 1.5vh 0;
padding: 0.8vh;
background: rgba(255, 0, 255, 0.1);
box-shadow: 0 0 4px #00ffcc;
}
.bar {
width: 35vw;
height: 2.5vh;
background: #222;
display: inline-block;
box-shadow: inset 0 0 4px #ff00ff;
}
.health { height: 100%; background: #ff0066; transition: width 0.3s; }
.mana { height: 100%; background: #00ccff; transition: width 0.3s; }
.exp { height: 100%; background: #ffff00; transition: width 0.3s; }
#combat-log {
height: 18vh;
overflow-y: auto;
padding: 0.8vh;
background: rgba(0, 0, 0, 0.5);
color: #00ffcc;
text-shadow: 0.5px 0.5px 1px #ff00ff;
font-size: 1.8vw;
}
button {
background: #ff00ff;
color: #00ffcc;
padding: 0.8vh 1.5vw;
font-family: 'Press Start 2P', cursive;
font-size: 1.8vw;
margin: 0.4vh;
cursor: pointer;
box-shadow: 0 0 4px #ff00ff;
touch-action: manipulation;
}
button:hover, button:active { background: #00ffcc; color: #ff00ff; }
#skill-buttons { display: flex; flex-wrap: wrap; justify-content: center; }
#inn-timer {
position: fixed;
top: 50%;
left: 50%;
font-size: 3vw; /* Reduced from 4vw */
color: #ff00ff;
background: rgba(0, 0, 0, 0.8);
padding: 2vh;
box-shadow: 0 0 16px #00ffcc;
display: none;
z-index: 100;
text-shadow: 2px 2px 4px #00ffcc;
min-width: 30vw;
}
#craft-menu {
display: none;
position: fixed;
top: 50%;
left: 50%;
width: 70vw;
max-width: 600px;
background: #000000;
border: 3px solid #ff00ff;
box-shadow: 0 0 15px #ff00ff, 0 0 25px #00ccff, inset 0 0 10px #ff00ff;
padding: 2vh;
z-index: 1000;
animation: neonPulse 1.5s infinite alternate;
}
#craft-menu h2 {
font-size: 2.5vw; /* Reduced from 3vw */
color: #ffff00;
text-shadow: 0 0 8px #ff00ff;
margin: 0 0 2vh 0;
text-align: center;
}
#craft-list {
list-style: none;
padding: 0;
margin: 0;
}
#craft-list li {
color: #00ffcc;
font-size: 1.5vw; /* Reduced from 1.8vw */
padding: 1vh 1.5vw;
margin: 0.5vh 0;
background: rgba(255, 0, 255, 0.1);
border-left: 5px solid #ff00ff;
display: flex;
justify-content: space-between;
align-items: center;
transition: all 0.3s ease;
}
#craft-list li:hover {
background: rgba(255, 0, 255, 0.3);
border-left: 5px solid #00ccff;
transform: translateX(5px);
}
#craft-list li button {
background: #ffff00;
color: #ff00ff;
font-size: 1.2vw; /* Reduced from 1.5vw */
padding: 0.5vh 1vw;
box-shadow: 0 0 5px #ffffff;
}
#craft-list li button:hover {
background: #00ccff;
color: #ffffff;
}
#craft-menu .close-btn {
position: absolute;
top: 1vh;
right: 1vh;
background: #ff0066;
padding: 0.5vh 1vw;
font-size: 1.5vw; /* Reduced from 1.8vw */
}
#game-over-screen {
display: none;
position: fixed;
top: 50%;
left: 50%;
width: 80vw;
max-width: 600px;
background: linear-gradient(45deg, #ff00ff, #00ccff);
color: #ffffff;
text-align: center;
padding: 2vh;
box-shadow: 0 0 20px #ff00ff, 0 0 30px #00ccff;
animation: popup 0.5s ease-out, pulse 2s infinite alternate;
z-index: 1000;
border-radius: 10px;
}
#game-over-screen h2 {
font-size: 3vw; /* Reduced from 4vw */
color: #ffff00;
text-shadow: 0 0 8px #ff00ff, 0 0 16px #00ccff;
margin: 1.5vh 0;
}
#game-over-screen p {
font-size: 1.5vw; /* Reduced from 2vw */
color: #ffffff;
text-shadow: 0 0 4px #000000;
margin: 0.8vh 0;
}
#webxosCode {
font-size: 1.2vw; /* Reduced from 1.5vw */
word-wrap: break-word;
white-space: pre-wrap;
background: rgba(0, 0, 0, 0.5);
padding: 1vh;
border: 1px solid #00ffcc;
margin: 1vh 0;
}
#game-over-screen button {
background: #ffff00;
color: #ff00ff;
box-shadow: 0 0 8px #ffffff;
font-size: 1.5vw; /* Reduced from 2vw */
padding: 1vh 2vw;
margin: 0.5vh;
}
@keyframes glow {
from { text-shadow: 2px 2px 0 #00ffcc, 0 0 8px #ffffff; }
to { text-shadow: 3px 3px 0 #00ffcc, 0 0 12px #ffffff; }
}
@keyframes pulse {
from { box-shadow: 0 0 20px #ff00ff, 0 0 30px #00ccff; }
to { box-shadow: 0 0 30px #ff00ff, 0 0 40px #00ccff; }
}
@keyframes popup {
from { transform: translate(-50%, -50%) scale(0); opacity: 0; }
to { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}
@keyframes neonPulse {
from { box-shadow: 0 0 15px #ff00ff, 0 0 25px #00ccff, inset 0 0 10px #ff00ff; }
to { box-shadow: 0 0 25px #ff00ff, 0 0 35px #00ccff, inset 0 0 15px #ff00ff; }
}
/* Desktop scaling (screens wider than 768px) */
@media screen and (min-width: 769px) {
#craft-menu {
transform: translate(-50%, -50%) scale(0.6);
}
#inn-timer {
transform: translate(-50%, -50%) scale(0.6);
}
#game-over-screen {
transform: translate(-50%, -50%) scale(0.6);
}
}
/* Mobile scaling (screens 768px or narrower) */
@media screen and (max-width: 768px) {
#craft-menu {
transform: translate(-50%, -50%) scale(1);
}
#inn-timer {
transform: translate(-50%, -50%) scale(1);
}
#game-over-screen {
transform: translate(-50%, -50%) scale(1);
}
}
</style>
</head>
<body>
<div id="game">
<h1>Emoji Quest</h1>
<div id="status">Tap a command to begin! 🎮</div>
<div id="stats">
Player: <span id="hero-emoji">🧙♂️</span> Lvl: <span id="hero-level">1</span> Gold: <span id="hero-gold">0</span> 💰<br>
HP: <div class="bar"><div class="health" id="hero-health" style="width: 100%;"></div></div> <span id="hero-hp">100/100</span> ❤️<br>
MP: <div class="bar"><div class="mana" id="hero-mana" style="width: 100%;"></div></div> <span id="hero-mp">50/50</span> 🔮<br>
EXP: <div class="bar"><div class="exp" id="hero-exp" style="width: 0%;"></div></div> <span id="hero-exp-text">0/50</span> ⭐<br>
STR: <span id="hero-str">5</span> 💪 | INT: <span id="hero-int">5</span> 🧠 | VIT: <span id="hero-vit">5</span> 🛡️ | DEF: <span id="hero-def">0</span> 🛡️<br>
Points: <span id="skill-points">0</span> 🎯 | Armor: <span id="armor-level">None</span> | Weapon: <span id="weapon-level">None</span>
</div>
<div id="skills" style="display: none;">
<button onclick="upgradeStat('str')">💪 +STR (1pt)</button>
<button onclick="upgradeStat('int')">🧠 +INT (1pt)</button>
<button onclick="upgradeStat('vit')">🛡️ +VIT (1pt)</button>
</div>
<div class="entity">Level: <span id="enemy-emoji">👾 Zargoth</span>
HP: <div class="bar"><div class="health" id="enemy-health" style="width: 100%;"></div></div> <span id="enemy-hp">60/60</span> ❤️
</div>
<div id="mission"></div>
<div id="combat-log"></div>
<div id="skill-buttons">
<button onclick="playerTurn(1)">⚔️ Attack</button>
<button onclick="playerTurn(2)">✨ Spell</button>
<button onclick="playerTurn(4)">🏡 Inn</button>
<button onclick="openCraftMenu()">🔨 Craft</button>
</div>
<div id="inn-timer"></div>
</div>
<div id="craft-menu">
<h2>🔨 Forge</h2>
<ul id="craft-list">
<li>Leather Armor (DEF +25) - 2000 Gold <button onclick="craftArmor(1)">Craft</button></li>
<li>Chain Mail (DEF +75) - 10000 Gold <button onclick="craftArmor(2)">Craft</button></li>
<li>Plate Armor (DEF +150) - 30000 Gold <button onclick="craftArmor(3)">Craft</button></li>
<li>Mythril Armor (DEF +250) - 60000 Gold <button onclick="craftArmor(4)">Craft</button></li>
<li>Great Staff (Spell +200) - 50000 Gold <button onclick="craftWeapon(1)">Craft</button></li>
<li>Great Sword (ATK +200) - 50000 Gold <button onclick="craftWeapon(2)">Craft</button></li>
</ul>
<button class="close-btn" onclick="closeCraftMenu()">X</button>
</div>
<div id="game-over-screen">
<h2>🏆 Game Over</h2>
<p>Level: <span id="game-over-level"></span> 🎖️</p>
<p>Total Gold: <span id="game-over-gold"></span> 💰</p>
<p>Total XP: <span id="game-over-exp"></span> ⭐</p>
<p>Time Elapsed: <span id="game-over-time"></span> ⏳</p>
<p>WEBXOS Code:</p>
<p id="webxosCode"></p>
<button onclick="copyWebxosCode()">📋 Copy Code</button>
<button onclick="location.reload()">🔄 Restart</button>
</div>
<script>
const status = document.getElementById('status');
const combatLog = document.getElementById('combat-log');
const heroHealth = document.getElementById('hero-health');
const heroHp = document.getElementById('hero-hp');
const heroMana = document.getElementById('hero-mana');
const heroMp = document.getElementById('hero-mp');
const heroExp = document.getElementById('hero-exp');
const heroExpText = document.getElementById('hero-exp-text');
const heroLevel = document.getElementById('hero-level');
const heroGold = document.getElementById('hero-gold');
const heroStr = document.getElementById('hero-str');
const heroInt = document.getElementById('hero-int');
const heroVit = document.getElementById('hero-vit');
const heroDef = document.getElementById('hero-def');
const skillPoints = document.getElementById('skill-points');
const armorLevel = document.getElementById('armor-level');
const weaponLevel = document.getElementById('weapon-level');
const enemyHealth = document.getElementById('enemy-health');
const enemyHp = document.getElementById('enemy-hp');
const enemyEmoji = document.getElementById('enemy-emoji');
const mission = document.getElementById('mission');
const skillsDiv = document.getElementById('skills');
const craftMenu = document.getElementById('craft-menu');
const gameOverScreen = document.getElementById('game-over-screen');
const gameOverLevel = document.getElementById('game-over-level');
const gameOverGold = document.getElementById('game-over-gold');
const gameOverExp = document.getElementById('game-over-exp');
const gameOverTime = document.getElementById('game-over-time');
const webxosCodeSpan = document.getElementById('webxosCode');
const innTimer = document.getElementById('inn-timer');
let hero = {
level: 1, hp: 100, maxHp: 100, mp: 50, maxMp: 50, exp: 0, expToLevel: 50,
str: 5, int: 5, vit: 5, def: 0, gold: 0, skillPoints: 0,
armorLevel: 0, hasGreatStaff: false, hasGreatSword: false, atkBonus: 0, spellBonus: 0
};
const startTime = Date.now();
const baseEnemies = [
{ emoji: '👾', name: 'Zargoth', hp: 60, attack: 10 },
{ emoji: '🕷️', name: 'Skrix', hp: 50, attack: 12 },
{ emoji: '🦇', name: 'Vlyth', hp: 55, attack: 11 },
{ emoji: '🐍', name: 'Slytheron', hp: 80, attack: 15 },
{ emoji: '🦂', name: 'Stingrax', hp: 70, attack: 18 },
{ emoji: '🤖', name: 'Mechalon', hp: 100, attack: 20 },
{ emoji: '💾', name: 'Datavore', hp: 120, attack: 25 },
{ emoji: '🖥️', name: 'Screenix', hp: 110, attack: 22 },
{ emoji: '🕸️', name: 'Webtron', hp: 130, attack: 28 },
{ emoji: '🔋', name: 'Voltrix', hp: 140, attack: 26 },
{ emoji: '🐉', name: 'Drakzul', hp: 150, attack: 30 },
{ emoji: '👻', name: 'Spectrix', hp: 140, attack: 32 },
{ emoji: '👽', name: 'Xenorath', hp: 200, attack: 40 }
];
let enemyCount = 0;
let currentEnemy = spawnEnemy();
let gameState = 'playing';
let innCooldown = false;
const audioContext = new (window.AudioContext || window.webkitAudioContext)();
function playTheme() {
const chordSets = [
[[261.63, 311.13, 392.00], [349.23, 415.30, 523.25], [349.23, 392.00, 466.16], [392.00, 493.88, 587.33]],
[[392.00, 466.16, 587.33], [311.13, 392.00, 466.16], [261.63, 311.13, 392.00], [293.66, 369.99, 440.00]],
[[349.23, 440.00, 523.25], [466.16, 587.33, 698.46], [523.25, 659.25, 783.99], [587.33, 698.46, 880.00]],
[[293.66, 349.23, 440.00], [466.16, 587.33, 698.46], [392.00, 466.16, 587.33], [440.00, 554.37, 659.25]]
];
const noteDuration = 0.5;
const barLength = 4;
const barDuration = noteDuration * barLength;
const loopDuration = 600;
let time = audioContext.currentTime;
function playChords(chords) {
const chordOscillators = [];
chords.forEach(() => {
const osc = audioContext.createOscillator();
const gain = audioContext.createGain();
osc.connect(gain);
gain.connect(audioContext.destination);
osc.type = 'triangle';
gain.gain.value = 0.05;
chordOscillators.push({ osc, gain });
});
chords.forEach((chord, index) => {
chord.forEach((freq, i) => {
chordOscillators[i].osc.frequency.setValueAtTime(freq, time + index * noteDuration);
});
});
chordOscillators.forEach(({ osc }) => osc.start());
return chordOscillators;
}
function loop() {
const numBars = Math.floor(loopDuration / barDuration);
let currentTime = time;
chordSets.forEach((chords) => {
const oscillators = playChords(chords);
setTimeout(() => oscillators.forEach(({ osc }) => osc.stop()), barDuration * 1000);
currentTime += barDuration;
});
time += numBars * barDuration;
setTimeout(loop, loopDuration * 1000);
}
loop();
}
function playClickSound() {
const oscillator = audioContext.createOscillator();
const gainNode = audioContext.createGain();
oscillator.connect(gainNode);
gainNode.connect(audioContext.destination);
oscillator.type = 'square';
oscillator.frequency.value = 880;
gainNode.gain.setValueAtTime(0.1, audioContext.currentTime);
gainNode.gain.exponentialRampToValueAtTime(0.001, audioContext.currentTime + 0.1);
oscillator.start();
oscillator.stop(audioContext.currentTime + 0.1);
}
function playInnSound() {
const oscillator = audioContext.createOscillator();
const gainNode = audioContext.createGain();
oscillator.connect(gainNode);
gainNode.connect(audioContext.destination);
oscillator.type = 'sine';
oscillator.frequency.setValueAtTime(440, audioContext.currentTime);
oscillator.frequency.exponentialRampToValueAtTime(880, audioContext.currentTime + 0.5);
gainNode.gain.setValueAtTime(0.1, audioContext.currentTime);
gainNode.gain.exponentialRampToValueAtTime(0.001, audioContext.currentTime + 0.5);
oscillator.start();
oscillator.stop(audioContext.currentTime + 0.5);
}
const commands = {
1: { name: 'Attack', emoji: '⚔️', cost: 0, effect: (enemy) => { let dmg = (hero.str * 3) + hero.atkBonus; enemy.hp -= dmg; }, log: 'slashes with Attack ⚔️' },
2: { name: 'Spell', emoji: '✨', cost: 15, effect: (enemy) => { let dmg = 75 + (hero.int * 3) + hero.spellBonus; enemy.hp -= dmg; }, log: 'casts Spell ✨' },
4: { name: 'Inn', emoji: '🏡', cost: 0, effect: () => startInnTimer(), log: 'rests at Inn 🏡' }
};
const armors = [
{ name: 'None', def: 0, cost: 0 },
{ name: 'Leather Armor', def: 25, cost: 2000 },
{ name: 'Chain Mail', def: 75, cost: 10000 },
{ name: 'Plate Armor', def: 150, cost: 30000 },
{ name: 'Mythril Armor', def: 250, cost: 60000 }
];
const weapons = [
{ name: 'None', spellBonus: 0, atkBonus: 0, cost: 0 },
{ name: 'Great Staff', spellBonus: 200, atkBonus: 0, cost: 50000 },
{ name: 'Great Sword', spellBonus: 0, atkBonus: 200, cost: 50000 }
];
function spawnEnemy() {
enemyCount++;
let baseEnemy = baseEnemies[Math.floor(Math.random() * baseEnemies.length)];
let scale = 1 + (enemyCount * 0.1);
let levelScale = 0.8 + (hero.level * 0.05);
let enemy = {
...baseEnemy,
hp: Math.floor(baseEnemy.hp * scale),
maxHp: Math.floor(baseEnemy.hp * scale),
attack: Math.floor(baseEnemy.attack * scale * levelScale)
};
if (enemyCount % 10 === 0) {
enemy.hp *= 2;
enemy.maxHp *= 2;
enemy.attack *= 2;
enemy.emoji = `👑${enemy.emoji}`;
enemy.name = `King ${enemy.name}`;
enemy.isBoss = true;
} else if (Math.random() < 0.2) {
enemy.hp = Math.floor(enemy.hp * 1.5);
enemy.maxHp = Math.floor(enemy.hp * 1.5);
enemy.attack = Math.floor(enemy.attack * 1.5);
enemy.emoji = `⭐${enemy.emoji}`;
enemy.name = `Elite ${enemy.name}`;
enemy.isElite = true;
}
return enemy;
}
function update() {
if (gameState === 'playing' && !innCooldown) {
updateUI();
}
requestAnimationFrame(update);
}
function playerTurn(commandId) {
if (gameState !== 'playing' || innCooldown) return;
playClickSound();
const command = commands[commandId];
if (command.cost > 0 && hero.mp < command.cost) {
appendLog('Not enough Mana! 🔮');
return;
}
hero.mp -= command.cost;
let log = `🧙♂️ ${command.log}`;
command.effect(currentEnemy);
if (commandId === 1) log += ` for ${(hero.str * 3) + hero.atkBonus} damage!`;
if (commandId === 2) log += ` for ${75 + (hero.int * 3) + hero.spellBonus} damage!`;
appendLog(log);
updateUI();
if (currentEnemy.hp <= 0) {
winCombat();
} else if (!innCooldown) {
setTimeout(randomEnemyTurn, 500);
}
}
function randomEnemyTurn() {
if (gameState !== 'playing' || innCooldown) return;
if (Math.random() < 0.5) {
let damage = Math.max(1, currentEnemy.attack - hero.def);
hero.hp -= damage;
appendLog(`${currentEnemy.emoji} ${currentEnemy.name} strikes for ${damage} damage! 💥 (Def: ${hero.def})`);
updateUI();
if (hero.hp <= 0) {
gameState = 'over';
status.textContent = 'System Crash! Game Over. 💀';
showGameOverScreen();
}
} else {
appendLog(`${currentEnemy.emoji} ${currentEnemy.name} hesitates... ⏳`);
}
}
function startInnTimer() {
innCooldown = true;
playInnSound();
let timeLeft = 10;
innTimer.style.display = 'block';
status.textContent = 'Resting at the Inn... 🏡';
const timer = setInterval(() => {
timeLeft--;
innTimer.textContent = `Resting: ${timeLeft}s ⏳`;
if (timeLeft <= 0) {
clearInterval(timer);
hero.hp = hero.maxHp;
hero.mp = hero.maxMp;
innCooldown = false;
innTimer.style.display = 'none';
status.textContent = 'Tap a command to fight! 🎮';
appendLog('🧙♂️ fully restored! 🌟');
updateUI();
}
}, 1000);
}
function winCombat() {
const enemyKey = `${currentEnemy.emoji} ${currentEnemy.name}`;
let expGain = Math.floor(currentEnemy.maxHp / 2 * (1 + enemyCount * 0.05));
let goldGain = Math.floor(currentEnemy.maxHp * (1 + enemyCount * 0.05));
appendLog(`${enemyKey} defeated! +${expGain} EXP ⭐, +${goldGain} Gold 💰`);
hero.exp += expGain;
hero.gold += goldGain;
if (hero.exp >= hero.expToLevel) levelUp();
currentEnemy = spawnEnemy();
updateMission();
updateUI();
}
function levelUp() {
hero.level++;
hero.exp -= hero.expToLevel;
hero.expToLevel = Math.floor(hero.expToLevel * 1.5);
hero.skillPoints += 2;
hero.maxHp += 20 + hero.vit * 2;
hero.maxMp += 10;
appendLog(`Level Up! Now Level ${hero.level}. +2 Skill Points! 🌟`);
skillsDiv.style.display = hero.skillPoints > 0 ? 'block' : 'none';
updateUI();
}
function upgradeStat(stat) {
if (hero.skillPoints > 0) {
playClickSound();
hero[stat]++;
hero.skillPoints--;
appendLog(`+1 ${stat.toUpperCase()}! 🎯`);
skillsDiv.style.display = hero.skillPoints > 0 ? 'block' : 'none';
updateUI();
}
}
function openCraftMenu() {
playClickSound();
craftMenu.style.display = 'block';
}
function closeCraftMenu() {
playClickSound();
craftMenu.style.display = 'none';
}
function craftArmor(level) {
playClickSound();
const armor = armors[level];
if (hero.gold >= armor.cost && hero.armorLevel < level) {
hero.gold -= armor.cost;
hero.def = armor.def;
hero.armorLevel = level;
appendLog(`Crafted ${armor.name}! DEF increased to ${hero.def} 🛡️`);
closeCraftMenu();
updateUI();
} else if (hero.gold < armor.cost) {
appendLog('Not enough Gold! 💰');
} else {
appendLog('You already have better armor! 🛡️');
}
}
function craftWeapon(index) {
playClickSound();
const weapon = weapons[index];
let alreadyOwned = (index === 1 && hero.hasGreatStaff) || (index === 2 && hero.hasGreatSword);
if (hero.gold >= weapon.cost && !alreadyOwned) {
hero.gold -= weapon.cost;
if (index === 1) {
hero.hasGreatStaff = true;
hero.spellBonus += weapon.spellBonus;
appendLog(`Crafted ${weapon.name}! Spell damage increased by ${weapon.spellBonus} ✨`);
} else if (index === 2) {
hero.hasGreatSword = true;
hero.atkBonus += weapon.atkBonus;
appendLog(`Crafted ${weapon.name}! Attack damage increased by ${weapon.atkBonus} ⚔️`);
}
closeCraftMenu();
updateUI();
} else if (hero.gold < weapon.cost) {
appendLog('Not enough Gold! 💰');
} else {
appendLog(`You already own the ${weapon.name}!`);
}
}
function showGameOverScreen() {
gameOverScreen.style.display = 'block';
gameOverLevel.textContent = hero.level;
gameOverGold.textContent = hero.gold;
gameOverExp.textContent = Math.floor(hero.exp);
const elapsedSeconds = Math.floor((Date.now() - startTime) / 1000);
const minutes = Math.floor(elapsedSeconds / 60);
const seconds = elapsedSeconds % 60;
gameOverTime.textContent = `${minutes}m ${seconds}s`;
const now = new Date();
const dateStr = now.toISOString().split('T')[0];
const timeStr = now.toTimeString().split(' ')[0];
const gameData = `Game:Emoji Quest;Date:${dateStr};Time:${timeStr};Level:${hero.level};Gold:${hero.gold};TotalXP:${Math.floor(hero.exp)};TimeElapsed:${minutes}m${seconds}s`;
const webxosCode = encodeWebXOS(gameData);
webxosCodeSpan.textContent = webxosCode;
}
function stringToHex(str) {
return Array.from(str)
.map(c => c.charCodeAt(0).toString(16).padStart(2, '0'))
.join('')
.toUpperCase();
}
function encodeWebXOS(message) {
if (!message || typeof message !== 'string') return 'WEBXOS-00000000-0000-0000-000000000000';
const timestamp = Date.now().toString(36).toUpperCase().padStart(8, '0');
const messageHex = stringToHex(message);
const random1 = Math.random().toString(36).substr(2, 6).toUpperCase();
const random2 = Math.random().toString(36).substr(2, 6).toUpperCase();
const checksum = (message.length * 17).toString(36).toUpperCase().padStart(4, '0');
return `WEBXOS-${timestamp}-${messageHex}-${random1}-${random2}-${checksum}`;
}
function copyWebxosCode() {
const code = webxosCodeSpan.textContent;
navigator.clipboard.writeText(code).then(() => {
alert('WebXOS Code copied to clipboard!');
}).catch(err => {
alert('Failed to copy code: ' + err);
});
}
function updateUI() {
heroHealth.style.width = `${(hero.hp / hero.maxHp) * 100}%`;
heroHp.textContent = `${hero.hp}/${hero.maxHp}`;
heroMana.style.width = `${(hero.mp / hero.maxMp) * 100}%`;
heroMp.textContent = `${hero.mp}/${hero.maxMp}`;
heroExp.style.width = `${(hero.exp / hero.expToLevel) * 100}%`;
heroExpText.textContent = `${Math.floor(hero.exp)}/${hero.expToLevel}`;
heroLevel.textContent = hero.level;
heroGold.textContent = hero.gold;
heroStr.textContent = hero.str;
heroInt.textContent = hero.int;
heroVit.textContent = hero.vit;
heroDef.textContent = hero.def;
skillPoints.textContent = hero.skillPoints;
armorLevel.textContent = armors[hero.armorLevel].name;
weaponLevel.textContent = `${hero.hasGreatStaff ? 'Staff' : ''}${hero.hasGreatStaff && hero.hasGreatSword ? ' + ' : ''}${hero.hasGreatSword ? 'Sword' : ''}` || 'None';
enemyHealth.style.width = `${(currentEnemy.hp / currentEnemy.maxHp) * 100}%`;
enemyHp.textContent = currentEnemy.hp <= 0 ? 'DEFEATED' : `${currentEnemy.hp}/${currentEnemy.maxHp}`;
enemyEmoji.textContent = `${currentEnemy.emoji} ${currentEnemy.name}`;
}
function updateMission() {
mission.textContent = `Enemy Count: ${enemyCount} | Survive the endless onslaught!`;
}
function appendLog(message) {
if (message) {
combatLog.innerHTML += `<p>${message}</p>`;
combatLog.scrollTop = combatLog.scrollHeight;
}
}
playTheme();
updateMission();
updateUI();
update();
</script>
</body>
</html>