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),
    });
  }
}