Skip to content

Commit

Permalink
types: Add types for game-related structures.
Browse files Browse the repository at this point in the history
- Globally exposed the GameEngine type.
- Declared types pertaining to game events.
  • Loading branch information
kuv2707 committed Jun 1, 2024
1 parent e35eb60 commit 57413d6
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions backend/src/types.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// We declare those types which are used throughout the application here.
// For types that are used only in one file, we can declare them in that file itself.

type CardType = 'number' | 'special' | 'wild';

type CardColor = 'red' | 'blue' | 'green' | 'yellow';
Expand All @@ -18,3 +21,31 @@ type Player = {
id: string;
cards: UNOCard[];
};

type EventResult = {
type: 'SUCCESS' | 'ERROR';
message: string;
};

declare global {
type GameEngine = import('./engine').GameEngine;
}

type GameEventType = 'DRAW_CARD' | 'THROW_CARD';

type GameEvent =
| {
type: 'DRAW_CARD';
playerId: string;
data: {
card: UNOCard;
};
}
| {
type: 'THROW_CARD';
playerId: string;
data: {
card: UNOCard;
};
};
//todo: Add more events

0 comments on commit 57413d6

Please sign in to comment.