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,
+15 -2
View File
@@ -140,6 +140,20 @@ const resolveDeathYear = (deathYear: number, birthYear: number, startYear: numbe
return 0;
};
const resolveKillturnFromDeathYear = (
currentYear: number | null,
currentMonth: number,
deathYear: number,
fallback: number
): number => {
if (currentYear === null || !Number.isFinite(deathYear) || deathYear <= 0) {
return fallback;
}
const deathMonth = Math.floor(Math.random() * 12) + 1;
const diff = (deathYear - currentYear) * 12 + (deathMonth - currentMonth);
return Math.max(diff, 0);
};
const resolveAge = (startYear: number | null, birthYear: number): number => {
if (startYear === null || birthYear <= 0) {
return 20;
@@ -299,7 +313,7 @@ const buildGeneralSeeds = (
seeds.push(seed);
const generalMeta: GeneralMeta = {
killturn: DEFAULT_GENERAL_KILLTURN,
killturn: resolveKillturnFromDeathYear(scenario.startYear, 1, deathYear, DEFAULT_GENERAL_KILLTURN),
npcType,
crewTypeId: defaultCrewTypeId,
};
@@ -313,7 +327,6 @@ const buildGeneralSeeds = (
addTriggerMeta(generalMeta, 'book', row.book ?? undefined);
addTriggerMeta(generalMeta, 'item', row.item ?? undefined);
addTriggerMeta(generalMeta, 'birthYear', birthYear);
addTriggerMeta(generalMeta, 'deathYear', deathYear);
addTriggerMeta(generalMeta, 'text', row.text ?? undefined);
generals.push({