feat: 죽음 연도에 따른 killturn 계산 로직 추가 및 관련 메타 데이터 수정

This commit is contained in:
2026-01-25 06:17:27 +00:00
parent 46759022fd
commit 21d8507fc5
4 changed files with 99 additions and 13 deletions
@@ -48,6 +48,7 @@ export interface TalentScoutResolveContext<
TriggerState extends GeneralTriggerState = GeneralTriggerState,
> extends GeneralActionResolveContext<TriggerState> {
currentYear: number;
currentMonth: number;
worldSummary: TalentScoutWorldSummary;
generalPool?: TalentScoutCandidate[];
cityPool?: City[];
@@ -86,6 +87,20 @@ const DEFAULT_MAX_AGE = 25;
const DEFAULT_DEATH_MIN = 10;
const DEFAULT_DEATH_MAX = 50;
const resolveKillturnFromDeathYear = (
currentYear: number,
currentMonth: number,
deathYear: number,
rng: RandomGenerator
): number => {
if (!Number.isFinite(deathYear) || deathYear <= 0) {
return 0;
}
const deathMonth = randomRangeInt(rng, 1, 12);
const diff = (deathYear - currentYear) * 12 + (deathMonth - currentMonth);
return Math.max(diff, 0);
};
const addMetaValue = (
meta: Record<string, TriggerValue>,
key: string,
@@ -302,14 +317,18 @@ export class ActionResolver<
? this.env.decorateName(resolvedCandidate.name, NPC_TYPE)
: resolvedCandidate.name;
const meta: GeneralMeta = {
killturn: context.general.meta.killturn,
killturn: resolveKillturnFromDeathYear(
context.currentYear,
context.currentMonth,
deathYear,
context.rng
),
npcType: NPC_TYPE,
crewTypeId: this.env.defaultCrewTypeId,
};
addMetaValue(meta, 'affinity', resolvedCandidate.affinity ?? null);
addMetaValue(meta, 'picture', resolvedCandidate.picture ?? null);
addMetaValue(meta, 'birthYear', birthYear);
addMetaValue(meta, 'deathYear', deathYear);
addMetaValue(meta, 'text', resolvedCandidate.text ?? null);
const newGeneral = buildRecruitmentGeneral<TriggerState>({
@@ -393,6 +412,7 @@ export class ActionDefinition<
export const actionContextBuilder: ActionContextBuilder = (base, options) => ({
...base,
currentYear: options.world.currentYear,
currentMonth: options.world.currentMonth,
worldSummary: buildWorldSummary(options.worldRef),
createGeneralId: options.createGeneralId,
});
@@ -46,6 +46,7 @@ export interface VolunteerRecruitResolveContext<
TriggerState extends GeneralTriggerState = GeneralTriggerState,
> extends GeneralActionResolveContext<TriggerState> {
currentYear: number;
currentMonth: number;
startYear: number;
averageNationGeneralCount: number;
nationAverageStats?: StatBlock;
@@ -91,6 +92,20 @@ const DEFAULT_KILLTURN_MIN = 64;
const DEFAULT_KILLTURN_MAX = 70;
const DEFAULT_SPEC_AGE = 19;
const resolveKillturnFromDeathYear = (
currentYear: number,
currentMonth: number,
deathYear: number,
rng: RandomGenerator
): number => {
if (!Number.isFinite(deathYear) || deathYear <= 0) {
return 0;
}
const deathMonth = randomRangeInt(rng, 1, 12);
const diff = (deathYear - currentYear) * 12 + (deathMonth - currentMonth);
return Math.max(diff, 0);
};
const addMetaValue = (
meta: Record<string, TriggerValue>,
key: string,
@@ -269,17 +284,21 @@ export class ActionResolver<
const deathYear = context.currentYear + deathYears;
const stats = resolveStats(context, context.rng, this.env, candidate);
const meta: GeneralMeta = {
killturn: randomRangeInt(context.rng, killTurnMin, killTurnMax),
killturn: resolveKillturnFromDeathYear(
context.currentYear,
context.currentMonth,
deathYear,
context.rng
),
npcType: NPC_TYPE,
crewTypeId: this.env.defaultCrewTypeId,
};
addMetaValue(meta, 'affinity', candidate.affinity ?? null);
addMetaValue(meta, 'picture', candidate.picture ?? null);
addMetaValue(meta, 'birthYear', birthYear);
addMetaValue(meta, 'deathYear', deathYear);
addMetaValue(meta, 'specAge', DEFAULT_SPEC_AGE);
addMetaValue(meta, 'specAge2', DEFAULT_SPEC_AGE);
addMetaValue(meta, 'killturn', meta.killturn);
addMetaValue(meta, 'killturn', meta.killturn || randomRangeInt(context.rng, killTurnMin, killTurnMax));
addMetaValue(meta, 'text', candidate.text ?? null);
const newGeneral = buildRecruitmentGeneral<TriggerState>({
@@ -357,6 +376,7 @@ export const actionContextBuilder: ActionContextBuilder = (base, options) => {
return {
...base,
currentYear: options.world.currentYear,
currentMonth: options.world.currentMonth,
startYear: resolveStartYear(options.world, options.scenarioMeta),
averageNationGeneralCount: buildAverageNationGeneralCount(options.worldRef),
nationAverageStats: nationSummary.averageStats,