-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
2624 lines (2559 loc) · 291 KB
/
Copy pathindex.html
File metadata and controls
2624 lines (2559 loc) · 291 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
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no,viewport-fit=cover">
<meta name="theme-color" content="#0a0c10">
<title>Dungeon Quest 3D</title>
<meta name="description" content="Dungeon Quest 3D — a hand-crafted first-person action-RPG in a single HTML file. Three classes, a town hub, designed dungeon floors, a boss, procedural audio. Plays on any device.">
<style>
:root{
--fg:#e7ecf3; --muted:#98a0ad; --dim:#5d6573;
--bg:#0a0c10; --panel:#13171f; --panel2:#1b2029; --line:#2c333f;
--gold:#e8c24a; --gold2:#caa54a; --red:#d9433f; --blue:#3f7fd9; --green:#56b85b;
--hp:#cf3b38; --mp:#2f6fd0; --sta:#3fae6a; --xp:#caa54a;
--ui:"Segoe UI",system-ui,-apple-system,Roboto,Helvetica,Arial,sans-serif;
--mono:"Courier New",Courier,monospace;
}
*{box-sizing:border-box;-webkit-tap-highlight-color:transparent;}
html,body{margin:0;padding:0;height:100%;background:#000;color:var(--fg);font-family:var(--ui);overflow:hidden;-webkit-text-size-adjust:100%;-webkit-user-select:none;user-select:none;touch-action:none;overscroll-behavior:none;}
#game{position:fixed;inset:0;background:radial-gradient(circle at 50% 40%,#10141c,#05070a 80%);display:flex;align-items:center;justify-content:center;}
#stage{position:relative;width:100%;height:100%;max-width:1280px;max-height:800px;}
#cv{position:absolute;inset:0;width:100%;height:100%;display:block;image-rendering:auto;background:#05070a;}
/* ── retro/arcade text ── */
.arcade{font-family:var(--mono);text-transform:uppercase;letter-spacing:2px;font-weight:700;}
.glow{text-shadow:0 0 8px rgba(232,194,74,.6),0 2px 0 #000;}
/* ── generic buttons ── */
.btn{display:inline-flex;align-items:center;justify-content:center;gap:6px;background:linear-gradient(#222936,#161b24);color:var(--fg);border:1px solid var(--line);border-radius:9px;padding:11px 16px;font-size:14px;font-weight:700;cursor:pointer;font-family:var(--ui);transition:filter .08s,transform .04s;}
.btn:hover{filter:brightness(1.18);}
.btn:active{transform:translateY(1px);filter:brightness(.9);}
.btn.small{padding:7px 11px;font-size:12px;border-radius:8px;min-height:34px;}
.btn.primary{background:linear-gradient(#e8c24a,#b8902f);color:#1a1206;border-color:#e8c24a;text-shadow:none;}
.btn.danger{background:linear-gradient(#b5403c,#7e2724);border-color:#c0504c;color:#fff;}
.btn:disabled{opacity:.4;cursor:default;filter:none;}
.btn.primary{box-shadow:0 4px 16px rgba(232,194,74,.32),inset 0 1px 0 rgba(255,255,255,.25);}
/* graphical menu buttons: gold accent bar, depth, hover lift */
.menu-btns .btn{padding:13px 18px 13px 20px;font-size:15px;border-radius:12px;letter-spacing:.3px;justify-content:flex-start;box-shadow:0 2px 0 rgba(0,0,0,.4),inset 0 1px 0 rgba(255,255,255,.05);}
.menu-btns .btn:not(.primary):not(.danger){border-left:3px solid var(--gold);background:linear-gradient(100deg,#262d3b,#171c25 70%);}
.menu-btns .btn:hover{transform:translateY(-2px);filter:brightness(1.14);}
.menu-btns .btn:active{transform:translateY(0);}
.panel h2{position:relative;padding-bottom:8px;}
.panel h2::after{content:'';position:absolute;left:50%;bottom:0;transform:translateX(-50%);width:64px;height:2px;border-radius:2px;background:linear-gradient(90deg,transparent,var(--gold),transparent);}
/* ── overlay panels (menus/dialogue/shop) ── */
.overlay{position:absolute;inset:0;display:none;flex-direction:column;align-items:center;justify-content:center;z-index:40;padding:18px;text-align:center;}
.overlay.show{display:flex;animation:fade .25s ease;}
.scrim{position:absolute;inset:0;background:rgba(5,7,11,.82);backdrop-filter:blur(2px);}
.panel{position:relative;z-index:1;background:linear-gradient(#161b24,#0f131a);border:1px solid var(--line);border-radius:16px;box-shadow:0 18px 60px rgba(0,0,0,.6),inset 0 1px 0 rgba(255,255,255,.04);padding:22px;max-width:560px;width:100%;max-height:90%;overflow-y:auto;}
@keyframes fade{from{opacity:0}to{opacity:1}}
@keyframes pop{from{opacity:0;transform:scale(.94)}to{opacity:1;transform:scale(1)}}
/* ── title screen ── */
#menu{position:relative;padding-top:6px;}
#menu .crest{font-size:44px;line-height:1;margin-bottom:2px;filter:drop-shadow(0 2px 8px rgba(232,194,74,.55));}
#menu .title{font-size:clamp(32px,7.5vw,60px);color:var(--gold);margin:0;line-height:1;letter-spacing:3px;text-shadow:0 0 18px rgba(232,194,74,.55),0 3px 0 #000;animation:tglow 2.8s ease-in-out infinite;}
@keyframes tglow{0%,100%{text-shadow:0 0 14px rgba(232,194,74,.4),0 3px 0 #000;}50%{text-shadow:0 0 30px rgba(232,194,74,.85),0 3px 0 #000;}}
#menu .tag{color:#efe1b4;font-size:12.5px;margin:12px auto 20px;letter-spacing:1px;background:rgba(232,194,74,.1);border:1px solid rgba(232,194,74,.28);padding:5px 14px;border-radius:20px;width:fit-content;}
#menu::before{content:'';position:absolute;left:50%;top:18px;width:300px;height:170px;transform:translateX(-50%);background:radial-gradient(ellipse at center,rgba(232,194,74,.16),transparent 70%);pointer-events:none;}
.menu-btns{display:flex;flex-direction:column;gap:10px;width:min(340px,80vw);margin:0 auto;}
.creditline{color:var(--dim);font-size:11px;margin-top:18px;line-height:1.6;}
/* ── class select ── */
.classrow{display:flex;gap:12px;flex-wrap:wrap;justify-content:center;margin:10px 0 6px;}
.classcard{flex:1;min-width:150px;max-width:180px;background:var(--panel2);border:2px solid var(--line);border-radius:12px;padding:14px;cursor:pointer;transition:border-color .12s,transform .08s,filter .12s;}
.classcard:hover{filter:brightness(1.12);}
.classcard.sel{border-color:var(--gold);box-shadow:0 0 0 2px rgba(232,194,74,.25);transform:translateY(-3px);}
.classcard .ico{font-size:34px;margin-bottom:6px;}
.classcard h3{margin:0 0 4px;font-size:15px;}
.classcard p{margin:0;font-size:11px;color:var(--muted);line-height:1.5;}
/* ── in-game HUD ── */
#hud{position:absolute;inset:0;z-index:20;pointer-events:none;font-family:var(--ui);}
#hud .topleft{position:absolute;left:12px;top:10px;display:flex;flex-direction:column;gap:5px;width:min(260px,46vw);}
.bar{height:13px;border-radius:7px;background:rgba(8,10,14,.7);border:1px solid rgba(0,0,0,.5);overflow:hidden;position:relative;box-shadow:inset 0 1px 2px rgba(0,0,0,.6);}
.bar>i{display:block;height:100%;width:0;transition:width .12s linear;}
.bar>span{position:absolute;inset:0;display:flex;align-items:center;justify-content:space-between;padding:0 7px;font-size:9px;font-weight:800;font-family:var(--mono);letter-spacing:.5px;text-shadow:0 1px 1px #000;}
.bar.hp>i{background:linear-gradient(#e2514d,#a52a27);}
.bar.mp>i{background:linear-gradient(#4f8de0,#264f9c);}
.bar.sta>i{background:linear-gradient(#54c07a,#2c7a4a);}
.bar.xp{height:7px;} .bar.xp>i{background:linear-gradient(#e8c24a,#9c7a1e);}
#hud .meta{position:absolute;left:14px;top:0;transform:translateY(-2px);}
#hud .topright{position:absolute;right:10px;top:10px;display:flex;flex-direction:column;align-items:flex-end;gap:6px;}
#minimap{position:relative;width:120px;height:120px;border:1px solid var(--line);border-radius:8px;background:rgba(8,10,14,.66);box-shadow:0 4px 16px rgba(0,0,0,.4);}
#objective{position:absolute;left:50%;top:10px;transform:translateX(-50%);background:rgba(8,10,14,.6);border:1px solid var(--line);border-radius:20px;padding:5px 14px;font-size:11px;color:var(--gold);max-width:70vw;text-align:center;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}
#log{position:absolute;left:12px;bottom:96px;display:flex;flex-direction:column;gap:2px;font-family:var(--mono);font-size:11px;color:#cfd6df;text-shadow:0 1px 2px #000;max-width:60vw;}
#log div{opacity:.92;}
#interact{position:absolute;left:50%;bottom:140px;transform:translateX(-50%);background:rgba(232,194,74,.92);color:#1a1206;font-weight:800;font-size:12px;padding:6px 14px;border-radius:20px;display:none;font-family:var(--mono);letter-spacing:.5px;}
#interact.show{display:block;animation:pop .15s;}
/* ── on-screen controls (touch) ── */
#touch{position:absolute;inset:0;z-index:25;pointer-events:none;}
#stick{position:absolute;left:18px;bottom:18px;width:128px;height:128px;border-radius:50%;background:rgba(20,24,32,.42);border:1px solid var(--line);pointer-events:auto;touch-action:none;}
#stick .nub{position:absolute;left:50%;top:50%;width:54px;height:54px;margin:-27px;border-radius:50%;background:rgba(120,132,150,.6);border:1px solid rgba(255,255,255,.2);}
.actbtns{position:absolute;right:14px;bottom:18px;display:grid;grid-template-columns:64px 64px;grid-auto-rows:64px;gap:10px;pointer-events:none;}
.actbtns .ab{pointer-events:auto;touch-action:none;display:flex;align-items:center;justify-content:center;border-radius:50%;background:rgba(28,33,43,.7);border:1px solid var(--line);font-size:22px;font-weight:800;font-family:var(--mono);color:var(--fg);}
.actbtns .ab.big{width:64px;height:64px;} .actbtns .ab:active{filter:brightness(1.4);}
.actbtns .ab.atk{background:rgba(150,52,48,.7);} .actbtns .ab.cast{background:rgba(52,86,150,.7);} .actbtns .ab.abil{background:rgba(60,120,80,.7);}
.toprow{position:absolute;right:10px;bottom:160px;display:flex;gap:8px;pointer-events:auto;}
.toprow .ab{width:46px;height:46px;font-size:16px;}
/* hide touch controls on devices with a fine pointer (desktop) unless forced */
@media (pointer:fine){ #touch.autohide{display:none;} }
/* iPads/touchscreens (which may also report a fine pointer via trackpad) keep their controls */
html.touch #touch.autohide{display:block;}
.toprow{flex-wrap:wrap;justify-content:flex-end;max-width:64vw;}
/* bigger, comfier controls on tablet-sized touch screens (iPad) */
@media (min-width:760px){
html.touch #stick{width:156px;height:156px;left:26px;bottom:26px;}
html.touch #stick .nub{width:64px;height:64px;margin:-32px;}
html.touch .actbtns{grid-template-columns:80px 80px;grid-auto-rows:80px;gap:12px;right:24px;bottom:26px;}
html.touch .actbtns .ab.big{width:80px;height:80px;} html.touch .actbtns .ab{font-size:27px;}
html.touch .toprow{bottom:190px;right:18px;}
html.touch .toprow .ab{width:56px;height:56px;font-size:20px;}
}
/* ── dialogue ── */
#dialogue{position:absolute;left:0;right:0;bottom:0;z-index:45;display:none;padding:14px;}
#dialogue.show{display:block;animation:fade .2s;}
.dbox{max-width:640px;margin:0 auto;background:linear-gradient(#171c25,#0e121a);border:1px solid var(--line);border-radius:14px;padding:14px 16px;box-shadow:0 -8px 30px rgba(0,0,0,.5);}
.dbox .who{color:var(--gold);font-weight:800;font-size:13px;margin-bottom:4px;display:flex;align-items:center;gap:8px;}
.dbox .por{width:26px;height:26px;border-radius:6px;background:#2a3140;display:inline-flex;align-items:center;justify-content:center;font-size:16px;}
.dbox .say{font-size:14px;line-height:1.55;min-height:42px;}
.dbox .choices{display:flex;flex-direction:column;gap:6px;margin-top:10px;}
.dbox .choices .btn{justify-content:flex-start;text-align:left;}
.dbox .cont{color:var(--dim);font-size:11px;text-align:right;margin-top:6px;}
/* ── shop / inventory list ── */
.shoptabs{display:flex;gap:6px;justify-content:center;margin-bottom:10px;flex-wrap:wrap;}
.itemrow{display:flex;align-items:center;gap:10px;padding:9px 11px;border:1px solid var(--line);border-radius:9px;margin-bottom:7px;background:var(--panel2);text-align:left;}
.itemrow .ico{font-size:20px;width:26px;text-align:center;}
.itemrow .info{flex:1;min-width:0;}
.itemrow .nm{font-size:13px;font-weight:700;}
.itemrow .ds{font-size:10.5px;color:var(--muted);line-height:1.4;}
.tag{display:inline-block;font-size:10px;font-weight:800;padding:1px 7px;border-radius:10px;background:rgba(232,194,74,.16);color:var(--gold);}
.statgrid{display:grid;grid-template-columns:1fr 1fr;gap:6px 16px;font-size:13px;margin:8px 0;text-align:left;}
.statgrid b{color:var(--gold);}
/* damage vignette + flashes (full-screen fx) */
#fx{position:absolute;inset:0;z-index:30;pointer-events:none;}
#vig{position:absolute;inset:0;box-shadow:inset 0 0 120px rgba(150,0,0,0);transition:box-shadow .25s;}
#flash{position:absolute;inset:0;background:#fff;opacity:0;}
/* fullscreen minigames + back button */
#ovl.mgfull .scrim{background:rgba(5,7,11,.97);backdrop-filter:none;}
#ovl.mgfull .panel{max-width:none;width:100%;height:100%;max-height:100%;border-radius:0;border:0;box-shadow:none;padding:54px 10px 18px;justify-content:flex-start;background:linear-gradient(#0e121a,#06080c);}
#mgback{position:absolute;left:12px;top:11px;z-index:3;display:none;}
#ovl.mgfull #mgback{display:inline-flex;}
/* loading screen */
#loader{position:absolute;inset:0;z-index:60;background:radial-gradient(circle at 50% 38%,#11161f,#05070a 80%);display:flex;flex-direction:column;align-items:center;justify-content:center;transition:opacity .6s;}
#loader.hide{opacity:0;pointer-events:none;}
#loader .lt{font-size:clamp(26px,6.5vw,54px);color:var(--gold);text-align:center;}
#loader .by{color:#cfd6df;margin-top:12px;letter-spacing:3px;font-size:13px;}
#loader .lb{margin-top:24px;width:min(280px,68vw);height:8px;border-radius:6px;background:#1b2029;overflow:hidden;border:1px solid var(--line);}
#loader .lb>i{display:block;height:100%;width:0;background:linear-gradient(90deg,#e8c24a,#b8902f);animation:ld 1.5s ease forwards;}
@keyframes ld{from{width:0}to{width:100%}}
.hidden{display:none!important;}
.kbd{font-family:var(--mono);background:#222936;border:1px solid var(--line);border-radius:5px;padding:1px 6px;font-size:11px;}
</style>
</head>
<body>
<div id="game"><div id="stage">
<canvas id="cv"></canvas>
<div id="loader"><div class="lt arcade glow">DUNGEON QUEST 3D</div><div class="by arcade">A game by Aran</div><div class="lb"><i></i></div></div>
<div id="fx"><div id="vig"></div><div id="flash"></div></div>
<div id="hud" class="hidden">
<div class="meta arcade glow" id="meta"></div>
<div class="topleft" id="bars"></div>
<div class="topright"><canvas id="minimap" width="132" height="132"></canvas></div>
<div id="objective"></div>
<div id="log"></div>
<div id="interact"></div>
</div>
<div id="touch" class="hidden">
<div id="stick"><div class="nub"></div></div>
<div class="toprow" id="toprow"></div>
<div class="actbtns" id="actbtns"></div>
</div>
<div id="dialogue"><div class="dbox">
<div class="who"><span class="por" id="dpor">🙂</span><span id="dwho">NPC</span></div>
<div class="say" id="dsay"></div>
<div class="choices" id="dchoices"></div>
<div class="cont" id="dcont">▶ tap / Space</div>
</div></div>
<div class="overlay" id="ovl"><div class="scrim"></div><button class="btn small" id="mgback">← Back</button><div class="panel" id="ovlpanel"></div></div>
</div></div>
<script>
"use strict";
/* ════════════════════════════════════════════════════════════════════
DUNGEON QUEST 3D — core
════════════════════════════════════════════════════════════════════ */
var TS=1; // world is in tile units
var FOV=Math.PI/3; // 60°
var HALF_FOV=FOV/2;
var RAYDPP=1; // ray density handled by NR below
/* render buffer (internal); CSS scales it to the stage */
var BW=720, BH=450; // 16:10 — high internal resolution
var NR=BW; // one ray per buffer column (High); halved in Fast
var cv=document.getElementById('cv'), ctx=cv.getContext('2d',{alpha:false});
var mmc=document.getElementById('minimap'), mmx=mmc.getContext('2d');
var stageEl=document.getElementById('stage');
/* offscreen render target we composite into, then blit to the visible canvas */
var rb=document.createElement('canvas'); rb.width=BW; rb.height=BH;
var rbx=rb.getContext('2d',{alpha:false});
/* floor/ceiling cast into a half-res image then scaled up */
var FBW=BW>>1, FBH=BH>>1;
var fbuf=document.createElement('canvas'); fbuf.width=FBW; fbuf.height=FBH;
var fbx=fbuf.getContext('2d'); var fimg=fbx.createImageData(FBW,FBH);
function fitCanvas(){
var r=stageEl.getBoundingClientRect();
var dpr=Math.min(window.devicePixelRatio||1,2);
cv.width=Math.max(2,Math.round(r.width*dpr)); cv.height=Math.max(2,Math.round(r.height*dpr));
ctx.imageSmoothingEnabled=true;
}
window.addEventListener('resize',fitCanvas);
window.addEventListener('orientationchange',function(){setTimeout(fitCanvas,300);});
if(window.visualViewport)window.visualViewport.addEventListener('resize',fitCanvas);
/* ── math/util ── */
function clamp(v,a,b){return v<a?a:(v>b?b:v);}
function lerp(a,b,t){return a+(b-a)*t;}
function rnd(n){return Math.random()*n;}
function rndi(n){return Math.floor(Math.random()*n);}
function chance(p){return Math.random()<p;}
function pick(a){return a[rndi(a.length)];}
function dist2(ax,ay,bx,by){var dx=ax-bx,dy=ay-by;return dx*dx+dy*dy;}
function dist(ax,ay,bx,by){return Math.sqrt(dist2(ax,ay,bx,by));}
function norm(a){while(a<-Math.PI)a+=Math.PI*2;while(a>Math.PI)a-=Math.PI*2;return a;}
function angTo(ax,ay,bx,by){return Math.atan2(by-ay,bx-ax);}
function now(){return performance.now();}
/* ── global game state ── */
var G={
mode:'boot', // boot|menu|class|town|dungeon|dialogue|shop|inv|pause|over|win
prevMode:null,
level:null, // current level object {map,W,H,theme,...}
area:'town', // 'town' or 'dungeon'
floor:0, // dungeon floor index (0 = town gate target floor 1)
px:2.5,py:2.5,ang:0, // camera
vx:0,vy:0, // smoothed movement (for head-bob)
bob:0, shake:0, hitstop:0, flash:0, vignette:0,
entities:[], particles:[], projectiles:[], pickups:[], decals:[],
zbuf:new Float32Array(NR),
P:null, // player character
keys:{}, input:{f:0,b:0,l:0,r:0,sl:0,sr:0,turnL:0,turnR:0},
lookDX:0,
attackHeld:false, blockHeld:false,
atkCd:0, abilCd:0, castCd:0, swing:0, swingType:null, drawT:0, rollT:0, blockT:0,
invuln:0,
msgs:[], objective:'',
time:0, paused:false, started:false,
quality:1, // 1=High (floor casting), 0=Fast
muted:false, volume:0.7, musicOff:false,
save:null,
flags:{}, // world flags: doors opened, gates, quests, keys
fps:60, _facc:0, _fct:0
};
/* persistence */
var SAVE_KEY='dq3d_v2';
function loadSave(){try{var r=localStorage.getItem(SAVE_KEY);return r?JSON.parse(r):null;}catch(e){return null;}}
function writeSave(obj){try{localStorage.setItem(SAVE_KEY,JSON.stringify(obj));}catch(e){}}
function clearSave(){try{localStorage.removeItem(SAVE_KEY);}catch(e){}}
function loadBest(){try{return parseInt(localStorage.getItem('dq3d_best')||'0',10)||0;}catch(e){return 0;}}
function saveBest(s){try{if(s>loadBest())localStorage.setItem('dq3d_best',String(s));}catch(e){}}
/* tiny message log */
function logMsg(t,col){G.msgs.push({t:t,col:col||'#cfd6df',life:5});if(G.msgs.length>30)G.msgs.shift();renderLog();}
function renderLog(){
var el=document.getElementById('log'); if(!el)return; el.innerHTML='';
var v=G.msgs.slice(-4);
for(var i=0;i<v.length;i++){var d=document.createElement('div');d.textContent=v[i].t;d.style.color=v[i].col;d.style.opacity=String(0.55+0.45*(i+1)/v.length);el.appendChild(d);}
}
/* ════════════════════════════════════════════════════════════════════
AUDIO — fully procedural (Web Audio API). No files. Starts on first
user gesture. SFX + a lookahead-scheduled adaptive music sequencer.
════════════════════════════════════════════════════════════════════ */
var AC=null, MASTER=null, MUSGAIN=null, SFXGAIN=null, audioOK=false;
var MUSIC_VOL=0.34; // base music level — kept low so it underscores rather than nags
function m2f(m){return 440*Math.pow(2,(m-69)/12);}
function initAudio(){
if(AC) { if(AC.state==='suspended')AC.resume(); return; }
try{
var Ctx=window.AudioContext||window.webkitAudioContext; if(!Ctx)return;
AC=new Ctx();
MASTER=AC.createGain(); MASTER.gain.value=G.muted?0:G.volume; MASTER.connect(AC.destination);
MUSGAIN=AC.createGain(); MUSGAIN.gain.value=G.musicOff?0:MUSIC_VOL; MUSGAIN.connect(MASTER);
SFXGAIN=AC.createGain(); SFXGAIN.gain.value=0.95; SFXGAIN.connect(MASTER);
audioOK=true;
startMusicClock();startAmbientClock();
}catch(e){audioOK=false;}
}
function setVolume(v){G.volume=clamp(v,0,1);if(MASTER)MASTER.gain.value=G.muted?0:G.volume;}
function setMuted(m){G.muted=m;if(MASTER)MASTER.gain.value=m?0:G.volume;}
function setMusicMuted(m){G.musicOff=m;if(MUSGAIN)MUSGAIN.gain.value=m?0:MUSIC_VOL;}
/* a single voice: osc -> gain(env) -> dest */
function voice(freq,t0,dur,type,vol,dest,glide){
if(!audioOK)return;
var o=AC.createOscillator(), g=AC.createGain();
o.type=type||'square'; o.frequency.setValueAtTime(freq,t0);
if(glide)o.frequency.exponentialRampToValueAtTime(Math.max(1,glide),t0+dur);
g.gain.setValueAtTime(0.0001,t0);
g.gain.exponentialRampToValueAtTime(vol||0.2,t0+0.008);
g.gain.exponentialRampToValueAtTime(0.0001,t0+dur);
o.connect(g); g.connect(dest||SFXGAIN); o.start(t0); o.stop(t0+dur+0.02);
}
function noise(t0,dur,vol,lp,dest){
if(!audioOK)return;
var n=Math.floor(AC.sampleRate*dur), buf=AC.createBuffer(1,n,AC.sampleRate), d=buf.getChannelData(0);
for(var i=0;i<n;i++)d[i]=(Math.random()*2-1);
var s=AC.createBufferSource(); s.buffer=buf;
var f=AC.createBiquadFilter(); f.type='lowpass'; f.frequency.value=lp||3000;
var g=AC.createGain(); g.gain.setValueAtTime(vol||0.3,t0); g.gain.exponentialRampToValueAtTime(0.0001,t0+dur);
s.connect(f); f.connect(g); g.connect(dest||SFXGAIN); s.start(t0); s.stop(t0+dur+0.02);
}
var sfx={
step:function(type){if(!audioOK)return;var t=AC.currentTime;if(type==='hard')noise(t,0.05,0.12,2600);else if(type==='sand')noise(t,0.09,0.07,500);else noise(t,0.07,0.09,900);},
swing:function(){if(!audioOK)return;var t=AC.currentTime;noise(t,0.16,0.18,1600);voice(420,t,0.14,'sawtooth',0.05,SFXGAIN,160);},
hit:function(){if(!audioOK)return;var t=AC.currentTime;noise(t,0.12,0.34,2600);voice(150,t,0.12,'square',0.22,SFXGAIN,60);},
crit:function(){if(!audioOK)return;var t=AC.currentTime;noise(t,0.16,0.4,4000);voice(220,t,0.16,'square',0.25,SFXGAIN,70);voice(660,t+0.02,0.14,'triangle',0.18,SFXGAIN);},
hurt:function(){if(!audioOK)return;var t=AC.currentTime;voice(300,t,0.22,'sawtooth',0.28,SFXGAIN,90);noise(t,0.2,0.2,1400);},
die:function(){if(!audioOK)return;var t=AC.currentTime;voice(330,t,0.3,'square',0.2,SFXGAIN,70);voice(220,t+0.06,0.3,'square',0.16,SFXGAIN,55);noise(t,0.3,0.18,1200);},
bow:function(){if(!audioOK)return;var t=AC.currentTime;voice(700,t,0.18,'triangle',0.12,SFXGAIN,1400);},
arrow:function(){if(!audioOK)return;var t=AC.currentTime;noise(t,0.12,0.16,3000);voice(900,t,0.1,'triangle',0.1,SFXGAIN,300);},
thunk:function(){if(!audioOK)return;var t=AC.currentTime;noise(t,0.1,0.3,1800);voice(180,t,0.1,'square',0.2,SFXGAIN,90);},
cast:function(){if(!audioOK)return;var t=AC.currentTime;voice(300,t,0.24,'sine',0.18,SFXGAIN,900);voice(450,t+0.02,0.22,'triangle',0.12,SFXGAIN,1300);},
frost:function(){if(!audioOK)return;var t=AC.currentTime;voice(1200,t,0.3,'sine',0.14,SFXGAIN,500);noise(t,0.3,0.08,5000);},
heal:function(){if(!audioOK)return;var t=AC.currentTime;[523,659,784,1046].forEach(function(f,i){voice(f,t+i*0.06,0.3,'sine',0.14,SFXGAIN);});},
boom:function(){if(!audioOK)return;var t=AC.currentTime;noise(t,0.4,0.5,900);voice(90,t,0.4,'square',0.32,SFXGAIN,40);voice(160,t,0.3,'sawtooth',0.16,SFXGAIN,50);},
gold:function(){if(!audioOK)return;var t=AC.currentTime;voice(880,t,0.1,'square',0.12,SFXGAIN);voice(1320,t+0.05,0.12,'square',0.12,SFXGAIN);},
potion:function(){if(!audioOK)return;var t=AC.currentTime;voice(500,t,0.18,'sine',0.16,SFXGAIN,1100);},
door:function(){if(!audioOK)return;var t=AC.currentTime;noise(t,0.5,0.18,500);voice(80,t,0.5,'sawtooth',0.12,SFXGAIN,120);},
key:function(){if(!audioOK)return;var t=AC.currentTime;voice(1200,t,0.1,'triangle',0.14,SFXGAIN);voice(1600,t+0.06,0.14,'triangle',0.12,SFXGAIN);},
levelup:function(){if(!audioOK)return;var t=AC.currentTime;[392,523,659,784,1046].forEach(function(f,i){voice(f,t+i*0.09,0.4,'triangle',0.2,SFXGAIN);});},
quest:function(){if(!audioOK)return;var t=AC.currentTime;[523,784,1046].forEach(function(f,i){voice(f,t+i*0.08,0.3,'sine',0.16,SFXGAIN);});},
blip:function(){if(!audioOK)return;var t=AC.currentTime;voice(720,t,0.06,'square',0.1,SFXGAIN);},
deny:function(){if(!audioOK)return;var t=AC.currentTime;voice(200,t,0.14,'square',0.14,SFXGAIN,120);},
roar:function(){if(!audioOK)return;var t=AC.currentTime;voice(70,t,0.9,'sawtooth',0.4,SFXGAIN,50);voice(110,t,0.8,'square',0.2,SFXGAIN,60);noise(t,0.9,0.16,700);},
win:function(){if(!audioOK)return;var t=AC.currentTime;[523,659,784,1046,1318].forEach(function(f,i){voice(f,t+i*0.12,0.5,'triangle',0.22,SFXGAIN);});},
chest:function(){if(!audioOK)return;var t=AC.currentTime;noise(t,0.18,0.16,700);[660,880,1100].forEach(function(f,i){voice(f,t+0.08+i*0.07,0.25,'triangle',0.16,SFXGAIN);});},
buy:function(){if(!audioOK)return;var t=AC.currentTime;voice(880,t,0.09,'square',0.12,SFXGAIN);voice(1320,t+0.06,0.12,'square',0.12,SFXGAIN);},
splash:function(){if(!audioOK)return;var t=AC.currentTime;noise(t,0.32,0.26,1400);voice(300,t,0.2,'sine',0.1,SFXGAIN,900);},
fish:function(){if(!audioOK)return;var t=AC.currentTime;noise(t,0.2,0.2,1200);[400,520,660].forEach(function(f,i){voice(f,t+i*0.05,0.18,'triangle',0.14,SFXGAIN);});},
bird:function(){if(!audioOK)return;var t=AC.currentTime;voice(2200,t,0.06,'triangle',0.05,SFXGAIN,2600);voice(2600,t+0.08,0.05,'triangle',0.045,SFXGAIN,2000);},
gull:function(){if(!audioOK)return;var t=AC.currentTime;voice(1400,t,0.12,'sawtooth',0.05,SFXGAIN,900);voice(1100,t+0.14,0.1,'sawtooth',0.04,SFXGAIN,800);},
bug:function(){if(!audioOK)return;var t=AC.currentTime;voice(3200,t,0.18,'square',0.02,SFXGAIN,3000);},
drip:function(){if(!audioOK)return;var t=AC.currentTime;voice(1600,t,0.18,'sine',0.07,SFXGAIN,400);},
crackle:function(){if(!audioOK)return;var t=AC.currentTime;noise(t,0.04,0.05,3000);if(chance(0.5))noise(t+0.06,0.03,0.04,2200);},
thunder:function(){if(!audioOK)return;var t=AC.currentTime;noise(t,0.06,0.5,9000);noise(t+0.02,1.5,0.34,420);noise(t+0.55,0.9,0.2,240);voice(46,t,1.3,'sine',0.13,SFXGAIN);},
jump:function(){if(!audioOK)return;var t=AC.currentTime;noise(t,0.16,0.05,1800);voice(360,t,0.16,'sine',0.08,SFXGAIN,760);},
land:function(){if(!audioOK)return;var t=AC.currentTime;noise(t,0.09,0.16,640);voice(120,t,0.08,'square',0.1,SFXGAIN,70);},
wave:function(){if(!audioOK)return;var t=AC.currentTime;noise(t,0.7,0.1,500);noise(t+0.32,0.5,0.07,340);},
chime:function(){if(!audioOK)return;var t=AC.currentTime;[659,988,1319].forEach(function(f,i){voice(f,t+i*0.07,0.42,'sine',0.1,SFXGAIN);});},
frog:function(){if(!audioOK)return;var t=AC.currentTime;voice(210,t,0.12,'square',0.05,SFXGAIN,170);voice(180,t+0.15,0.1,'square',0.045,SFXGAIN,150);},
owl:function(){if(!audioOK)return;var t=AC.currentTime;voice(420,t,0.2,'sine',0.06,SFXGAIN,360);voice(380,t+0.24,0.16,'sine',0.05,SFXGAIN,340);}
};
var _ambTimer=null,_ambArea='';
function setAmbientArea(a){_ambArea=a;}
function startAmbientClock(){
if(_ambTimer)return;
_ambTimer=setInterval(function(){
if(!audioOK||G.muted||document.hidden)return;
var reg=(typeof regionAt==='function'&&G.level)?regionAt(G.px,G.py):'';
if(_ambArea==='cave'){if(chance(0.5))sfx.drip();}
else if(_ambArea==='interior'){if(chance(0.4))sfx.crackle();}
else if(reg==='jungle'){if(chance(0.6))sfx.bug();else if(chance(0.3))sfx.bird();else if(chance(0.4))sfx.frog();}
else if(reg==='beach'||reg==='water'){if(chance(0.5))sfx.gull();else if(chance(0.4))sfx.wave();else sfx.splash();}
else {var night=(G.tod<0.24||G.tod>0.78);if(night){if(chance(0.5))sfx.owl();else if(chance(0.4))sfx.frog();}else{if(chance(0.5))sfx.bird();else if(chance(0.25))sfx.frog();}}
},1700);
}
/* ── music: lookahead scheduler ── */
var MUS={track:'none', bpm:96, step:0, next:0, timer:null};
var TRACKS={
menu: {bpm:76, root:57, scale:[0,3,5,7,10], bass:[0,0,5,5,3,3,-2,-2], lead:[12,15,14,12,10,12,7,10,12,15,17,15,14,12,10,7], pad:true, drums:false},
town: {bpm:88, root:60, scale:[0,2,4,5,7,9,11], bass:[0,0,7,7,5,5,4,4], lead:[12,14,16,14,12,11,9,7,9,11,12,14,16,17,16,14], pad:true, drums:false},
dungeon:{bpm:80, root:50, scale:[0,2,3,5,7,8,10], bass:[0,0,0,3,0,0,-2,-2], lead:[0,3,7,10,7,3,0,-2,0,3,5,7,8,7,5,3], pad:true, drums:true},
boss: {bpm:132,root:45, scale:[0,2,3,5,7,8,10], bass:[0,0,3,3,5,5,3,1], lead:[12,15,12,10,12,8,10,12,15,17,15,12,10,8,7,5], pad:false, drums:true}
};
function setMusic(name){
if(MUS.track===name)return;
MUS.track=name; MUS.step=0;
if(audioOK){MUS.bpm=(TRACKS[name]&&TRACKS[name].bpm)||96; MUS.next=AC.currentTime+0.05;}
}
function startMusicClock(){
if(MUS.timer)return;
MUS.timer=setInterval(function(){
if(!audioOK||MUS.track==='none'||MUS.track==='off')return;
var tk=TRACKS[MUS.track]; if(!tk)return;
var spb=60/MUS.bpm/2; // eighth-note steps
var ahead=AC.currentTime+0.12;
while(MUS.next<ahead){
var t=MUS.next, s=MUS.step%16, bar=Math.floor(MUS.step/2)%8;
// bass on every quarter
if(s%2===0){voice(m2f(tk.root+tk.bass[bar]-12),t,spb*1.9,'triangle',0.2,MUSGAIN);}
// lead: one flowing note per quarter, soft triangle, 16-note phrase (repeats only every 4 bars)
if(tk.lead && s%2===0){var ln=tk.lead[Math.floor(MUS.step/2)%tk.lead.length];voice(m2f(tk.root+ln),t,spb*1.7,'triangle',0.05,MUSGAIN);}
// pad chord at bar starts
if(tk.pad && s===0){[0,4,7].forEach(function(iv){voice(m2f(tk.root+iv),t,spb*7,'sine',0.05,MUSGAIN);});}
// drums — softened so they pulse rather than thump
if(tk.drums){ if(s%4===0)noise(t,0.1,0.12,250); if(s%4===2)noise(t,0.04,0.07,6000); }
MUS.next+=spb; MUS.step++;
}
},25);
}
/* ════════════════════════════════════════════════════════════════════
ASSETS — procedural textures (walls/floors/ceilings, per theme) and
creature / NPC / prop sprites. Everything drawn to offscreen canvases.
════════════════════════════════════════════════════════════════════ */
var TEX={}, FLR={}, CEL={}, SPR={};
var THEMES={
town: {wall:['#b7a07c','#8a7350','#d3c19a'], alt:['#8c7c63','#5f5340','#a99a7e'], floor:'#7a6b50', floorB:'#67583f', ceil:'#3a4658', fog:'#cdd6e2'},
crypt: {wall:['#7d828c','#565b66','#9aa0ab'], alt:['#6a6f79','#474b54','#888d97'], floor:'#4a4f59', floorB:'#3a3f48', ceil:'#22262e', fog:'#c2c9d4'},
catacomb:{wall:['#8a7a5e','#5e5240','#a89madd'.slice(0,7)], alt:['#6e5f4a','#4a4032','#8a795f'], floor:'#534632', floorB:'#42381f'.slice(0,7), ceil:'#241d14', fog:'#cabfa8'},
frost: {wall:['#7fa0b6','#557184','#aacae0'], alt:['#6c8ba0','#46606f','#9bbed4'], floor:'#5d7886','floorB':'#46606e', ceil:'#1f2a33', fog:'#d7e6f2'},
inferno:{wall:['#9a5740','#5e2f1f','#c98a5f'], alt:['#7d4330','#481f12','#a36a45'], floor:'#5a2d1f','floorB':'#3d1c12', ceil:'#2a140c', fog:'#e0a070'},
lich: {wall:['#6f56a0','#3f2d62','#a586d8'], alt:['#5a4486','#33245a','#8a6dc0'], floor:'#3a2456','floorB':'#281640', ceil:'#1d1030', fog:'#caa8e8'},
beach: {wall:['#cdb98a','#a8946a','#e6d6ad'], alt:['#9a9488','#6f6a60','#b8b2a4'], floor:'#dcc88f','floorB':'#c8b074', ceil:'#7fb0e0', fog:'#cfe6f5', outdoor:true, sky:['#3f8fdc','#bfe2f5'], sea:'#3f7fb0'},
forest: {wall:['#3f6a3a','#2c4a2a','#5f8a55'], alt:['#6a4a2a','#48321c','#8a6a44'], floor:'#4f7a3f','floorB':'#3f6432', ceil:'#9ec8e0', fog:'#cfe6cf', outdoor:true, sky:['#6fa8dc','#d2ecf2']},
city: {wall:['#9a9088','#6f675f','#bcb2a6'], alt:['#7a7068','#544c44','#9a9088'], floor:'#8f8a82','floorB':'#736f69', ceil:'#7fb0e0', fog:'#cdd6e6', outdoor:true, sky:['#5fa0dc','#cfe2f2']},
jungle: {wall:['#2f5a2f','#1f3d1f','#4a7a44'], alt:['#5a4326','#3a2c18','#7a5a36'], floor:'#415a2f','floorB':'#33491f', ceil:'#9ec8b0', fog:'#bcd6a8', outdoor:true, sky:['#7fbf9a','#d2ecd6']},
field: {wall:['#4a7a3f','#386030','#5f9a52'], alt:['#6a4a2a','#48321c','#8a6a44'], floor:'#5f9a47','floorB':'#4f8a3a', ceil:'#9ec8e0', fog:'#d2ecc8', outdoor:true, sky:['#6fa8dc','#d6ecf4']},
mountain:{wall:['#8a8278','#5e574e','#a8a096'], alt:['#7a7268','#544d44','#9a9288'], floor:'#7c756a','floorB':'#5e584e', ceil:'#9ec8e0', fog:'#c8cdd6', outdoor:true, sky:['#6a86a8','#cdd8e6']},
cave: {wall:['#6a6258','#46403a','#8a8076'], alt:['#5a534a','#3a342e','#7a7066'], floor:'#3e3832','floorB':'#2e2a24', ceil:'#181512', fog:'#8a847a'},
interior:{wall:['#bba07a','#937152','#dac6a0'], alt:['#caa86a','#9a7a44','#e0c488'], floor:'#9c7c50','floorB':'#7e6238', ceil:'#6e5a40', fog:'#d2bb96'}
};
/* fix any sloppy hex from the table above */
(function(){for(var k in THEMES){var t=THEMES[k];['wall','alt'].forEach(function(a){t[a]=t[a].map(function(h){h=String(h).slice(0,7);return /^#[0-9a-f]{6}$/i.test(h)?h:'#777777';});});}})();
function mkc(w,h){var c=document.createElement('canvas');c.width=w;c.height=h;return c;}
function noisePx(x,n,w,h,amt){for(var i=0;i<n;i++){var v=(Math.random()*2-1)*amt|0;x.fillStyle='rgba('+(v>0?255:0)+','+(v>0?255:0)+','+(v>0?255:0)+','+(Math.abs(v)/255*0.5).toFixed(2)+')';x.fillRect(rndi(w),rndi(h),1,1);}}
function texBrick(pal){
var c=mkc(64,64),x=c.getContext('2d');
x.fillStyle=pal[1];x.fillRect(0,0,64,64);
var bh=16;
for(var row=0;row<4;row++){
var off=(row%2)*16;
for(var bx=-16;bx<64;bx+=32){
var px2=bx+off+1, py=row*bh+1;
var shade=0.85+Math.random()*0.3;
x.fillStyle=shadeHex(pal[0],shade);x.fillRect(px2,py,30,bh-2);
x.fillStyle=shadeHex(pal[2],1);x.fillRect(px2,py,30,2); // top highlight
x.fillStyle=shadeHex(pal[1],0.7);x.fillRect(px2,py+bh-3,30,2); // bottom shadow
}
}
noisePx(x,420,64,64,120);
return c;
}
function texDoor(){
var c=mkc(64,64),x=c.getContext('2d');
x.fillStyle='#5a3f22';x.fillRect(0,0,64,64);
for(var i=0;i<4;i++){x.fillStyle=i%2?'#6b4b2a':'#5a3f22';x.fillRect(i*16,0,15,64);x.fillStyle='#402c18';x.fillRect(i*16+15,0,1,64);}
x.fillStyle='#2c2018';x.fillRect(0,8,64,5);x.fillRect(0,51,64,5); // iron bands
x.fillStyle='#9a9aa2';x.fillRect(44,30,6,6); // handle
noisePx(x,200,64,64,80);
return c;
}
function texLocked(){
var c=texDoor(),x=c.getContext('2d');
x.fillStyle='#d9b94a';x.fillRect(26,26,12,16);x.fillStyle='#1a1206';x.fillRect(30,32,4,5);x.fillRect(31,34,2,5);
return c;
}
function texGate(){
var c=mkc(64,64),x=c.getContext('2d');
x.fillStyle='rgba(10,12,16,0.85)';x.fillRect(0,0,64,64);
x.fillStyle='#3a4350';for(var i=4;i<64;i+=10){x.fillRect(i,0,5,64);}
for(var j=4;j<64;j+=20){x.fillStyle='#4a5563';x.fillRect(0,j,64,4);}
return c;
}
function texBanner(pal){
var c=texBrick(pal),x=c.getContext('2d');
x.fillStyle='#7a2230';x.fillRect(22,4,20,46);
x.fillStyle='#561622';x.fillRect(22,4,20,3);
x.beginPath();x.moveTo(22,50);x.lineTo(32,58);x.lineTo(42,50);x.closePath();x.fillStyle='#7a2230';x.fill();
x.fillStyle='#e8c24a';x.beginPath();x.arc(32,24,7,0,7);x.fill();x.fillStyle='#7a2230';x.beginPath();x.arc(32,24,3.4,0,7);x.fill();
return c;
}
function texFloor(pal){
var c=mkc(64,64),x=c.getContext('2d');
x.fillStyle=pal.floor;x.fillRect(0,0,64,64);
/* organic mottled ground (seamless-tiling soft patches — no chessboard) */
for(var i=0;i<20;i++){
var px=Math.random()*64,py=Math.random()*64,r=5+Math.random()*9;
x.globalAlpha=0.16;
x.fillStyle=(Math.random()<0.5)?shadeHex(pal.floor,1.16):shadeHex(pal.floorB,1.04);
for(var ox=-64;ox<=64;ox+=64)for(var oy=-64;oy<=64;oy+=64){x.beginPath();x.arc(px+ox,py+oy,r,0,7);x.fill();}
}
x.globalAlpha=1;
for(i=0;i<55;i++){x.fillStyle=shadeHex(Math.random()<0.5?pal.floor:pal.floorB,0.7+Math.random()*0.5);x.fillRect((Math.random()*64)|0,(Math.random()*64)|0,1,1);}
noisePx(x,500,64,64,70);
return c;
}
function texCeil(pal){
var c=mkc(64,64),x=c.getContext('2d');
x.fillStyle=pal.ceil;x.fillRect(0,0,64,64);
x.fillStyle=shadeHex(pal.ceil,1.4);for(var i=0;i<64;i+=16)x.fillRect(0,i,64,1),x.fillRect(i,0,1,64);
noisePx(x,300,64,64,60);
return c;
}
function shadeHex(hex,f){
hex=hex.replace('#','');if(hex.length<6)hex='777777';
var r=clamp((parseInt(hex.substr(0,2),16)*f)|0,0,255),g=clamp((parseInt(hex.substr(2,2),16)*f)|0,0,255),b=clamp((parseInt(hex.substr(4,2),16)*f)|0,0,255);
return 'rgb('+r+','+g+','+b+')';
}
/* pre-extract pixel data of a 64x64 canvas for fast floor sampling */
function pixData(c){var d=c.getContext('2d').getImageData(0,0,64,64).data;return d;}
/* ── sprites ── */
function rect(x,a,b,w,h,c){x.fillStyle=c;x.fillRect(a,b,w,h);}
function circ(x,a,b,r,c){x.fillStyle=c;x.beginPath();x.arc(a,b,r,0,7);x.fill();}
function humanoid(opt){
var c=mkc(48,72),x=c.getContext('2d'); var o=opt||{};
var sk=o.skin||'#d8a878', cl=o.cloth||'#3a5a8a', cl2=o.cloth2||cl, hr=o.hair||'#3a2a18';
rect(x,16,60,6,12,'#222'); rect(x,26,60,6,12,'#222'); // legs/boots
rect(x,14,30,20,32,cl); // torso
rect(x,14,30,20,6,cl2);
rect(x,10,32,5,22,sk); rect(x,33,32,5,22,sk); // arms
circ(x,24,20,11,sk); // head
rect(x,13,10,22,8,hr); // hair
rect(x,19,20,3,3,'#1a1a22'); rect(x,26,20,3,3,'#1a1a22'); // eyes
if(o.helm){rect(x,12,8,24,9,o.helm);rect(x,12,8,24,3,shadeHex(o.helm,1.3));}
if(o.cape){x.fillStyle=o.cape;x.beginPath();x.moveTo(14,30);x.lineTo(34,30);x.lineTo(30,66);x.lineTo(18,66);x.closePath();x.fill();}
if(o.prop==='hammer'){rect(x,36,26,4,24,'#5a3f22');rect(x,32,22,14,9,'#888f99');}
if(o.prop==='staff'){rect(x,36,16,3,40,'#5a3f22');circ(x,37,16,5,o.gem||'#6fd0e0');}
if(o.prop==='sword'){rect(x,37,24,3,26,'#cfd4dc');rect(x,33,46,11,4,'#caa54a');}
if(o.prop==='book'){rect(x,8,40,12,9,'#7a2230');rect(x,9,41,10,7,'#e8dcc0');}
return c;
}
function buildAssets(){
for(var k in THEMES){
var p=THEMES[k];
TEX[k]={wall:texBrick(p.wall), alt:texBrick(p.alt), door:texDoor(), locked:texLocked(), gate:texGate(), banner:texBanner(p.wall)};
FLR[k]=pixData(texFloor(p)); CEL[k]=pixData(texCeil(p));
}
// creatures
var rat=mkc(48,72),rx=rat.getContext('2d'); rect(rx,12,46,26,14,'#7a6048'); circ(rx,40,50,8,'#7a6048'); rect(rx,8,52,8,4,'#caa'); rect(rx,38,40,5,5,'#5a4636'); rect(rx,38,40,3,3,'#d44'); rect(rx,12,40,5,8,'#5a4636'); SPR.rat={body:rat,h:0.5};
var slime=mkc(48,72),sx=slime.getContext('2d'); sx.fillStyle='#54ad57'; sx.beginPath(); sx.moveTo(6,66); sx.quadraticCurveTo(2,30,24,26); sx.quadraticCurveTo(46,30,42,66); sx.closePath(); sx.fill(); rect(sx,16,40,6,9,'#16321a'); rect(sx,28,40,6,9,'#16321a'); sx.fillStyle='rgba(255,255,255,.3)'; sx.beginPath();sx.arc(18,38,4,0,7);sx.fill(); SPR.slime={body:slime,h:0.62};
var bat=mkc(48,72),bx=bat.getContext('2d'); circ(bx,24,34,9,'#6a4f8a'); bx.fillStyle='#6a4f8a'; bx.beginPath();bx.moveTo(24,34);bx.lineTo(2,22);bx.lineTo(8,40);bx.closePath();bx.fill(); bx.beginPath();bx.moveTo(24,34);bx.lineTo(46,22);bx.lineTo(40,40);bx.closePath();bx.fill(); rect(bx,18,30,4,4,'#f55'); rect(bx,26,30,4,4,'#f55'); SPR.bat={body:bat,h:0.5,fly:true};
SPR.skel=humanoid({skin:'#e6e9ee',cloth:'#9aa0aa',cloth2:'#7d828c',hair:'#cfd4dc',helm:'#b8bcc4',prop:'sword'});SPR.skel={body:SPR.skel,h:0.78};
SPR.wraith=(function(){var c=mkc(48,72),x=c.getContext('2d');var grd=x.createLinearGradient(0,8,0,68);grd.addColorStop(0,'#aab6e0');grd.addColorStop(1,'rgba(120,140,200,0)');x.fillStyle=grd;x.beginPath();x.moveTo(24,8);x.quadraticCurveTo(46,18,40,68);x.lineTo(8,68);x.quadraticCurveTo(2,18,24,8);x.closePath();x.fill();rect(x,17,28,5,7,'#fff');rect(x,27,28,5,7,'#fff');return {body:c,h:0.82,fly:true};})();
SPR.ogre=humanoid({skin:'#86965f',cloth:'#5b4a2e',cloth2:'#3f3320',hair:'#2e2716',prop:'hammer'});SPR.ogre={body:SPR.ogre,h:1.0};
// boss lich
SPR.lich=(function(){var c=mkc(48,72),x=c.getContext('2d');x.fillStyle='#2a1d3e';x.beginPath();x.moveTo(24,12);x.quadraticCurveTo(48,22,40,70);x.lineTo(8,70);x.quadraticCurveTo(0,22,24,12);x.closePath();x.fill();circ(x,24,16,11,'#d8d2e6');rect(x,18,15,4,4,'#b06bff');rect(x,26,15,4,4,'#b06bff');x.fillStyle='#caa54a';x.beginPath();x.moveTo(14,8);x.lineTo(18,16);x.lineTo(24,9);x.lineTo(30,16);x.lineTo(34,8);x.lineTo(31,18);x.lineTo(17,18);x.closePath();x.fill();rect(x,36,18,3,42,'#3a2a4a');circ(x,37,18,5,'#b06bff');return {body:c,h:1.18};})();
// props
SPR.chest=(function(){var c=mkc(48,48),x=c.getContext('2d');rect(x,8,18,32,24,'#7a5326');rect(x,8,16,32,8,'#5a3a18');rect(x,8,16,32,3,'#caa54a');rect(x,22,26,4,7,'#caa54a');return {body:c,h:0.5};})();
SPR.chestO=(function(){var c=mkc(48,48),x=c.getContext('2d');rect(x,8,24,32,18,'#5a3a18');rect(x,8,10,32,9,'#4a3018');circ(x,24,30,6,'#e8c24a');return {body:c,h:0.5};})();
SPR.brazier=(function(){var c=mkc(48,72),x=c.getContext('2d');rect(x,20,44,8,22,'#3a3a40');rect(x,14,38,20,8,'#4a4a52');x.fillStyle='#ff9a3a';x.beginPath();x.moveTo(16,40);x.quadraticCurveTo(24,12,32,40);x.closePath();x.fill();x.fillStyle='#ffe08a';x.beginPath();x.moveTo(20,40);x.quadraticCurveTo(24,24,28,40);x.closePath();x.fill();return {body:c,h:1.0,light:true};})();
SPR.pillar=(function(){var c=mkc(48,72),x=c.getContext('2d');rect(x,14,4,20,64,'#9aa0aa');rect(x,12,2,24,6,'#b0b6c0');rect(x,12,64,24,6,'#b0b6c0');rect(x,18,8,3,56,'#7d828c');return {body:c,h:1.0,solid:true};})();
SPR.gold=(function(){var c=mkc(48,48),x=c.getContext('2d');circ(x,20,34,7,'#e8c24a');circ(x,30,36,6,'#caa54a');circ(x,25,28,6,'#f0d060');return {body:c,h:0.34};})();
SPR.hp=(function(){var c=mkc(48,48),x=c.getContext('2d');rect(x,18,14,12,26,'#c0392b');rect(x,20,12,8,4,'#7a241b');rect(x,23,18,2,14,'#fff');rect(x,18,23,12,2,'#fff');return {body:c,h:0.42};})();
SPR.mp=(function(){var c=mkc(48,48),x=c.getContext('2d');rect(x,18,14,12,26,'#2d6cc0');rect(x,20,12,8,4,'#1a3f7a');circ(x,24,28,4,'#bfe0ff');return {body:c,h:0.42};})();
SPR.key=(function(){var c=mkc(48,48),x=c.getContext('2d');circ(x,18,26,7,'#e8c24a');circ(x,18,26,3,'#1a1206');rect(x,24,23,16,5,'#e8c24a');rect(x,36,28,4,6,'#e8c24a');rect(x,30,28,3,6,'#e8c24a');return {body:c,h:0.4};})();
SPR.stairs=(function(){var c=mkc(48,64),x=c.getContext('2d');var n=6;for(var i=0;i<n;i++){var w=42-i*5,sx=24-w/2,sy=56-i*9;rect(x,sx,sy,w,9,shadeHex('#8a93a3',1-i*0.05));rect(x,sx,sy,w,2,shadeHex('#b6bdc9',1.12));rect(x,sx,sy+7,w,2,shadeHex('#565d68',0.85));}x.fillStyle='#e8c24a';x.font='bold 13px monospace';x.textAlign='center';x.fillText('▲',24,12);return {body:c,h:1.0};})();
SPR.exit=(function(){var c=mkc(48,72),x=c.getContext('2d');rect(x,10,8,28,60,'#2a2e34');x.fillStyle='#bfe0ff';x.fillRect(15,16,18,46);x.fillStyle='#7fa0d0';x.fillRect(15,16,18,6);return {body:c,h:1.0};})();
SPR.fountain=(function(){var c=mkc(64,72),x=c.getContext('2d');rect(x,8,48,48,18,'#7d828c');x.fillStyle='#4f8de0';x.fillRect(12,50,40,10);rect(x,28,20,8,30,'#9aa0aa');circ(x,32,18,10,'#9aa0aa');x.fillStyle='#bfe0ff';circ(x,32,18,5,'#bfe0ff');return {body:c,h:1.1,solid:true};})();
// NPCs
SPR.npc_inn=humanoid({skin:'#e0b48a',cloth:'#6a4a2a',cloth2:'#8a6a3a',hair:'#5a3a18'});SPR.npc_inn={body:SPR.npc_inn,h:0.86,npc:true};
SPR.npc_smith=humanoid({skin:'#caa078',cloth:'#4a4a52',cloth2:'#2e2e34',hair:'#1a1a1a',prop:'hammer'});SPR.npc_smith={body:SPR.npc_smith,h:0.9,npc:true};
SPR.npc_mage=humanoid({skin:'#e6c8a0',cloth:'#3a2a6a',cloth2:'#5a3aa0',hair:'#d8d8e0',prop:'staff',gem:'#6fd0e0'});SPR.npc_mage={body:SPR.npc_mage,h:0.9,npc:true};
SPR.npc_cap=humanoid({skin:'#d8a878',cloth:'#7a2230',cloth2:'#561622',hair:'#3a2a18',helm:'#caa54a',cape:'#7a2230'});SPR.npc_cap={body:SPR.npc_cap,h:0.92,npc:true};
SPR.npc_vil=humanoid({skin:'#e0b48a',cloth:'#4a6a4a',cloth2:'#3a523a',hair:'#6a4a2a'});SPR.npc_vil={body:SPR.npc_vil,h:0.84,npc:true};
SPR.npc_gate=humanoid({skin:'#c8a070',cloth:'#3a3a44',cloth2:'#2a2a32',hair:'#2a2a2a',helm:'#8a8f99',prop:'sword'});SPR.npc_gate={body:SPR.npc_gate,h:0.9,npc:true};
// crab enemy
SPR.crab=(function(){var c=mkc(48,48),x=c.getContext('2d');x.fillStyle='#c85a3a';x.beginPath();x.ellipse(24,30,16,10,0,0,7);x.fill();circ(x,16,18,4,'#c85a3a');circ(x,32,18,4,'#c85a3a');rect(x,15,14,2,5,'#c85a3a');rect(x,31,14,2,5,'#c85a3a');rect(x,15,12,3,3,'#1a1a1a');rect(x,30,12,3,3,'#1a1a1a');x.strokeStyle='#a84020';x.lineWidth=2;for(var i=0;i<3;i++){x.beginPath();x.moveTo(12,28+i*3);x.lineTo(4,24+i*4);x.stroke();x.beginPath();x.moveTo(36,28+i*3);x.lineTo(44,24+i*4);x.stroke();}return {body:c,h:0.42};})();
// props (solid billboards, non-wall)
SPR.palm=(function(){var c=mkc(56,96),x=c.getContext('2d');x.fillStyle='#8a6a3a';x.beginPath();x.moveTo(26,94);x.quadraticCurveTo(20,50,34,18);x.lineTo(38,20);x.quadraticCurveTo(26,52,32,94);x.closePath();x.fill();x.fillStyle='#3f8a3f';for(var i=0;i<6;i++){var a=-1.6+i*0.6;x.save();x.translate(34,20);x.rotate(a);x.beginPath();x.ellipse(22,0,24,7,0,0,7);x.fill();x.restore();}x.fillStyle='#9a5a2a';circ(x,30,16,5,'#9a5a2a');return {body:c,h:1.5,solid:true};})();
SPR.tree=(function(){var c=mkc(56,96),x=c.getContext('2d');x.fillStyle='#5a3f22';x.fillRect(24,52,9,42);x.fillStyle='#2f6a30';circ(x,28,34,22,'#2f6a30');circ(x,16,42,14,'#357537');circ(x,40,42,14,'#357537');x.fillStyle='#3f8540';circ(x,24,28,10,'#3f8540');return {body:c,h:1.45,solid:true};})();
SPR.bush=(function(){var c=mkc(48,48),x=c.getContext('2d');circ(x,16,34,11,'#2f6a30');circ(x,32,34,11,'#357537');circ(x,24,26,12,'#3f8540');x.fillStyle='#d04a4a';circ(x,18,30,2,'#d04a4a');circ(x,30,32,2,'#d04a4a');return {body:c,h:0.6,solid:true};})();
SPR.rock=(function(){var c=mkc(56,56),x=c.getContext('2d');x.fillStyle='#7d828c';x.beginPath();x.moveTo(8,52);x.lineTo(14,26);x.lineTo(30,16);x.lineTo(46,28);x.lineTo(50,52);x.closePath();x.fill();x.fillStyle='#9aa0ab';x.beginPath();x.moveTo(14,26);x.lineTo(30,16);x.lineTo(34,30);x.lineTo(20,34);x.closePath();x.fill();x.fillStyle='#5d636e';x.beginPath();x.moveTo(34,30);x.lineTo(46,28);x.lineTo(50,52);x.lineTo(36,50);x.closePath();x.fill();return {body:c,h:0.78,solid:true};})();
// citizens (wandering townsfolk) — colour variants
var CIT=[['#d8a878','#b5403c','#3a2a18'],['#e0b48a','#3a6a8a','#5a3a18'],['#caa078','#4a6a4a','#2a2a2a'],['#e6c8a0','#7a4a8a','#d8d8e0'],['#d8a060','#caa54a','#6a4a2a']];
SPR.citizens=CIT.map(function(p){return {body:humanoid({skin:p[0],cloth:p[1],cloth2:shadeHex(p[1],0.7).replace('rgb','').replace(/[() ]/g,''),hair:p[2]}),h:0.85,npc:true};});
// fix cloth2 (humanoid expects hex); just reuse cloth tone
SPR.citizens=CIT.map(function(p){return {body:humanoid({skin:p[0],cloth:p[1],cloth2:p[1],hair:p[2]}),h:0.85,npc:true};});
// the player hero (shown in the tilted overhead view), one per class
SPR.hero={
knight:{body:humanoid({skin:'#e8c89a',cloth:'#42506e',cloth2:'#2e3950',hair:'#3a2a18',helm:'#c2c6ce',cape:'#7a2230',prop:'sword'}),h:0.94},
ranger:{body:humanoid({skin:'#e0b48a',cloth:'#3f7a44',cloth2:'#2e552f',hair:'#5a3a18',prop:'sword'}),h:0.92},
mage:{body:humanoid({skin:'#e6c8a0',cloth:'#3a2a6a',cloth2:'#5a3aa0',hair:'#d8d8e0',prop:'staff',gem:'#7fe0ff'}),h:0.94}
};
// buyable gadgets (companions that fly beside the hero)
SPR.drone=(function(){var c=mkc(40,40),x=c.getContext('2d');rect(x,9,17,22,9,'#3a4150');rect(x,9,17,22,3,'#5a6273');circ(x,20,22,5,'#4ad0ff');circ(x,20,22,2,'#eaffff');rect(x,4,14,11,3,'#9aa0ab');rect(x,25,14,11,3,'#9aa0ab');x.fillStyle='rgba(180,230,255,.4)';circ(x,9,15,4,'#bfe6ff');circ(x,31,15,4,'#bfe6ff');return {body:c,h:0.4,fly:true};})();
SPR.wasp=(function(){var c=mkc(28,28),x=c.getContext('2d');rect(x,11,12,6,10,'#f0c020');rect(x,11,12,6,3,'#1a1a1a');rect(x,11,18,6,3,'#1a1a1a');circ(x,14,11,4,'#2a2a2a');rect(x,13,7,2,4,'#888');x.fillStyle='rgba(220,235,255,.5)';circ(x,8,12,5,'#dbeaff');circ(x,20,12,5,'#dbeaff');return {body:c,h:0.26,fly:true};})();
SPR.medbot=(function(){var c=mkc(36,40),x=c.getContext('2d');rect(x,8,16,20,16,'#e8edf2');rect(x,8,16,20,3,'#c2c8d0');circ(x,18,31,5,'#b9c0c8');rect(x,16,20,4,8,'#d04a4a');rect(x,14,22,8,4,'#d04a4a');rect(x,12,12,12,3,'#9aa0ab');return {body:c,h:0.42,fly:true};})();
SPR.plane=(function(){var c=mkc(80,64),x=c.getContext('2d');rect(x,34,10,12,52,'#dde2ea');x.fillStyle='#c2c8d0';x.beginPath();x.moveTo(40,10);x.lineTo(48,20);x.lineTo(32,20);x.closePath();x.fill();rect(x,8,30,64,9,'#cfd5de');rect(x,8,30,64,3,'#aeb6c0');rect(x,30,52,20,8,'#b9c0c8');rect(x,36,16,8,8,'#7fc0ef');rect(x,8,30,8,9,'#b04a4a');rect(x,64,30,8,9,'#b04a4a');return {body:c,h:1.2};})();
SPR.mountain=(function(){var c=mkc(140,128),x=c.getContext('2d');x.fillStyle='#6b727d';x.beginPath();x.moveTo(70,6);x.lineTo(132,124);x.lineTo(8,124);x.closePath();x.fill();x.fillStyle='#7d848e';x.beginPath();x.moveTo(34,52);x.lineTo(70,124);x.lineTo(2,124);x.closePath();x.fill();x.fillStyle='rgba(0,0,0,.2)';x.beginPath();x.moveTo(70,6);x.lineTo(132,124);x.lineTo(70,124);x.closePath();x.fill();x.fillStyle='#eef2f7';x.beginPath();x.moveTo(70,6);x.lineTo(88,44);x.lineTo(78,42);x.lineTo(70,52);x.lineTo(62,42);x.lineTo(52,44);x.closePath();x.fill();x.fillStyle='#cfe0ee';x.beginPath();x.moveTo(34,52);x.lineTo(44,72);x.lineTo(38,71);x.lineTo(34,78);x.lineTo(30,71);x.lineTo(24,72);x.closePath();x.fill();return {body:c,h:2.7};})();
SPR.lamp=(function(){var c=mkc(40,96),x=c.getContext('2d');rect(x,17,20,6,72,'#3a3a40');rect(x,12,12,16,10,'#2a2a30');x.fillStyle='#ffe9a0';circ(x,20,17,7,'#ffe9a0');var g=x.createRadialGradient(20,17,2,20,17,18);g.addColorStop(0,'rgba(255,233,160,0.8)');g.addColorStop(1,'rgba(255,233,160,0)');x.fillStyle=g;x.beginPath();x.arc(20,17,18,0,7);x.fill();return {body:c,h:1.5,solid:true,light:true};})();
SPR.flower=(function(){var c=mkc(32,32),x=c.getContext('2d');rect(x,15,18,2,12,'#2f6a30');['#e85a8a','#ffd24a','#7fb0ff'].forEach(function(col,i){circ(x,12+i*4,14,3,col);});circ(x,16,12,2.5,'#fff');return {body:c,h:0.3};})();
SPR.sign=(function(){var c=mkc(48,72),x=c.getContext('2d');rect(x,22,40,4,30,'#5a3f22');rect(x,8,18,32,22,'#caa54a');rect(x,10,20,28,18,'#3a2a18');x.fillStyle='#7fe07f';x.font='bold 11px monospace';x.textAlign='center';x.fillText('PLAY',24,33);return {body:c,h:0.95};})();
SPR.arcade=(function(){var c=mkc(56,84),x=c.getContext('2d');rect(x,10,18,36,60,'#2a2e3a');rect(x,14,24,28,20,'#0b0e14');x.fillStyle='#7fd0ff';for(var i=0;i<5;i++)rect(x,16+i*5,26+(i%2)*9,3,4,['#ff6a6a','#7fd0ff','#ffd24a','#7fe07f','#c08aff'][i]);rect(x,16,46,24,8,'#15181f');rect(x,18,55,20,12,'#3a3f4a');x.fillStyle='#ff6a6a';circ(x,24,61,2,'#ff6a6a');circ(x,32,61,2,'#7fd0ff');rect(x,10,8,36,12,'#caa54a');x.fillStyle='#1a1206';x.font='bold 9px monospace';x.textAlign='center';x.fillText('ARCADE',28,17);return {body:c,h:1.0,solid:true};})();
SPR.crystal=(function(){var c=mkc(40,56),x=c.getContext('2d');var g=x.createLinearGradient(0,4,0,52);g.addColorStop(0,'#fff6c0');g.addColorStop(1,'#e8a93a');x.fillStyle=g;x.beginPath();x.moveTo(20,2);x.lineTo(34,22);x.lineTo(20,54);x.lineTo(6,22);x.closePath();x.fill();x.fillStyle='rgba(255,255,255,.5)';x.beginPath();x.moveTo(20,2);x.lineTo(27,22);x.lineTo(20,40);x.closePath();x.fill();return {body:c,h:0.7};})();
SPR.door=(function(){var c=mkc(44,64),x=c.getContext('2d');rect(x,2,2,40,62,'#9aa0aa');rect(x,2,2,40,4,'#b4bac4');rect(x,4,6,36,56,'#6b6f79');rect(x,7,8,30,54,'#6b4b2a');rect(x,7,8,30,3,'#7d5a34');rect(x,9,11,12,46,'#5a3f22');rect(x,23,11,12,46,'#5a3f22');rect(x,9,11,12,2,'#7d5a34');rect(x,23,11,12,2,'#7d5a34');circ(x,31,36,2.6,'#e8c24a');rect(x,2,60,40,4,'#7a8089');rect(x,2,60,40,1,'#b4bac4');var g=x.createLinearGradient(0,8,0,60);g.addColorStop(0,'rgba(255,233,160,0.16)');g.addColorStop(1,'rgba(255,233,160,0)');x.fillStyle=g;x.fillRect(7,8,30,52);return {body:c,h:1.0,flat:true};})();
SPR.butler=(function(){return {body:humanoid({skin:'#e6c8a0',cloth:'#1c1c26',cloth2:'#eef0f6',hair:'#2a2a2a'}),h:0.9,npc:true};})();
SPR.target=(function(){var c=mkc(44,44),x=c.getContext('2d');['#e23b3b','#ffffff','#e23b3b','#ffffff','#ffd24a'].forEach(function(col,i){circ(x,22,22,21-i*4,col);});return {body:c,h:0.6};})();
SPR.barrel=(function(){var c=mkc(40,52),x=c.getContext('2d');rect(x,8,8,24,40,'#7a5326');rect(x,8,8,24,4,'#9a6a3a');rect(x,8,44,24,4,'#9a6a3a');rect(x,8,24,24,4,'#5a3a18');return {body:c,h:0.6,solid:true};})();
SPR.golfflag=(function(){var c=mkc(40,72),x=c.getContext('2d');x.fillStyle='#3f8a3f';x.beginPath();x.ellipse(20,66,16,6,0,0,7);x.fill();rect(x,19,8,3,58,'#d8d8d8');x.fillStyle='#e23b3b';x.beginPath();x.moveTo(22,9);x.lineTo(38,15);x.lineTo(22,21);x.closePath();x.fill();x.fillStyle='#fff';x.beginPath();x.arc(20,62,3,0,7);x.fill();return {body:c,h:1.0};})();
// ── furniture (interiors) ──
SPR.bed=(function(){var c=mkc(52,40),x=c.getContext('2d');rect(x,4,14,44,24,'#6a4a2a');rect(x,6,10,16,18,'#7a5a36');rect(x,8,16,40,14,'#cfd6e2');rect(x,8,16,12,14,'#e8eef5');rect(x,8,16,40,5,'#b5403c');return {body:c,h:0.5,solid:true};})();
SPR.table=(function(){var c=mkc(48,40),x=c.getContext('2d');rect(x,6,12,36,8,'#8a6a3a');rect(x,8,20,4,18,'#6a4a2a');rect(x,36,20,4,18,'#6a4a2a');x.fillStyle='#caa54a';circ(x,18,14,3,'#caa54a');return {body:c,h:0.5,solid:true};})();
SPR.chair=(function(){var c=mkc(32,44),x=c.getContext('2d');rect(x,8,6,16,4,'#6a4a2a');rect(x,8,18,16,5,'#8a6a3a');rect(x,9,23,3,18,'#6a4a2a');rect(x,20,23,3,18,'#6a4a2a');return {body:c,h:0.55,solid:true};})();
SPR.bookshelf=(function(){var c=mkc(48,84),x=c.getContext('2d');rect(x,4,4,40,78,'#5e472c');for(var r=0;r<4;r++){var yy=8+r*19;rect(x,8,yy,32,15,'#3a2c1c');for(var i=0;i<6;i++){x.fillStyle=['#b5403c','#3a6a8a','#caa54a','#4a7a4a','#7a4a8a'][(r*6+i)%5];x.fillRect(9+i*5,yy+2,4,12);}rect(x,6,yy+15,36,2,'#4a3620');}return {body:c,h:1.2,solid:true};})();
SPR.fireplace=(function(){var c=mkc(56,72),x=c.getContext('2d');rect(x,4,8,48,62,'#7d828c');rect(x,12,30,32,38,'#1a1410');x.fillStyle='#ff9a3a';x.beginPath();x.moveTo(18,66);x.quadraticCurveTo(28,34,38,66);x.closePath();x.fill();x.fillStyle='#ffe08a';x.beginPath();x.moveTo(24,66);x.quadraticCurveTo(28,46,32,66);x.closePath();x.fill();rect(x,2,4,52,8,'#9aa0ab');return {body:c,h:1.0,solid:true,light:true};})();
SPR.plant=(function(){var c=mkc(40,60),x=c.getContext('2d');rect(x,12,44,16,14,'#9a6a3a');x.fillStyle='#3f8a3f';circ(x,20,30,12,'#3f8a3f');circ(x,12,38,8,'#357537');circ(x,28,38,8,'#357537');return {body:c,h:0.7,solid:true};})();
SPR.cauldron=(function(){var c=mkc(48,48),x=c.getContext('2d');rect(x,20,40,8,8,'#333');x.fillStyle='#2a2a2e';x.beginPath();x.arc(24,30,16,0,7);x.fill();x.fillStyle='#5fd06a';x.beginPath();x.ellipse(24,22,13,5,0,0,7);x.fill();x.fillStyle='#9af0a0';circ(x,20,20,2,'#9af0a0');circ(x,28,21,2,'#9af0a0');return {body:c,h:0.5,solid:true,light:true};})();
SPR.anvil=(function(){var c=mkc(48,40),x=c.getContext('2d');rect(x,18,28,12,10,'#3a3a40');x.fillStyle='#5a5f68';x.beginPath();x.moveTo(8,22);x.lineTo(40,22);x.lineTo(34,30);x.lineTo(14,30);x.closePath();x.fill();rect(x,10,18,28,5,'#6a6f78');return {body:c,h:0.45,solid:true};})();
SPR.counter=(function(){var c=mkc(56,44),x=c.getContext('2d');rect(x,4,16,48,24,'#6a4a2a');rect(x,2,12,52,6,'#8a6a3a');for(var i=0;i<3;i++)rect(x,10+i*16,20,3,18,'#4a3620');return {body:c,h:0.55,solid:true};})();
SPR.board=(function(){var c=mkc(52,72),x=c.getContext('2d');rect(x,8,30,4,42,'#5a3f22');rect(x,40,30,4,42,'#5a3f22');rect(x,4,8,44,30,'#7a5326');rect(x,7,11,38,24,'#caa86a');x.fillStyle='#f0ead8';x.fillRect(10,14,12,9);x.fillRect(26,14,14,8);x.fillRect(12,26,16,6);x.fillStyle='#9a3030';x.fillRect(31,25,9,7);x.fillStyle='#3a2c1c';rect(x,4,6,44,4,'#3a2c1c');return {body:c,h:1.0};})();
}
/* ════════════════════════════════════════════════════════════════════
DATA — classes, enemies, items, NPCs, themes; the country + enterable
building interiors + a second district (the Harbour) + caves. Areas are
linked by walkable doors/roads (portals) and cave stairs.
════════════════════════════════════════════════════════════════════ */
var CLASSES={
knight:{name:'Knight',icon:'🛡️',blurb:'Tanky melee. Heavy sword cleave. Hold BLOCK to halve damage.',hp:140,mp:24,sta:110,atk:8,def:6,wkind:'sword',ability:'block',spd:2.6,abilDesc:'Block (hold): take 70% less damage while stamina lasts.'},
ranger:{name:'Ranger',icon:'🏹',blurb:'Agile ranged. Fire arrows (hold to charge). DODGE-roll for i-frames.',hp:100,mp:40,sta:120,atk:5,def:3,wkind:'bow',ability:'dodge',spd:3.0,abilDesc:'Dodge (tap): a fast roll with brief invulnerability.'},
mage:{name:'Mage',icon:'🔮',blurb:'Glass cannon. Quick magic bolts, plus an explosive FIREBALL.',hp:78,mp:130,sta:90,atk:3,def:2,wkind:'staff',ability:'fireball',spd:2.75,abilDesc:'Fireball (cast): explosive splash damage. Costs mana.'}
};
var WEAPONS=[{name:'Worn Blade',dmg:6,price:0},{name:'Iron Sword',dmg:12,price:70},{name:'Knight\'s Longsword',dmg:21,price:190},{name:'Runed Greatsword',dmg:33,price:430},{name:'Sunsteel Edge',dmg:50,price:920}];
var ARMORS=[{name:'Travel Garb',def:0,price:0},{name:'Leather Cuirass',def:6,price:80},{name:'Iron Mail',def:13,price:220},{name:'Knight Plate',def:22,price:480},{name:'Aegis of Dawn',def:34,price:980}];
var ENEMIES={
crab:{name:'Sand Crab',spr:'crab',hp:20,atk:6,spd:1.3,xp:10,gold:4,aggro:5,range:0.9,windup:0.4,cd:1.1},
rat:{name:'Plague Rat',spr:'rat',hp:18,atk:5,spd:1.7,xp:9,gold:3,aggro:5,range:0.9,windup:0.35,cd:1.0},
slime:{name:'Jungle Slime',spr:'slime',hp:30,atk:8,spd:1.0,xp:14,gold:6,aggro:5,range:0.95,windup:0.5,cd:1.2},
bat:{name:'Cave Bat',spr:'bat',hp:24,atk:9,spd:2.4,xp:17,gold:8,aggro:7,range:0.85,windup:0.3,cd:0.9,fly:true},
skel:{name:'Skeleton',spr:'skel',hp:46,atk:13,spd:1.7,xp:26,gold:12,aggro:7,range:1.05,windup:0.45,cd:1.1},
wraith:{name:'Wraith',spr:'wraith',hp:66,atk:19,spd:1.6,xp:46,gold:22,aggro:8,range:1.0,windup:0.4,cd:1.0,fly:true,caster:true},
ogre:{name:'Cave Ogre',spr:'ogre',hp:124,atk:30,spd:1.25,xp:84,gold:42,aggro:6,range:1.2,windup:0.7,cd:1.5},
lich:{name:'The Lich King',spr:'lich',hp:680,atk:34,spd:1.4,xp:800,gold:600,aggro:22,range:1.3,windup:0.55,cd:1.1,boss:true,caster:true}
};
var ECHAR={c:'crab',r:'rat',s:'slime',b:'bat',z:'skel',w:'wraith',g:'ogre',X:'lich'};
var PROPCHAR={T:'tree',R:'rock',U:'bush',l:'lamp',f:'flower',k:'barrel'};
var NPCS={
I:{key:'inn',spr:'npc_inn',name:'Innkeeper Bram',por:'🍺',action:'rest',lines:['Welcome in! Rest by the hearth — it mends body and mind, and saves your tale.']},
S:{key:'smith',spr:'npc_smith',name:'Blacksmith Dorn',por:'⚒️',action:'shop_smith',lines:['Steel wins quests. Let me show you my wares.']},
A:{key:'arc',spr:'npc_mage',name:'Arcanist Vell',por:'🔮',action:'shop_arc',lines:['Potions and tomes, fresh stocked. Brave the caves prepared.']},
Q:{key:'cap',spr:'npc_cap',name:'Captain Aldra',por:'⚔️',action:'quest',lines:['The Lich King stole the Sun Crystal into the caves beneath our country.','Visit the shops, see the Harbour if you like, then descend a cave and end him.']},
V:{key:'vil',spr:'npc_vil',name:'Townsperson',por:'🧑',action:'talk',lines:['The arcade\'s just inside — Snake, Apple Catch, a shooting range, even mini-golf!','Take the road to the Harbour. Inns, a library, a tavern — and fishing off the dock.']},
H:{key:'bar',spr:'npc_inn',name:'Barkeep Mira',por:'🍺',action:'tavern',lines:['What\'ll it be — ale, gossip, or a quiet corner?','A hearty ale will set you right for the road.']},
Y:{key:'scholar',spr:'npc_mage',name:'Scholar Pell',por:'📖',action:'study',lines:['Every house in Vel-Anor has a story in its timbers.','Sit a while and study — it sharpens the mind for the hunt.']},
Z:{key:'resident',spr:'npc_vil',name:'Cottager Fen',por:'🧑',action:'talk',lines:['Make yourself at home. Mind the cat.','Storms blow hard off the water this time of year.']}
};
var QUESTS={main:{name:'Reclaim the Sun Crystal',desc:'Descend the caves and slay the Lich King.'}};
var BOARD_QUESTS=[
{id:'crabs',name:'Cull the Crabs',desc:'Defeat 6 Sand Crabs on the shore.',kind:'kill',target:'crab',need:6,gold:80,xp:40,pots:0},
{id:'slimes',name:'Slime Trouble',desc:'Defeat 8 Jungle Slimes.',kind:'kill',target:'slime',need:8,gold:110,xp:70,pots:0},
{id:'tax',name:'Tax Collector',desc:'Collect 200 gold out in the world.',kind:'gold',need:200,gold:60,xp:30,pots:2},
{id:'bones',name:'Bonebreaker',desc:'Destroy 8 Skeletons in the caves.',kind:'kill',target:'skel',need:8,gold:140,xp:90,pots:0},
{id:'rats',name:'Rat Catcher',desc:'Defeat 6 Plague Rats in the fields.',kind:'kill',target:'rat',need:6,gold:70,xp:35,pots:0},
{id:'bats',name:'Pest Control',desc:'Defeat 8 Cave Bats underground.',kind:'kill',target:'bat',need:8,gold:130,xp:80,pots:1},
{id:'gold2',name:'Treasure Hunter',desc:'Amass 500 gold on your travels.',kind:'gold',need:500,gold:120,xp:60,pots:3}
];
var CITIZEN_LINES=['Lovely day, isn\'t it?','Heard the arcade got a new high score.','Welcome, traveller.','Careful past the jungle — beasts about.','Off to the Harbour market later.','The lamplighter does good work at dusk.'];
/* ── the long tale of Vel-Anor — a 15-chapter arc threaded through the world ── */
/* One coherent thread — every beat points the same way: down, into the caves,
to the Lich. No contradictory side-errands. */
var STORY=[
{t:'Prologue · The Dimming',o:'Find Captain Aldra (⚔) in the square and hear what was stolen.',
l:['For a thousand years the Sun Crystal warmed the country of Vel-Anor, and no winter ever truly bit.','Then, on a moonless night, it was torn from its shrine, and a grey cold began to creep up from the deep places of the earth.','Captain Aldra holds the square against the rising dark — and she is looking for someone willing to go down and end it.'],
done:function(){return G.flags&&G.flags.questMain>=1;}},
{t:'Chapter I · Make Ready',o:'Gear up in town if you wish, then find the cave mouth (▼) and descend.',
l:['"The thing that took the Crystal went back the way it came — down, into the old cave mouth past the square," Aldra says. "That is your road."','Visit the smithy and the arcanist if you like. Then go down — everything that matters now lies below.'],
done:function(){return G.flags.visited&&G.flags.visited.cave;}},
{t:'Chapter II · The Bonefields',o:'Fight deeper into the Hollow Caves — cut down 20 of the risen dead.',
l:['The cold has set the long-dead marching, rank upon rank, and they do not tire as the living do.','Carve a path through bone and shadow toward the cold heart of the caves.'],
done:function(){return (G.flags.totalKills||0)>=20;}},
{t:'Chapter III · The Deep Stair',o:'Find the deep stair (▼) that spirals down to the Throne.',
l:['Far below, the Sun Crystal still pulses, its warmth fighting faint and far against the dark.','Somewhere in the deep is the stair to the throne — and the thing that sits upon it. Down, then.'],
done:function(){return G.flags.visited&&G.flags.visited.lair;}},
{t:'Chapter IV · Korvash, the Lich King',o:'Destroy Korvash the Lich King and reclaim the Sun Crystal.',
l:['He waits on a throne of frost, the Crystal caged in his ribs like a captured star.','"You are warm," Korvash rasps, almost kindly. "I will fix that." Burn him out, hero of Vel-Anor.'],
done:function(){return G.flags.won;}},
{t:'Epilogue · Sunrise',o:'Vel-Anor is saved. Roam your country in the returning light.',
l:['The Crystal returns to its shrine, and dawn rolls back across the fields like a tide of gold.','The cold sinks away into the deep places, and in the square they are already singing your name.','THE END — but the country is yours to wander. Thank you for playing Dungeon Quest 3D.'],
done:function(){return false;}}
];
/* Investigation sites are retired — they pulled the player away from the one
downward thread and contradicted Aldra's guidance. The world stays open to
explore freely, but no side-quest marker competes with the main objective. */
var SITES=[];
function snapWalk(L,x,y){var bx=clamp(Math.round(x),1,L.W-2),by=clamp(Math.round(y),1,L.H-2),dx,dy;if(L.wall[by][bx]!==1)return {x:bx+0.5,y:by+0.5};for(var r=1;r<16;r++)for(dy=-r;dy<=r;dy++)for(dx=-r;dx<=r;dx++){var tx=bx+dx,ty=by+dy;if(tx<1||ty<1||tx>=L.W-1||ty>=L.H-1)continue;if(L.wall[ty][tx]!==1)return {x:tx+0.5,y:ty+0.5};}return {x:bx+0.5,y:by+0.5};}
function setupSites(L){G.sitePos={};var refs={},i;for(i=0;i<L.portals.length;i++)refs[L.portals[i].to]={x:L.portals[i].x,y:L.portals[i].y};if(L.caveDown)refs.cave={x:L.caveDown.x,y:L.caveDown.y};for(i=0;i<G.npcs.length;i++)if(G.npcs[i].def&&G.npcs[i].def.action==='quest')refs.aldra={x:G.npcs[i].x,y:G.npcs[i].y};SITES.forEach(function(s){var r=refs[s.ref]||refs.aldra||{x:L.W*0.4,y:L.H*0.5};G.sitePos[s.id]=snapWalk(L,r.x+(s.dx||0),r.y+(s.dy||0));});syncSiteMarker();}
function activeSite(){if(!G.flags||G.flags.story==null)return null;for(var i=0;i<SITES.length;i++){var s=SITES[i];if(s.chapter===G.flags.story&&!(G.flags.found&&G.flags.found[s.id]))return s;}return null;}
function syncSiteMarker(){if(!G.things)return;G.things=G.things.filter(function(t){return t.t!=='qsite';});if(G.curKey!=='world')return;var s=activeSite();if(!s||!G.sitePos||!G.sitePos[s.id])return;var p=G.sitePos[s.id];G.things.push({kind:'thing',t:'qsite',x:p.x,y:p.y,site:s});}
function discoverSite(s){if(!G.flags.found)G.flags.found={};if(G.flags.found[s.id])return;G.flags.found[s.id]=true;var gold=20+rndi(26),xp=14;if(G.P)G.P.gold+=gold;if(typeof gainXp==='function')gainXp(xp);if(sfx.quest)sfx.quest();showSiteCard(s,gold,xp);syncSiteMarker();}
function showSiteCard(s,gold,xp){G.mode='pause';var lore=h('div',{style:'text-align:left;font-size:13.5px;line-height:1.78;color:#ece0c6;'});s.lore.forEach(function(t){lore.appendChild(h('p',{style:'margin:0 0 10px;',text:t}));});var box=h('div',{style:'max-width:500px;'},[h('div',{class:'arcade glow',style:'color:#7fd0ff;font-size:11px;letter-spacing:3px;margin-bottom:3px;',text:'★ DISCOVERY'}),h('h2',{style:'color:#9fe0ff;margin:0 0 10px;text-transform:capitalize;',text:s.name}),lore,h('div',{style:'color:#8fd08f;font-size:11px;margin:8px 0 12px;',text:'A clue uncovered. +'+xp+' XP +'+gold+'g'}),btn('Continue',function(){resumeWorld();},'primary')]);openOverlay(box,'pause');}
/* legend: # wall % accent . floor ~ water P start v/u cave down/up
a arcade n snake-stone p citizen I/S/A/Q/V npc l lamp f flower k barrel
T/R/U props c/r/s/b/z/w/g enemy X boss C chest o/h/m pickup K key
D door L locked +/G lever/gate B brazier F fountain
portals (doors/roads) are defined as data, not chars */
var LEVELS={
world:{name:'The Country of Vel-Anor',baseTheme:'field',area:'world',music:'town',linkDown:'cave',
intro:'Your homeland — a sprawling country. The town square at its heart is ringed by shops you can walk into; beyond lie open fields, a great jungle, lakes and rivers you can wade, and the shore. A cave (▼) plunges underground; the south road runs to the Harbour.',
objective:'Explore the country. Talk to the Captain (⚔️), take notice-board jobs, or find the cave ▼.',
regions:[{"x":10,"y":46,"w":34,"h":30,"theme":"city"},{"x":58,"y":4,"w":96,"h":40,"theme":"city"},{"x":4,"y":4,"w":48,"h":38,"theme":"mountain"},{"x":112,"y":44,"w":54,"h":84,"theme":"jungle"},{"x":4,"y":114,"w":160,"h":14,"theme":"beach"}],
venuesData:[{"type":"board","x":17.5,"y":48.5},{"type":"golf","x":26.5,"y":50.5},{"type":"board","x":24.5,"y":55.5}],
portals:[{"x":15.5,"y":44.5,"to":"inn","label":"Enter the Inn"},{"x":27.5,"y":44.5,"to":"smithy","label":"Enter the Smithy"},{"x":15.5,"y":59.5,"to":"arcanist","label":"Enter the Arcanist"},{"x":27.5,"y":59.5,"to":"arcade","label":"Enter the Arcade"},{"x":41.5,"y":49.5,"to":"house1","label":"Enter the Cottage"},{"x":49.5,"y":49.5,"to":"house2","label":"Enter the Cottage"},{"x":36.5,"y":57.5,"to":"airport","label":"Vel-Anor Airfield"},{"x":20.5,"y":10.5,"to":"mountain","label":"The trail up Mount Vel"},{"x":64.5,"y":90.5,"to":"harbor","label":"The road to the Harbour"},{"x":96.5,"y":52.5,"to":"cave2","label":"A second cave network ▼"}],
map:[
"########################################################################################################################################################################",
"#......................................................................................................................................................................#",
"#....f..................................R.........T................o..........f....U...Tf..R.......................r..........f..f..................TU.................#",
"#.................................U.........U.........U.....T.........................f......U..............U.................T.............RT..f......................#",
"#........................U......U........f..................................................................f..........................................................#",
"#.f..........f.................U.R......U.....U........f...%%..........###...................................f...........................##............................#",
"#...........................U..R...f...................r...%%......#######.....###..%%..l%%%%........%%%................###.........##...##.....................r....f.#",
"#........R...............f....................f.......T........f...#######.....###..%%...%%%%...\"\"\"\".%%%...##.....###...###..%%%....##..........%%p..%%%%....f.........#",
"#....T.....f.........................R..........R..................####........###..%%...%%%%...\"\"\"\"..f....##.....###........%%%.f..............%%...%%%%..............#",
"#........f..........................U..R..........r..T.....................................................##.....###..........f.....................%%%%..............#",
"#.....Rf...............U...............f.........................f.................%%f........f.##.............................................%%%...............U.....#",
"#.......R..................T.....f...........................................####..%%...C.......##.....%%....###..pf....###..%%%%..p....m.\"\"\"..%%%....###..............#",
"#...............UT..................f..........r.......U....####...###..\"\"...####.........%%....##.....%%....###.%%f..p.###.f%%%%..##.....\"\"\".........###....U.........#",
"#............T...T...R.T..T................T................####..f###..\"\"...####.........%%.......l....p....###.%%..........%%%%..##.....\"\"\".........###...U..........#",
"#............T.T..................R.......z..........U.............###..\"\".................................f.......................##.....................f............#",
"#..U....r............R.......R....U..................R......###....%%%.............##...........l....%%%.....%%............f.......%%%%....###f......f.................#",
"#..r......zf.U..............R...R......U....................###....%%%..f......\"\"\".##..........%%....%%%.....%%....................%%%%p...###.........................#",
"#.....................U......R..R..R.....f.........................%%%..%%.....\"\"\".......p.%%%%%%..p.%%%..l........###.\"\"\"\"..%%%........p..###.####..%%.......z........#",
"#................U................~....f..............f.................%%.................%%%%....................###.\"\"\"\"..%%%...............####..%%...........U....#",
"#.........................Tf.....r~~.............R....T.................%%......C..........%%%%............f..p....###..............f..........####....................#",
"#......U........R...f..Tr.........~~.....................U...%%.................................##.....p.................................##.p....####................R.#",
"#...............................U.R~....................R....%%....####\"\"\".........%%%....%%%%..##.....####%%%%....##..........####..%%%.##......####\"\"\"\"...T..........#",
"#.f..........................R..R...~ff....f....Uf...........%%....####\"\"\"...####..%%%....%%%%..##.....####%%%%....##.o..###...####..%%%.##....f.####\"\"\"\"..............#",
"#.............UR...................f.~~........TR........f....f...l....\"\"\".p.####.........%%%%.........####...l....##....###.........%%%.............f.........U.......#",
"#..............ff..............f...r..~~............................ff.......####...f....................................###..f..................................R.....#",
"#...............................f......~..........................f......%%%..............###..........##.............f...f....p.....................####...U..........#",
"#.....R.T....UR....Uf..............fR.f.~.......R.T..U..U.........%%%%...%%%.\"\"\"..........###f.........##.p%%......##..%%%...........................####..f.U.........#",
"#............R.........................R...........f..Ro....###...%%%%...%%%.\"\"\"....p%%%..###..%%%.....##..%%......##..%%%.....###.##.....##....###..............R.....#",
"#.....rzf.....U............R..R..R.....~R...................###...%%%%.....f.\"\"\".....%%%.....f.%%%....f....%%......##..........###.##.....##....###....................#",
"#.........R.T...R...R.R...U.f......R...~..........f..............................f....................................f............##.....##.................z.........#",
"#....f......T.r......T....R........fU.U~T.T..r....f.......v..\"\"\"\"\"\"\"\"..........####............................................p....%%%........f...f.%%.......U.T....R.#",
"#.................................R....~~......U.............\"\"\"\"\"\"\"\"...%%%....####......##....%%%..f..f...%%%%f.##......%%..\"\"\"\"...%%%f.............%%...f.......f....#",
"#..........................R...R.U.....R~....r...............\"\"\"\".......%%%.........####f##....%%%.....%%..%%%%..##......%%..\"\"\"\"...%%%...####...##..%%...........T....#",
"#..U.......T.....U.......U..........f...~....T...U.R...................l%%%.........####.f.....%%%.....%%......l.##......%%f.\"\"\"\".........####...##.............RT.....#",
"#.....f......f..........................~~......z........f..........................####.............................................f.f.l...........................U.#",
"#.....fU..U.........f...................T~......f.......T................###f..........................................##...........................................T..#",
"#........R...z...........T.........f......~..f...............####....f...###...###...........................\"\"\"....m..##..................%%%...\"\"\".......U...........#",
"#.........U...r.........T...f........f....~~...R.............######............###.###....##.....###..###....\"\"\".\"\"....##.....%%....%%%%..l%%%...\"\"\".###.......U.......#",
"#..........T....U.................T........~.................f...##................###f...##.....###..###........\"\"...........%%....%%%%.........\"\"\".###............f..#",
"#.r......r.................R...............~~....................................p.###....##.......~~~........................%%.......................................#",
"#.........T..........................T....~~...fT.....T..........................................~~~~~~~..................................................z....T....oR.#",
"#............%%%%%.......%%%%%.........f..~~..T..................................................~~~~~~~...........f...................................................#",
"#.T....f..f..%%%%%.......%%%%%.......T.....~~...T..R.U.......................................f..~~~~~~~~~.....................................................f.....f..#",
"#............%%%%%.......%%%%%.......f......~..........U..................................f......~~~~~~~.........f....f....................................ff..........#",
"#.................l..l..............R........~~...R................f........f.........f..........~~~~~~~..........UTT..............f..........T........T...Ts..........#",
"#..U....f.....l.............l.................~~.....U....R....T...................f.........R.r...~~~f.......fz..U..f.T.................U.......s...T...T......T......#",
"#....................Q.p................%%%%.~~.%%%%...r............U...........................U.......ff.....U....T.U...T....TT.....T...T.U...T.....T.s...TT.........#",
"#.......f...............................%%%%..~.%%%%..R...f......f....f........Uf..........TT......T............s...T..T.T........sT........T..T....T....T.............#",
"#....U..U...............................%%%%Rfp~%%%%...............Tf......U.........zf.f.................................T..TT...U........T.TT.T..s.TfT..T.......T....#",
"#.....U.f....k..........p....k.........l.....~~......l...............U.................U.........................TTU...T..........TT.........T...s.........T...U....TT.#",
"#..U..............p..F......................~fT......................r........r....r.................................TT.......f..................T..TTT..f....T....T...#",
"#.R....f...................................~~.....r..f.r.........f............R........................T...U.......T........T.......T...T.fT.....b.........T..T........#",
"#...............p....P......................p~.....................T...U.U.....................................U..T..T..T..............T..T...b.......T..TT.........T..#",
"#.........................p...............p~~............T.....UR.................f.U.......f..............r...f.....m...T..ff....T.TU.T.T.T..TT.T.......T.s..T..T.....#",
"#..U.......................................~~T..............f.f......f...................T......................f.TT............T.U.......TT....T........T..T...T......#",
"#.T.................p......................~~U.......f................................................f......f.U.....b..........UfT...............T..........T....T.f..#",
"#.......f.................................~.........r.R......ff..U.................~~~~~~~...U.f.........f......U.U.....U......T...T.............Ub......U.........T...#",
"#......T..................................~~..U.............T......r..............~~~~~~~~~........T..f......f....fT..................T...........TT.....T........s.T..#",
"#.............l.........l...l.....%%%%%..~~........f.........R.....f...f.........~~~~~~~~~~~...........U.........b.........TU.......U....U............T............T...#",
"#....T............................%%%%%..~~...........................f.......fT.~~~~~~~~~~~.............Uf.R...b.T............TT...T..U.......T.................T.TT..#",
"#.f..........%%%%%...l...%%%%%....%%%%%..~~.............................U......R~~~~~~~~~~~~~.........U.T............UT...U.......T...s.........T..........U....U......#",
"#............%%%%%.......%%%%%...........~~.......R....U.........U....T........R.~~~~~~~~~~~T.....................T....f.T.......T.....o.T............T.....f..........#",
"#......f.....%%%%%......f%%%%%...........~~..............R..U....U...............~~~~~~~~~~~..h.....R..................TU....T.......s............T.T.....T........s...#",
"#....U.f...........................f....~.................T.......................~~~~~~~~~z.............R......T..T..U.T...T..T..........T..................U....U..T.#",
"#..........................f............~....U............................f......R.~~~~~~~.f....U...U..........f......T...s..T...............T........T.TT.............#",
"#.z.....................................~~............U....f...........rf...............T........T.R....U.........U.T...T....T.....T..T..T.T.f.f.UT.T.....f...T....U.f.#",
"#....f........................f........~.........T...................U............................T........f...T...........UT...s.....T..TT.....f....T.b........sT.....#",
"#.T..............f......................~.........................U.....Tf....f......U.......r.........f.......f.UT...............T....Ts....T................TT.......#",
"#...............................ff......~................T...............RU...........f..............T...U......U.....T..T..........s.....T...T....T......T.T..U..T....#",
"#.U.f.T.............................f~~~~~~~...............U....................U...............f......................U.......T...b.............U..T.T..T......T......#",
"#......f...........................f~~~~~~~~~.rU.................fR..................................f.f........T........U..............T..T.........TT.T..T...........#",
"#...................................~~~~~~~~~......f..TU................f...Rf.U.............f.....f.............T..........fT.T....T.......U.......T....T.T...........#",
"#....U.............................~~~f~~~~~~~.............f.......fT....f.....f..f.fR.........f...............U.....T..s......U.............T..fT..T............T.....#",
"#...........................f.......~~~~~~~~~.fU.....U...U...r.........fU......U..........................r.f.....T....U.f.T...T.......TU...T..........o.....T.......T.#",
"#...................................~~~~~f~~~...f.................T.f...........T.........R...................T.f.T...........T.....Us.s....T.....T.....TT...T.........#",
"#....................................~~~~~~~.........R.......................f........U...............................b......T..U..T.....T................U.U..........#",
"#.................f............R........~~..f..............R..U.......U..r...R................................R....TT.UT...T..fTT...T..T..f..........fs......T.........#",
"#.......Uf......f........................~..............U.f.........fr..R.......T............T....f..............T........T...TU.....f....T.T..........T..TU.T......T..#",
"#..............................f..........~~...f..................................z....R...........r...........zT..............................T.........T....T.T.T....#",
"#............r...........................~~........................f.U........................f....f.....f..........f.b...TfU.................U...UT..U...T....T.......#",
"#..............f........................~~..~~~~~.f.......................RR..r......z.....................ff..............T...U...T........U......U...T.....T.........#",
"#......f.................f.............~~~~~~~~~~~~~.......................f.f........T.......T.....f..............f.Tf........T.............fTU.....T.fT..............#",
"#............RU.......f................~~~~~~~~~~~~~~f.............R..f....R.U............f.....f...................T......U................T.......T.U................#",
"#.f..........Ur.........U.............~~~~~~~~~~~~~~~~~..........U.............U...f.................o..............U.....U......TT.............T...........T..........#",
"#...............R.........f..........~~~~~~~~~~~~~~~~~~f....f....T......f..........f...........................U..............s..T.....f.b..............T......T...T...#",
"#.........................T.........~~~~~~~~~~~~~~~~~~~~~......T.........U........T...........f......T..................T.........s.U..T..........T..UTTT....f.........#",
"#...R..........................U...~~~~~~~~~.....~~~~~~~~~f...f................................T..................T.........U...f.s.sU.....T..T.fT...s..U..............#",
"#......f...R..........U..R.........~~~~~~~~.o..T..~~~~~~~~........Uf.......f.U....f...f...Rf.......f...............T.....T........f.T........................Us......U.#",
"#........U........T.........T......~~~~~~~~...C.w.~~~~~~~~...f.....f.....................r........T......T..z...............f......TT.T...T.T......T.....fT............#",
"#.............U....................~~~~~~~~...k...~~~~~~~~.............f............................f...U...............T..TT.....................TTT.T.....TU...T.....#",
"#.U.fr....f.........U..............~~~~~~~~~.....~~~~~~~~~..........................T..f....T............f.T......T.TT....................T....T.U...T.........TTTTTTT.#",
"#.....................z.......fUR...~~~~~~~~~~~~~~~~~~~~~...f.................................R............U........s...............T...T.....U.T.U......f.T....f.b....#",
"#.........fr..r......................~~~~~~~~~~~~~~~~~~~...........f..........r.........U...........r....R...........TT...............Ts.........U.....T........U......#",
"#.f..............f....................~~~~~~~~~~~~~~~~~........T...f..............R............U..f....f.......R..TT.T.f.......T..U......T................T...s......T.#",
"#.f..R.....R......f..r.........f.......~~~~~~~~~~~~~~~.................f...U......f..................T....f..................T........U...........T.....T..T.T....T....#",
"#...................f...f.................................................................................................T.bT......................U..T........T......#",
"#.............f................fU...................................U.Uf.........................................T....T..U..m...f..T......U.......TT....U.....T.U......#",
"#........T......U.U.f....T....f................................................................f....f........................T........T.f........T..TT.T..U.......T.U..#",
"#..........r........T.....R...U.............................f................................R..................T.Uf...............T...................T.......TT....T.#",
"#....fU...U..........T...................................R...f............r........T.........................z....f..TT..TU.TT..T............TTT........T...T..........#",
"#.T............T.....................f.................f.T.......................f.............................f...U.........T.....T...f.........T......f....U.........#",
"#.............................T..f...........................UT......................f...........z.........R.f......f..TTf....T.............T...T...T..................#",
"#...T.......T..R..f......................................T.fR....U...T.........U.r...f...f.......................T......T...T...s.T..................T.....T...b.......#",
"#..........................U.........................f............f.............R...........................f..................T......................U...fT..T........#",
"#......R..................U....................................f........................U.T...........f...................U..T..U.......T..Us..TT........f...T.........#",
"#.....U.o..........fz...............U.f..T.............R..U..........R........R..........U.............T...............T..U....oT...T.....f....U.T..........T.......TU.#",
"#..................f..............................f...r.......f....................r..............R.T.........f.........b..T........TT.............T..T..f...T......T..#",
"#.......U........R....f...........T.....T.......................f.f.....f.....f.R.........R................................T.T..............U..T..T..T...T..T..T.......#",
"#....U..................U........................f......f.................f......................U...f................................T..o..........T..f...............#",
"#............z.........f.........f...TU.....U..f.T...hT.f.U.f.........T..f.............R........................U................TT..........U..T.T....U.T.T..T....T...#",
"#.f..............UTT.....r..........T.....................R............f.......T.........................R.U.......T.T......T..T.....T..Ts..T...TT..TT..T...T.T.T......#",
"#..f........T....................T.f....U............R....r...........................R.T..U.....f...................U....................fT........s..................#",
"#.......f.ff............................................zT.............f......U..........T........r..............f...TT..................................T.......T.....#",
"#.......f........h...f........................U............................R......U.f......................f....TT.....T.......T......T.....T...U....T....T............#",
"#..................T..................R...............T....................T...T.....................................T......s..U.......T.....T.......f.................#",
"#...........c..................................................................c.R...........R.............R............T....T.U......TT.s...T.T.................U.....#",
"#......R..R....................T...R...R................................R...................R..........................f..T....T...T...T.....................U.....Ts..#",
"#.....R...T...........................................c...R.......c.......................................................T............U...........T.f.T.T.T...........#",
"#..f...........................T................T...T.........c.........R........R.R.........................m....T.......T....U....T.T.....TfTs..T....T.....T.....T...#",
"#..U..........................T................................c.....................c.......................R...CT........U.U.T...f.UU...T.........T.T...T.....U.b....#",
"#..........................T....................R...T..........T........R..............................R.c......U.T......T..............T....s.................U.......#",
"#............................c...........R..............................T...............c......................c...s.....T..U..........T.................f.T..TT.......#",
"#...R.....c..R......c...........T....................T.....c....................R...............................TT.f.....TT..TT.T.f........U................s....T.....#",
"#.......................................T..R........................................T................................T.T..............T.................T........T...T.#",
"#.....................T..........h..................T.............c...............T......................c.........T.....T......T....sT..U....f...TU......T..T.........#",
"#.........................................................................T..................c............R........f.TU........T...TT.T..........T....T.....UU.........#",
"#......................................................................................................................................................................#",
"########################################################################################################################################################################"
]},
inn:{name:'The Hearthside Inn',baseTheme:'interior',area:'interior',music:'town',linkUp:'inn_up',
intro:'The Hearthside Inn — warm and safe. Speak to Bram to rest (full heal & save). The stairs (▲) lead up to the guest rooms.',objective:'Rest at the Inn, climb ▲ to the rooms, then leave.',
portals:[{x:6.5,y:7.5,to:'world',tx:4.5,ty:6.5,label:'Leave the Inn'}],
decor:[{t:'fireplace',x:2.5,y:1.6},{t:'table',x:3.5,y:4.5},{t:'chair',x:4.5,y:4.5},{t:'table',x:9.5,y:4.5},{t:'chair',x:8.5,y:4.5},{t:'plant',x:10.5,y:1.6}],
map:["#############","#...........#","#..k.....I..#","#...........#","#...........#","#........u..#","#...........#","#####...#####","#############"]},
inn_up:{name:'The Inn — Upstairs',baseTheme:'interior',area:'interior',music:'town',linkDown:'inn',
intro:'The inn\'s upper floor — quiet guest rooms tucked under the eaves. The stairs (▼) lead back down.',objective:'Look around, then take the stairs ▼ down.',
decor:[{t:'bed',x:2.5,y:1.6},{t:'bed',x:4.5,y:1.6},{t:'bed',x:10.5,y:1.6},{t:'table',x:7.5,y:4.5},{t:'chair',x:7.5,y:3.5},{t:'plant',x:1.5,y:5.5},{t:'fireplace',x:10.5,y:5.5}],
map:["#############","#...........#","#...........#","#...........#","#........v..#","#...........#","#...........#","#####...#####","#############"]},
smithy:{name:'Dorn\'s Smithy',baseTheme:'interior',area:'interior',music:'town',linkUp:'smithy_up',
intro:'The Smithy — iron and sparks. Talk to Dorn for weapons and armour. The stairs (▲) reach the forge loft.',objective:'Buy gear; climb ▲ to the loft if you like, then leave.',
portals:[{x:6.5,y:7.5,to:'world',tx:11.5,ty:6.5,label:'Leave the Smithy'}],
decor:[{t:'anvil',x:3.5,y:4.5},{t:'fireplace',x:9.5,y:1.6},{t:'barrel',x:10.5,y:5.5},{t:'barrel',x:2.5,y:5.5}],
map:["#############","#...........#","#..S........#","#...........#","#...........#","#........u..#","#...........#","#####...#####","#############"]},
smithy_up:{name:'The Forge Loft',baseTheme:'interior',area:'interior',music:'town',linkDown:'smithy',
intro:'The forge loft — racks of steel and a chest of oddments. Take the stairs (▼) back down.',objective:'Look around, then take the stairs ▼ down.',
decor:[{t:'bookshelf',x:1.5,y:1.5},{t:'barrel',x:3.5,y:1.6},{t:'anvil',x:10.5,y:4.5},{t:'table',x:6.5,y:5.5},{t:'plant',x:2.5,y:5.5}],
map:["#############","#.....C.....#","#...........#","#...........#","#........v..#","#...........#","#...........#","#####...#####","#############"]},
arcanist:{name:'Vell\'s Workshop',baseTheme:'interior',area:'interior',music:'town',
intro:'The Arcanist\'s workshop — potions and tomes. Talk to Vell to buy supplies.',objective:'Buy potions, then leave.',
portals:[{x:6.5,y:7.5,to:'world',tx:4.5,ty:12.5,label:'Leave the Workshop'}],
decor:[{t:'bookshelf',x:1.5,y:1.5},{t:'bookshelf',x:2.5,y:1.5},{t:'cauldron',x:9.5,y:4.5},{t:'plant',x:10.5,y:1.6},{t:'bookshelf',x:11.5,y:1.5}],
map:["#############","#...........#","#..A........#","#...........#","#...........#","#...........#","#...........#","#####...#####","#############"]},
arcade:{name:'The Arcade',baseTheme:'interior',area:'interior',music:'town',
intro:'The Arcade! Step up to a cabinet and play — Snake, Apple Catch, or the Shooting Gallery.',objective:'Play a game, then leave.',
portals:[{x:6.5,y:7.5,to:'world',tx:11.5,ty:12.5,label:'Leave the Arcade'}],
decor:[{t:'arcade',x:2.5,y:1.6},{t:'arcade',x:10.5,y:1.6},{t:'arcade',x:1.5,y:4.5},{t:'arcade',x:11.5,y:4.5}],
map:["#############","#...........#","#...a.......#","#...........#","#...........#","#...........#","#...........#","#####...#####","#############"]},
cottage:{name:'A Cottage',baseTheme:'interior',area:'interior',music:'town',
intro:'A cozy cottage — a bed, a hearth, and a life lived in timber.',objective:'Look around, then leave.',
portals:[{x:6.5,y:7.5,to:'harbor',tx:20.5,ty:5.5,label:'Leave the Cottage'}],
decor:[{t:'bed',x:2.5,y:1.6},{t:'fireplace',x:10.5,y:1.6},{t:'table',x:9.5,y:5.5},{t:'chair',x:8.5,y:5.5},{t:'plant',x:2.5,y:5.5}],
map:["#############","#...........#","#.......Z...#","#...........#","#...........#","#...........#","#...........#","#####...#####","#############"]},
house1:{name:'Maris’ Cottage',baseTheme:'interior',area:'interior',music:'town',
intro:'A weaver’s cottage in the village — looms, wool and a warm hearth.',objective:'Look around, then leave.',
portals:[{x:6.5,y:7.5,to:'world',label:'Leave the Cottage'}],
decor:[{t:'bed',x:2.5,y:1.6},{t:'fireplace',x:10.5,y:1.6},{t:'bookshelf',x:1.5,y:1.5},{t:'table',x:6.5,y:5.5},{t:'chair',x:6.5,y:4.5},{t:'plant',x:10.5,y:5.5}],
map:["#############","#...........#","#...Z.......#","#...........#","#...........#","#...........#","#...........#","#####...#####","#############"]},
house2:{name:'The Old Farmhouse',baseTheme:'interior',area:'interior',music:'town',
intro:'An old farmhouse — sacks of grain, a long table, and a resident who’s seen it all.',objective:'Look around, then leave.',
portals:[{x:6.5,y:7.5,to:'world',label:'Leave the Farmhouse'}],
decor:[{t:'table',x:6.5,y:4.5},{t:'chair',x:5.5,y:4.5},{t:'chair',x:7.5,y:4.5},{t:'barrel',x:2.5,y:1.6},{t:'barrel',x:3.5,y:1.6},{t:'fireplace',x:10.5,y:1.6},{t:'plant',x:2.5,y:5.5}],
map:["#############","#...........#","#........Z..#","#...........#","#...........#","#...........#","#...........#","#####...#####","#############"]},
airport:{name:'Vel-Anor Airfield',baseTheme:'interior',area:'interior',music:'town',
intro:'The airfield hangar — oil, canvas and a waiting biplane. Step up to the plane to take off over the country.',objective:'Board the plane ✈ to fly, or leave.',
venuesData:[{type:'plane',x:6.5,y:4.5}],
portals:[{x:6.5,y:7.5,to:'world',label:'Leave the Airfield'}],
decor:[{t:'counter',x:10.5,y:1.6},{t:'barrel',x:2.5,y:1.6},{t:'barrel',x:11.5,y:5.5},{t:'bookshelf',x:1.5,y:5.5},{t:'anvil',x:2.5,y:5.5}],
map:["#############","#...........#","#...........#","#...........#","#...........#","#...........#","#...........#","#####...#####","#############"]},
mountain:{name:'Mount Vel',baseTheme:'mountain',area:'world',music:'town',
intro:'The cold trail up Mount Vel. Pick your way past the crags to the summit — they say the old sun-shrine still stands there, and the view runs to the sea.',objective:'Climb the trail to the summit at the top.',
portals:[{x:11.5,y:16.5,to:'world',label:'Back down the trail'}],
map:[
"########################",
"#....R...CC....R......R#",
"#..RR..B......B..RR....#",
"#.....R..........R.....#",
"#..R.......g.RR....h...#",
"#......RR.......R......#",
"#..R........R.....RR...#",
"#.....R...........R...R#",
"#..RR....R......R......#",
"#......R............R..#",
"#..R......RR......R....#",
"#.....R........R......R#",
"#..R.........h....RR...#",
"#......RR......R.......#",
"#..R........R.........R#",
"#.....R..........R.....#",
"#......................#",
"########################"]},
library:{name:'The Library',baseTheme:'interior',area:'interior',music:'town',
intro:'The Library — shelves to the rafters, paper and candle wax.',objective:'Browse, then leave.',
portals:[{x:6.5,y:7.5,to:'harbor',tx:4.5,ty:5.5,label:'Leave the Library'}],
decor:[{t:'bookshelf',x:1.5,y:1.5},{t:'bookshelf',x:2.5,y:1.5},{t:'bookshelf',x:3.5,y:1.5},{t:'bookshelf',x:9.5,y:1.5},{t:'bookshelf',x:10.5,y:1.5},{t:'bookshelf',x:11.5,y:1.5},{t:'table',x:9.5,y:5.5},{t:'chair',x:9.5,y:4.5}],
map:["#############","#...........#","#...Y.......#","#...........#","#...........#","#...........#","#...........#","#####...#####","#############"]},
tavern:{name:'The Tavern',baseTheme:'interior',area:'interior',music:'town',
intro:'The Tavern — warm, loud, and smelling of ale. Patrons crowd the benches.',objective:'Have a look, then leave.',
portals:[{x:6.5,y:7.5,to:'harbor',tx:16.5,ty:5.5,label:'Leave the Tavern'}],
decor:[{t:'counter',x:8.5,y:4.5},{t:'counter',x:9.5,y:4.5},{t:'fireplace',x:2.5,y:1.6},{t:'table',x:3.5,y:5.5},{t:'chair',x:4.5,y:5.5},{t:'barrel',x:11.5,y:1.6}],
map:["#############","#...........#","#.......H...#","#..p........#","#..........p#","#...........#","#...........#","#####...#####","#############"]},
harbor:{name:'The Harbour of Vel-Anor',baseTheme:'city',area:'world',music:'town',
intro:'The Harbour — market stalls, gulls, and the open sea. Enter the Library, Tavern or a Cottage; fish off the dock; play the arcade. The west road leads back to town.',
objective:'Browse the Harbour. The west road ◄ returns to town.',
regions:[{x:1,y:1,w:32,h:9,theme:'city'},{x:1,y:13,w:32,h:9,theme:'beach'}],
venuesData:[{type:'fish',x:14.5,y:11.5},{type:'board',x:24.5,y:8.5}],
portals:[{x:2.5,y:11.5,to:'world',tx:19.5,ty:28.5,label:'Road back to town'},{x:4.5,y:4.5,to:'library',tx:6.5,ty:2.5,label:'Enter the Library'},{x:16.5,y:4.5,to:'tavern',tx:6.5,ty:2.5,label:'Enter the Tavern'},{x:20.5,y:4.5,to:'cottage',tx:6.5,ty:2.5,label:'Enter the Cottage'}],
map:[
"##################################",
"#..l........l.........l..........#",
"#..%%%..%%%....%%%..%%%....p......#",
"#..%%%..%%%....%%%..%%%...........#",
"#....p........p..........p.....a..#",
"#........l..........p............#",
"#..p.......%%%..%%%......p........#",
"#..........%%%..%%%..........p....#",
"#...p..................p.........#",
"#................................#",
"#................................#",
"#..<.............................#",
"#....k...k.....f.......k....k.....#",
"#..~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~.#",
"#..~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~.#",
"#..~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~.#",
"#..~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~.#",
"#..~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~.#",
"#..~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~.#",
"#..~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~.#",
"#................................#",
"##################################"
]},
cave:{name:'The Hollow Caves',baseTheme:'cave',area:'cave',music:'dungeon',depth:1,linkUp:'world',linkDown:'lair',
intro:'Beneath the country — the Hollow Caves: a winding natural cavern. Braziers light the way. Find the deep stair (▼) to the Lich\'s throne; the stair (▲) climbs back to daylight.',objective:'Delve the caves and take the deep stair ▼. ▲ climbs back up.',
map:[
"##########################################################################",
"############################u.############################################",
"###########################............#########...........####...########",
"##########################...............######.............##.....#######",
"####################...##.............b...#####.....................######",
"####################.........h............######....##......Cz.........###",
"####################..B...................#######..###............b.....##",
"####################...............###..C.#######..###...b....g.z.......##",
"####################................#.....######.................o......##",
"###################.z......................#####.......m................##",
"###################.......#.................####.b...........##..........#",
"###################.....C###................o##....g......h..###.........#",
"###################.B....#####...............................###.........#",
"##################..C....######.................g####........###.........#",
"##################......#######....z.##.........######.......###.........#",
"###################....#######......####........#######......####........#",
"###########################........####..........######o.....#####.......#",
"##########################.......z#####............####......#####.......#",
"##########################.......#####..............###....b#####.......##",
"##########################.....#######..............###.....####........##",
"##########################....########.........#....##.......##..o......##",
"###########################.z#########........###..###.........b........##",
"#####################################.........######...#...............###",
"###################################............####...###..............###",
"##################################......####.........####..............###",
"#################################......######.......####...............###",
"#################################.....#######.......####.........b......##",
"##################################...#######........####z....oB...C......#",
"############################################........####....#..........B.#",
"############################################.......####....###...m......##",
"######################################.v###......#####.....##..........###",
"#####################################...####.#########.................###",
"#####################################...#############..................###",
"####################################....#######..####.................####",
"####################################...#######....##..............########",
"###################################...#######..........####..#############",
"###################################..#######..........####################",
"##################################...#####...........#####################",
"##################################...####............#####################",
"##################################....##..............############...#####",
"###################################..........oh.......###########....#####",
"#####################################.....B......##...##########....######",
"######################################...........##....###.h.......#######",
"#######################################.z...z...###.b............m.#######",
"######################################.........###.B................##.z##",
"#####################################B........####.......................#",
"#####################################........#####.......................#",