fix core domestic command persistence parity
This commit is contained in:
@@ -23,6 +23,7 @@ import {
|
||||
CommandResolver,
|
||||
type DomesticActionContext,
|
||||
type InvestmentConfig,
|
||||
updateDomesticCriticalMeta,
|
||||
} from './che_상업투자.js';
|
||||
import { JosaUtil } from '@sammo-ts/common';
|
||||
import { clamp } from 'es-toolkit';
|
||||
@@ -54,7 +55,7 @@ const readTech = (nation: Nation): number => {
|
||||
};
|
||||
|
||||
// 레거시 nation.tech는 MariaDB FLOAT이며 다음 명령 재조회 시 6자리 유효숫자로 양자화된다.
|
||||
const toLegacyStoredTech = (value: number): number => Number(value.toPrecision(6));
|
||||
const toLegacyStoredTech = (value: number): number => Number(Math.fround(value).toPrecision(6));
|
||||
|
||||
export class ActionDefinition<
|
||||
TriggerState extends GeneralTriggerState = GeneralTriggerState,
|
||||
@@ -116,11 +117,14 @@ export class ActionDefinition<
|
||||
context.general.experience += result.exp;
|
||||
context.general.dedication += result.dedication;
|
||||
const intelExp = typeof context.general.meta.intel_exp === 'number' ? context.general.meta.intel_exp : 0;
|
||||
context.general.meta = {
|
||||
...context.general.meta,
|
||||
intel_exp: intelExp + 1,
|
||||
max_domestic_critical: result.pick === 'success' ? result.score : 0,
|
||||
};
|
||||
context.general.meta = updateDomesticCriticalMeta(
|
||||
{
|
||||
...context.general.meta,
|
||||
intel_exp: intelExp + 1,
|
||||
},
|
||||
result.pick,
|
||||
result.score
|
||||
);
|
||||
|
||||
const scoreText = Math.round(result.score).toLocaleString();
|
||||
const josaUl = JosaUtil.pick(ACTION_NAME, '을');
|
||||
|
||||
@@ -125,6 +125,15 @@ const addMetaNumber = (meta: GeneralMeta, key: string, delta: number): GeneralMe
|
||||
return { ...meta, [key]: current + delta };
|
||||
};
|
||||
|
||||
export const updateDomesticCriticalMeta = (
|
||||
meta: GeneralMeta,
|
||||
pick: DomesticCriticalPick,
|
||||
score: number
|
||||
): GeneralMeta => ({
|
||||
...meta,
|
||||
max_domestic_critical: pick === 'success' ? (getMetaNumber(meta, 'max_domestic_critical') ?? 0) + score / 2 : 0,
|
||||
});
|
||||
|
||||
export const buildDomesticContextFromView = <TriggerState extends GeneralTriggerState = GeneralTriggerState>(
|
||||
ctx: ConstraintContext,
|
||||
view: StateView
|
||||
@@ -360,10 +369,7 @@ export class ActionResolver<
|
||||
general.dedication += result.dedication;
|
||||
|
||||
const metaWithStatExp = addMetaNumber(general.meta, this.config.statExpKey, 1);
|
||||
general.meta =
|
||||
result.pick === 'success'
|
||||
? { ...metaWithStatExp, max_domestic_critical: result.score }
|
||||
: { ...metaWithStatExp, max_domestic_critical: 0 };
|
||||
general.meta = updateDomesticCriticalMeta(metaWithStatExp, result.pick, result.score);
|
||||
|
||||
const scoreText = Math.round(result.score).toLocaleString();
|
||||
const josaUl = JosaUtil.pick(this.config.name, '을');
|
||||
|
||||
@@ -20,6 +20,7 @@ import {
|
||||
CommandResolver,
|
||||
type DomesticActionContext,
|
||||
type InvestmentConfig,
|
||||
updateDomesticCriticalMeta,
|
||||
} from './che_상업투자.js';
|
||||
import { JosaUtil } from '@sammo-ts/common';
|
||||
import { clamp } from 'es-toolkit';
|
||||
@@ -95,11 +96,14 @@ export class ActionDefinition<
|
||||
context.general.dedication += result.dedication;
|
||||
const leadershipExp =
|
||||
typeof context.general.meta.leadership_exp === 'number' ? context.general.meta.leadership_exp : 0;
|
||||
context.general.meta = {
|
||||
...context.general.meta,
|
||||
leadership_exp: leadershipExp + 1,
|
||||
max_domestic_critical: result.pick === 'success' ? result.score : 0,
|
||||
};
|
||||
context.general.meta = updateDomesticCriticalMeta(
|
||||
{
|
||||
...context.general.meta,
|
||||
leadership_exp: leadershipExp + 1,
|
||||
},
|
||||
result.pick,
|
||||
result.score
|
||||
);
|
||||
|
||||
const scoreText = populationGain.toLocaleString();
|
||||
const josaUl = JosaUtil.pick(ACTION_NAME, '을');
|
||||
|
||||
@@ -19,6 +19,7 @@ import {
|
||||
CommandResolver,
|
||||
type DomesticActionContext,
|
||||
type InvestmentConfig,
|
||||
updateDomesticCriticalMeta,
|
||||
} from './che_상업투자.js';
|
||||
import { JosaUtil } from '@sammo-ts/common';
|
||||
import { clamp } from 'es-toolkit';
|
||||
@@ -48,7 +49,7 @@ const readTrust = (city: City): number => {
|
||||
|
||||
// 레거시 city.trust는 MariaDB FLOAT이며 다음 명령에서 6자리 유효숫자로
|
||||
// 재조회된다. 같은 턴의 후속 명령도 그 저장 경계를 보도록 정규화한다.
|
||||
const toLegacyStoredTrust = (value: number): number => Number(value.toPrecision(6));
|
||||
const toLegacyStoredTrust = (value: number): number => Number(Math.fround(value).toPrecision(6));
|
||||
|
||||
const remainCityTrust = (): Constraint => ({
|
||||
name: 'remainCityTrust',
|
||||
@@ -117,11 +118,14 @@ export class ActionDefinition<
|
||||
context.general.dedication += result.dedication;
|
||||
const leadershipExp =
|
||||
typeof context.general.meta.leadership_exp === 'number' ? context.general.meta.leadership_exp : 0;
|
||||
context.general.meta = {
|
||||
...context.general.meta,
|
||||
leadership_exp: leadershipExp + 1,
|
||||
max_domestic_critical: result.pick === 'success' ? result.score : 0,
|
||||
};
|
||||
context.general.meta = updateDomesticCriticalMeta(
|
||||
{
|
||||
...context.general.meta,
|
||||
leadership_exp: leadershipExp + 1,
|
||||
},
|
||||
result.pick,
|
||||
result.score
|
||||
);
|
||||
|
||||
const scoreText = trustDelta.toFixed(1);
|
||||
const josaUl = JosaUtil.pick(ACTION_NAME, '을');
|
||||
|
||||
Reference in New Issue
Block a user