system message guardados en historial por sala

This commit is contained in:
2025-08-27 18:23:22 -06:00
parent 80af7461a4
commit d7c0b79549
3 changed files with 35 additions and 3 deletions

View File

@@ -6,6 +6,7 @@ import { broadcastDashboardUpdate } from "../adminApi";
export class GameRoom extends Room<GameState> {
maxClients = 2;
private systemMessages: { text: string; kind: string; timestamp: number }[] = [];
getFilterOptions() {
// If waiting for shuffled players, report as available regardless of current client count
@@ -45,6 +46,11 @@ export class GameRoom extends Room<GameState> {
if (kind !== 'round_advance') {
this.recentSystemMessage = { text, kind, timestamp };
}
// Persist in per-room history (keep last 200)
this.systemMessages.push({ text, kind, timestamp });
if (this.systemMessages.length > 200) {
this.systemMessages.splice(0, this.systemMessages.length - 200);
}
this.broadcast("chat", {
id: `${timestamp}-${Math.random().toString(36).slice(2)}`,
@@ -937,6 +943,7 @@ export class GameRoom extends Room<GameState> {
variant: this.state.currentVariant,
round: this.state.currentRound,
recentSystemMessage: this.recentSystemMessage,
systemMessages: this.systemMessages.slice(-50),
decisions: {
p1Action: this.state.p1Action,
p2Action: this.state.p2Action,