@@ -20,6 +20,8 @@ import localStorageDriver from "unstorage/drivers/localstorage";
20
20
import { registerSW } from "virtual:pwa-register" ;
21
21
import { fromZodError } from "zod-validation-error" ;
22
22
import type { Level , Lvl } from "./data/data-types.ts" ;
23
+ import { level0 , level1 , level2 } from "./data/levels.ts" ;
24
+ import { rooms } from "./data/rooms.ts" ;
23
25
import {
24
26
btmStairsSchema ,
25
27
profilesListSchema ,
@@ -28,10 +30,6 @@ import {
28
30
type ProfilesList ,
29
31
type Room ,
30
32
} from "./data/schemas.ts" ;
31
- import gridLvl0 from "./data/level0.ts" ;
32
- import gridLvl1 from "./data/level1.ts" ;
33
- import gridLvl2 from "./data/level2.ts" ;
34
- import { rooms } from "./data/rooms.ts" ;
35
33
import { btmStairs , stairs } from "./data/stairs.ts" ;
36
34
37
35
const updateSW = registerSW ( {
@@ -299,17 +297,17 @@ function printGrid(level: Lvl): void {
299
297
300
298
switch ( level ) {
301
299
case 1 : {
302
- currentGrid = gridLvl1 ;
300
+ currentGrid = level1 ;
303
301
304
302
break ;
305
303
}
306
304
case 2 : {
307
- currentGrid = gridLvl2 ;
305
+ currentGrid = level2 ;
308
306
309
307
break ;
310
308
}
311
309
case 0 : {
312
- currentGrid = gridLvl0 ;
310
+ currentGrid = level0 ;
313
311
314
312
break ;
315
313
}
@@ -475,11 +473,11 @@ function stairPath(x1: number, y1: number, x2: number, y2: number, fl: number) {
475
473
[ sx1 , sy1 ] = stairs [ stairsSchema . parse ( indexmin . toString ( ) ) ] ;
476
474
477
475
if ( fl === 2 ) {
478
- path ( gridLvl2 , x1 , y1 , sx1 , sy1 ) ;
479
- path ( gridLvl1 , sx1 , sy1 , x2 , y2 ) ;
476
+ path ( level2 , x1 , y1 , sx1 , sy1 ) ;
477
+ path ( level1 , sx1 , sy1 , x2 , y2 ) ;
480
478
} else {
481
- path ( gridLvl1 , x1 , y1 , sx1 , sy1 ) ;
482
- path ( gridLvl2 , sx1 , sy1 , x2 , y2 ) ;
479
+ path ( level1 , x1 , y1 , sx1 , sy1 ) ;
480
+ path ( level2 , sx1 , sy1 , x2 , y2 ) ;
483
481
}
484
482
}
485
483
@@ -520,9 +518,9 @@ function btmPath(
520
518
[ sx1 , sy1 ] = btmStairs [ btmStairsSchema . parse ( indexmin . toString ( ) ) ] ;
521
519
522
520
if ( flr1 === 2 ) {
523
- path ( gridLvl2 , x1 , y1 , sx1 , sy1 ) ;
521
+ path ( level2 , x1 , y1 , sx1 , sy1 ) ;
524
522
} else {
525
- path ( gridLvl1 , x1 , y1 , sx1 , sy1 ) ;
523
+ path ( level1 , x1 , y1 , sx1 , sy1 ) ;
526
524
}
527
525
} else if ( flr2 !== 0 ) {
528
526
tempdist1 = Object . values ( btmStairs )
@@ -536,16 +534,16 @@ function btmPath(
536
534
indexmin = tempdist . indexOf ( min ) ;
537
535
[ sx1 , sy1 ] = btmStairs [ btmStairsSchema . parse ( indexmin . toString ( ) ) ] ;
538
536
if ( flr2 === 2 ) {
539
- path ( gridLvl2 , x2 , y2 , sx1 , sy1 ) ;
537
+ path ( level2 , x2 , y2 , sx1 , sy1 ) ;
540
538
} else {
541
- path ( gridLvl1 , x2 , y2 , sx1 , sy1 ) ;
539
+ path ( level1 , x2 , y2 , sx1 , sy1 ) ;
542
540
}
543
541
}
544
542
545
543
if ( flr1 === 0 ) {
546
- path ( gridLvl0 , x1 , y1 , sx1 , sy1 - 8 ) ;
544
+ path ( level0 , x1 , y1 , sx1 , sy1 - 8 ) ;
547
545
} else if ( flr2 === 0 ) {
548
- path ( gridLvl0 , x2 , y2 , sx1 , sy1 - 8 ) ;
546
+ path ( level0 , x2 , y2 , sx1 , sy1 - 8 ) ;
549
547
}
550
548
if ( flr1 === 1 || flr2 === 1 ) {
551
549
mainToBtm ( x1 , y1 , sx1 , sy1 , flr1 , flr2 ) ;
@@ -556,24 +554,24 @@ function clearGrid(): void {
556
554
const img = source ;
557
555
558
556
ctx . drawImage ( img , 0 , 0 , size , size ) ;
559
- for ( let y = 0 ; y < gridLvl0 . length ; y ++ ) {
560
- for ( let x = 0 ; x < ( gridLvl0 [ y ] ?. length ?? 0 ) ; x ++ ) {
561
- if ( gridLvl0 [ x ] ?. [ y ] === - 4 ) {
562
- gridLvl0 [ x ] ! [ y ] = 0 ;
557
+ for ( let y = 0 ; y < level0 . length ; y ++ ) {
558
+ for ( let x = 0 ; x < ( level0 [ y ] ?. length ?? 0 ) ; x ++ ) {
559
+ if ( level0 [ x ] ?. [ y ] === - 4 ) {
560
+ level0 [ x ] ! [ y ] = 0 ;
563
561
}
564
562
}
565
563
}
566
- for ( let y = 0 ; y < gridLvl1 . length ; y ++ ) {
567
- for ( let x = 0 ; x < ( gridLvl1 [ y ] ?. length ?? 0 ) ; x ++ ) {
568
- if ( gridLvl1 [ x ] ?. [ y ] === - 4 ) {
569
- gridLvl1 [ x ] ! [ y ] = 0 ;
564
+ for ( let y = 0 ; y < level1 . length ; y ++ ) {
565
+ for ( let x = 0 ; x < ( level1 [ y ] ?. length ?? 0 ) ; x ++ ) {
566
+ if ( level1 [ x ] ?. [ y ] === - 4 ) {
567
+ level1 [ x ] ! [ y ] = 0 ;
570
568
}
571
569
}
572
570
}
573
- for ( let y = 0 ; y < gridLvl2 . length ; y ++ ) {
574
- for ( let x = 0 ; x < ( gridLvl2 [ y ] ?. length ?? 0 ) ; x ++ ) {
575
- if ( gridLvl2 [ x ] ?. [ y ] === - 4 ) {
576
- gridLvl2 [ x ] ! [ y ] = 0 ;
571
+ for ( let y = 0 ; y < level2 . length ; y ++ ) {
572
+ for ( let x = 0 ; x < ( level2 [ y ] ?. length ?? 0 ) ; x ++ ) {
573
+ if ( level2 [ x ] ?. [ y ] === - 4 ) {
574
+ level2 [ x ] ! [ y ] = 0 ;
577
575
}
578
576
}
579
577
}
@@ -612,10 +610,10 @@ function passingTime(num: number, profNum: number) {
612
610
flr2 = rooms [ end ] [ 2 ] ;
613
611
614
612
if ( flr1 === 1 && flr2 === 1 ) {
615
- grid = gridLvl1 ;
613
+ grid = level1 ;
616
614
path ( grid , x1 , y1 , x2 , y2 ) ;
617
615
} else if ( flr1 === 2 && flr2 === 2 ) {
618
- grid = gridLvl2 ;
616
+ grid = level2 ;
619
617
path ( grid , x1 , y1 , x2 , y2 ) ;
620
618
} else if ( flr1 !== 0 && flr2 !== 0 ) {
621
619
stairPath ( x1 , y1 , x2 , y2 , flr1 ) ;
@@ -696,17 +694,17 @@ let old: number;
696
694
function onKeyDown ( event : KeyboardEvent ) {
697
695
switch ( viewLvl ) {
698
696
case 1 : {
699
- grid = gridLvl1 ;
697
+ grid = level1 ;
700
698
701
699
break ;
702
700
}
703
701
case 2 : {
704
- grid = gridLvl2 ;
702
+ grid = level2 ;
705
703
706
704
break ;
707
705
}
708
706
case 0 : {
709
- grid = gridLvl0 ;
707
+ grid = level0 ;
710
708
711
709
break ;
712
710
}
0 commit comments