@battle-racing/br-common-lib
Version:
Common library for all Battle Racing Repositorios
42 lines (38 loc) • 1.17 kB
text/typescript
import type { GameTrack } from '../gameTrack';
import type { PowerUp } from '../powerUp';
import type { GameStatus } from './GameStatus';
import type { GameType } from './GameType';
import type { KartRankingItem } from './KartRankingItem';
export enum GameFinishedReason {
/** The time set for the game was over */
TIME_IS_OVER = 'TIME_IS_OVER',
/** There is a winner on the game */
GAME_KARTS_FINISHED = 'GAME_KARTS_FINISHED',
/** The game was stopped by an emergency */
EMERGENCY = 'EMERGENCY',
/** The Controller of the game finished the game */
BY_CONTROLLER = 'BY_CONTROLLER',
}
export interface GameKartState {
coins: number;
}
export interface Game {
id: number;
status: GameStatus;
kartsGuids: string[];
powerUpsIds: PowerUp['id'][];
gameTrackId: GameTrack['id'];
type: GameType;
coins: number;
/** Time set in seconds */
time: number;
/** Speed % will be the default for the game */
speedConfig: number;
createdAt: Date;
startedAt?: Date;
finishedAt?: Date;
finishedReason?: GameFinishedReason;
/** The key is the kart guid */
kartsState: Record<string, GameKartState>;
gameRanking: KartRankingItem[];
}