fix: restore legacy gameplay messages and record details
This commit is contained in:
@@ -230,6 +230,12 @@ export const generalRouter = router({
|
||||
injury: true,
|
||||
experience: true,
|
||||
dedication: true,
|
||||
age: true,
|
||||
turnTime: true,
|
||||
crewTypeId: true,
|
||||
personalCode: true,
|
||||
specialCode: true,
|
||||
special2Code: true,
|
||||
weaponCode: true,
|
||||
horseCode: true,
|
||||
bookCode: true,
|
||||
@@ -309,6 +315,19 @@ export const generalRouter = router({
|
||||
injury: general.injury,
|
||||
experience: general.experience,
|
||||
dedication: general.dedication,
|
||||
age: general.age,
|
||||
turnTime: general.turnTime.toISOString(),
|
||||
crewTypeId: general.crewTypeId,
|
||||
traits: {
|
||||
personal: general.personalCode,
|
||||
specialWar: general.specialCode,
|
||||
specialDomestic: general.special2Code,
|
||||
},
|
||||
progression: {
|
||||
experienceLevel: readNumber(metaRecord.explevel, 0),
|
||||
dedicationLevel: readNumber(metaRecord.dedlevel, 0),
|
||||
dex: [1, 2, 3, 4, 5].map((index) => readNumber(metaRecord[`dex${index}`], 0)),
|
||||
},
|
||||
items: {
|
||||
horse: normalizeItemCode(general.horseCode),
|
||||
weapon: normalizeItemCode(general.weaponCode),
|
||||
@@ -468,12 +487,12 @@ export const generalRouter = router({
|
||||
ctx.db.logEntry.findMany({
|
||||
where: {
|
||||
scope: LogScope.SYSTEM,
|
||||
category: LogCategory.SUMMARY,
|
||||
category: { in: [LogCategory.SUMMARY, LogCategory.ACTION] },
|
||||
id: { gte: input.lastGeneralRecordId },
|
||||
},
|
||||
orderBy: { id: 'desc' },
|
||||
take,
|
||||
select: { id: true, text: true },
|
||||
select: { id: true, text: true, createdAt: true },
|
||||
}),
|
||||
ctx.db.logEntry.findMany({
|
||||
where: {
|
||||
@@ -484,7 +503,7 @@ export const generalRouter = router({
|
||||
},
|
||||
orderBy: { id: 'desc' },
|
||||
take,
|
||||
select: { id: true, text: true },
|
||||
select: { id: true, text: true, createdAt: true },
|
||||
}),
|
||||
ctx.db.logEntry.findMany({
|
||||
where: {
|
||||
@@ -494,7 +513,7 @@ export const generalRouter = router({
|
||||
},
|
||||
orderBy: { id: 'desc' },
|
||||
take,
|
||||
select: { id: true, text: true },
|
||||
select: { id: true, text: true, createdAt: true },
|
||||
}),
|
||||
]);
|
||||
|
||||
|
||||
@@ -186,9 +186,14 @@ const zRevealMode = z.enum(['after_vote', 'after_end']);
|
||||
export const voteRouter = router({
|
||||
getVoteList: authedProcedure.query(async ({ ctx }) => {
|
||||
const worldState = await ctx.db.worldState.findFirst();
|
||||
const worldMeta = asRecord(worldState?.meta ?? {});
|
||||
const config = asRecord(worldState?.config ?? {});
|
||||
const constValues = asRecord(config.const);
|
||||
const develCost = resolveNumber(constValues, ['develCost', 'develcost', 'develrate'], 0);
|
||||
const develCost = resolveNumber(
|
||||
worldMeta,
|
||||
['develcost', 'develCost'],
|
||||
resolveNumber(constValues, ['develCost', 'develcost', 'develrate'], 0)
|
||||
);
|
||||
const voteReward = develCost * 5;
|
||||
|
||||
const rows = await ctx.db.$queryRaw<VoteListRow[]>(GamePrisma.sql`
|
||||
@@ -404,12 +409,16 @@ export const voteRouter = router({
|
||||
throw new TRPCError({ code: 'PRECONDITION_FAILED', message: 'World state is not initialized.' });
|
||||
}
|
||||
|
||||
const worldMeta = asRecord(worldState.meta);
|
||||
const config = asRecord(worldState.config);
|
||||
const constValues = asRecord(config.const);
|
||||
const develCost = resolveNumber(constValues, ['develCost', 'develcost', 'develrate'], 0);
|
||||
const develCost = resolveNumber(
|
||||
worldMeta,
|
||||
['develcost', 'develCost'],
|
||||
resolveNumber(constValues, ['develCost', 'develcost', 'develrate'], 0)
|
||||
);
|
||||
const voteReward = develCost * 5;
|
||||
|
||||
const worldMeta = asRecord(worldState.meta);
|
||||
const scenarioMeta = asRecord(worldMeta.scenarioMeta);
|
||||
const startYear = readMetaNumber(scenarioMeta, 'startYear', worldState.currentYear);
|
||||
const initYear = readMetaNumber(worldMeta, 'initYear', startYear);
|
||||
|
||||
@@ -241,10 +241,10 @@ describe('in-game my information ownership', () => {
|
||||
expect(fixture.db.logEntry.findMany).toHaveBeenNthCalledWith(
|
||||
1,
|
||||
expect.objectContaining({
|
||||
where: { scope: 'SYSTEM', category: 'SUMMARY', id: { gte: 0 } },
|
||||
where: { scope: 'SYSTEM', category: { in: ['SUMMARY', 'ACTION'] }, id: { gte: 0 } },
|
||||
orderBy: { id: 'desc' },
|
||||
take: 16,
|
||||
select: { id: true, text: true },
|
||||
select: { id: true, text: true, createdAt: true },
|
||||
})
|
||||
);
|
||||
expect(fixture.db.logEntry.findMany).toHaveBeenNthCalledWith(
|
||||
@@ -253,7 +253,7 @@ describe('in-game my information ownership', () => {
|
||||
where: { scope: 'GENERAL', category: 'ACTION', generalId: 7, id: { gte: 0 } },
|
||||
orderBy: { id: 'desc' },
|
||||
take: 16,
|
||||
select: { id: true, text: true },
|
||||
select: { id: true, text: true, createdAt: true },
|
||||
})
|
||||
);
|
||||
expect(fixture.db.logEntry.findMany).toHaveBeenNthCalledWith(
|
||||
@@ -262,7 +262,7 @@ describe('in-game my information ownership', () => {
|
||||
where: { scope: 'SYSTEM', category: 'HISTORY', id: { gte: 0 } },
|
||||
orderBy: { id: 'desc' },
|
||||
take: 16,
|
||||
select: { id: true, text: true },
|
||||
select: { id: true, text: true, createdAt: true },
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
@@ -24,13 +24,13 @@ const auth: GameSessionTokenPayload = {
|
||||
type LogQuery = {
|
||||
where: {
|
||||
scope: LogScope;
|
||||
category: LogCategory;
|
||||
category: LogCategory | { in: LogCategory[] };
|
||||
generalId?: number;
|
||||
id: { gte: number };
|
||||
};
|
||||
orderBy: { id: 'desc' };
|
||||
take: number;
|
||||
select: { id: true; text: true };
|
||||
select: { id: true; text: true; createdAt: true };
|
||||
};
|
||||
|
||||
const buildContext = (findMany: (query: LogQuery) => Promise<Array<{ id: number; text: string }>>) =>
|
||||
@@ -56,7 +56,7 @@ describe('general.getRecentRecords', () => {
|
||||
{ id: 20, text: '개인 cursor' },
|
||||
];
|
||||
}
|
||||
if (query.where.category === LogCategory.SUMMARY) {
|
||||
if (typeof query.where.category === 'object' && query.where.category.in.includes(LogCategory.SUMMARY)) {
|
||||
return [
|
||||
{ id: 32, text: '장수 최신' },
|
||||
{ id: 20, text: '장수 cursor' },
|
||||
@@ -89,7 +89,7 @@ describe('general.getRecentRecords', () => {
|
||||
},
|
||||
orderBy: { id: 'desc' },
|
||||
take: 16,
|
||||
select: { id: true, text: true },
|
||||
select: { id: true, text: true, createdAt: true },
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -92,6 +92,7 @@ const buildContext = (options: {
|
||||
voteRows?: Array<{ selection: number[]; cnt: number }>;
|
||||
pollRow?: typeof poll;
|
||||
configConst?: Record<string, unknown>;
|
||||
metaDevelCost?: number;
|
||||
auctionTargets?: string[];
|
||||
}) => {
|
||||
const auth = options.auth === undefined ? buildAuth() : options.auth;
|
||||
@@ -136,6 +137,7 @@ const buildContext = (options: {
|
||||
tickSeconds: 3600,
|
||||
config: { const: { develCost: 18, allItems: {}, ...(options.configConst ?? {}) } },
|
||||
meta: {
|
||||
...(options.metaDevelCost === undefined ? {} : { develcost: options.metaDevelCost }),
|
||||
hiddenSeed: 'seed',
|
||||
scenarioId: 200,
|
||||
initYear: 180,
|
||||
@@ -216,6 +218,16 @@ describe('vote router actor and permission boundaries', () => {
|
||||
);
|
||||
});
|
||||
|
||||
it('uses the current world develcost for the legacy five-times survey reward', async () => {
|
||||
const fixture = buildContext({ metaDevelCost: 30, configConst: { develCost: 0 } });
|
||||
|
||||
await expect(appRouter.createCaller(fixture.context).vote.getVoteList()).resolves.toMatchObject({
|
||||
voteReward: 150,
|
||||
});
|
||||
await appRouter.createCaller(fixture.context).vote.submitVote({ voteId: 1, selection: [0] });
|
||||
expect(fixture.requestCommand).toHaveBeenCalledWith(expect.objectContaining({ goldReward: 150 }));
|
||||
});
|
||||
|
||||
it('includes active unique auctions in the API-side reward expectation', async () => {
|
||||
const fixture = buildContext({
|
||||
configConst: {
|
||||
|
||||
Reference in New Issue
Block a user