diff --git a/apps/server/src/entities/Player.ts b/apps/server/src/entities/Player.ts index 33c3cfc..cac7401 100644 --- a/apps/server/src/entities/Player.ts +++ b/apps/server/src/entities/Player.ts @@ -1,4 +1,5 @@ import type { PlayerData } from "@repo/shared/src/types/player"; +import { GAME_CONFIG } from "@repo/shared/src/config/gameConfig"; // サーバー側保持プレイヤー状態モデル export class Player implements PlayerData { @@ -10,7 +11,8 @@ constructor(id: string) { this.id = id; - // 0〜3 範囲ランダムチームID割り当て - this.teamId = Math.floor(Math.random() * 4); + // GAME_CONFIGからチーム数を動的に取得して割り当て + const teamCount = GAME_CONFIG.TEAM_COLORS.length; + this.teamId = Math.floor(Math.random() * teamCount); } } \ No newline at end of file diff --git a/apps/server/src/managers/GameManager.ts b/apps/server/src/managers/GameManager.ts index c39ca32..73c7dd2 100644 --- a/apps/server/src/managers/GameManager.ts +++ b/apps/server/src/managers/GameManager.ts @@ -1,4 +1,5 @@ import { Player } from "../entities/Player.js"; +import { GAME_CONFIG } from "@repo/shared/src/config/gameConfig"; // プレイヤー集合の生成・更新・参照管理クラス export class GameManager { @@ -13,8 +14,8 @@ const player = new Player(id); // 初期スポーン位置 - player.x = 1000; - player.y = 1000; + player.x = GAME_CONFIG.MAP_WIDTH / 2; + player.y = GAME_CONFIG.MAP_HEIGHT / 2; this.players.set(id, player); return player; diff --git "a/docs/01_Env/ENV_01_\347\222\260\345\242\203\346\247\213\347\257\211\343\203\273\346\212\200\350\241\223\343\202\271\343\202\277\343\203\203\343\202\257.txt" "b/docs/01_Env/ENV_01_\347\222\260\345\242\203\346\247\213\347\257\211\343\203\273\346\212\200\350\241\223\343\202\271\343\202\277\343\203\203\343\202\257.txt" index fd36c35..2af0301 100644 --- "a/docs/01_Env/ENV_01_\347\222\260\345\242\203\346\247\213\347\257\211\343\203\273\346\212\200\350\241\223\343\202\271\343\202\277\343\203\203\343\202\257.txt" +++ "b/docs/01_Env/ENV_01_\347\222\260\345\242\203\346\247\213\347\257\211\343\203\273\346\212\200\350\241\223\343\202\271\343\202\277\343\203\203\343\202\257.txt" @@ -43,10 +43,11 @@ │ ├── client/ # 【演出】フロントエンド (Browser) │ │ ├── src/ │ │ │ ├── assets/ # 画像・音声リソース - │ │ │ ├── entities/ # クライアント側エンティティ (Player, GameMap など) - │ │ │ ├── input/ # 入力処理 (Joystick, Keyboard) - │ │ │ ├── network/ # 通信処理 (SocketClient, Reconciler/補正処理) - │ │ │ ├── scenes/ # 画面管理 (Title, Lobby, Game, Result) + │ │ │ ├── entities/ # ゲーム内オブジェクト(Player, GameMap) + │ │ │ ├── input/ # 入力処理 (VirtualJoystick) + │ │ │ ├── managers # 状態管理・エンジン制御(GameManager) + │ │ │ ├── network/ # 通信処理 (SocketClient) + │ │ │ ├── scenes/ # 画面管理 (Title, Lobby, GameScene) │ │ │ └── main.ts # エントリーポイント │ │ ├── index.html │ │ ├── vite.config.ts @@ -54,9 +55,9 @@ │ │ │ └── server/ # 【権限】バックエンド (Node.js) │ ├── src/ - │ │ ├── entities/ # サーバー側エンティティ (Player, Item - 状態管理のみ) - │ │ ├── managers/ # 管理クラス (RoomManager, ScoreManager) - │ │ ├── network/ # WebSocket処理 (Connection, PacketHandler) + │ │ ├── entities/ # サーバー側エンティティ (Player) + │ │ ├── managers/ # 管理クラス (GameManager) + │ │ ├── network/ # WebSocket処理 (SocketManager) │ │ └── index.ts # エントリーポイント │ ├── tsconfig.json │ └── package.json @@ -64,9 +65,9 @@ └── packages/ └── shared/ # 【最重要】「真実」の定義場所(型、定数、純粋ロジック) ├── src/ - │ ├── config/ # ゲーム定数 (マップサイズ, TickRate, 物理定数) - │ ├── protocol/ # 通信規約 (パケット構造, OpCode, バイナリ定義) - │ ├── types/ # 型定義 (PlayerState, InputData, RoomInfo) + │ ├── config/ # 共通定数(gameConfig.ts) + │ ├── protocol/ # 通信イベント定義(events.ts) + │ ├── types/ # 型定義(player.ts, room.ts) │ └── index.ts # エントリーポイント (tsupビルド対象) ├── tsup.config.ts # ビルド設定 └── package.json