feat: port scenario action effects

This commit is contained in:
2026-07-30 19:00:04 +00:00
parent 7f31459385
commit c68d992046
39 changed files with 1131 additions and 95 deletions
@@ -0,0 +1,31 @@
export const SCENARIO_EFFECT_KEYS = [
'event_UnlimitedDefenceThresholdChange',
'event_StrongAttacker',
'event_MoreEffect',
] as const;
export type ScenarioEffectKey = (typeof SCENARIO_EFFECT_KEYS)[number];
const DEFENCE_TRAIN_PENALTY_WAIVER_EFFECTS = new Set<ScenarioEffectKey>([
'event_UnlimitedDefenceThresholdChange',
'event_StrongAttacker',
'event_MoreEffect',
]);
export const isScenarioEffectKey = (value: string): value is ScenarioEffectKey =>
SCENARIO_EFFECT_KEYS.includes(value as ScenarioEffectKey);
export const normalizeScenarioEffect = (value: unknown): ScenarioEffectKey | null => {
if (value === undefined || value === null || value === '' || value === 'None') {
return null;
}
if (typeof value === 'string' && isScenarioEffectKey(value)) {
return value;
}
throw new Error(`Unknown scenario effect: ${String(value)}`);
};
export const isDefenceTrainPenaltyWaivedByScenarioEffect = (value: string | null | undefined): boolean => {
const effect = normalizeScenarioEffect(value);
return effect !== null && DEFENCE_TRAIN_PENALTY_WAIVER_EFFECTS.has(effect);
};