Newer
Older
PixelPaintWar / apps / server / src / entities / Player.ts
import type { PlayerData } from "@repo/shared/src/types/player";
import { GAME_CONFIG } from "@repo/shared/src/config/gameConfig";

// サーバー側保持プレイヤー状態モデル
export class Player implements PlayerData {
  public id: string;
  public x: number = 0;
  public y: number = 0;
  public teamId: number;

  constructor(id: string) {
    this.id = id;
    
    // GAME_CONFIGからチーム数を動的に取得して割り当て
    const teamCount = GAME_CONFIG.TEAM_COLORS.length;
    this.teamId = Math.floor(Math.random() * teamCount);
  }
}