Add sabotage probability clamp parity
This commit is contained in:
@@ -46,6 +46,10 @@ const ARGS_SCHEMA = z.object({
|
||||
});
|
||||
export type AgitateArgs = z.infer<typeof ARGS_SCHEMA>;
|
||||
|
||||
// 레거시 city.trust는 MariaDB FLOAT이며 다음 명령에서 6자리 유효숫자로
|
||||
// 재조회된다. 메모리 상태도 같은 persistence 경계로 정규화한다.
|
||||
const toLegacyStoredTrust = (value: number): number => Number(value.toPrecision(6));
|
||||
|
||||
export class ActionResolver<
|
||||
TriggerState extends GeneralTriggerState = GeneralTriggerState,
|
||||
> implements GeneralActionResolver<TriggerState, AgitateArgs> {
|
||||
@@ -95,7 +99,7 @@ export class ActionResolver<
|
||||
general.meta.firenum = (typeof general.meta.firenum === 'number' ? general.meta.firenum : 0) + 1;
|
||||
const newSecu = Math.max(0, destCity.security - result.agriDamage);
|
||||
const currentTrust = typeof destCity.meta.trust === 'number' ? destCity.meta.trust : 50;
|
||||
const newTrust = Math.max(0, currentTrust - result.commDamage);
|
||||
const newTrust = toLegacyStoredTrust(Math.max(0, currentTrust - result.commDamage));
|
||||
|
||||
// Log
|
||||
const commandName = ACTION_NAME;
|
||||
@@ -118,7 +122,6 @@ export class ActionResolver<
|
||||
effects.push(
|
||||
createCityPatchEffect(
|
||||
{
|
||||
...destCity,
|
||||
security: newSecu,
|
||||
state: 32,
|
||||
meta: {
|
||||
|
||||
@@ -1,12 +1,5 @@
|
||||
import type { RandomGenerator } from '@sammo-ts/common';
|
||||
import type {
|
||||
City,
|
||||
General,
|
||||
GeneralMeta,
|
||||
GeneralTriggerState,
|
||||
Nation,
|
||||
TriggerValue,
|
||||
} from '@sammo-ts/logic/domain/entities.js';
|
||||
import type { City, General, GeneralMeta, GeneralTriggerState, Nation } from '@sammo-ts/logic/domain/entities.js';
|
||||
import type { Constraint, ConstraintContext } from '@sammo-ts/logic/constraints/types.js';
|
||||
import {
|
||||
disallowDiplomacyBetweenStatus,
|
||||
@@ -350,18 +343,13 @@ export class ActionResolver<
|
||||
return { effects: [] };
|
||||
}
|
||||
|
||||
const updatedCityMeta: Record<string, TriggerValue> = {
|
||||
...context.destCity.meta,
|
||||
state: CITY_STATE_BURNING,
|
||||
};
|
||||
|
||||
// 타겟 도시는 Draft가 아니므로 Effect 반환
|
||||
effects.push(
|
||||
createCityPatchEffect(
|
||||
{
|
||||
agriculture: context.destCity.agriculture - result.agriDamage,
|
||||
commerce: context.destCity.commerce - result.commDamage,
|
||||
meta: updatedCityMeta,
|
||||
state: CITY_STATE_BURNING,
|
||||
},
|
||||
context.destCity.id
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user