system message guardados en historial por sala
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user