Files
gridpilot.gg/core/racing/domain/entities/Game.ts
2025-12-29 18:34:12 +01:00

30 lines
725 B
TypeScript

import type { IEntity } from '@core/shared/domain';
import { GameId } from './GameId';
import { GameName } from './GameName';
export class Game implements IEntity<GameId> {
readonly id: GameId;
readonly name: GameName;
private constructor(props: { id: GameId; name: GameName }) {
this.id = props.id;
this.name = props.name;
}
static create(props: { id: string; name: string }): Game {
const id = GameId.create(props.id);
const name = GameName.create(props.name);
return new Game({
id,
name,
});
}
static rehydrate(props: { id: string; name: string }): Game {
return new Game({
id: GameId.create(props.id),
name: GameName.create(props.name),
});
}
}