Skip to content

Commit 14ace4d

Browse files
committed
feat: update game types
1 parent 43edebe commit 14ace4d

File tree

1 file changed

+48
-14
lines changed

1 file changed

+48
-14
lines changed

electron/main/game/game.types.ts

+48-14
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@ export type GameEvent =
1515
| CompassGameEvent
1616
| VitalsProgressBarGameEvent
1717
| ExperienceGameEvent
18-
| PromptGameEvent
19-
| RoundtimeGameEvent;
18+
| RoomGameEvent
19+
| ServerTimeGameEvent
20+
| RoundTimeGameEvent;
2021

2122
/**
2223
* Indicates text to display to the player.
@@ -121,7 +122,7 @@ export interface CompassGameEvent {
121122
* <progressBar id='mana' value='100'/>
122123
*/
123124
export interface VitalsProgressBarGameEvent {
124-
type: GameEventType.VITALS_PROGRESS_BAR;
125+
type: GameEventType.VITALS;
125126
vitalId: string; // health, mana, concentration, spirit, stamina
126127
value: number; // 0-100 (percentage)
127128
}
@@ -140,19 +141,40 @@ export interface ExperienceGameEvent {
140141
mindState: string; // e.g. 'clear', 'pondering', 'mind lock', etc.
141142
}
142143

144+
/**
145+
* One or more properties might be specified.
146+
* If defined then that property has changed.
147+
* If undefined then that property has not changed.
148+
*
149+
* <streamWindow id='room' title='Room' subtitle=" - [The Crossing, Hodierna Way]"/>
150+
* <component id='room desc'>The hustle...</component>
151+
* <component id='room objs'>You also see ...</component>
152+
* <component id='room players'>Also here: Katoak.</component>
153+
* <component id='room exits'>Obvious paths: <d>east</d>, <d>southwest</d>, <d>northwest</d>.<compass></compass></component>
154+
*/
155+
export interface RoomGameEvent {
156+
type: GameEventType.ROOM;
157+
roomName?: string;
158+
roomDescription?: string;
159+
roomCreatures?: string;
160+
roomObjects?: string;
161+
roomPlayers?: string;
162+
roomExits?: string;
163+
}
164+
143165
/**
144166
* <prompt time="1703617000">&gt;</prompt>
145167
*/
146-
export interface PromptGameEvent {
147-
type: GameEventType.PROMPT;
168+
export interface ServerTimeGameEvent {
169+
type: GameEventType.SERVER_TIME;
148170
time: number;
149171
}
150172

151173
/**
152174
* <roundTime value='1703617016'/>
153175
*/
154-
export interface RoundtimeGameEvent {
155-
type: GameEventType.ROUNDTIME;
176+
export interface RoundTimeGameEvent {
177+
type: GameEventType.ROUND_TIME;
156178
time: number;
157179
}
158180

@@ -214,26 +236,31 @@ export enum GameEventType {
214236
*/
215237
COMPASS = 'COMPASS',
216238
/**
217-
* Indicates one of the character's vital progress bars.
218-
* For example, health, energy (mana, conc. or inner fire), stamina, spirit
239+
* Indicates one of the character's vitals.
240+
* For example, health, energy (mana, conc. or inner fire), stamina, spirit.
219241
*/
220-
VITALS_PROGRESS_BAR = 'VITALS_PROGRESS_BAR',
242+
VITALS = 'VITALS',
221243
/**
222244
* Indicates a change in the character's experience for a specific skill.
223245
*/
224246
EXPERIENCE = 'EXPERIENCE',
225247
/**
226-
* Tells us the game server time, as well as outputting a `>` line
227-
* to the main game window.
248+
* Indicates a change in the current room.
249+
* For example, the name, description, attendees, etc.
228250
*/
229-
PROMPT = 'PROMPT',
251+
ROOM = 'ROOM',
252+
/**
253+
* Tells us the game server time.
254+
* Use this in round time and cast time calculations.
255+
*/
256+
SERVER_TIME = 'SERVER_TIME',
230257
/**
231258
* Indicates the character took an action that they must now wait
232259
* until the game server time reaches the specified roundtime.
233260
* Subtracting the roundtime from the current game time tells you
234261
* the number of seconds to wait.
235262
*/
236-
ROUNDTIME = 'ROUNDTIME',
263+
ROUND_TIME = 'ROUND_TIME',
237264
}
238265

239266
export enum IndicatorType {
@@ -305,3 +332,10 @@ export interface GameSocket {
305332
*/
306333
send(command: string): void;
307334
}
335+
336+
export interface GameParser {
337+
/**
338+
* Parses the game socket stream to emit game events.
339+
*/
340+
parse(gameSocketStream: rxjs.Observable<string>): rxjs.Observable<GameEvent>;
341+
}

0 commit comments

Comments
 (0)