Refactor: Remove audio processing and game state management modules

This commit is contained in:
2025-10-15 23:33:40 +02:00
parent 56d7511bd6
commit 58c668de63
69 changed files with 5836 additions and 1319 deletions

View File

@@ -0,0 +1,79 @@
import type { ID, Player } from '../types.ts';
/**
* Player domain model
* Represents a player in the game with their connection state
*/
export class PlayerModel implements Player {
id: ID;
sessionId: ID;
name: string;
connected: boolean;
roomId: ID | null;
spectator?: boolean;
constructor(
id: ID,
sessionId: ID,
name?: string,
connected = true,
roomId: ID | null = null,
) {
this.id = id;
this.sessionId = sessionId;
this.name = name || `Player-${id.slice(0, 4)}`;
this.connected = connected;
this.roomId = roomId;
}
/**
* Update player's connection status
*/
setConnected(connected: boolean): void {
this.connected = connected;
}
/**
* Update player's name
*/
setName(name: string): void {
if (name && name.trim().length > 0) {
this.name = name.trim();
}
}
/**
* Join a room
*/
joinRoom(roomId: ID): void {
this.roomId = roomId;
}
/**
* Leave current room
*/
leaveRoom(): void {
this.roomId = null;
}
/**
* Toggle spectator mode
*/
setSpectator(spectator: boolean): void {
this.spectator = spectator;
}
/**
* Create a safe representation for serialization
*/
toJSON(): Player {
return {
id: this.id,
sessionId: this.sessionId,
name: this.name,
connected: this.connected,
roomId: this.roomId,
spectator: this.spectator,
};
}
}