인게임 예약 명령과 장수 상태 표시를 바로잡음
This commit is contained in:
@@ -49,6 +49,7 @@ const redactDiplomacyMessages = (messages: MessageView[], permission: number): M
|
||||
return {
|
||||
...message,
|
||||
text: '조회 권한이 없는 외교 메시지입니다.',
|
||||
option: { ...(message.option ?? {}), permissionRedacted: true },
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
@@ -89,6 +89,11 @@ export const getSecretGeneralList = accessAuthedProcedure.query(async ({ ctx })
|
||||
name: general.name,
|
||||
npcState: general.npcState,
|
||||
injury: general.injury,
|
||||
baseStats: {
|
||||
leadership: general.leadership,
|
||||
strength: general.strength,
|
||||
intelligence: general.intel,
|
||||
},
|
||||
stats: {
|
||||
leadership: woundedStat(general.leadership, general.injury),
|
||||
strength: woundedStat(general.strength, general.injury),
|
||||
|
||||
@@ -109,11 +109,17 @@ const resolveScenarioStat = (config: Record<string, unknown>): { max: number; np
|
||||
};
|
||||
|
||||
const resolveCommandEnv = (
|
||||
config: Record<string, unknown>
|
||||
config: Record<string, unknown>,
|
||||
worldMeta: Record<string, unknown>
|
||||
): { develCost: number; defaultCrewTypeId: number; maxTechLevel: number } => {
|
||||
const constValues = asRecord(config.const ?? config.consts);
|
||||
const configuredDevelCost = resolveNumberFromKeys(constValues, ['develCost', 'develcost', 'develrate'], 0);
|
||||
return {
|
||||
develCost: resolveNumberFromKeys(constValues, ['develCost', 'develcost', 'develrate'], 0),
|
||||
develCost: resolveNumberFromKeys(
|
||||
worldMeta,
|
||||
['develcost', 'develCost', 'develrate'],
|
||||
configuredDevelCost
|
||||
),
|
||||
defaultCrewTypeId: resolveNumberFromKeys(constValues, ['defaultCrewTypeId'], 0),
|
||||
maxTechLevel: resolveNumberFromKeys(constValues, ['maxTechLevel'], 12),
|
||||
};
|
||||
@@ -409,7 +415,7 @@ export const npcRouter = router({
|
||||
|
||||
const config = asRecord(worldState.config);
|
||||
const stat = resolveScenarioStat(config);
|
||||
const env = resolveCommandEnv(config);
|
||||
const env = resolveCommandEnv(config, worldMeta);
|
||||
const unitSetName = resolveUnitSetName(config, 'che');
|
||||
const nationTech = readNumber(nation.tech, 0);
|
||||
|
||||
|
||||
@@ -224,7 +224,10 @@ export const troopRouter = router({
|
||||
name: troop.name,
|
||||
nationId: troop.nationId,
|
||||
turnTime: leader?.turnTime.toISOString() ?? null,
|
||||
reservedCommands: reservedByLeader.get(troop.troopLeaderId) ?? [],
|
||||
reservedCommands:
|
||||
leader?.npcState === 5
|
||||
? ['집합', '집합', '집합', '집합', '집합']
|
||||
: (reservedByLeader.get(troop.troopLeaderId) ?? []),
|
||||
leader: leader
|
||||
? {
|
||||
id: leader.id,
|
||||
|
||||
@@ -79,6 +79,7 @@ export interface TurnCommandInputField {
|
||||
required: boolean;
|
||||
min?: number;
|
||||
max?: number;
|
||||
legacyWidthMax?: number;
|
||||
step?: number;
|
||||
defaultValue?: TurnCommandOptionValue | boolean;
|
||||
constValue?: TurnCommandOptionValue;
|
||||
@@ -328,6 +329,7 @@ const buildField = (key: string, rawSchema: unknown, required: boolean): TurnCom
|
||||
required,
|
||||
min: typeof schema.minLength === 'number' ? schema.minLength : undefined,
|
||||
max: typeof schema.maxLength === 'number' ? schema.maxLength : undefined,
|
||||
legacyWidthMax: key === 'nationName' ? 18 : undefined,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -565,7 +567,7 @@ export const assertReservedTurnArgsPassLegacyBasicValidation = (rawArgs: unknown
|
||||
getLegacyStringWidth(nationName) < 1 ||
|
||||
getLegacyStringWidth(nationName) > 18)
|
||||
) {
|
||||
throwLegacyBasicTurnArgError();
|
||||
throw new Error('국가명은 전각 9자 또는 반각 18자 이하여야 합니다.');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -64,7 +64,7 @@ export const buildRefGeneralTargetOptions = (options: {
|
||||
const isTroopExit = action === 'che_부대탈퇴지시';
|
||||
const availableNow = isTroopExit ? isTroopMember && entry.id !== options.actorId : undefined;
|
||||
const label = (() => {
|
||||
if (action === 'che_발령') return `${entry.name} (${troopLabel} · ${cityName})`;
|
||||
if (action === 'che_발령') return `${entry.name} (${cityName})`;
|
||||
if (action === 'che_포상' || action === 'che_몰수') return `${entry.name} (${cityName})`;
|
||||
return `${entry.name} (${options.nationNames.get(entry.nationId) ?? '무소속'} · ${cityName})`;
|
||||
})();
|
||||
|
||||
@@ -112,12 +112,22 @@ describe('turn command argument input', () => {
|
||||
).toThrow('턴이 입력되지 않았습니다.');
|
||||
expect(() => assertReservedTurnArgsPassLegacyBasicValidation({ month: '12', year: 0 })).not.toThrow();
|
||||
expect(() => assertReservedTurnArgsPassLegacyBasicValidation({ nationName: '0' })).not.toThrow();
|
||||
expect(() => assertReservedTurnArgsPassLegacyBasicValidation({ nationName: '가나다라마바사아자차' })).toThrow(
|
||||
'국가명은 전각 9자 또는 반각 18자 이하여야 합니다.'
|
||||
);
|
||||
expect(() => assertReservedTurnArgsPassLegacyBasicValidation({ year: '0x10' })).toThrow(
|
||||
'턴이 입력되지 않았습니다.'
|
||||
);
|
||||
await expect(parseReservedTurnArgs('nation', 'che_국호변경', { nationName: '0' })).rejects.toBeDefined();
|
||||
});
|
||||
|
||||
it('exposes the Ref fullwidth nation-name limit to command input clients', async () => {
|
||||
const specs = await loadGeneralTurnCommandSpecs(['che_건국']);
|
||||
expect(buildTurnCommandInputFields(specs[0]!)).toContainEqual(
|
||||
expect.objectContaining({ key: 'nationName', legacyWidthMax: 18 })
|
||||
);
|
||||
});
|
||||
|
||||
it('recursively sanitizes reserved command strings like Ref before command parsing', async () => {
|
||||
expect(
|
||||
sanitizeReservedTurnArgs({
|
||||
|
||||
@@ -88,9 +88,9 @@ describe('Ref command general targets', () => {
|
||||
description: expect.stringContaining('탑승 부대 청룡대'),
|
||||
});
|
||||
expect(detailed.generalTargets.che_발령?.map((entry) => entry.label)).toEqual([
|
||||
'본인 (부대 없음 · 업)',
|
||||
'부대원 (청룡대 · 업)',
|
||||
'부대장 (청룡대 (부대장) · 업)',
|
||||
'본인 (업)',
|
||||
'부대원 (업)',
|
||||
'부대장 (업)',
|
||||
]);
|
||||
expect(detailed.generalTargets.che_발령?.[1]?.description).not.toContain('탑승 부대');
|
||||
expect(detailed.generalTargets.che_포상?.map((entry) => entry.label)).toEqual([
|
||||
|
||||
@@ -177,12 +177,12 @@ describe('messages router missing-flow compatibility', () => {
|
||||
expect(recent.permission).toBe(2);
|
||||
expect(recent.diplomacy[0]).toMatchObject({
|
||||
text: '조회 권한이 없는 외교 메시지입니다.',
|
||||
option: { action: 'noAggression' },
|
||||
option: { action: 'noAggression', permissionRedacted: true },
|
||||
});
|
||||
expect(recent.diplomacy[0]?.option).not.toHaveProperty('invalid');
|
||||
expect(old.diplomacy[0]).toMatchObject({
|
||||
text: '조회 권한이 없는 외교 메시지입니다.',
|
||||
option: { action: 'noAggression' },
|
||||
option: { action: 'noAggression', permissionRedacted: true },
|
||||
});
|
||||
expect(old.diplomacy[0]?.option).not.toHaveProperty('invalid');
|
||||
});
|
||||
|
||||
@@ -154,6 +154,7 @@ describe('nation general and secret office permissions', () => {
|
||||
const ally = general({
|
||||
id: 3,
|
||||
userId: 'u3',
|
||||
injury: 25,
|
||||
gold: 3000,
|
||||
crew: 200,
|
||||
train: 80,
|
||||
@@ -166,6 +167,10 @@ describe('nation general and secret office permissions', () => {
|
||||
expect(result.viewer).toEqual({ generalId: 2, permission: 2 });
|
||||
expect(result.generals.map((g) => g.id)).toEqual([1, 2, 3]);
|
||||
expect(result.generals.find((entry) => entry.id === 3)?.experienceLevel).toBe(200);
|
||||
expect(result.generals.find((entry) => entry.id === 3)).toMatchObject({
|
||||
baseStats: { leadership: 70, strength: 60, intelligence: 50 },
|
||||
stats: { leadership: 52, strength: 45, intelligence: 37 },
|
||||
});
|
||||
expect(result.summary).toMatchObject({ gold: 5000, crew: 800, generalCount: 3 });
|
||||
expect(result.generals[0]?.reservedCommands).toEqual([
|
||||
{ action: 'che_징병', args: { crewType: 1, amount: 300 } },
|
||||
|
||||
@@ -161,6 +161,20 @@ describe('NPC policy router', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('uses the live world development cost instead of the scenario snapshot', async () => {
|
||||
const fixture = createContext({
|
||||
world: {
|
||||
...baseWorld,
|
||||
config: { ...baseWorld.config, const: { develCost: 100 } },
|
||||
meta: { ...baseWorld.meta, develcost: 42 } as typeof baseWorld.meta & { develcost: number },
|
||||
},
|
||||
});
|
||||
|
||||
const result = await appRouter.createCaller(fixture.context).npc.getPolicy();
|
||||
|
||||
expect(result.zeroPolicy.reqNPCDevelGold).toBe(1_260);
|
||||
});
|
||||
|
||||
it('lets a secret-level reader load the page while mapping authoritative ENGINE rejection', async () => {
|
||||
const reader = { ...baseGeneral, officerLevel: 2 };
|
||||
const requestCommand = vi.fn(async () => ({
|
||||
|
||||
@@ -282,6 +282,18 @@ describe('troop router permissions and mutations', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('shows all five visible turns as assembly for a managed NPC troop leader', async () => {
|
||||
const fixture = buildContext({
|
||||
me: buildGeneral({ troopId: 1, npcState: 5, meta: { killturn: 70 } }),
|
||||
turns: [{ generalId: 1, turnIdx: 0, actionCode: '휴식' }],
|
||||
result: null,
|
||||
});
|
||||
|
||||
const result = await appRouter.createCaller(fixture.context).troop.getList();
|
||||
|
||||
expect(result.troops[0]?.reservedCommands).toEqual(['집합', '집합', '집합', '집합', '집합']);
|
||||
});
|
||||
|
||||
it('creates a troop only for the general owned by the authenticated user', async () => {
|
||||
const { context, requestCommand } = buildContext({
|
||||
result: { type: 'troopCreate', ok: true, generalId: 1, troopId: 1, troopName: '백마대' },
|
||||
|
||||
Reference in New Issue
Block a user