채팅 소리 기본 크기를 게임 소리의 80%로 올리고(60%는 너무 안 들린다는 의견), 관리자 사이트 설정에 "채팅 소리 크기"(게임 소리의 0~200%, 정수, 기본 80%)를 추가. 0%면 채팅 소리 없음. 각자의 소리 크기(0~100)는 그대로 곱해짐. 저장하면 /api/config와 방 정보(RoomView.chatSound)로 열린 방에도 바로 적용. 설정 화면에 저장 없이 그 값으로 울려 보는 "들어 보기" 버튼. feedback.test.ts·admin.test.ts·admin.e2e.ts에 확인 추가, docs/14-admin.md 표에 항목 추가

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
EJClaw
2026-10-15 00:45:33 +09:00
parent 42e8d7650b
commit b61be627c9
14 changed files with 153 additions and 17 deletions

View File

@@ -223,6 +223,32 @@ describe('site settings, rooms, users', () => {
expect((await next).room.gameSpeed).toBe(2);
});
test('chat sound: 0~200% (default 80), shown in /api/config and open rooms, out of range rejected', async () => {
const s = start();
const sup = await discordLogin(s, SUPER);
const site = (await api(s.base, '/api/admin/site', { cookie: sup.cookie })).body.site;
expect(site.chatSound).toBe(80);
expect((await api(s.base, '/api/config')).body.chatSound).toBe(80);
for (const bad of [-1, 201, 50.5]) {
const r = await api(s.base, '/api/admin/site', { method: 'PUT', cookie: sup.cookie, body: JSON.stringify({ ...site, chatSound: bad }) });
expect(r.res.status).toBe(400);
}
for (const ok of [0, 200, 120]) {
const r = await api(s.base, '/api/admin/site', { method: 'PUT', cookie: sup.cookie, body: JSON.stringify({ ...site, chatSound: ok }) });
expect(r.res.status).toBe(200);
expect((await api(s.base, '/api/config')).body.chatSound).toBe(ok);
}
const g = await guest(s.base, '방장님');
const room = await api(s.base, '/api/rooms', { method: 'POST', cookie: g.cookie, body: JSON.stringify({ gameId: 'omok' }) });
const c = await new Client(s.base, g.cookie, g.id).connect();
clients.push(c);
c.send({ t: 'join', code: room.body.code, as: 'player' });
expect((await c.next('room')).room.chatSound).toBe(120);
const next = c.next('room');
await api(s.base, '/api/admin/site', { method: 'PUT', cookie: sup.cookie, body: JSON.stringify({ ...site, chatSound: 30 }) });
expect((await next).room.chatSound).toBe(30);
});
test('admin closes a room: everyone is told and disconnected from it', async () => {
const s = start();
const sup = await discordLogin(s, SUPER);

View File

@@ -5,7 +5,7 @@
import type { Database } from 'bun:sqlite';
import { z } from 'zod';
import type { AnyGameDefinition } from '@bg/engine';
import { CATALOG, GAME_SPEED_DEFAULT, GAME_SPEED_MAX, GAME_SPEED_MIN, type CatalogEntry } from '@bg/shared';
import { CATALOG, CHAT_SOUND_DEFAULT, CHAT_SOUND_MAX, CHAT_SOUND_MIN, GAME_SPEED_DEFAULT, GAME_SPEED_MAX, GAME_SPEED_MIN, type CatalogEntry } from '@bg/shared';
export const SiteSettingsSchema = z.object({
siteName: z.string().trim().min(1).max(40).default('같이 놀자 보드게임'),
@@ -21,6 +21,8 @@ export const SiteSettingsSchema = z.object({
chatFloodGuard: z.boolean().default(false),
/** Animations and the computers' thinking time are divided by this (applies at once, also to running games). */
gameSpeed: z.number().min(GAME_SPEED_MIN).max(GAME_SPEED_MAX).default(GAME_SPEED_DEFAULT),
/** Chat sound in % of a game sound (0 = silent, applies at once, also to open rooms). */
chatSound: z.number().int().min(CHAT_SOUND_MIN).max(CHAT_SOUND_MAX).default(CHAT_SOUND_DEFAULT),
});
export type SiteSettings = z.infer<typeof SiteSettingsSchema>;

View File

@@ -93,8 +93,8 @@ export function createAdminApp(d: AdminDeps) {
const before = d.settings.getSite();
d.settings.setSite(parsed.data, actor(c));
d.audit.log(actor(c), 'site.update', null, before, parsed.data);
// The game speed applies at once: open rooms get it with a fresh room view (their animations follow it).
if (before.gameSpeed !== parsed.data.gameSpeed) for (const r of d.rooms.all()) r.broadcastRoom();
// The game speed and chat sound apply at once: open rooms get them with a fresh room view.
if (before.gameSpeed !== parsed.data.gameSpeed || before.chatSound !== parsed.data.chatSound) for (const r of d.rooms.all()) r.broadcastRoom();
return c.json({ site: parsed.data });
});

View File

@@ -98,6 +98,7 @@ export function createHttpApp(d: HttpDeps) {
announcement: site.announcement,
maintenance: site.maintenance,
gameSpeed: site.gameSpeed,
chatSound: site.chatSound,
});
});

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 { botChatRequired, clampGameSpeed, botsAllowed, isBotId, makeBotId, botNumber, maskProfanity, type BotPick, type PublicUser, type RoomView, type ServerMessage, type SeatView } from '@bg/shared';
import { botChatRequired, clampChatSound, clampGameSpeed, 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';
@@ -440,6 +440,7 @@ export class Room {
// Levels are revealed only once the game is over (fairness check).
...(this.game?.finished && this.game.bots ? { lastBots: this.game.bots, lastShuffles: this.game.shuffles ?? 1 } : {}),
gameSpeed: this.gameSpeed(),
chatSound: clampChatSound(this.deps.settings?.getSite().chatSound),
};
}