Revert "wip: 바보 젬3플. type 재정의 준비"

This reverts commit 6bddbc3aa0.
This commit is contained in:
2026-01-05 19:53:22 +00:00
parent 33ccf31d55
commit da6a095151
7 changed files with 167 additions and 254 deletions
+37 -37
View File
@@ -2,7 +2,7 @@ import type { RandUtil } from '@sammo-ts/common';
import type { City, General, GeneralTriggerState, Nation } from '@sammo-ts/logic/domain/entities.js';
import type { ActionLogger } from '@sammo-ts/logic/logging/actionLogger.js';
import type { WarStatBundleMap, WarStatName } from '@sammo-ts/logic/triggers/types.js';
import type { WarStatName } from '@sammo-ts/logic/triggers/types.js';
import type { WarUnit } from './units.js';
import { WarTriggerCaller } from './triggers.js';
@@ -24,30 +24,30 @@ export interface WarActionModule<TriggerState extends GeneralTriggerState = Gene
getBattlePhaseTriggerList?: ((context: WarActionContext<TriggerState>) => WarTriggerCaller | null) | undefined;
onCalcStat?:
| (<T extends WarStatName>(
context: WarActionContext<TriggerState>,
statName: T,
value: WarStatBundleMap[T]['value'],
aux?: WarStatBundleMap[T]['aux']
) => WarStatBundleMap[T]['return'])
| undefined;
| ((
context: WarActionContext<TriggerState>,
statName: WarStatName,
value: number | [number, number],
aux?: unknown
) => number | [number, number])
| undefined;
onCalcOpposeStat?:
| (<T extends WarStatName>(
context: WarActionContext<TriggerState>,
statName: T,
value: WarStatBundleMap[T]['value'],
aux?: WarStatBundleMap[T]['aux']
) => WarStatBundleMap[T]['return'])
| undefined;
| ((
context: WarActionContext<TriggerState>,
statName: WarStatName,
value: number | [number, number],
aux?: unknown
) => number | [number, number])
| undefined;
getWarPowerMultiplier?:
| ((
context: WarActionContext<TriggerState>,
unit: WarUnit<TriggerState>,
oppose: WarUnit<TriggerState>
) => [number, number])
| undefined;
| ((
context: WarActionContext<TriggerState>,
unit: WarUnit<TriggerState>,
oppose: WarUnit<TriggerState>
) => [number, number])
| undefined;
}
export class WarActionPipeline<TriggerState extends GeneralTriggerState = GeneralTriggerState> {
@@ -80,36 +80,36 @@ export class WarActionPipeline<TriggerState extends GeneralTriggerState = Genera
return caller;
}
onCalcStat<T extends WarStatName>(
onCalcStat<T extends number | [number, number]>(
context: WarActionContext<TriggerState>,
statName: T,
value: WarStatBundleMap[T]['value'],
aux?: WarStatBundleMap[T]['aux']
): WarStatBundleMap[T]['return'] {
let current = value;
statName: WarStatName,
value: T,
aux?: unknown
): T {
let current: number | [number, number] = value;
for (const module of this.modules) {
if (!module.onCalcStat) {
continue;
}
current = module.onCalcStat(context, statName, current as never, aux as never) as never;
current = module.onCalcStat(context, statName, current, aux);
}
return current;
return current as T;
}
onCalcOpposeStat<T extends WarStatName>(
onCalcOpposeStat<T extends number | [number, number]>(
context: WarActionContext<TriggerState>,
statName: T,
value: WarStatBundleMap[T]['value'],
aux?: WarStatBundleMap[T]['aux']
): WarStatBundleMap[T]['return'] {
let current = value;
statName: WarStatName,
value: T,
aux?: unknown
): T {
let current: number | [number, number] = value;
for (const module of this.modules) {
if (!module.onCalcOpposeStat) {
continue;
}
current = module.onCalcOpposeStat(context, statName, current as never, aux as never) as never;
current = module.onCalcOpposeStat(context, statName, current, aux);
}
return current;
return current as T;
}
getWarPowerMultiplier(
+10 -15
View File
@@ -466,8 +466,8 @@ export class WarUnitGeneral<
const baseTurnTime = this.isAttacker()
? getMetaString(this.general.meta, META_TURN_TIME)
: oppose instanceof WarUnitGeneral
? getMetaString(oppose.general.meta, META_TURN_TIME)
: getMetaString(this.general.meta, META_TURN_TIME);
? getMetaString(oppose.general.meta, META_TURN_TIME)
: getMetaString(this.general.meta, META_TURN_TIME);
if (!baseTurnTime) {
return;
}
@@ -480,8 +480,9 @@ export class WarUnitGeneral<
public override getMaxPhase(): number {
const base = this.getCrewType().speed;
const aux = { isAttacker: this.isAttacker() };
const context = this.getActionContext();
const phase = this.actionPipeline.onCalcStat(context, 'initWarPhase', base, { isAttacker: this.isAttacker() });
const phase = this.actionPipeline.onCalcStat(context, 'initWarPhase', base, aux);
return phase + this.bonusPhase;
}
@@ -506,16 +507,12 @@ export class WarUnitGeneral<
return strength;
}
private resolveOpposeStatValue(statName: WarStatName, value: number, aux?: any): number {
private resolveOpposeStatValue(statName: WarStatName, value: number, aux?: Record<string, unknown>): number {
const oppose = this.getOppose();
if (!(oppose instanceof WarUnitGeneral)) {
return value;
}
const result = oppose.getActionPipeline().onCalcOpposeStat(this.getActionContext(), statName, value, aux);
if (typeof result === 'number') {
return result;
}
return value;
return oppose.getActionPipeline().onCalcOpposeStat(this.getActionContext(), statName, value, aux);
}
public override getDex(crewType: WarCrewType): number {
@@ -530,10 +527,8 @@ export class WarUnitGeneral<
};
const statName = toDexStatName(armType);
let dex = this.actionPipeline.onCalcStat(this.getActionContext(), statName, base, aux);
if (typeof dex === 'number') {
dex = this.resolveOpposeStatValue(statName, dex, aux);
}
return typeof dex === 'number' ? dex : base;
dex = this.resolveOpposeStatValue(statName, dex, aux);
return dex;
}
public override getComputedAttack(): number {
@@ -583,8 +578,8 @@ export class WarUnitGeneral<
const mainStat = this.resolveMainStat(armType);
const coef =
armType === this.config.armTypes.wizard ||
armType === this.config.armTypes.siege ||
armType === this.config.armTypes.misc
armType === this.config.armTypes.siege ||
armType === this.config.armTypes.misc
? 0.4
: 0.5;