Skip to content

Commit b2d7538

Browse files
committed
feat: move game code to common types
1 parent bcfb528 commit b2d7538

File tree

2 files changed

+65
-5
lines changed

2 files changed

+65
-5
lines changed

electron/common/game/types.ts

+58
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,61 @@
1+
/**
2+
* Simutronics has multiple games and instances per game.
3+
* Only interested in DragonRealms, though.
4+
*/
5+
export enum GameCode {
6+
PRIME = 'DR',
7+
PLATINUM = 'DRX',
8+
FALLEN = 'DRF',
9+
TEST = 'DRT',
10+
DEVELOPMENT = 'DRD',
11+
}
12+
13+
export interface GameCodeMeta {
14+
/**
15+
* The game code.
16+
* Example: 'DR' or 'DRX'.
17+
*/
18+
code: GameCode;
19+
/**
20+
* The code name.
21+
* Example: 'Prime' or 'Platinum'.
22+
*/
23+
name: string;
24+
/**
25+
* The game name.
26+
* Example: 'DragonRealms'.
27+
*/
28+
game: string;
29+
}
30+
31+
export const GameCodeMetaMap: Record<GameCode, GameCodeMeta> = {
32+
DR: {
33+
code: GameCode.PRIME,
34+
name: 'Prime',
35+
game: 'DragonRealms',
36+
},
37+
DRX: {
38+
code: GameCode.PLATINUM,
39+
name: 'Platinum',
40+
game: 'DragonRealms',
41+
},
42+
DRF: {
43+
code: GameCode.FALLEN,
44+
name: 'Fallen',
45+
game: 'DragonRealms',
46+
},
47+
DRT: {
48+
code: GameCode.TEST,
49+
name: 'Test',
50+
game: 'DragonRealms',
51+
},
52+
DRD: {
53+
code: GameCode.DEVELOPMENT,
54+
name: 'Development',
55+
game: 'DragonRealms',
56+
},
57+
};
58+
159
/**
260
* Events emitted by the game parser of data received from the game socket.
361
*/

electron/main/sge/types.ts

+7-5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { GameCode } from '../../common/game/types.js';
2+
13
export enum SGEGameProtocol {
24
STORMFRONT = 'STORM',
35
}
@@ -7,11 +9,11 @@ export enum SGEGameProtocol {
79
* Only interested in DragonRealms, though.
810
*/
911
export enum SGEGameCode {
10-
DRAGONREALMS_PRIME = 'DR',
11-
DRAGONREALMS_DEVELOPMENT = 'DRD',
12-
DRAGONREALMS_THE_FALLEN = 'DRF',
13-
DRAGONREALMS_PRIME_TEST = 'DRT',
14-
DRAGONREALMS_PLATINUM = 'DRX',
12+
DRAGONREALMS_PRIME = GameCode.PRIME,
13+
DRAGONREALMS_FALLEN = GameCode.FALLEN,
14+
DRAGONREALMS_PLATINUM = GameCode.PLATINUM,
15+
DRAGONREALMS_TEST = GameCode.TEST,
16+
DRAGONREALMS_DEVELOPMENT = GameCode.DEVELOPMENT,
1517
}
1618

1719
export interface SGEGame {

0 commit comments

Comments
 (0)