-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.d.ts
162 lines (140 loc) · 3.2 KB
/
index.d.ts
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
import type { AiName } from '$lib/Ai';
import type { DoodadName } from '$lib/Doodad';
import type { Level } from '$lib/Level';
import type { ColorRepresentation } from 'three';
export type Position2d = [number, number];
export type Map2d = number[][];
export type GameState = (
| {
state: 'main' | 'control' | 'editor';
running: 'newGame' | 'continue';
}
| {
state: 'running' | 'stats' | 'inventory' | 'container';
running: 'continue' | 'gameOver';
}
) & {
isLoading: boolean;
};
export interface Store {
game: GameState;
levels: Level[];
currentLevelNumber: number;
screen: {
shaking: boolean;
dirty: boolean;
};
}
export interface LevelProp {
width: number;
height: number;
floor: string;
ceiling: string;
collisionMap: Map2d;
textureMap: string[][];
lights: Light[];
scripts: Script[];
}
export type Doodad = {
id: number;
type: DoodadName;
collision?: boolean;
interactive?: boolean;
texture: string[];
color?: ColorRepresentation;
z?: number;
} & OrientedPosition;
export type Npc = {
id: number;
type: 'npc';
name: string;
collision?: boolean;
texture: string[];
dialogs: string[];
color?: number;
depth?: number;
z?: number;
} & OrientedPosition;
export type AiMode = 'idle' | 'attack-on-sight';
export type Ai = {
id: number;
type: 'ai';
name: AiName;
mode: AiMode;
collision?: boolean;
texture: string[];
color?: number;
stats: Stats;
loot?: ItemName;
xp: number;
} & OrientedPosition;
export type Panel = {
id: number;
type: 'panel';
collision?: boolean;
texture: string[];
color?: ColorRepresentation;
content: string[];
} & OrientedPosition;
export type Loot = {
id: number;
type: 'loot';
name: ItemName;
texture: string[];
collision?: boolean;
color?: ColorRepresentation;
} & OrientedPosition;
export type Container = {
id: number;
type: 'container';
name: string;
texture: string[];
collision?: boolean;
content: ItemName[];
} & OrientedPosition;
export type Script = Doodad | Ai | Npc | Loot | Panel | Container;
export interface OrientedPosition {
x: number;
y: number;
t: number;
}
export interface BaseStats {
strength: number;
dexterity: number;
wisdom: number;
}
export type BaseStatsName = keyof BaseStats;
export interface Stats {
hp: number;
maxHp: number;
ac: number;
hit: number;
pDefense: number;
pAttack: number;
}
export interface Inventory {
mainHand: Item | null;
offHand: Item | null;
armor: Item | null;
bag: Item[];
}
type ItemName = 'sword' | 'shield' | 'armor' | 'key' | 'not-found';
export interface Item {
name: ItemName;
texture: string;
slot: 'mainHand' | 'offHand' | 'armor' | 'none';
baseStats: BaseStats;
stats: Stats;
cooldown: number;
lastAttackTimestamp: number;
}
export interface UI {
weaponCooldownPercent: number;
}
export type Light = { id: number } & OrientedPosition;
export type Tile = {
collision: boolean;
light?: Light;
texture: string;
script?: Script;
} & OrientedPosition;