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