diff --git a/apps/client/src/scenes/game/application/GameLoop.ts b/apps/client/src/scenes/game/application/GameLoop.ts index 4fc4139..6a67d2e 100644 --- a/apps/client/src/scenes/game/application/GameLoop.ts +++ b/apps/client/src/scenes/game/application/GameLoop.ts @@ -6,9 +6,9 @@ import { Application, Container, Ticker } from "pixi.js"; import { config } from "@client/config"; import { LocalPlayerController } from "@client/scenes/game/entities/player/PlayerController"; +import { PlayerRepository } from "@client/scenes/game/entities/player/PlayerRepository"; import { BombManager } from "@client/scenes/game/entities/bomb/BombManager"; import type { GamePlayers } from "./game.types"; -import { PlayerRepository } from "./player/PlayerRepository"; import { InputStep } from "./loopSteps/InputStep"; import { SimulationStep } from "./loopSteps/SimulationStep"; import { CameraStep } from "./loopSteps/CameraStep"; diff --git a/apps/client/src/scenes/game/application/GameNetworkSync.ts b/apps/client/src/scenes/game/application/GameNetworkSync.ts index bc3318f..22f35d8 100644 --- a/apps/client/src/scenes/game/application/GameNetworkSync.ts +++ b/apps/client/src/scenes/game/application/GameNetworkSync.ts @@ -22,7 +22,7 @@ toRemoteBombPlacedPayload, toRemotePlayerDeadPayload, } from "./network/adapters/GameNetworkEventAdapter"; -import { PlayerRepository } from "./player/PlayerRepository"; +import { PlayerRepository } from "@client/scenes/game/entities/player/PlayerRepository"; import { PlayerSyncHandler } from "./network/handlers/PlayerSyncHandler"; import { MapSyncHandler } from "./network/handlers/MapSyncHandler"; import { CombatSyncHandler } from "./network/handlers/CombatSyncHandler"; diff --git a/apps/client/src/scenes/game/application/loopSteps/LoopStep.ts b/apps/client/src/scenes/game/application/loopSteps/LoopStep.ts index 2e3c883..ac8d393 100644 --- a/apps/client/src/scenes/game/application/loopSteps/LoopStep.ts +++ b/apps/client/src/scenes/game/application/loopSteps/LoopStep.ts @@ -5,7 +5,7 @@ */ import type { Application, Container } from "pixi.js"; import type { LocalPlayerController } from "@client/scenes/game/entities/player/PlayerController"; -import type { PlayerRepository } from "@client/scenes/game/application/player/PlayerRepository"; +import type { PlayerRepository } from "@client/scenes/game/entities/player/PlayerRepository"; /** 1フレーム分の更新文脈を表す型 */ export type LoopFrameContext = { diff --git a/apps/client/src/scenes/game/application/loopSteps/SimulationStep.ts b/apps/client/src/scenes/game/application/loopSteps/SimulationStep.ts index 59beed9..e34a162 100644 --- a/apps/client/src/scenes/game/application/loopSteps/SimulationStep.ts +++ b/apps/client/src/scenes/game/application/loopSteps/SimulationStep.ts @@ -5,8 +5,8 @@ */ import { config } from "@client/config"; import { LocalPlayerController, RemotePlayerController } from "@client/scenes/game/entities/player/PlayerController"; +import type { PlayerRepository } from "@client/scenes/game/entities/player/PlayerRepository"; import type { MoveSender } from "@client/scenes/game/application/network/PlayerMoveSender"; -import type { PlayerRepository } from "../player/PlayerRepository"; import type { LoopFrameContext, LoopStep } from "./LoopStep"; /** SimulationStep の初期化入力 */ diff --git a/apps/client/src/scenes/game/application/player/PlayerRepository.ts b/apps/client/src/scenes/game/application/player/PlayerRepository.ts index cb51025..19466a2 100644 --- a/apps/client/src/scenes/game/application/player/PlayerRepository.ts +++ b/apps/client/src/scenes/game/application/player/PlayerRepository.ts @@ -1,49 +1,8 @@ /** * PlayerRepository - * プレイヤー集合の更新窓口を提供する - * 参照と更新を集約して副作用の追跡を容易にする + * entities層のPlayerRepositoryを段階移行のため再公開する + * 既存import互換を維持して移行コストを抑える */ -import type { - GamePlayerController, - GamePlayers, -} from "@client/scenes/game/application/game.types"; -/** プレイヤー集合の更新と参照を管理するリポジトリ */ -export class PlayerRepository { - private readonly players: GamePlayers; - - constructor(players: GamePlayers = {}) { - this.players = players; - } - - /** プレイヤーIDでコントローラーを取得する */ - public getById(playerId: string): GamePlayerController | undefined { - return this.players[playerId]; - } - - /** プレイヤーを追加または更新する */ - public upsert(playerId: string, controller: GamePlayerController): void { - this.players[playerId] = controller; - } - - /** プレイヤーを削除して削除対象を返す */ - public remove(playerId: string): GamePlayerController | undefined { - const target = this.players[playerId]; - if (!target) { - return undefined; - } - - delete this.players[playerId]; - return target; - } - - /** 管理中プレイヤー配列を返す */ - public values(): GamePlayerController[] { - return Object.values(this.players); - } - - /** 内部で保持するプレイヤー集合を返す */ - public toRecord(): GamePlayers { - return this.players; - } -} \ No newline at end of file +/** entities層のPlayerRepositoryを互換再エクスポートする */ +export { PlayerRepository } from "@client/scenes/game/entities/player/PlayerRepository"; \ No newline at end of file diff --git a/apps/client/src/scenes/game/application/presentation/GameUiPresenter.ts b/apps/client/src/scenes/game/application/presentation/GameUiPresenter.ts deleted file mode 100644 index b9b8cec..0000000 --- a/apps/client/src/scenes/game/application/presentation/GameUiPresenter.ts +++ /dev/null @@ -1,25 +0,0 @@ -/** - * GameUiPresenter - * ゲーム画面の表示用データ変換を提供する - * 残り時間と開始カウントダウンの表示生成を扱う - */ -import { config } from "@client/config"; - -/** 残り秒数を mm:ss 形式へ変換する */ -export const formatRemainingTime = (remainingSec: number): string => { - const mins = Math.floor(remainingSec / 60); - const secs = Math.floor(remainingSec % 60); - return `${mins}:${secs.toString().padStart(2, "0")}`; -}; - -/** 開始カウントダウン表示文字列を生成する */ -export const buildStartCountdownText = ( - remainingSec: number, -): string | null => { - return remainingSec > 0 ? String(remainingSec) : null; -}; - -/** ゲーム画面の初期残り時間表示を返す */ -export const getInitialTimeDisplay = (): string => { - return formatRemainingTime(config.GAME_CONFIG.GAME_DURATION_SEC); -}; \ No newline at end of file diff --git a/apps/client/src/scenes/game/entities/player/PlayerRepository.ts b/apps/client/src/scenes/game/entities/player/PlayerRepository.ts new file mode 100644 index 0000000..cb51025 --- /dev/null +++ b/apps/client/src/scenes/game/entities/player/PlayerRepository.ts @@ -0,0 +1,49 @@ +/** + * PlayerRepository + * プレイヤー集合の更新窓口を提供する + * 参照と更新を集約して副作用の追跡を容易にする + */ +import type { + GamePlayerController, + GamePlayers, +} from "@client/scenes/game/application/game.types"; + +/** プレイヤー集合の更新と参照を管理するリポジトリ */ +export class PlayerRepository { + private readonly players: GamePlayers; + + constructor(players: GamePlayers = {}) { + this.players = players; + } + + /** プレイヤーIDでコントローラーを取得する */ + public getById(playerId: string): GamePlayerController | undefined { + return this.players[playerId]; + } + + /** プレイヤーを追加または更新する */ + public upsert(playerId: string, controller: GamePlayerController): void { + this.players[playerId] = controller; + } + + /** プレイヤーを削除して削除対象を返す */ + public remove(playerId: string): GamePlayerController | undefined { + const target = this.players[playerId]; + if (!target) { + return undefined; + } + + delete this.players[playerId]; + return target; + } + + /** 管理中プレイヤー配列を返す */ + public values(): GamePlayerController[] { + return Object.values(this.players); + } + + /** 内部で保持するプレイヤー集合を返す */ + public toRecord(): GamePlayers { + return this.players; + } +} \ No newline at end of file diff --git a/apps/client/src/scenes/game/hooks/useGameSceneController.ts b/apps/client/src/scenes/game/hooks/useGameSceneController.ts index 4a1ff5b..079c232 100644 --- a/apps/client/src/scenes/game/hooks/useGameSceneController.ts +++ b/apps/client/src/scenes/game/hooks/useGameSceneController.ts @@ -9,7 +9,7 @@ buildStartCountdownText, formatRemainingTime, getInitialTimeDisplay, -} from "@client/scenes/game/application/presentation/GameUiPresenter"; +} from "@client/scenes/game/input/presentation/GameUiPresenter"; /** ゲーム画面の状態と入力ハンドラを提供するフック */ export const useGameSceneController = (myId: string | null) => { diff --git a/apps/client/src/scenes/game/input/presentation/GameUiPresenter.ts b/apps/client/src/scenes/game/input/presentation/GameUiPresenter.ts new file mode 100644 index 0000000..b9b8cec --- /dev/null +++ b/apps/client/src/scenes/game/input/presentation/GameUiPresenter.ts @@ -0,0 +1,25 @@ +/** + * GameUiPresenter + * ゲーム画面の表示用データ変換を提供する + * 残り時間と開始カウントダウンの表示生成を扱う + */ +import { config } from "@client/config"; + +/** 残り秒数を mm:ss 形式へ変換する */ +export const formatRemainingTime = (remainingSec: number): string => { + const mins = Math.floor(remainingSec / 60); + const secs = Math.floor(remainingSec % 60); + return `${mins}:${secs.toString().padStart(2, "0")}`; +}; + +/** 開始カウントダウン表示文字列を生成する */ +export const buildStartCountdownText = ( + remainingSec: number, +): string | null => { + return remainingSec > 0 ? String(remainingSec) : null; +}; + +/** ゲーム画面の初期残り時間表示を返す */ +export const getInitialTimeDisplay = (): string => { + return formatRemainingTime(config.GAME_CONFIG.GAME_DURATION_SEC); +}; \ No newline at end of file