fix(gateway): 입구 공지의 자율행동 복사를 복원
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { TRPCError } from '@trpc/server';
|
||||
|
||||
import { asRecord } from '@sammo-ts/common';
|
||||
import { asNumber, asRecord } from '@sammo-ts/common';
|
||||
|
||||
import { zWorldStateConfig, zWorldStateMeta } from '../../context.js';
|
||||
import { isSelectionPoolWorld, resolveSelectionMaxGeneral } from '@sammo-ts/game-engine/turn/selectPoolService.js';
|
||||
@@ -26,7 +26,14 @@ export const lobbyRouter = router({
|
||||
const userCnt = await ctx.db.general.count({ where: { npcState: { lt: 2 } } });
|
||||
const npcCnt = await ctx.db.general.count({ where: { npcState: { gte: 2 } } });
|
||||
const nationCnt = await ctx.db.nation.count({ where: { level: { gt: 0 } } });
|
||||
const rawConfig = asRecord(rawWorldState.config);
|
||||
const scenarioTitle = asRecord(asRecord(rawWorldState.meta).scenarioMeta).title;
|
||||
const autorunUser = worldState.meta.autorun_user;
|
||||
const autorunOptions = autorunUser?.options
|
||||
? Object.entries(autorunUser.options)
|
||||
.filter(([, enabled]) => enabled)
|
||||
.map(([option]) => option)
|
||||
: [];
|
||||
const gameTime = await loadCurrentGameTime(ctx.db);
|
||||
|
||||
let myGeneral = null;
|
||||
@@ -55,10 +62,20 @@ export const lobbyRouter = router({
|
||||
fictionMode: worldState.config.fictionMode ?? '사실',
|
||||
starttime: worldState.meta.starttime ?? '',
|
||||
opentime: worldState.meta.opentime ?? '',
|
||||
preopenAt: worldState.meta.preopenAt ?? '',
|
||||
turntime: worldState.meta.turntime ?? '',
|
||||
serverTime: gameTime.now.toISOString(),
|
||||
clockMode: gameTime.mode ?? 'realtime',
|
||||
otherTextInfo: worldState.meta.otherTextInfo ?? '',
|
||||
npcMode: worldState.config.npcMode ?? 0,
|
||||
defaultStatTotal: asNumber(asRecord(rawConfig.stat).total, 165),
|
||||
autorunUser:
|
||||
autorunUser?.limit_minutes && autorunUser.limit_minutes > 0 && autorunOptions.length > 0
|
||||
? {
|
||||
limitMinutes: autorunUser.limit_minutes,
|
||||
options: autorunOptions,
|
||||
}
|
||||
: null,
|
||||
isUnited: worldState.meta.isunited ?? worldState.meta.isUnited ?? 0,
|
||||
selectionPoolEnabled: isSelectionPoolWorld(rawWorldState),
|
||||
npcPossessionEnabled: worldState.config.npcMode === 1,
|
||||
|
||||
@@ -10,7 +10,8 @@ const buildContext = (
|
||||
tick?: bigint;
|
||||
mode?: string;
|
||||
wallAnchor?: Date;
|
||||
} = {}
|
||||
} = {},
|
||||
config: Record<string, unknown> = {}
|
||||
): GameApiContext =>
|
||||
({
|
||||
auth: null,
|
||||
@@ -22,7 +23,7 @@ const buildContext = (
|
||||
currentYear: 200,
|
||||
currentMonth: 1,
|
||||
tickSeconds: 3_600,
|
||||
config: {},
|
||||
config,
|
||||
meta,
|
||||
clockBaseTime: clock.baseTime ?? null,
|
||||
clockTick: clock.tick ?? null,
|
||||
@@ -67,4 +68,48 @@ describe('lobby season state', () => {
|
||||
expect(result.serverTime).toBe('2026-08-15T02:00:00.000Z');
|
||||
expect(result.clockMode).toBe('manual');
|
||||
});
|
||||
|
||||
it('projects the Ref-compatible opening announcement settings without exposing disabled autorun options', async () => {
|
||||
const result = await appRouter
|
||||
.createCaller(
|
||||
buildContext(
|
||||
{
|
||||
preopenAt: '2026-08-19 22:00:00',
|
||||
opentime: '2026-08-19 23:00:00',
|
||||
scenarioMeta: { title: '【가상모드27-b】 아시아 명장전(비급)' },
|
||||
autorun_user: {
|
||||
limit_minutes: 1_440,
|
||||
options: {
|
||||
develop: true,
|
||||
warp: true,
|
||||
recruit: false,
|
||||
recruit_high: true,
|
||||
train: true,
|
||||
battle: true,
|
||||
chief: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
{},
|
||||
{
|
||||
fictionMode: '가상',
|
||||
npcMode: 0,
|
||||
stat: { total: 310, min: 10, max: 110 },
|
||||
}
|
||||
)
|
||||
)
|
||||
.lobby.info();
|
||||
|
||||
expect(result).toMatchObject({
|
||||
preopenAt: '2026-08-19 22:00:00',
|
||||
opentime: '2026-08-19 23:00:00',
|
||||
scenarioTitle: '【가상모드27-b】 아시아 명장전(비급)',
|
||||
npcMode: 0,
|
||||
defaultStatTotal: 310,
|
||||
autorunUser: {
|
||||
limitMinutes: 1_440,
|
||||
options: ['develop', 'warp', 'recruit_high', 'train', 'battle', 'chief'],
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user