게임 속도 배율: 1배도 애니메이션·연출·컴퓨터 생각 시간을 예전의 1.5배로 늦추고, 관리자 사이트 설정 "게임 속도 배율"(1/16~16배, 기본 1)로 나눠 조절. 저장하면 열린 방에도 바로 적용(RoomView.gameSpeed 재전송)
- 서버: SiteSettings.gameSpeed, /api/config에 노출, 컴퓨터 생각 시간(defaultBotDelay)과 마피아·라이어 컴퓨터가 살펴보는 간격에 BOT_SLOWDOWN(1.5)/배율. 게임이 정한 반응 시각(원카드 외치기)은 그대로 - 웹: lib/motion.ts — .game-layout 안 CSS 애니메이션·트랜지션은 useMotionScope가 playbackRate로, Web Animations는 fxAnim, 연출 타이머(배너 유지·다음 단계·복사본 정리·숫자 세기·다시 보기 한 칸)는 fxMs. 채팅·role="timer"·규칙 시간·꾹 눌러 보기는 제외 - 관리자 사이트 탭에 배율 버튼(1/16~16)과 직접 입력 - 테스트: 배율 검증(API 400/200, 열린 방 즉시 반영), 컴퓨터 생각 시간 배율, motion 단위 테스트, e2e/speed.e2e.ts(돌 애니메이션 재생 배율·컴퓨터 응답 시간), 관리자 e2e에 배율 저장 - 문서: 14-admin §5, 07-ui-ux, 06-lobby-rooms, 13-decisions, README Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -5,6 +5,7 @@ import { BOT_STRATEGIES, LIVE_BOT_STRATEGIES, botReactionAt } from '@bg/games/bo
|
||||
import { classicDeck, type OneCardState } from '@bg/games/one-card';
|
||||
import { BOT_GAMES, ClientMessage, botProfile, isBotId, type ServerMessage } from '@bg/shared';
|
||||
import { openDb } from '../db';
|
||||
import { SiteSettingsSchema, type SettingsStore } from '../admin/settings';
|
||||
import { botPace, defaultBotDelay, type BotDelayInput } from './bots';
|
||||
import { RoomManager } from './manager';
|
||||
import { Room, type Conn, type RoomSnapshot } from './room';
|
||||
@@ -89,6 +90,41 @@ describe('bot list', () => {
|
||||
}
|
||||
});
|
||||
|
||||
test('game speed scales the thinking time, but not a reaction the game timed itself', () => {
|
||||
const bot = 'bot:1:01J0000000000000000000000';
|
||||
const r = () => 0.5;
|
||||
const input = { choices: 4, withPeople: true, bot, followUp: false };
|
||||
expect(defaultBotDelay(input, r, 3)).toBe(Math.round((2600 * botPace(bot) + 1500) * 3));
|
||||
expect(defaultBotDelay(input, r, 0.25)).toBe(Math.round((2600 * botPace(bot) + 1500) * 0.25));
|
||||
expect(defaultBotDelay({ ...input, reactMs: 800 }, r, 3)).toBe(800);
|
||||
});
|
||||
|
||||
test('the admin game speed reaches the computers (×1.5 slower base) and the room view', () => {
|
||||
let speed = 1 / 16;
|
||||
const db = openDb(':memory:');
|
||||
let now = 1_000_000;
|
||||
const users = { publicUser: (id: string) => botProfile(id) ?? { id, nickname: id, avatar: null, kind: 'guest' as const } };
|
||||
const settings = { game: () => null, getSite: () => SiteSettingsSchema.parse({ gameSpeed: speed }) } as unknown as SettingsStore;
|
||||
const manager = new RoomManager({ store: new RoomStore(db), games: GAMES, users, now: () => now, settings });
|
||||
const play = () => {
|
||||
const room = manager.createPractice('A', 'omok') as Room;
|
||||
rooms.push(room);
|
||||
room.join({ userId: 'A', send: () => {}, close: () => {} }, 'player');
|
||||
room.configure('A', { options: { ...(room.config.options as object), colorAssignment: 'hostBlack' } });
|
||||
expect(room.start('A')).toBeNull();
|
||||
room.act('A', 1, { type: 'place', x: 7, y: 7 });
|
||||
expect(room.roomView().gameSpeed).toBe(speed);
|
||||
return room.bots.dueAt! - now;
|
||||
};
|
||||
// 1/16: at least the shortest thought (0.49 s) × 1.5 × 16, though never past half the 30 s turn timer.
|
||||
const slow = play();
|
||||
expect(slow).toBeGreaterThanOrEqual(11_000);
|
||||
expect(slow).toBeLessThanOrEqual(15_000);
|
||||
speed = 16;
|
||||
// ×16: at most the longest thought (10.4 s) × 1.5 / 16.
|
||||
expect(play()).toBeLessThanOrEqual(1000);
|
||||
});
|
||||
|
||||
test('thinking never takes more than half of the time left on the turn timer', () => {
|
||||
const h = harness(undefined, undefined, () => 60 * 60_000);
|
||||
const room = h.manager.createPractice('A', 'omok') as Room;
|
||||
|
||||
Reference in New Issue
Block a user