webxos commited on
Commit
9f5da3a
·
verified ·
1 Parent(s): f4e41ab

Upload webXOS_emoji_quest_RL.html

Browse files
Files changed (1) hide show
  1. webXOS_emoji_quest_RL.html +1101 -0
webXOS_emoji_quest_RL.html ADDED
@@ -0,0 +1,1101 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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, maximum-scale=1.0, user-scalable=no">
6
+ <title>Emoji Quest RL • WebXOS 2026</title>
7
+ <link href="https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap" rel="stylesheet">
8
+ <script src="https://cdn.jsdelivr.net/npm/jszip@3.10.1/dist/jszip.min.js"></script>
9
+ <style>
10
+ body {
11
+ font-family: 'Press Start 2P', cursive;
12
+ background: #000000;
13
+ color: #00ffcc;
14
+ margin: 0;
15
+ padding: 0;
16
+ overflow-x: hidden;
17
+ overflow-y: auto;
18
+ height: 100vh;
19
+ display: flex;
20
+ justify-content: center;
21
+ align-items: flex-start;
22
+ }
23
+ #game {
24
+ width: 100vw;
25
+ max-width: 100%;
26
+ padding: 1.5vh;
27
+ background: rgba(0, 0, 0, 0.9);
28
+ box-shadow: 0 0 8px #ff00ff;
29
+ text-shadow: 1px 1px 2px #ff00ff;
30
+ box-sizing: border-box;
31
+ }
32
+ h1 {
33
+ font-size: 3.5vw;
34
+ color: #ff00ff;
35
+ text-shadow: 2px 2px 0 #00ffcc, 0 0 8px #ffffff;
36
+ margin: 1.5vh 0;
37
+ animation: glow 1.5s infinite alternate;
38
+ }
39
+ #status, #mission {
40
+ font-size: 2vw;
41
+ color: #ffff00;
42
+ text-shadow: 1px 1px 2px #ff00ff;
43
+ margin: 1vh 0;
44
+ }
45
+ .entity, #stats, #skills {
46
+ margin: 1.5vh 0;
47
+ padding: 0.8vh;
48
+ background: rgba(255, 0, 255, 0.1);
49
+ box-shadow: 0 0 4px #00ffcc;
50
+ }
51
+ .bar {
52
+ width: 35vw;
53
+ height: 2.5vh;
54
+ background: #222;
55
+ display: inline-block;
56
+ box-shadow: inset 0 0 4px #ff00ff;
57
+ }
58
+ .health { height: 100%; background: #ff0066; transition: width 0.3s; }
59
+ .mana { height: 100%; background: #00ccff; transition: width 0.3s; }
60
+ .exp { height: 100%; background: #ffff00; transition: width 0.3s; }
61
+ #combat-log {
62
+ height: 18vh;
63
+ overflow-y: auto;
64
+ padding: 0.8vh;
65
+ background: rgba(0, 0, 0, 0.5);
66
+ color: #00ffcc;
67
+ text-shadow: 0.5px 0.5px 1px #ff00ff;
68
+ font-size: 1.8vw;
69
+ }
70
+ button {
71
+ background: #ff00ff;
72
+ color: #00ffcc;
73
+ padding: 0.8vh 1.5vw;
74
+ font-family: 'Press Start 2P', cursive;
75
+ font-size: 1.8vw;
76
+ margin: 0.4vh;
77
+ cursor: pointer;
78
+ box-shadow: 0 0 4px #ff00ff;
79
+ touch-action: manipulation;
80
+ }
81
+ button:hover, button:active { background: #00ffcc; color: #ff00ff; }
82
+ #skill-buttons { display: flex; flex-wrap: wrap; justify-content: center; }
83
+
84
+ /* Inn Timer */
85
+ #inn-timer {
86
+ position: fixed;
87
+ top: 50%;
88
+ left: 50%;
89
+ font-size: 3vw;
90
+ color: #ff00ff;
91
+ background: rgba(0, 0, 0, 0.8);
92
+ padding: 2vh;
93
+ box-shadow: 0 0 16px #00ffcc;
94
+ display: none;
95
+ z-index: 100;
96
+ text-shadow: 2px 2px 4px #00ccff;
97
+ min-width: 30vw;
98
+ text-align: center;
99
+ border: 2px solid #ff00ff;
100
+ border-radius: 10px;
101
+ transform: translate(-50%, -50%);
102
+ }
103
+
104
+ /* Minimal Export Popup */
105
+ #export-popup {
106
+ display: none;
107
+ position: fixed;
108
+ top: 50%;
109
+ left: 50%;
110
+ width: 50vw;
111
+ max-width: 400px;
112
+ min-width: 300px;
113
+ background: #000000;
114
+ border: 3px solid #ff00ff;
115
+ box-shadow: 0 0 15px #ff00ff, 0 0 25px #00ccff, inset 0 0 10px #ff00ff;
116
+ padding: 2vh;
117
+ z-index: 2000;
118
+ animation: neonPulse 1.5s infinite alternate;
119
+ transform: translate(-50%, -50%);
120
+ text-align: center;
121
+ }
122
+ #export-popup h2 {
123
+ font-size: 2.2vw;
124
+ color: #ffff00;
125
+ text-shadow: 0 0 8px #ff00ff;
126
+ margin: 0 0 2vh 0;
127
+ }
128
+ #export-stats {
129
+ color: #00ffcc;
130
+ font-size: 1.5vw;
131
+ line-height: 1.6;
132
+ margin: 2vh 0;
133
+ }
134
+ .export-buttons {
135
+ display: flex;
136
+ flex-direction: column;
137
+ gap: 1.5vh;
138
+ margin-top: 2vh;
139
+ }
140
+ .export-btn {
141
+ background: #ff00ff;
142
+ color: #00ffcc;
143
+ padding: 1.2vh 0;
144
+ font-size: 1.8vw;
145
+ width: 100%;
146
+ border: none;
147
+ cursor: pointer;
148
+ box-shadow: 0 0 8px #ff00ff;
149
+ }
150
+ .export-btn:hover {
151
+ background: #00ffcc;
152
+ color: #ff00ff;
153
+ }
154
+ .close-export {
155
+ background: #ff0066;
156
+ color: #ffffff;
157
+ padding: 0.8vh 2vw;
158
+ font-size: 1.5vw;
159
+ margin-top: 1vh;
160
+ width: 100%;
161
+ }
162
+
163
+ /* Game Over Screen */
164
+ #game-over-screen {
165
+ display: none;
166
+ position: fixed;
167
+ top: 50%;
168
+ left: 50%;
169
+ width: 80vw;
170
+ max-width: 600px;
171
+ background: linear-gradient(45deg, #ff00ff, #00ccff);
172
+ color: #ffffff;
173
+ text-align: center;
174
+ padding: 2vh;
175
+ box-shadow: 0 0 20px #ff00ff, 0 0 30px #00ccff;
176
+ animation: popup 0.5s ease-out, pulse 2s infinite alternate;
177
+ z-index: 1000;
178
+ border-radius: 10px;
179
+ transform: translate(-50%, -50%);
180
+ }
181
+ #game-over-screen h2 {
182
+ font-size: 3vw;
183
+ color: #ffff00;
184
+ text-shadow: 0 0 8px #ff00ff, 0 0 16px #00ccff;
185
+ margin: 1.5vh 0;
186
+ }
187
+ #game-over-screen p {
188
+ font-size: 1.5vw;
189
+ color: #ffffff;
190
+ text-shadow: 0 0 4px #000000;
191
+ margin: 0.8vh 0;
192
+ }
193
+
194
+ /* Craft Menu */
195
+ #craft-menu {
196
+ display: none;
197
+ position: fixed;
198
+ top: 50%;
199
+ left: 50%;
200
+ width: 70vw;
201
+ max-width: 600px;
202
+ background: #000000;
203
+ border: 3px solid #ff00ff;
204
+ box-shadow: 0 0 15px #ff00ff, 0 0 25px #00ccff, inset 0 0 10px #ff00ff;
205
+ padding: 2vh;
206
+ z-index: 1000;
207
+ animation: neonPulse 1.5s infinite alternate;
208
+ transform: translate(-50%, -50%);
209
+ }
210
+ #craft-menu h2 {
211
+ font-size: 2.5vw;
212
+ color: #ffff00;
213
+ text-shadow: 0 0 8px #ff00ff;
214
+ margin: 0 0 2vh 0;
215
+ text-align: center;
216
+ }
217
+ #craft-list {
218
+ list-style: none;
219
+ padding: 0;
220
+ margin: 0;
221
+ }
222
+ #craft-list li {
223
+ color: #00ffcc;
224
+ font-size: 1.5vw;
225
+ padding: 1vh 1.5vw;
226
+ margin: 0.5vh 0;
227
+ background: rgba(255, 0, 255, 0.1);
228
+ border-left: 5px solid #ff00ff;
229
+ display: flex;
230
+ justify-content: space-between;
231
+ align-items: center;
232
+ transition: all 0.3s ease;
233
+ }
234
+ #craft-list li:hover {
235
+ background: rgba(255, 0, 255, 0.3);
236
+ border-left: 5px solid #00ccff;
237
+ transform: translateX(5px);
238
+ }
239
+ #craft-list li button {
240
+ background: #ffff00;
241
+ color: #ff00ff;
242
+ font-size: 1.2vw;
243
+ padding: 0.5vh 1vw;
244
+ box-shadow: 0 0 5px #ffffff;
245
+ }
246
+ #craft-list li button:hover {
247
+ background: #00ccff;
248
+ color: #ffffff;
249
+ }
250
+
251
+ @keyframes glow {
252
+ from { text-shadow: 2px 2px 0 #00ffcc, 0 0 8px #ffffff; }
253
+ to { text-shadow: 3px 3px 0 #00ffcc, 0 0 12px #ffffff; }
254
+ }
255
+ @keyframes pulse {
256
+ from { box-shadow: 0 0 20px #ff00ff, 0 0 30px #00ccff; }
257
+ to { box-shadow: 0 0 30px #ff00ff, 0 0 40px #00ccff; }
258
+ }
259
+ @keyframes popup {
260
+ from { transform: translate(-50%, -50%) scale(0); opacity: 0; }
261
+ to { transform: translate(-50%, -50%) scale(1); opacity: 1; }
262
+ }
263
+ @keyframes neonPulse {
264
+ from { box-shadow: 0 0 15px #ff00ff, 0 0 25px #00ccff, inset 0 0 10px #ff00ff; }
265
+ to { box-shadow: 0 0 25px #ff00ff, 0 0 35px #00ccff, inset 0 0 15px #ff00ff; }
266
+ }
267
+
268
+ /* Mobile scaling */
269
+ @media screen and (max-width: 768px) {
270
+ h1 { font-size: 5vw; }
271
+ #status, #mission { font-size: 3vw; }
272
+ #export-popup { width: 70vw; }
273
+ #export-popup h2 { font-size: 3vw; }
274
+ #export-stats { font-size: 2.2vw; }
275
+ .export-btn { font-size: 2.5vw; }
276
+ .close-export { font-size: 2.2vw; }
277
+ #craft-list li { font-size: 2.5vw; }
278
+ button { font-size: 2.5vw; }
279
+ #inn-timer { font-size: 5vw; }
280
+ }
281
+
282
+ @media screen and (max-width: 480px) {
283
+ h1 { font-size: 6vw; }
284
+ #status, #mission { font-size: 4vw; }
285
+ #export-popup { width: 85vw; padding: 1.5vh; }
286
+ #export-popup h2 { font-size: 4vw; }
287
+ #export-stats { font-size: 3vw; }
288
+ .export-btn { font-size: 3.5vw; padding: 1.5vh 0; }
289
+ .close-export { font-size: 3vw; }
290
+ button { font-size: 3vw; padding: 1vh 3vw; }
291
+ #skill-buttons { flex-direction: column; align-items: center; }
292
+ .bar { width: 50vw; }
293
+ }
294
+ </style>
295
+ </head>
296
+ <body>
297
+ <div id="game">
298
+ <h1>Emoji Quest RL • WebXOS 2026</h1>
299
+ <div id="status">Tap a command to begin! 🎮</div>
300
+ <div id="stats">
301
+ Player: <span id="hero-emoji">🧙‍♂️</span> Lvl: <span id="hero-level">1</span> Gold: <span id="hero-gold">0</span> 💰<br>
302
+ HP: <div class="bar"><div class="health" id="hero-health" style="width: 100%;"></div></div> <span id="hero-hp">100/100</span> ❤️<br>
303
+ MP: <div class="bar"><div class="mana" id="hero-mana" style="width: 100%;"></div></div> <span id="hero-mp">50/50</span> 🔮<br>
304
+ EXP: <div class="bar"><div class="exp" id="hero-exp" style="width: 0%;"></div></div> <span id="hero-exp-text">0/50</span> ⭐<br>
305
+ 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>
306
+ Points: <span id="skill-points">0</span> 🎯 | Armor: <span id="armor-level">None</span> | Weapon: <span id="weapon-level">None</span>
307
+ </div>
308
+ <div id="skills" style="display: none;">
309
+ <button onclick="upgradeStat('str')">💪 +STR (1pt)</button>
310
+ <button onclick="upgradeStat('int')">🧠 +INT (1pt)</button>
311
+ <button onclick="upgradeStat('vit')">🛡️ +VIT (1pt)</button>
312
+ </div>
313
+ <div class="entity">Enemy: <span id="enemy-emoji">👾 Zargoth</span>
314
+ HP: <div class="bar"><div class="health" id="enemy-health" style="width: 100%;"></div></div> <span id="enemy-hp">60/60</span> ❤️
315
+ </div>
316
+ <div id="mission"></div>
317
+ <div id="combat-log"></div>
318
+ <div id="skill-buttons">
319
+ <button onclick="playerTurn(1)">⚔️ Attack</button>
320
+ <button onclick="playerTurn(2)">✨ Spell</button>
321
+ <button onclick="playerTurn(4)">🏡 Inn</button>
322
+ <button onclick="openCraftMenu()">🔨 Craft</button>
323
+ <button onclick="showExportPopup()">💾 Export</button>
324
+ </div>
325
+ </div>
326
+
327
+ <!-- Inn Timer -->
328
+ <div id="inn-timer"></div>
329
+
330
+ <!-- Minimal Export Popup -->
331
+ <div id="export-popup">
332
+ <h2>💾 Export Dataset</h2>
333
+ <div id="export-stats">
334
+ <div>📊 Decisions: <span id="export-decision-count">0</span></div>
335
+ <div>👾 Enemies: <span id="export-enemy-count">0</span></div>
336
+ <div>💰 Gold: <span id="export-gold">0</span></div>
337
+ <div>⭐ Level: <span id="export-level">1</span></div>
338
+ <div>⏱️ Playtime: <span id="export-time">0s</span></div>
339
+ </div>
340
+ <div class="export-buttons">
341
+ <button class="export-btn" onclick="exportDataset()">📥 Export as ZIP</button>
342
+ <button class="close-export" onclick="closeExportPopup()">Close</button>
343
+ </div>
344
+ </div>
345
+
346
+ <!-- Craft Menu -->
347
+ <div id="craft-menu">
348
+ <h2>🔨 Forge</h2>
349
+ <ul id="craft-list">
350
+ <li>Leather Armor (DEF +25) - 2000 Gold <button onclick="craftArmor(1)">Craft</button></li>
351
+ <li>Chain Mail (DEF +75) - 10000 Gold <button onclick="craftArmor(2)">Craft</button></li>
352
+ <li>Plate Armor (DEF +150) - 30000 Gold <button onclick="craftArmor(3)">Craft</button></li>
353
+ <li>Mythril Armor (DEF +250) - 60000 Gold <button onclick="craftArmor(4)">Craft</button></li>
354
+ <li>Great Staff (Spell +200) - 50000 Gold <button onclick="craftWeapon(1)">Craft</button></li>
355
+ <li>Great Sword (ATK +200) - 50000 Gold <button onclick="craftWeapon(2)">Craft</button></li>
356
+ </ul>
357
+ <button class="close-export" onclick="closeCraftMenu()">Close</button>
358
+ </div>
359
+
360
+ <!-- Game Over Screen -->
361
+ <div id="game-over-screen">
362
+ <h2>🏆 Game Over</h2>
363
+ <p>Level: <span id="game-over-level"></span> 🎖️</p>
364
+ <p>Total Gold: <span id="game-over-gold"></span> 💰</p>
365
+ <p>Total XP: <span id="game-over-exp"></span> ⭐</p>
366
+ <p>Total Decisions: <span id="game-over-decisions"></span> 📊</p>
367
+ <button onclick="showExportPopup()">💾 Export Dataset</button>
368
+ <button onclick="location.reload()">🔄 Restart</button>
369
+ </div>
370
+
371
+ <script>
372
+ // Game state tracking
373
+ let gameData = {
374
+ states: [],
375
+ flatStates: [],
376
+ decisions: [],
377
+ metadata: {
378
+ game: "Emoji Quest RL",
379
+ version: "WebXOS 2026",
380
+ created: new Date().toISOString(),
381
+ license: "MIT",
382
+ default_config: "csv",
383
+ features: [
384
+ {name: "timestamp", dtype: "int64"},
385
+ {name: "action", dtype: "string"},
386
+ {name: "reward", dtype: "float64"},
387
+ {name: "outcome", dtype: "string"},
388
+ {name: "decision_type", dtype: "string"},
389
+ {name: "player_state", dtype: "string"},
390
+ {name: "enemy_info", dtype: "string"},
391
+ {name: "player_state_snapshot", dtype: "string"},
392
+ {name: "enemy_state", dtype: "string"},
393
+ {name: "enemy_count", dtype: "int64"},
394
+ {name: "game_state", dtype: "string"}
395
+ ]
396
+ }
397
+ };
398
+
399
+ // Core game variables
400
+ const status = document.getElementById('status');
401
+ const combatLog = document.getElementById('combat-log');
402
+ const heroHealth = document.getElementById('hero-health');
403
+ const heroHp = document.getElementById('hero-hp');
404
+ const heroMana = document.getElementById('hero-mana');
405
+ const heroMp = document.getElementById('hero-mp');
406
+ const heroExp = document.getElementById('hero-exp');
407
+ const heroExpText = document.getElementById('hero-exp-text');
408
+ const heroLevel = document.getElementById('hero-level');
409
+ const heroGold = document.getElementById('hero-gold');
410
+ const heroStr = document.getElementById('hero-str');
411
+ const heroInt = document.getElementById('hero-int');
412
+ const heroVit = document.getElementById('hero-vit');
413
+ const heroDef = document.getElementById('hero-def');
414
+ const skillPoints = document.getElementById('skill-points');
415
+ const armorLevel = document.getElementById('armor-level');
416
+ const weaponLevel = document.getElementById('weapon-level');
417
+ const enemyHealth = document.getElementById('enemy-health');
418
+ const enemyHp = document.getElementById('enemy-hp');
419
+ const enemyEmoji = document.getElementById('enemy-emoji');
420
+ const mission = document.getElementById('mission');
421
+ const skillsDiv = document.getElementById('skills');
422
+ const craftMenu = document.getElementById('craft-menu');
423
+ const exportPopup = document.getElementById('export-popup');
424
+ const gameOverScreen = document.getElementById('game-over-screen');
425
+ const innTimer = document.getElementById('inn-timer');
426
+
427
+ let hero = {
428
+ level: 1, hp: 100, maxHp: 100, mp: 50, maxMp: 50, exp: 0, expToLevel: 50,
429
+ str: 5, int: 5, vit: 5, def: 0, gold: 0, skillPoints: 0,
430
+ armorLevel: 0, hasGreatStaff: false, hasGreatSword: false, atkBonus: 0, spellBonus: 0
431
+ };
432
+ const startTime = Date.now();
433
+ const baseEnemies = [
434
+ { emoji: '👾', name: 'Zargoth', hp: 60, attack: 10 },
435
+ { emoji: '🕷️', name: 'Skrix', hp: 50, attack: 12 },
436
+ { emoji: '🦇', name: 'Vlyth', hp: 55, attack: 11 },
437
+ { emoji: '🐍', name: 'Slytheron', hp: 80, attack: 15 },
438
+ { emoji: '🦂', name: 'Stingrax', hp: 70, attack: 18 },
439
+ { emoji: '🤖', name: 'Mechalon', hp: 100, attack: 20 },
440
+ { emoji: '💾', name: 'Datavore', hp: 120, attack: 25 },
441
+ { emoji: '🖥️', name: 'Screenix', hp: 110, attack: 22 },
442
+ { emoji: '🕸️', name: 'Webtron', hp: 130, attack: 28 },
443
+ { emoji: '🔋', name: 'Voltrix', hp: 140, attack: 26 },
444
+ { emoji: '🐉', name: 'Drakzul', hp: 150, attack: 30 },
445
+ { emoji: '👻', name: 'Spectrix', hp: 140, attack: 32 },
446
+ { emoji: '👽', name: 'Xenorath', hp: 200, attack: 40 }
447
+ ];
448
+ let enemyCount = 0;
449
+ let currentEnemy = spawnEnemy();
450
+ let gameState = 'playing';
451
+ let innCooldown = false;
452
+ let decisionCount = 0;
453
+
454
+ // Audio
455
+ const audioContext = new (window.AudioContext || window.webkitAudioContext)();
456
+ function playClickSound() {
457
+ const oscillator = audioContext.createOscillator();
458
+ const gainNode = audioContext.createGain();
459
+ oscillator.connect(gainNode);
460
+ gainNode.connect(audioContext.destination);
461
+ oscillator.type = 'square';
462
+ oscillator.frequency.value = 880;
463
+ gainNode.gain.setValueAtTime(0.1, audioContext.currentTime);
464
+ gainNode.gain.exponentialRampToValueAtTime(0.001, audioContext.currentTime + 0.1);
465
+ oscillator.start();
466
+ oscillator.stop(audioContext.currentTime + 0.1);
467
+ }
468
+
469
+ function playInnSound() {
470
+ const oscillator = audioContext.createOscillator();
471
+ const gainNode = audioContext.createGain();
472
+ oscillator.connect(gainNode);
473
+ gainNode.connect(audioContext.destination);
474
+ oscillator.type = 'sine';
475
+ oscillator.frequency.setValueAtTime(440, audioContext.currentTime);
476
+ oscillator.frequency.exponentialRampToValueAtTime(880, audioContext.currentTime + 0.5);
477
+ gainNode.gain.setValueAtTime(0.1, audioContext.currentTime);
478
+ gainNode.gain.exponentialRampToValueAtTime(0.001, audioContext.currentTime + 0.5);
479
+ oscillator.start();
480
+ oscillator.stop(audioContext.currentTime + 0.5);
481
+ }
482
+
483
+ // Record game state - FIXED VERSION with consistent data structure
484
+ function recordState(action, reward, outcome) {
485
+ const timestamp = Date.now();
486
+ const decision_type = getDecisionType(action);
487
+
488
+ // Create player state snapshot (the 6 missing columns)
489
+ const playerSnapshot = JSON.stringify({
490
+ level: hero.level,
491
+ hp: hero.hp,
492
+ maxHp: hero.maxHp,
493
+ mp: hero.mp,
494
+ maxMp: hero.maxMp,
495
+ str: hero.str,
496
+ int: hero.int,
497
+ vit: hero.vit,
498
+ def: hero.def,
499
+ gold: hero.gold,
500
+ skillPoints: hero.skillPoints
501
+ });
502
+
503
+ // Create enemy info (the 6 missing columns)
504
+ const enemyInfo = JSON.stringify({
505
+ name: currentEnemy.name,
506
+ emoji: currentEnemy.emoji,
507
+ hp: currentEnemy.hp,
508
+ maxHp: currentEnemy.maxHp,
509
+ attack: currentEnemy.attack,
510
+ is_boss: currentEnemy.isBoss || false,
511
+ is_elite: currentEnemy.isElite || false
512
+ });
513
+
514
+ // Create player state (the 4 new columns)
515
+ const playerState = JSON.stringify(hero);
516
+
517
+ // Create enemy state (the 4 new columns)
518
+ const enemyState = JSON.stringify(currentEnemy);
519
+
520
+ // Create the complete state object with ALL columns
521
+ const completeState = {
522
+ timestamp,
523
+ action: action.toString(),
524
+ reward: parseFloat(reward),
525
+ outcome,
526
+ decision_type,
527
+ player_state_snapshot: playerSnapshot,
528
+ enemy_info: enemyInfo,
529
+ player_state: playerState,
530
+ enemy_state: enemyState,
531
+ enemy_count: enemyCount,
532
+ game_state: gameState
533
+ };
534
+
535
+ // Add to game data
536
+ gameData.states.push(completeState);
537
+ gameData.decisions.push(completeState);
538
+ gameData.flatStates.push(completeState);
539
+
540
+ decisionCount++;
541
+ }
542
+
543
+ function getDecisionType(actionId) {
544
+ if (typeof actionId === 'string') {
545
+ if (actionId.includes('upgrade')) return "upgrade_stat";
546
+ if (actionId.includes('craft_armor')) return "craft_armor";
547
+ if (actionId.includes('craft_weapon')) return "craft_weapon";
548
+ if (actionId.includes('enemy_defeated')) return "combat_victory";
549
+ if (actionId.includes('player_death')) return "player_death";
550
+ if (actionId.includes('inn_rest')) return "rest_inn";
551
+ if (actionId.includes('level_up')) return "progression";
552
+ return actionId;
553
+ }
554
+
555
+ const types = {
556
+ 1: "combat_attack",
557
+ 2: "combat_spell",
558
+ 4: "rest_inn"
559
+ };
560
+ return types[actionId] || "unknown";
561
+ }
562
+
563
+ // CSV helper
564
+ function convertToCSV(data, columns) {
565
+ if (data.length === 0) return '';
566
+
567
+ const headers = columns.join(',');
568
+ const rows = data.map(item => {
569
+ return columns.map(col => {
570
+ let value = item[col];
571
+ if (value === undefined || value === null) value = '';
572
+ if (typeof value === 'object' && value !== null) {
573
+ value = JSON.stringify(value).replace(/"/g, '""');
574
+ return `"${value}"`;
575
+ }
576
+ if (typeof value === 'string' && (value.includes(',') || value.includes('"'))) {
577
+ return `"${value.replace(/"/g, '""')}"`;
578
+ }
579
+ return value;
580
+ }).join(',');
581
+ });
582
+
583
+ return [headers, ...rows].join('\n');
584
+ }
585
+
586
+ // Minimal export popup
587
+ function showExportPopup() {
588
+ playClickSound();
589
+
590
+ // Update stats
591
+ document.getElementById('export-decision-count').textContent = decisionCount;
592
+ document.getElementById('export-enemy-count').textContent = enemyCount;
593
+ document.getElementById('export-gold').textContent = hero.gold;
594
+ document.getElementById('export-level').textContent = hero.level;
595
+ document.getElementById('export-time').textContent = Math.floor((Date.now() - startTime) / 1000) + 's';
596
+
597
+ exportPopup.style.display = 'block';
598
+ }
599
+
600
+ function closeExportPopup() {
601
+ playClickSound();
602
+ exportPopup.style.display = 'none';
603
+ }
604
+
605
+ // Main export function - FIXED VERSION with consistent columns
606
+ function exportDataset() {
607
+ playClickSound();
608
+
609
+ // Define ALL columns for consistency
610
+ const allColumns = [
611
+ 'timestamp',
612
+ 'action',
613
+ 'reward',
614
+ 'outcome',
615
+ 'decision_type',
616
+ 'player_state_snapshot',
617
+ 'enemy_info',
618
+ 'player_state',
619
+ 'enemy_state',
620
+ 'enemy_count',
621
+ 'game_state'
622
+ ];
623
+
624
+ // Prepare dataset with consistent structure
625
+ const completeDataset = {
626
+ game_states: gameData.states.map(state => ({
627
+ timestamp: state.timestamp,
628
+ action: state.action,
629
+ reward: state.reward,
630
+ outcome: state.outcome,
631
+ decision_type: state.decision_type,
632
+ player_state_snapshot: state.player_state_snapshot,
633
+ enemy_info: state.enemy_info,
634
+ player_state: state.player_state,
635
+ enemy_state: state.enemy_state,
636
+ enemy_count: state.enemy_count,
637
+ game_state: state.game_state
638
+ })),
639
+ decisions: gameData.decisions.map(decision => ({
640
+ timestamp: decision.timestamp,
641
+ action: decision.action,
642
+ reward: decision.reward,
643
+ outcome: decision.outcome,
644
+ decision_type: decision.decision_type,
645
+ player_state_snapshot: decision.player_state_snapshot,
646
+ enemy_info: decision.enemy_info,
647
+ player_state: decision.player_state,
648
+ enemy_state: decision.enemy_state,
649
+ enemy_count: decision.enemy_count,
650
+ game_state: decision.game_state
651
+ })),
652
+ summary: {
653
+ total_states: gameData.states.length,
654
+ total_decisions: gameData.decisions.length,
655
+ total_enemies_defeated: enemyCount,
656
+ total_gold_earned: hero.gold,
657
+ total_xp_earned: hero.exp,
658
+ play_time: Math.floor((Date.now() - startTime) / 1000),
659
+ final_level: hero.level,
660
+ final_gold: hero.gold,
661
+ final_hp: hero.hp,
662
+ final_mp: hero.mp
663
+ },
664
+ metadata: {
665
+ ...gameData.metadata,
666
+ export_date: new Date().toISOString(),
667
+ license: "mit",
668
+ task_categories: ["reinforcement_learning", "decision_making"],
669
+ task_ids: ["emoji_quest_rl"],
670
+ pretty_name: "Emoji Quest RL Dataset"
671
+ }
672
+ };
673
+
674
+ // Create CSV files with ALL columns
675
+ const statesData = gameData.flatStates.map(state => {
676
+ const filtered = {};
677
+ allColumns.forEach(col => {
678
+ filtered[col] = state[col] !== undefined ? state[col] : '';
679
+ });
680
+ return filtered;
681
+ });
682
+
683
+ const decisionsData = gameData.decisions.map(decision => {
684
+ const filtered = {};
685
+ allColumns.forEach(col => {
686
+ filtered[col] = decision[col] !== undefined ? decision[col] : '';
687
+ });
688
+ return filtered;
689
+ });
690
+
691
+ const statesCSV = convertToCSV(statesData, allColumns);
692
+ const decisionsCSV = convertToCSV(decisionsData, allColumns);
693
+
694
+ // Create README with consistent config
695
+ const readme = `---
696
+ license: mit
697
+ task_categories:
698
+ - reinforcement_learning
699
+ - decision_making
700
+ task_ids:
701
+ - emoji_quest_rl
702
+ pretty_name: Emoji Quest RL Dataset
703
+ dataset_info:
704
+ configs:
705
+ - config_name: game_states
706
+ data_files:
707
+ - split: train
708
+ path: game_states.csv
709
+ features:
710
+ - name: timestamp
711
+ dtype: int64
712
+ - name: action
713
+ dtype: string
714
+ - name: reward
715
+ dtype: float64
716
+ - name: outcome
717
+ dtype: string
718
+ - name: decision_type
719
+ dtype: string
720
+ - name: player_state_snapshot
721
+ dtype: string
722
+ - name: enemy_info
723
+ dtype: string
724
+ - name: player_state
725
+ dtype: string
726
+ - name: enemy_state
727
+ dtype: string
728
+ - name: enemy_count
729
+ dtype: int64
730
+ - name: game_state
731
+ dtype: string
732
+ - config_name: decisions
733
+ data_files:
734
+ - split: train
735
+ path: decisions.csv
736
+ features:
737
+ - name: timestamp
738
+ dtype: int64
739
+ - name: action
740
+ dtype: string
741
+ - name: reward
742
+ dtype: float64
743
+ - name: outcome
744
+ dtype: string
745
+ - name: decision_type
746
+ dtype: string
747
+ - name: player_state_snapshot
748
+ dtype: string
749
+ - name: enemy_info
750
+ dtype: string
751
+ - name: player_state
752
+ dtype: string
753
+ - name: enemy_state
754
+ dtype: string
755
+ - name: enemy_count
756
+ dtype: int64
757
+ - name: game_state
758
+ dtype: string
759
+ default: game_states
760
+ ---
761
+ # Emoji Quest RL Dataset
762
+ Reinforcement learning dataset from Emoji Quest RL gameplay.
763
+
764
+ ## Files
765
+ ### game_states.csv
766
+ Game state snapshots at each decision point. Contains player and enemy stats.
767
+
768
+ ### decisions.csv
769
+ Player decisions with rewards and outcomes. Contains action choices and results.
770
+
771
+ ## Summary
772
+ - Total states: ${completeDataset.summary.total_states}
773
+ - Total decisions: ${completeDataset.summary.total_decisions}
774
+ - Total enemies defeated: ${completeDataset.summary.total_enemies_defeated}
775
+ - Total gold earned: ${completeDataset.summary.total_gold_earned}
776
+ - Total XP earned: ${completeDataset.summary.total_xp_earned}
777
+ - Play time: ${completeDataset.summary.play_time} seconds
778
+ - Final level: ${completeDataset.summary.final_level}
779
+ - Final gold: ${completeDataset.summary.final_gold}
780
+ - Final HP: ${completeDataset.summary.final_hp}
781
+ - Final MP: ${completeDataset.summary.final_mp}
782
+ `;
783
+
784
+ // Create ZIP - Only include the required 5 files
785
+ const zip = new JSZip();
786
+
787
+ // Add only the required files (no dataset_summary.json)
788
+ zip.file("game_states.csv", statesCSV);
789
+ zip.file("decisions.csv", decisionsCSV);
790
+ zip.file("game_states.json", JSON.stringify(completeDataset.game_states, null, 2));
791
+ zip.file("decisions.json", JSON.stringify(completeDataset.decisions, null, 2));
792
+ zip.file("README.md", readme);
793
+
794
+ // Generate and download
795
+ zip.generateAsync({type: "blob", compression: "DEFLATE"})
796
+ .then(blob => {
797
+ const url = URL.createObjectURL(blob);
798
+ const a = document.createElement('a');
799
+ a.href = url;
800
+ a.download = `emoji_quest_${Date.now()}.zip`;
801
+ document.body.appendChild(a);
802
+ a.click();
803
+ document.body.removeChild(a);
804
+ URL.revokeObjectURL(url);
805
+
806
+ appendLog("✅ Dataset exported! Ready for HF Upload.");
807
+ closeExportPopup();
808
+ })
809
+ .catch(error => {
810
+ appendLog("❌ Export failed: " + error);
811
+ console.error(error);
812
+ });
813
+ }
814
+
815
+ // ESC key for quick export
816
+ document.addEventListener('keydown', function(e) {
817
+ if (e.key === 'Escape' && gameState === 'playing') {
818
+ showExportPopup();
819
+ }
820
+ });
821
+
822
+ // Game commands
823
+ const commands = {
824
+ 1: { name: 'Attack', emoji: '⚔️', cost: 0, effect: (enemy) => {
825
+ let dmg = (hero.str * 3) + hero.atkBonus;
826
+ enemy.hp -= dmg;
827
+ return dmg;
828
+ }, log: 'slashes with Attack ⚔️' },
829
+ 2: { name: 'Spell', emoji: '✨', cost: 15, effect: (enemy) => {
830
+ let dmg = 75 + (hero.int * 3) + hero.spellBonus;
831
+ enemy.hp -= dmg;
832
+ return dmg;
833
+ }, log: 'casts Spell ✨' },
834
+ 4: { name: 'Inn', emoji: '🏡', cost: 0, effect: () => startInnTimer(), log: 'rests at Inn 🏡' }
835
+ };
836
+
837
+ const armors = [
838
+ { name: 'None', def: 0, cost: 0 },
839
+ { name: 'Leather Armor', def: 25, cost: 2000 },
840
+ { name: 'Chain Mail', def: 75, cost: 10000 },
841
+ { name: 'Plate Armor', def: 150, cost: 30000 },
842
+ { name: 'Mythril Armor', def: 250, cost: 60000 }
843
+ ];
844
+
845
+ const weapons = [
846
+ { name: 'None', spellBonus: 0, atkBonus: 0, cost: 0 },
847
+ { name: 'Great Staff', spellBonus: 200, atkBonus: 0, cost: 50000 },
848
+ { name: 'Great Sword', spellBonus: 0, atkBonus: 200, cost: 50000 }
849
+ ];
850
+
851
+ function spawnEnemy() {
852
+ enemyCount++;
853
+ let baseEnemy = baseEnemies[Math.floor(Math.random() * baseEnemies.length)];
854
+ let scale = 1 + (enemyCount * 0.1);
855
+ let levelScale = 0.8 + (hero.level * 0.05);
856
+ let enemy = {
857
+ ...baseEnemy,
858
+ hp: Math.floor(baseEnemy.hp * scale),
859
+ maxHp: Math.floor(baseEnemy.hp * scale),
860
+ attack: Math.floor(baseEnemy.attack * scale * levelScale),
861
+ isBoss: false,
862
+ isElite: false
863
+ };
864
+ if (enemyCount % 10 === 0) {
865
+ enemy.hp *= 2;
866
+ enemy.maxHp *= 2;
867
+ enemy.attack *= 2;
868
+ enemy.emoji = `👑${enemy.emoji}`;
869
+ enemy.name = `King ${enemy.name}`;
870
+ enemy.isBoss = true;
871
+ } else if (Math.random() < 0.2) {
872
+ enemy.hp = Math.floor(enemy.hp * 1.5);
873
+ enemy.maxHp = Math.floor(enemy.hp * 1.5);
874
+ enemy.attack = Math.floor(enemy.attack * 1.5);
875
+ enemy.emoji = `⭐${enemy.emoji}`;
876
+ enemy.name = `Elite ${enemy.name}`;
877
+ enemy.isElite = true;
878
+ }
879
+ return enemy;
880
+ }
881
+
882
+ function playerTurn(commandId) {
883
+ if (gameState !== 'playing' || innCooldown) return;
884
+ playClickSound();
885
+
886
+ const command = commands[commandId];
887
+ if (command.cost > 0 && hero.mp < command.cost) {
888
+ appendLog('Not enough Mana! 🔮');
889
+ return;
890
+ }
891
+
892
+ hero.mp -= command.cost;
893
+ let log = `🧙‍♂️ ${command.log}`;
894
+ let damage = 0;
895
+
896
+ if (commandId === 1 || commandId === 2) {
897
+ damage = command.effect(currentEnemy);
898
+ log += ` for ${damage} damage!`;
899
+ recordState(command.name, damage, "damage_dealt");
900
+ } else {
901
+ command.effect(currentEnemy);
902
+ return;
903
+ }
904
+
905
+ appendLog(log);
906
+ updateUI();
907
+
908
+ if (currentEnemy.hp <= 0) {
909
+ recordState("enemy_defeated", 100, "victory");
910
+ winCombat();
911
+ } else if (!innCooldown) {
912
+ setTimeout(randomEnemyTurn, 500);
913
+ }
914
+ }
915
+
916
+ function randomEnemyTurn() {
917
+ if (gameState !== 'playing' || innCooldown) return;
918
+ if (Math.random() < 0.5) {
919
+ let damage = Math.max(1, currentEnemy.attack - hero.def);
920
+ hero.hp -= damage;
921
+ appendLog(`${currentEnemy.emoji} ${currentEnemy.name} strikes for ${damage} damage! 💥 (Def: ${hero.def})`);
922
+ recordState("enemy_attack", -damage, "damage_taken");
923
+ updateUI();
924
+ if (hero.hp <= 0) {
925
+ gameState = 'over';
926
+ status.textContent = 'Game Over! 💀';
927
+ recordState("player_death", -1000, "defeat");
928
+ showGameOverScreen();
929
+ }
930
+ } else {
931
+ appendLog(`${currentEnemy.emoji} ${currentEnemy.name} hesitates... ⏳`);
932
+ recordState("enemy_hesitate", 0, "enemy_inaction");
933
+ }
934
+ }
935
+
936
+ function startInnTimer() {
937
+ if (innCooldown) return;
938
+
939
+ playInnSound();
940
+ innCooldown = true;
941
+ let timeLeft = 10;
942
+
943
+ innTimer.style.display = 'block';
944
+ innTimer.textContent = `Resting: ${timeLeft}s ⏳`;
945
+ status.textContent = 'Resting at the Inn... 🏡';
946
+
947
+ const timer = setInterval(() => {
948
+ timeLeft--;
949
+ innTimer.textContent = `Resting: ${timeLeft}s ⏳`;
950
+
951
+ if (timeLeft <= 0) {
952
+ clearInterval(timer);
953
+ hero.hp = hero.maxHp;
954
+ hero.mp = hero.maxMp;
955
+ innCooldown = false;
956
+ innTimer.style.display = 'none';
957
+ status.textContent = 'Tap a command to fight! 🎮';
958
+ appendLog('🧙‍♂️ fully restored! 🌟');
959
+ recordState("inn_rest", 200, "full_restoration");
960
+ updateUI();
961
+ }
962
+ }, 1000);
963
+ }
964
+
965
+ function winCombat() {
966
+ const enemyKey = `${currentEnemy.emoji} ${currentEnemy.name}`;
967
+ let expGain = Math.floor(currentEnemy.maxHp / 2 * (1 + enemyCount * 0.05));
968
+ let goldGain = Math.floor(currentEnemy.maxHp * (1 + enemyCount * 0.05));
969
+ appendLog(`${enemyKey} defeated! +${expGain} EXP ⭐, +${goldGain} Gold 💰`);
970
+ hero.exp += expGain;
971
+ hero.gold += goldGain;
972
+ if (hero.exp >= hero.expToLevel) levelUp();
973
+ currentEnemy = spawnEnemy();
974
+ updateMission();
975
+ updateUI();
976
+ }
977
+
978
+ function levelUp() {
979
+ hero.level++;
980
+ hero.exp -= hero.expToLevel;
981
+ hero.expToLevel = Math.floor(hero.expToLevel * 1.5);
982
+ hero.skillPoints += 2;
983
+ hero.maxHp += 20 + hero.vit * 2;
984
+ hero.maxMp += 10;
985
+ appendLog(`Level Up! Now Level ${hero.level}. +2 Skill Points! 🌟`);
986
+ recordState("level_up", 500, "progression");
987
+ skillsDiv.style.display = hero.skillPoints > 0 ? 'block' : 'none';
988
+ updateUI();
989
+ }
990
+
991
+ function upgradeStat(stat) {
992
+ if (hero.skillPoints > 0) {
993
+ playClickSound();
994
+ hero[stat]++;
995
+ hero.skillPoints--;
996
+ appendLog(`+1 ${stat.toUpperCase()}! 🎯`);
997
+ recordState(`upgrade_${stat}`, 50, "stat_improvement");
998
+ skillsDiv.style.display = hero.skillPoints > 0 ? 'block' : 'none';
999
+ updateUI();
1000
+ }
1001
+ }
1002
+
1003
+ function craftArmor(level) {
1004
+ playClickSound();
1005
+ const armor = armors[level];
1006
+ if (hero.gold >= armor.cost && hero.armorLevel < level) {
1007
+ hero.gold -= armor.cost;
1008
+ hero.def = armor.def;
1009
+ hero.armorLevel = level;
1010
+ appendLog(`Crafted ${armor.name}! DEF increased to ${hero.def} 🛡️`);
1011
+ recordState(`craft_armor_${level}`, armor.def, "equipment_craft");
1012
+ closeCraftMenu();
1013
+ updateUI();
1014
+ } else if (hero.gold < armor.cost) {
1015
+ appendLog('Not enough Gold! 💰');
1016
+ } else {
1017
+ appendLog('You already have better armor! 🛡️');
1018
+ }
1019
+ }
1020
+
1021
+ function craftWeapon(index) {
1022
+ playClickSound();
1023
+ const weapon = weapons[index];
1024
+ let alreadyOwned = (index === 1 && hero.hasGreatStaff) || (index === 2 && hero.hasGreatSword);
1025
+ if (hero.gold >= weapon.cost && !alreadyOwned) {
1026
+ hero.gold -= weapon.cost;
1027
+ if (index === 1) {
1028
+ hero.hasGreatStaff = true;
1029
+ hero.spellBonus += weapon.spellBonus;
1030
+ appendLog(`Crafted ${weapon.name}! Spell damage increased by ${weapon.spellBonus} ✨`);
1031
+ } else if (index === 2) {
1032
+ hero.hasGreatSword = true;
1033
+ hero.atkBonus += weapon.atkBonus;
1034
+ appendLog(`Crafted ${weapon.name}! Attack damage increased by ${weapon.atkBonus} ⚔️`);
1035
+ }
1036
+ recordState(`craft_weapon_${index}`, weapon.spellBonus + weapon.atkBonus, "weapon_craft");
1037
+ closeCraftMenu();
1038
+ updateUI();
1039
+ } else if (hero.gold < weapon.cost) {
1040
+ appendLog('Not enough Gold! 💰');
1041
+ } else {
1042
+ appendLog(`You already own the ${weapon.name}!`);
1043
+ }
1044
+ }
1045
+
1046
+ function showGameOverScreen() {
1047
+ gameOverScreen.style.display = 'block';
1048
+ document.getElementById('game-over-level').textContent = hero.level;
1049
+ document.getElementById('game-over-gold').textContent = hero.gold;
1050
+ document.getElementById('game-over-exp').textContent = Math.floor(hero.exp);
1051
+ document.getElementById('game-over-decisions').textContent = decisionCount;
1052
+ }
1053
+
1054
+ function updateUI() {
1055
+ heroHealth.style.width = `${(hero.hp / hero.maxHp) * 100}%`;
1056
+ heroHp.textContent = `${hero.hp}/${hero.maxHp}`;
1057
+ heroMana.style.width = `${(hero.mp / hero.maxMp) * 100}%`;
1058
+ heroMp.textContent = `${hero.mp}/${hero.maxMp}`;
1059
+ heroExp.style.width = `${(hero.exp / hero.expToLevel) * 100}%`;
1060
+ heroExpText.textContent = `${Math.floor(hero.exp)}/${hero.expToLevel}`;
1061
+ heroLevel.textContent = hero.level;
1062
+ heroGold.textContent = hero.gold;
1063
+ heroStr.textContent = hero.str;
1064
+ heroInt.textContent = hero.int;
1065
+ heroVit.textContent = hero.vit;
1066
+ heroDef.textContent = hero.def;
1067
+ skillPoints.textContent = hero.skillPoints;
1068
+ armorLevel.textContent = armors[hero.armorLevel].name;
1069
+ weaponLevel.textContent = `${hero.hasGreatStaff ? 'Great Staff' : ''}${hero.hasGreatStaff && hero.hasGreatSword ? ' + ' : ''}${hero.hasGreatSword ? 'Great Sword' : ''}` || 'None';
1070
+ enemyHealth.style.width = `${(currentEnemy.hp / currentEnemy.maxHp) * 100}%`;
1071
+ enemyHp.textContent = currentEnemy.hp <= 0 ? 'DEFEATED' : `${currentEnemy.hp}/${currentEnemy.maxHp}`;
1072
+ enemyEmoji.textContent = `${currentEnemy.emoji} ${currentEnemy.name}`;
1073
+ }
1074
+
1075
+ function updateMission() {
1076
+ mission.textContent = `Enemies: ${enemyCount} | Decisions: ${decisionCount} | Exportable for RL! 📊`;
1077
+ }
1078
+
1079
+ function appendLog(message) {
1080
+ if (message) {
1081
+ combatLog.innerHTML += `<p>${message}</p>`;
1082
+ combatLog.scrollTop = combatLog.scrollHeight;
1083
+ }
1084
+ }
1085
+
1086
+ function openCraftMenu() {
1087
+ playClickSound();
1088
+ craftMenu.style.display = 'block';
1089
+ }
1090
+
1091
+ function closeCraftMenu() {
1092
+ playClickSound();
1093
+ craftMenu.style.display = 'none';
1094
+ }
1095
+
1096
+ // Initialize
1097
+ updateMission();
1098
+ updateUI();
1099
+ </script>
1100
+ </body>
1101
+ </html>