감찰부 장수 카드에 특기와 장비 설명을 표시한다

This commit is contained in:
Hide_D committed 2026-11-19 00:29:16 +09:00
1 parent 8125d68c95
commit bebd4848b4
3 files changed
+111 -6

No files matched your search

@@ -6,7 +6,7 @@ import { getBillByLevel, LogCategory } from '@sammo-ts/logic';
import { accessAuthedProcedure } from '../../../trpc.js';
import {
loadCrewTypeDisplayNames,
loadItemDisplayNames,
loadItemDisplayDetails,
resolveDedicationLevelName,
resolveOfficerLevelName,
sanitizeInternalDisplayCode,
@@ -133,7 +133,7 @@ export const getBattleCenter = accessAuthedProcedure.query(async ({ ctx }) => {
typeof constValues.maxDedLevel === 'number' && Number.isFinite(constValues.maxDedLevel)
? Math.max(0, Math.trunc(constValues.maxDedLevel))
: 30;
const [personalityNames, domesticNames, warNames, crewTypeNames, itemNames] = await Promise.all([
const [personalityNames, domesticNames, warNames, crewTypeNames, itemDetails] = await Promise.all([
loadTraitNames(
generalRows.map((general) => general.personalCode),
'personality'
@@ -147,7 +147,7 @@ export const getBattleCenter = accessAuthedProcedure.query(async ({ ctx }) => {
'war'
),
loadCrewTypeDisplayNames(worldState, ctx.profile.id),
loadItemDisplayNames(
loadItemDisplayDetails(
generalRows.flatMap((general) => [
general.weaponCode,
general.bookCode,
@@ -158,7 +158,8 @@ export const getBattleCenter = accessAuthedProcedure.query(async ({ ctx }) => {
]);
const traitName = (code: string, names: Awaited<ReturnType<typeof loadTraitNames>>): string =>
names.get(code)?.name ?? sanitizeInternalDisplayCode(code);
const itemName = (code: string): string => itemNames.get(code) ?? sanitizeInternalDisplayCode(code);
const itemName = (code: string): string => itemDetails.get(code)?.name ?? sanitizeInternalDisplayCode(code);
const itemInfo = (code: string): string => itemDetails.get(code)?.info ?? '';
const generals = generalRows.map((general) => {
const meta =
@@ -225,11 +226,22 @@ export const getBattleCenter = accessAuthedProcedure.query(async ({ ctx }) => {
horse: itemName(general.horseCode),
item: itemName(general.itemCode),
},
itemInfo: {
weapon: itemInfo(general.weaponCode),
book: itemInfo(general.bookCode),
horse: itemInfo(general.horseCode),
item: itemInfo(general.itemCode),
},
traits: {
personal: traitName(general.personalCode, personalityNames),
specialDomestic: traitName(general.specialCode, domesticNames),
specialWar: traitName(general.special2Code, warNames),
},
traitInfo: {
personal: personalityNames.get(general.personalCode)?.info ?? '',
specialDomestic: domesticNames.get(general.specialCode)?.info ?? '',
specialWar: warNames.get(general.special2Code)?.info ?? '',
},
progression: {
experienceLevel: metaNumber('explevel'),
dedicationLevel,
@@ -1072,6 +1072,34 @@ describe('battle-center general and user permissions', () => {
});
});
it('projects registered trait and equipment descriptions for battle center viewers', async () => {
const me = buildGeneral({ meta: { belong: 3 } });
const other = buildGeneral({
id: 8,
personalCode: 'che_안전',
specialCode: 'che_상재',
special2Code: 'che_신산',
horseCode: 'che_명마_15_적토마',
weaponCode: 'unregistered',
itemCode: 'che_내정_납금박산로',
});
const fixture = createContext({ me, targets: [me, other], nationMeta: { secretLimit: 3 } });
const result = await appRouter.createCaller(fixture.context).nation.getBattleCenter();
expect(result.generals.find(({ id }) => id === other.id)).toMatchObject({
traitInfo: {
personal: expect.stringContaining('징·모병 비용'),
specialDomestic: expect.stringContaining('상업 투자'),
specialWar: expect.stringContaining('[계략] 화계·탈취·파괴·선동'),
},
itemInfo: { horse: '통솔 +15', weapon: '', book: '', item: '[내정] 내정 성공률 +15%p' },
});
expect(result.generals.find(({ id }) => id === me.id)).toMatchObject({
traitInfo: { personal: '', specialDomestic: '', specialWar: '' },
itemInfo: { horse: '', weapon: '', book: '', item: '' },
});
});
it('redacts another user action log while allowing own, NPC, chief, and non-private logs', async () => {
const me = buildGeneral({ meta: { belong: 3, permission: 'normal' } });
const otherUser = buildGeneral({ id: 8, userId: 'user-8', name: '타유저', npcState: 0 });