wip
This commit is contained in:
@@ -34,10 +34,10 @@ export const createStatItemModule = (options: StatItemOptions): ItemModule => {
|
||||
const name = `${options.rawName}(+${options.statValue})`;
|
||||
const baseInfo = `${statLabel} +${options.statValue}`;
|
||||
const info = options.extraInfo ? `${baseInfo}<br>${options.extraInfo}` : baseInfo;
|
||||
const onCalcStat = (
|
||||
const onCalcStat = ((
|
||||
_context: GeneralActionContext | WarActionContext,
|
||||
statName: GeneralStatName | WarStatName,
|
||||
value: number | [number, number]
|
||||
value: number | [number, number],
|
||||
): number | [number, number] => {
|
||||
if (statName !== options.statName) {
|
||||
return value;
|
||||
@@ -46,7 +46,7 @@ export const createStatItemModule = (options: StatItemOptions): ItemModule => {
|
||||
return value + options.statValue;
|
||||
}
|
||||
return value;
|
||||
};
|
||||
}) as ItemModule['onCalcStat'];
|
||||
|
||||
return {
|
||||
key: options.key,
|
||||
@@ -59,6 +59,6 @@ export const createStatItemModule = (options: StatItemOptions): ItemModule => {
|
||||
consumable: false,
|
||||
reqSecu: options.reqSecu,
|
||||
unique: options.unique ?? false,
|
||||
onCalcStat,
|
||||
onCalcStat: onCalcStat!,
|
||||
};
|
||||
};
|
||||
|
||||
@@ -3,7 +3,6 @@ import { type GeneralActionContext, GeneralTriggerCaller } from './general.js';
|
||||
import type {
|
||||
GeneralStatBundleMap,
|
||||
GeneralStatName,
|
||||
WarStatBundleMap,
|
||||
TriggerActionPhase,
|
||||
TriggerActionType,
|
||||
TriggerDomesticActionType,
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
import type { GeneralTriggerState } from '@sammo-ts/logic/domain/entities.js';
|
||||
import type { GeneralActionModule } from '@sammo-ts/logic/triggers/general-action.js';
|
||||
import type { WarActionModule, WarActionContext } from '@sammo-ts/logic/war/actions.js';
|
||||
import type { GeneralActionContext } from '@sammo-ts/logic/triggers/general.js';
|
||||
import type { GeneralStatName, WarStatName } from '@sammo-ts/logic/triggers/types.js';
|
||||
import type { WarActionModule } from '@sammo-ts/logic/war/actions.js';
|
||||
|
||||
export type TraitKind = 'domestic' | 'war' | 'personality';
|
||||
|
||||
@@ -13,42 +11,8 @@ export interface TraitSpec {
|
||||
kind: TraitKind;
|
||||
}
|
||||
|
||||
import type {
|
||||
GeneralStatName,
|
||||
GeneralStatBundleMap,
|
||||
WarStatName,
|
||||
WarStatBundleMap,
|
||||
} from '../types.js';
|
||||
|
||||
export interface TraitOnCalcStat<TriggerState extends GeneralTriggerState = GeneralTriggerState> {
|
||||
<T extends GeneralStatName>(
|
||||
context: GeneralActionContext<TriggerState>,
|
||||
statName: T,
|
||||
value: GeneralStatBundleMap[T]['value'],
|
||||
aux?: GeneralStatBundleMap[T]['aux']
|
||||
): GeneralStatBundleMap[T]['return'];
|
||||
<T extends WarStatName>(
|
||||
context: WarActionContext<TriggerState>,
|
||||
statName: T,
|
||||
value: WarStatBundleMap[T]['value'],
|
||||
aux?: WarStatBundleMap[T]['aux']
|
||||
): WarStatBundleMap[T]['return'];
|
||||
}
|
||||
|
||||
export interface TraitOnCalcOpposeStat<TriggerState extends GeneralTriggerState = GeneralTriggerState> {
|
||||
<T extends GeneralStatName>(
|
||||
context: GeneralActionContext<TriggerState>,
|
||||
statName: T,
|
||||
value: GeneralStatBundleMap[T]['value'],
|
||||
aux?: GeneralStatBundleMap[T]['aux']
|
||||
): GeneralStatBundleMap[T]['return'];
|
||||
<T extends WarStatName>(
|
||||
context: WarActionContext<TriggerState>,
|
||||
statName: T,
|
||||
value: WarStatBundleMap[T]['value'],
|
||||
aux?: WarStatBundleMap[T]['aux']
|
||||
): WarStatBundleMap[T]['return'];
|
||||
}
|
||||
import type { TraitOnCalcStat, TraitOnCalcOpposeStat, OnCalcStatParams } from '../types.js';
|
||||
export type { TraitOnCalcStat, TraitOnCalcOpposeStat, OnCalcStatParams };
|
||||
|
||||
export type TraitModule<TriggerState extends GeneralTriggerState = GeneralTriggerState> = TraitSpec &
|
||||
Omit<GeneralActionModule<TriggerState>, 'onCalcStat' | 'onCalcOpposeStat'> &
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
import type { TraitOnCalcStat, TraitModule } from '@sammo-ts/logic/triggers/special/types.js';
|
||||
import type { GeneralActionContext } from '@sammo-ts/logic/triggers/general.js';
|
||||
import type { WarActionContext } from '@sammo-ts/logic/war/actions.js';
|
||||
import type { GeneralStatName, WarStatName } from '@sammo-ts/logic/triggers/types.js';
|
||||
import type { TraitOnCalcStat, TraitModule, OnCalcStatParams } from '@sammo-ts/logic/triggers/special/types.js';
|
||||
import type { WarStatName, WarStatBundleMap } from '@sammo-ts/logic/triggers/types.js';
|
||||
import { getMetaNumber } from '@sammo-ts/logic/war/utils.js';
|
||||
|
||||
import { WarUnit } from '@sammo-ts/logic/war/units.js';
|
||||
@@ -11,19 +9,20 @@ type WarUnitWithGeneral = WarUnit & { getGeneral: () => { meta: Record<string, u
|
||||
const hasGeneral = (unit: WarUnit): unit is WarUnitWithGeneral =>
|
||||
'getGeneral' in unit && typeof (unit as { getGeneral?: unknown }).getGeneral === 'function';
|
||||
|
||||
const onCalcStat = ((
|
||||
_context: GeneralActionContext | WarActionContext,
|
||||
statName: GeneralStatName | WarStatName,
|
||||
value: number | [number, number],
|
||||
aux?: unknown
|
||||
): number | [number, number] => {
|
||||
const isAttacker = typeof aux === 'object' && aux !== null && (aux as { isAttacker?: unknown }).isAttacker === true;
|
||||
|
||||
if (statName === 'warCriticalRatio' && isAttacker && typeof value === 'number') {
|
||||
return value + 0.1;
|
||||
const onCalcStat: TraitOnCalcStat = <T extends WarStatName>(
|
||||
...args: [
|
||||
context: any,
|
||||
statName: T,
|
||||
value: WarStatBundleMap[T]['value'],
|
||||
aux: WarStatBundleMap[T]['aux'],
|
||||
]
|
||||
) => {
|
||||
const [_context, statName, value, aux] = args as OnCalcStatParams;
|
||||
if (statName === 'warCriticalRatio' && aux.isAttacker) {
|
||||
return (value + 0.1) as WarStatBundleMap[T]['return'];
|
||||
}
|
||||
return value;
|
||||
}) as unknown as TraitOnCalcStat;
|
||||
return value as WarStatBundleMap[T]['return'];
|
||||
};
|
||||
|
||||
export const traitModule: TraitModule = {
|
||||
key: 'che_무쌍',
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import type { GeneralTriggerState } from '@sammo-ts/logic/domain/entities.js';
|
||||
import type { GeneralActionContext } from './general.js';
|
||||
import type { WarActionContext } from '../war/actions.js';
|
||||
export type TriggerActionType = '장비매매';
|
||||
|
||||
export type TriggerActionPhase = '판매' | '구매';
|
||||
|
||||
@@ -56,11 +55,11 @@ export type WarStatBundle =
|
||||
| { statName: 'warMagicTrialProb'; value: number; aux: undefined; return: number }
|
||||
| { statName: 'warMagicSuccessProb'; value: number; aux: undefined; return: number }
|
||||
| {
|
||||
statName: `dex${number}`;
|
||||
value: number;
|
||||
aux: { isAttacker: boolean; opposeType: { armType: number } | null };
|
||||
return: number;
|
||||
};
|
||||
statName: `dex${number}`;
|
||||
value: number;
|
||||
aux: { isAttacker: boolean; opposeType: { armType: number } | null };
|
||||
return: number;
|
||||
};
|
||||
|
||||
export type WarStatBundleMap = {
|
||||
[T in WarStatBundle as T['statName']]: T;
|
||||
@@ -68,34 +67,29 @@ export type WarStatBundleMap = {
|
||||
|
||||
export type WarStatName = WarStatBundle['statName'];
|
||||
|
||||
export interface TraitOnCalcStat<TriggerState extends GeneralTriggerState = GeneralTriggerState> {
|
||||
<T extends GeneralStatName>(
|
||||
context: GeneralActionContext<TriggerState>,
|
||||
statName: T,
|
||||
value: GeneralStatBundleMap[T]['value'],
|
||||
aux?: GeneralStatBundleMap[T]['aux']
|
||||
): GeneralStatBundleMap[T]['return'];
|
||||
<T extends WarStatName>(
|
||||
context: WarActionContext<TriggerState>,
|
||||
export type OnCalcStatParams<TriggerState extends GeneralTriggerState = GeneralTriggerState> = {
|
||||
[T in WarStatName]: [
|
||||
context: T extends GeneralStatName
|
||||
? GeneralActionContext<TriggerState> | WarActionContext<TriggerState>
|
||||
: WarActionContext<TriggerState>,
|
||||
statName: T,
|
||||
value: WarStatBundleMap[T]['value'],
|
||||
aux?: WarStatBundleMap[T]['aux']
|
||||
): WarStatBundleMap[T]['return'];
|
||||
}
|
||||
aux: WarStatBundleMap[T]['aux'],
|
||||
];
|
||||
}[WarStatName];
|
||||
|
||||
export interface TraitOnCalcOpposeStat<TriggerState extends GeneralTriggerState = GeneralTriggerState> {
|
||||
<T extends GeneralStatName>(
|
||||
context: GeneralActionContext<TriggerState>,
|
||||
statName: T,
|
||||
value: GeneralStatBundleMap[T]['value'],
|
||||
aux?: GeneralStatBundleMap[T]['aux']
|
||||
): GeneralStatBundleMap[T]['return'];
|
||||
export type TraitOnCalcStat<TriggerState extends GeneralTriggerState = GeneralTriggerState> = {
|
||||
<T extends WarStatName>(
|
||||
context: WarActionContext<TriggerState>,
|
||||
context: T extends GeneralStatName
|
||||
? GeneralActionContext<TriggerState> | WarActionContext<TriggerState>
|
||||
: WarActionContext<TriggerState>,
|
||||
statName: T,
|
||||
value: WarStatBundleMap[T]['value'],
|
||||
aux?: WarStatBundleMap[T]['aux']
|
||||
aux: WarStatBundleMap[T]['aux'],
|
||||
): WarStatBundleMap[T]['return'];
|
||||
}
|
||||
};
|
||||
|
||||
export type TraitOnCalcOpposeStat<TriggerState extends GeneralTriggerState = GeneralTriggerState> =
|
||||
TraitOnCalcStat<TriggerState>;
|
||||
|
||||
export type TriggerActionType = '장비매매';
|
||||
|
||||
Reference in New Issue
Block a user