feat: update stat handling by introducing specific types for GeneralStatName and WarStatName across various modules
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
import type { GeneralActionContext } from '@sammo-ts/logic/triggers/general.js';
|
||||
import type { GeneralStatName, WarStatName } from '@sammo-ts/logic/triggers/types.js';
|
||||
import type { WarActionContext } from '@sammo-ts/logic/war/actions.js';
|
||||
import type { ItemModule, ItemSlot } from './types.js';
|
||||
|
||||
const resolveStatLabel = (statName: string): string => {
|
||||
const resolveStatLabel = (statName: GeneralStatName): string => {
|
||||
switch (statName) {
|
||||
case 'leadership':
|
||||
return '통솔';
|
||||
@@ -37,19 +38,19 @@ export const createStatItemModule = (
|
||||
const info = options.extraInfo ? `${baseInfo}<br>${options.extraInfo}` : baseInfo;
|
||||
function onCalcStat(
|
||||
_context: GeneralActionContext,
|
||||
statName: string,
|
||||
statName: GeneralStatName,
|
||||
value: number,
|
||||
_aux?: unknown
|
||||
): number;
|
||||
function onCalcStat(
|
||||
_context: WarActionContext,
|
||||
statName: string,
|
||||
statName: WarStatName,
|
||||
value: number | [number, number],
|
||||
_aux?: unknown
|
||||
): number | [number, number];
|
||||
function onCalcStat(
|
||||
_context: GeneralActionContext | WarActionContext,
|
||||
statName: string,
|
||||
statName: GeneralStatName | WarStatName,
|
||||
value: number | [number, number]
|
||||
): number | [number, number] {
|
||||
if (statName !== options.statName) {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { createStatItemModule } from './base.js';
|
||||
import type { ItemModule } from './types.js';
|
||||
import type { GeneralActionContext } from '@sammo-ts/logic/triggers/general.js';
|
||||
import type { GeneralStatName, WarStatName } from '@sammo-ts/logic/triggers/types.js';
|
||||
import type { WarActionContext } from '@sammo-ts/logic/war/actions.js';
|
||||
|
||||
const STAT_VALUE = 3;
|
||||
@@ -22,19 +23,19 @@ export const itemModule: ItemModule = {
|
||||
onCalcStat: (() => {
|
||||
function onCalcStat(
|
||||
_context: GeneralActionContext,
|
||||
statName: string,
|
||||
statName: GeneralStatName,
|
||||
value: number,
|
||||
_aux?: unknown
|
||||
): number;
|
||||
function onCalcStat(
|
||||
_context: WarActionContext,
|
||||
statName: string,
|
||||
statName: WarStatName,
|
||||
value: number | [number, number],
|
||||
_aux?: unknown
|
||||
): number | [number, number];
|
||||
function onCalcStat(
|
||||
_context: GeneralActionContext | WarActionContext,
|
||||
statName: string,
|
||||
statName: GeneralStatName | WarStatName,
|
||||
value: number | [number, number]
|
||||
): number | [number, number] {
|
||||
let base = value;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { createStatItemModule } from './base.js';
|
||||
import type { ItemModule } from './types.js';
|
||||
import type { GeneralActionContext } from '@sammo-ts/logic/triggers/general.js';
|
||||
import type { GeneralStatName, WarStatName } from '@sammo-ts/logic/triggers/types.js';
|
||||
import type { WarActionContext } from '@sammo-ts/logic/war/actions.js';
|
||||
|
||||
const STAT_VALUE = 8;
|
||||
@@ -23,19 +24,19 @@ export const itemModule: ItemModule = {
|
||||
onCalcStat: (() => {
|
||||
function onCalcStat(
|
||||
_context: GeneralActionContext,
|
||||
statName: string,
|
||||
statName: GeneralStatName,
|
||||
value: number,
|
||||
_aux?: unknown
|
||||
): number;
|
||||
function onCalcStat(
|
||||
_context: WarActionContext,
|
||||
statName: string,
|
||||
statName: WarStatName,
|
||||
value: number | [number, number],
|
||||
_aux?: unknown
|
||||
): number | [number, number];
|
||||
function onCalcStat(
|
||||
_context: GeneralActionContext | WarActionContext,
|
||||
statName: string,
|
||||
statName: GeneralStatName | WarStatName,
|
||||
value: number | [number, number]
|
||||
): number | [number, number] {
|
||||
let base = value;
|
||||
|
||||
@@ -4,6 +4,17 @@ import {
|
||||
GeneralTriggerCaller,
|
||||
type GeneralActionContext,
|
||||
} from '@sammo-ts/logic/triggers/general.js';
|
||||
import type {
|
||||
GeneralStatName,
|
||||
TriggerActionPhase,
|
||||
TriggerActionType,
|
||||
TriggerDomesticActionType,
|
||||
TriggerDomesticVarType,
|
||||
TriggerNationalIncomeType,
|
||||
TriggerStrategicActionType,
|
||||
TriggerStrategicVarType,
|
||||
WarStatName,
|
||||
} from '@sammo-ts/logic/triggers/types.js';
|
||||
import type { WarActionContext, WarActionModule } from '@sammo-ts/logic/war/actions.js';
|
||||
import { WarTriggerCaller } from '@sammo-ts/logic/war/triggers.js';
|
||||
import type { WarUnit } from '@sammo-ts/logic/war/units.js';
|
||||
@@ -138,8 +149,8 @@ class ItemGeneralActionRouter<
|
||||
|
||||
onCalcDomestic(
|
||||
context: GeneralActionContext<TriggerState>,
|
||||
turnType: string,
|
||||
varType: string,
|
||||
turnType: TriggerDomesticActionType,
|
||||
varType: TriggerDomesticVarType,
|
||||
value: number,
|
||||
aux?: unknown
|
||||
): number {
|
||||
@@ -155,7 +166,7 @@ class ItemGeneralActionRouter<
|
||||
|
||||
onCalcStat(
|
||||
context: GeneralActionContext<TriggerState>,
|
||||
statName: string,
|
||||
statName: GeneralStatName,
|
||||
value: number,
|
||||
aux?: unknown
|
||||
): number {
|
||||
@@ -171,7 +182,7 @@ class ItemGeneralActionRouter<
|
||||
|
||||
onCalcOpposeStat(
|
||||
context: GeneralActionContext<TriggerState>,
|
||||
statName: string,
|
||||
statName: GeneralStatName,
|
||||
value: number,
|
||||
aux?: unknown
|
||||
): number {
|
||||
@@ -187,8 +198,8 @@ class ItemGeneralActionRouter<
|
||||
|
||||
onCalcStrategic(
|
||||
context: GeneralActionContext<TriggerState>,
|
||||
turnType: string,
|
||||
varType: string,
|
||||
turnType: TriggerStrategicActionType,
|
||||
varType: TriggerStrategicVarType,
|
||||
value: number
|
||||
): number {
|
||||
let current = value;
|
||||
@@ -203,7 +214,7 @@ class ItemGeneralActionRouter<
|
||||
|
||||
onCalcNationalIncome(
|
||||
context: GeneralActionContext<TriggerState>,
|
||||
type: string,
|
||||
type: TriggerNationalIncomeType,
|
||||
amount: number
|
||||
): number {
|
||||
let current = amount;
|
||||
@@ -218,8 +229,8 @@ class ItemGeneralActionRouter<
|
||||
|
||||
onArbitraryAction(
|
||||
context: GeneralActionContext<TriggerState>,
|
||||
actionType: string,
|
||||
phase?: string | null,
|
||||
actionType: TriggerActionType,
|
||||
phase?: TriggerActionPhase | null,
|
||||
aux?: Record<string, unknown> | null
|
||||
): Record<string, unknown> | null {
|
||||
let current = aux ?? null;
|
||||
@@ -283,7 +294,7 @@ class ItemWarActionRouter<
|
||||
|
||||
onCalcStat(
|
||||
context: WarActionContext<TriggerState>,
|
||||
statName: string,
|
||||
statName: WarStatName,
|
||||
value: number | [number, number],
|
||||
aux?: unknown
|
||||
): number | [number, number] {
|
||||
@@ -299,7 +310,7 @@ class ItemWarActionRouter<
|
||||
|
||||
onCalcOpposeStat(
|
||||
context: WarActionContext<TriggerState>,
|
||||
statName: string,
|
||||
statName: WarStatName,
|
||||
value: number | [number, number],
|
||||
aux?: unknown
|
||||
): number | [number, number] {
|
||||
|
||||
@@ -3,6 +3,17 @@ import type {
|
||||
GeneralActionContext,
|
||||
GeneralTriggerCaller,
|
||||
} from '@sammo-ts/logic/triggers/general.js';
|
||||
import type {
|
||||
GeneralStatName,
|
||||
TriggerActionPhase,
|
||||
TriggerActionType,
|
||||
TriggerDomesticActionType,
|
||||
TriggerDomesticVarType,
|
||||
TriggerNationalIncomeType,
|
||||
TriggerStrategicActionType,
|
||||
TriggerStrategicVarType,
|
||||
WarStatName,
|
||||
} from '@sammo-ts/logic/triggers/types.js';
|
||||
import type { WarActionContext } from '@sammo-ts/logic/war/actions.js';
|
||||
import type { WarTriggerCaller } from '@sammo-ts/logic/war/triggers.js';
|
||||
import type { WarUnit } from '@sammo-ts/logic/war/units.js';
|
||||
@@ -29,8 +40,8 @@ export interface ItemModule<
|
||||
|
||||
onCalcDomestic?(
|
||||
context: GeneralActionContext<TriggerState>,
|
||||
turnType: string,
|
||||
varType: string,
|
||||
turnType: TriggerDomesticActionType,
|
||||
varType: TriggerDomesticVarType,
|
||||
value: number,
|
||||
aux?: unknown
|
||||
): number;
|
||||
@@ -38,13 +49,13 @@ export interface ItemModule<
|
||||
onCalcStat?: {
|
||||
(
|
||||
context: GeneralActionContext<TriggerState>,
|
||||
statName: string,
|
||||
statName: GeneralStatName,
|
||||
value: number,
|
||||
aux?: unknown
|
||||
): number;
|
||||
(
|
||||
context: WarActionContext<TriggerState>,
|
||||
statName: string,
|
||||
statName: WarStatName,
|
||||
value: number | [number, number],
|
||||
aux?: unknown
|
||||
): number | [number, number];
|
||||
@@ -53,13 +64,13 @@ export interface ItemModule<
|
||||
onCalcOpposeStat?: {
|
||||
(
|
||||
context: GeneralActionContext<TriggerState>,
|
||||
statName: string,
|
||||
statName: GeneralStatName,
|
||||
value: number,
|
||||
aux?: unknown
|
||||
): number;
|
||||
(
|
||||
context: WarActionContext<TriggerState>,
|
||||
statName: string,
|
||||
statName: WarStatName,
|
||||
value: number | [number, number],
|
||||
aux?: unknown
|
||||
): number | [number, number];
|
||||
@@ -67,21 +78,21 @@ export interface ItemModule<
|
||||
|
||||
onCalcStrategic?(
|
||||
context: GeneralActionContext<TriggerState>,
|
||||
turnType: string,
|
||||
varType: string,
|
||||
turnType: TriggerStrategicActionType,
|
||||
varType: TriggerStrategicVarType,
|
||||
value: number
|
||||
): number;
|
||||
|
||||
onCalcNationalIncome?(
|
||||
context: GeneralActionContext<TriggerState>,
|
||||
type: string,
|
||||
type: TriggerNationalIncomeType,
|
||||
amount: number
|
||||
): number;
|
||||
|
||||
onArbitraryAction?(
|
||||
context: GeneralActionContext<TriggerState>,
|
||||
actionType: string,
|
||||
phase?: string | null,
|
||||
actionType: TriggerActionType,
|
||||
phase?: TriggerActionPhase | null,
|
||||
aux?: Record<string, unknown> | null
|
||||
): Record<string, unknown> | null;
|
||||
|
||||
|
||||
@@ -1,5 +1,15 @@
|
||||
import type { GeneralTriggerState } from '@sammo-ts/logic/domain/entities.js';
|
||||
import { type GeneralActionContext, GeneralTriggerCaller } from './general.js';
|
||||
import type {
|
||||
GeneralStatName,
|
||||
TriggerActionPhase,
|
||||
TriggerActionType,
|
||||
TriggerDomesticActionType,
|
||||
TriggerDomesticVarType,
|
||||
TriggerNationalIncomeType,
|
||||
TriggerStrategicActionType,
|
||||
TriggerStrategicVarType,
|
||||
} from './types.js';
|
||||
|
||||
export interface GeneralActionModule<TriggerState extends GeneralTriggerState = GeneralTriggerState> {
|
||||
getName?(): string;
|
||||
@@ -11,43 +21,43 @@ export interface GeneralActionModule<TriggerState extends GeneralTriggerState =
|
||||
|
||||
onCalcDomestic?(
|
||||
context: GeneralActionContext<TriggerState>,
|
||||
turnType: string,
|
||||
varType: string,
|
||||
turnType: TriggerDomesticActionType,
|
||||
varType: TriggerDomesticVarType,
|
||||
value: number,
|
||||
aux?: unknown
|
||||
): number;
|
||||
|
||||
onCalcStat?(
|
||||
context: GeneralActionContext<TriggerState>,
|
||||
statName: string,
|
||||
statName: GeneralStatName,
|
||||
value: number,
|
||||
aux?: unknown
|
||||
): number;
|
||||
|
||||
onCalcOpposeStat?(
|
||||
context: GeneralActionContext<TriggerState>,
|
||||
statName: string,
|
||||
statName: GeneralStatName,
|
||||
value: number,
|
||||
aux?: unknown
|
||||
): number;
|
||||
|
||||
onCalcStrategic?(
|
||||
context: GeneralActionContext<TriggerState>,
|
||||
turnType: string,
|
||||
varType: string,
|
||||
turnType: TriggerStrategicActionType,
|
||||
varType: TriggerStrategicVarType,
|
||||
value: number
|
||||
): number;
|
||||
|
||||
onCalcNationalIncome?(
|
||||
context: GeneralActionContext<TriggerState>,
|
||||
type: string,
|
||||
type: TriggerNationalIncomeType,
|
||||
amount: number
|
||||
): number;
|
||||
|
||||
onArbitraryAction?(
|
||||
context: GeneralActionContext<TriggerState>,
|
||||
actionType: string,
|
||||
phase?: string | null,
|
||||
actionType: TriggerActionType,
|
||||
phase?: TriggerActionPhase | null,
|
||||
aux?: Record<string, unknown> | null
|
||||
): Record<string, unknown> | null;
|
||||
}
|
||||
@@ -76,8 +86,8 @@ export class GeneralActionPipeline<TriggerState extends GeneralTriggerState = Ge
|
||||
|
||||
onCalcDomestic(
|
||||
context: GeneralActionContext<TriggerState>,
|
||||
turnType: string,
|
||||
varType: string,
|
||||
turnType: TriggerDomesticActionType,
|
||||
varType: TriggerDomesticVarType,
|
||||
value: number,
|
||||
aux?: unknown
|
||||
): number {
|
||||
@@ -93,7 +103,7 @@ export class GeneralActionPipeline<TriggerState extends GeneralTriggerState = Ge
|
||||
|
||||
onCalcStat(
|
||||
context: GeneralActionContext<TriggerState>,
|
||||
statName: string,
|
||||
statName: GeneralStatName,
|
||||
value: number,
|
||||
aux?: unknown
|
||||
): number {
|
||||
@@ -109,7 +119,7 @@ export class GeneralActionPipeline<TriggerState extends GeneralTriggerState = Ge
|
||||
|
||||
onCalcOpposeStat(
|
||||
context: GeneralActionContext<TriggerState>,
|
||||
statName: string,
|
||||
statName: GeneralStatName,
|
||||
value: number,
|
||||
aux?: unknown
|
||||
): number {
|
||||
@@ -125,8 +135,8 @@ export class GeneralActionPipeline<TriggerState extends GeneralTriggerState = Ge
|
||||
|
||||
onCalcStrategic(
|
||||
context: GeneralActionContext<TriggerState>,
|
||||
turnType: string,
|
||||
varType: string,
|
||||
turnType: TriggerStrategicActionType,
|
||||
varType: TriggerStrategicVarType,
|
||||
value: number
|
||||
): number {
|
||||
let current = value;
|
||||
@@ -141,7 +151,7 @@ export class GeneralActionPipeline<TriggerState extends GeneralTriggerState = Ge
|
||||
|
||||
onCalcNationalIncome(
|
||||
context: GeneralActionContext<TriggerState>,
|
||||
type: string,
|
||||
type: TriggerNationalIncomeType,
|
||||
amount: number
|
||||
): number {
|
||||
let current = amount;
|
||||
@@ -156,8 +166,8 @@ export class GeneralActionPipeline<TriggerState extends GeneralTriggerState = Ge
|
||||
|
||||
onArbitraryAction(
|
||||
context: GeneralActionContext<TriggerState>,
|
||||
actionType: string,
|
||||
phase?: string | null,
|
||||
actionType: TriggerActionType,
|
||||
phase?: TriggerActionPhase | null,
|
||||
aux?: Record<string, unknown> | null
|
||||
): Record<string, unknown> | null {
|
||||
let current = aux ?? null;
|
||||
|
||||
@@ -1,6 +1,17 @@
|
||||
import type { GeneralTriggerState } from '@sammo-ts/logic/domain/entities.js';
|
||||
import type { GeneralActionContext } from '@sammo-ts/logic/triggers/general.js';
|
||||
import type { GeneralActionModule } from '@sammo-ts/logic/triggers/general-action.js';
|
||||
import type {
|
||||
GeneralStatName,
|
||||
TriggerActionPhase,
|
||||
TriggerActionType,
|
||||
TriggerDomesticActionType,
|
||||
TriggerDomesticVarType,
|
||||
TriggerNationalIncomeType,
|
||||
TriggerStrategicActionType,
|
||||
TriggerStrategicVarType,
|
||||
WarStatName,
|
||||
} from '@sammo-ts/logic/triggers/types.js';
|
||||
import type { WarActionContext, WarActionModule } from '@sammo-ts/logic/war/actions.js';
|
||||
import type { WarUnit } from '@sammo-ts/logic/war/units.js';
|
||||
import type { WarTriggerCaller } from '@sammo-ts/logic/war/triggers.js';
|
||||
@@ -57,8 +68,8 @@ export class SpecialGeneralActionRouter<
|
||||
|
||||
onCalcDomestic(
|
||||
context: GeneralActionContext<TriggerState>,
|
||||
turnType: string,
|
||||
varType: string,
|
||||
turnType: TriggerDomesticActionType,
|
||||
varType: TriggerDomesticVarType,
|
||||
value: number,
|
||||
aux?: unknown
|
||||
): number {
|
||||
@@ -68,7 +79,7 @@ export class SpecialGeneralActionRouter<
|
||||
|
||||
onCalcStat(
|
||||
context: GeneralActionContext<TriggerState>,
|
||||
statName: string,
|
||||
statName: GeneralStatName,
|
||||
value: number,
|
||||
aux?: unknown
|
||||
): number {
|
||||
@@ -78,7 +89,7 @@ export class SpecialGeneralActionRouter<
|
||||
|
||||
onCalcOpposeStat(
|
||||
context: GeneralActionContext<TriggerState>,
|
||||
statName: string,
|
||||
statName: GeneralStatName,
|
||||
value: number,
|
||||
aux?: unknown
|
||||
): number {
|
||||
@@ -90,8 +101,8 @@ export class SpecialGeneralActionRouter<
|
||||
|
||||
onCalcStrategic(
|
||||
context: GeneralActionContext<TriggerState>,
|
||||
turnType: string,
|
||||
varType: string,
|
||||
turnType: TriggerStrategicActionType,
|
||||
varType: TriggerStrategicVarType,
|
||||
value: number
|
||||
): number {
|
||||
const module = this.getModule(context);
|
||||
@@ -100,7 +111,7 @@ export class SpecialGeneralActionRouter<
|
||||
|
||||
onCalcNationalIncome(
|
||||
context: GeneralActionContext<TriggerState>,
|
||||
type: string,
|
||||
type: TriggerNationalIncomeType,
|
||||
amount: number
|
||||
): number {
|
||||
const module = this.getModule(context);
|
||||
@@ -109,8 +120,8 @@ export class SpecialGeneralActionRouter<
|
||||
|
||||
onArbitraryAction(
|
||||
context: GeneralActionContext<TriggerState>,
|
||||
actionType: string,
|
||||
phase?: string | null,
|
||||
actionType: TriggerActionType,
|
||||
phase?: TriggerActionPhase | null,
|
||||
aux?: Record<string, unknown> | null
|
||||
): Record<string, unknown> | null {
|
||||
const module = this.getModule(context);
|
||||
@@ -156,7 +167,7 @@ export class SpecialWarActionRouter<
|
||||
|
||||
onCalcStat(
|
||||
context: WarActionContext<TriggerState>,
|
||||
statName: string,
|
||||
statName: WarStatName,
|
||||
value: number | [number, number],
|
||||
aux?: unknown
|
||||
): number | [number, number] {
|
||||
@@ -166,7 +177,7 @@ export class SpecialWarActionRouter<
|
||||
|
||||
onCalcOpposeStat(
|
||||
context: WarActionContext<TriggerState>,
|
||||
statName: string,
|
||||
statName: WarStatName,
|
||||
value: number | [number, number],
|
||||
aux?: unknown
|
||||
): number | [number, number] {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import type { GeneralActionContext } from '@sammo-ts/logic/triggers/general.js';
|
||||
import type { GeneralStatName, WarStatName } from '@sammo-ts/logic/triggers/types.js';
|
||||
import type { WarActionContext } from '@sammo-ts/logic/war/actions.js';
|
||||
import type { SpecialActionModule } from '@sammo-ts/logic/triggers/special/types.js';
|
||||
|
||||
@@ -18,19 +19,19 @@ const resolveLeadershipBonus = (
|
||||
|
||||
function onCalcStat(
|
||||
context: GeneralActionContext,
|
||||
statName: string,
|
||||
statName: GeneralStatName,
|
||||
value: number,
|
||||
aux?: unknown
|
||||
): number;
|
||||
function onCalcStat(
|
||||
context: WarActionContext,
|
||||
statName: string,
|
||||
statName: WarStatName,
|
||||
value: number | [number, number],
|
||||
aux?: unknown
|
||||
): number | [number, number];
|
||||
function onCalcStat(
|
||||
context: GeneralActionContext | WarActionContext,
|
||||
statName: string,
|
||||
statName: GeneralStatName | WarStatName,
|
||||
value: number | [number, number]
|
||||
): number | [number, number] {
|
||||
if (statName !== 'leadership') {
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
export type TriggerActionType = '장비매매';
|
||||
|
||||
export type TriggerActionPhase = '판매' | '구매';
|
||||
|
||||
export type TriggerDomesticActionType =
|
||||
| '상업'
|
||||
| '인재탐색'
|
||||
| '징병'
|
||||
| '징집인구'
|
||||
| '계략'
|
||||
| '민심'
|
||||
| '인구'
|
||||
| '기술'
|
||||
| '모병';
|
||||
|
||||
export type TriggerDomesticVarType =
|
||||
| 'cost'
|
||||
| 'score'
|
||||
| 'success'
|
||||
| 'fail'
|
||||
| 'train'
|
||||
| 'atmos'
|
||||
| 'rice'
|
||||
| 'probability';
|
||||
|
||||
export type TriggerStrategicActionType = '의병모집';
|
||||
|
||||
export type TriggerStrategicVarType = 'delay' | 'globalDelay';
|
||||
|
||||
export type TriggerNationalIncomeType = 'gold' | 'rice';
|
||||
|
||||
export type GeneralStatName = 'leadership' | 'strength' | 'intelligence';
|
||||
|
||||
export type WarStatName =
|
||||
| GeneralStatName
|
||||
| 'cityBattleOrder'
|
||||
| 'initWarPhase'
|
||||
| 'bonusTrain'
|
||||
| 'bonusAtmos'
|
||||
| 'warCriticalRatio'
|
||||
| 'warAvoidRatio'
|
||||
| 'killRice'
|
||||
| 'criticalDamageRange'
|
||||
| 'warMagicSuccessDamage'
|
||||
| 'warMagicTrialProb'
|
||||
| `dex${number}`;
|
||||
@@ -7,6 +7,7 @@ import type {
|
||||
Nation,
|
||||
} from '@sammo-ts/logic/domain/entities.js';
|
||||
import type { ActionLogger } from '@sammo-ts/logic/logging/actionLogger.js';
|
||||
import type { WarStatName } from '@sammo-ts/logic/triggers/types.js';
|
||||
import type { WarUnit } from './units.js';
|
||||
import { WarTriggerCaller } from './triggers.js';
|
||||
|
||||
@@ -33,14 +34,14 @@ export interface WarActionModule<TriggerState extends GeneralTriggerState = Gene
|
||||
|
||||
onCalcStat?(
|
||||
context: WarActionContext<TriggerState>,
|
||||
statName: string,
|
||||
statName: WarStatName,
|
||||
value: number | [number, number],
|
||||
aux?: unknown
|
||||
): number | [number, number];
|
||||
|
||||
onCalcOpposeStat?(
|
||||
context: WarActionContext<TriggerState>,
|
||||
statName: string,
|
||||
statName: WarStatName,
|
||||
value: number | [number, number],
|
||||
aux?: unknown
|
||||
): number | [number, number];
|
||||
@@ -90,7 +91,7 @@ export class WarActionPipeline<
|
||||
|
||||
onCalcStat<T extends number | [number, number]>(
|
||||
context: WarActionContext<TriggerState>,
|
||||
statName: string,
|
||||
statName: WarStatName,
|
||||
value: T,
|
||||
aux?: unknown
|
||||
): T {
|
||||
@@ -106,7 +107,7 @@ export class WarActionPipeline<
|
||||
|
||||
onCalcOpposeStat<T extends number | [number, number]>(
|
||||
context: WarActionContext<TriggerState>,
|
||||
statName: string,
|
||||
statName: WarStatName,
|
||||
value: T,
|
||||
aux?: unknown
|
||||
): T {
|
||||
|
||||
@@ -10,6 +10,7 @@ import type {
|
||||
} from '@sammo-ts/logic/domain/entities.js';
|
||||
import type { ActionLogger } from '@sammo-ts/logic/logging/actionLogger.js';
|
||||
import { LogFormat } from '@sammo-ts/logic/logging/types.js';
|
||||
import type { WarStatName } from '@sammo-ts/logic/triggers/types.js';
|
||||
import { getTechAbility, getTechCost } from '@sammo-ts/logic/world/unitSet.js';
|
||||
import { WarActionPipeline, type WarActionContext } from './actions.js';
|
||||
import type { WarEngineConfig } from './types.js';
|
||||
@@ -38,6 +39,9 @@ const META_LEADERSHIP_EXP = 'leadershipExp';
|
||||
|
||||
const RANK_WARNUM = `${META_RANK_PREFIX}warnum`;
|
||||
const RANK_KILLNUM = `${META_RANK_PREFIX}killnum`;
|
||||
|
||||
const toDexStatName = (armType: number): WarStatName =>
|
||||
`dex${armType}` as WarStatName;
|
||||
const RANK_DEATHNUM = `${META_RANK_PREFIX}deathnum`;
|
||||
const RANK_OCCUPIED = `${META_RANK_PREFIX}occupied`;
|
||||
const RANK_KILLCREW = `${META_RANK_PREFIX}killcrew`;
|
||||
@@ -526,7 +530,7 @@ export class WarUnitGeneral<
|
||||
}
|
||||
|
||||
private resolveOpposeStatValue(
|
||||
statName: string,
|
||||
statName: WarStatName,
|
||||
value: number,
|
||||
aux?: Record<string, unknown>
|
||||
): number {
|
||||
@@ -549,13 +553,14 @@ export class WarUnitGeneral<
|
||||
isAttacker: this.isAttacker(),
|
||||
opposeType: this.oppose?.getCrewType() ?? null,
|
||||
};
|
||||
const statName = toDexStatName(armType);
|
||||
let dex = this.actionPipeline.onCalcStat(
|
||||
this.getActionContext(),
|
||||
`dex${armType}`,
|
||||
statName,
|
||||
base,
|
||||
aux
|
||||
);
|
||||
dex = this.resolveOpposeStatValue(`dex${armType}`, dex, aux);
|
||||
dex = this.resolveOpposeStatValue(statName, dex, aux);
|
||||
return dex;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user