방 설정 "컴퓨터 채팅": 컴퓨터가 혼자 말하는 건 방장이 켤 때만(기본 끄기), 마피아는 항상 켜짐

- RoomConfig/RoomView.botChat, config 메시지에 botChat. 새 방·옛 방 모두 끄기.
- BotBrain: 꺼져 있으면 도발·반응·대답·시작 인사·끝 인사 안 함, 모델 미리 올리기도 안 함.
  바퀴벌레 포커 진짜/블러핑 판단은 그대로, 한마디만 뺌.
- BOT_CHAT_REQUIRED(마피아): 설정과 상관없이 항상 켜짐, 설정 칸에 "항상 켜짐" 표시.
- 대기실 설정에 컴퓨터 채팅 켜기/끄기(컴퓨터 상대가 있는 게임만).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
EJClaw
2026-10-12 21:59:30 +09:00
parent bd179c7a43
commit 2ec622ebf6
9 changed files with 113 additions and 13 deletions

View File

@@ -115,6 +115,7 @@ export class RoomManager {
allowSpectators: true,
chatEnabled: site?.chatEnabledDefault ?? true,
chatFilter: site?.chatFilterDefault ?? true,
botChat: false,
graceSec: site?.graceSec ?? 60,
};
const code = this.newCode();

View File

@@ -4,7 +4,7 @@
*/
import { ulid } from 'ulid';
import { SeededRng, createSeed, secureRandom, seedToHex, type AnyGameDefinition, type ChaChaSeed, type GameResult, type RngState } from '@bg/engine';
import { botsAllowed, isBotId, makeBotId, botNumber, maskProfanity, type BotPick, type PublicUser, type RoomView, type ServerMessage, type SeatView } from '@bg/shared';
import { botChatRequired, botsAllowed, isBotId, makeBotId, botNumber, maskProfanity, type BotPick, type PublicUser, type RoomView, type ServerMessage, type SeatView } from '@bg/shared';
import { botPersona } from '@bg/games/bots';
import { luckApplies, shufflesFor, type LuckJob } from '@bg/games/bots/luck';
import { sha256Hex } from '../auth/sessions';
@@ -29,6 +29,8 @@ export interface RoomConfig {
allowSpectators: boolean;
chatEnabled: boolean;
chatFilter: boolean;
/** Computers chat on their own (docs/06 §12.1). Off unless the host turns it on; rooms saved before it existed read as off. */
botChat?: boolean;
/** Seconds a disconnected player keeps their turn timer before auto actions kick in (docs/03 §6.2). */
graceSec: number;
}
@@ -189,6 +191,7 @@ export class Room {
},
recentChat: () => this.chatLog.slice(-8).map((m) => ({ from: m.from?.nickname ?? '누군가', text: m.text })),
smart: (bot) => botPersona(bot, this.profile(bot).base).smart,
chatty: () => this.botChatOn(),
now: this.now,
},
deps.ai ?? null,
@@ -222,6 +225,11 @@ export class Room {
);
}
/** The computers' own chat: the room setting, or always where the game needs it (마피아). */
private botChatOn(): boolean {
return botChatRequired(this.config.gameId) || this.config.botChat === true;
}
get def(): AnyGameDefinition {
const d = this.deps.games[this.config.gameId];
if (!d) throw new Error(`unknown game ${this.config.gameId}`);
@@ -411,6 +419,7 @@ export class Room {
allowSpectators: this.config.allowSpectators,
chatEnabled: this.config.chatEnabled,
chatFilter: this.config.chatFilter,
botChat: this.botChatOn(),
seats,
spectators: [...this.spectators].map(pub),
status: this.status,
@@ -689,7 +698,7 @@ export class Room {
else if (next.gameId === this.config.gameId && this.config.maxPlayers === this.playerRange().max) next.maxPlayers = range.max;
next.maxPlayers = Math.min(Math.max(next.maxPlayers, range.min), range.max);
if (next.maxPlayers < this.seatedIds().length) return `이미 ${this.seatedIds().length}명이 앉아 있어요.`;
for (const k of ['visibility', 'allowSpectators', 'chatEnabled', 'chatFilter'] as const) {
for (const k of ['visibility', 'allowSpectators', 'chatEnabled', 'chatFilter', 'botChat'] as const) {
if (patch[k] !== undefined) (next as unknown as Record<string, unknown>)[k] = patch[k];
}
// Resize seats, compacting occupied seats to the front if needed.