예약 커맨드 비용 표시 복원
This commit is contained in:
@@ -21,6 +21,8 @@ export interface GeneralActionDefinition<
|
||||
getPreReqTurn?(context: Context, args: Args): number;
|
||||
// 입력 시점에 대상이 정해져야 소요 턴을 계산할 수 있는 명령의 Ref 표시 문구.
|
||||
getTurnDurationHint?(): string;
|
||||
// Ref getCommandDetailTitle()처럼 예약 목록에 현재 비용 또는 계산식을 투영한다.
|
||||
getCostHint?(ctx: ConstraintContext, view: StateView): ActionCostHint | null;
|
||||
getPostReqTurn?(context: Context, args: Args): number;
|
||||
getStackSequence?(context: Context, args: Args): number | null;
|
||||
getProgressText?(context: Context, args: Args, term: number, termMax: number): string;
|
||||
@@ -28,3 +30,9 @@ export interface GeneralActionDefinition<
|
||||
getInheritanceActiveActionAmount?(context: Context, args: Args): number;
|
||||
resolve(context: Context, args: Args): GeneralActionOutcome<TriggerState>;
|
||||
}
|
||||
|
||||
export interface ActionCostHint {
|
||||
gold?: number;
|
||||
rice?: number;
|
||||
formula?: string;
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ import {
|
||||
reqGeneralRice,
|
||||
suppliedCity,
|
||||
} from '@sammo-ts/logic/constraints/presets.js';
|
||||
import type { GeneralActionDefinition } from '@sammo-ts/logic/actions/definition.js';
|
||||
import type { ActionCostHint, GeneralActionDefinition } from '@sammo-ts/logic/actions/definition.js';
|
||||
import type { GeneralActionOutcome } from '@sammo-ts/logic/actions/engine.js';
|
||||
import type {
|
||||
ActionContextBase,
|
||||
@@ -89,6 +89,11 @@ export class ActionDefinition<
|
||||
];
|
||||
}
|
||||
|
||||
getCostHint(ctx: ConstraintContext, view: StateView): ActionCostHint | null {
|
||||
const context = buildDomesticContextFromView<TriggerState>(ctx, view);
|
||||
return context ? this.command.getCost(context) : null;
|
||||
}
|
||||
|
||||
resolve(context: TechResearchContext<TriggerState>, _args: TechResearchArgs): GeneralActionOutcome<TriggerState> {
|
||||
const result = this.command.resolve(context, context.rng);
|
||||
let techScore = result.score;
|
||||
|
||||
@@ -14,6 +14,7 @@ import {
|
||||
import { GeneralActionPipeline, type GeneralActionModule } from '@sammo-ts/logic/actionModules/general.js';
|
||||
import type { TriggerDomesticActionType } from '@sammo-ts/logic/actionModules/types.js';
|
||||
import type { GeneralActionDefinition } from '@sammo-ts/logic/actions/definition.js';
|
||||
import type { ActionCostHint } from '@sammo-ts/logic/actions/definition.js';
|
||||
import type {
|
||||
GeneralActionOutcome,
|
||||
GeneralActionResolver,
|
||||
@@ -448,6 +449,11 @@ export class ActionDefinition<
|
||||
];
|
||||
}
|
||||
|
||||
getCostHint(ctx: ConstraintContext, view: StateView): ActionCostHint | null {
|
||||
const context = buildDomesticContextFromView<TriggerState>(ctx, view);
|
||||
return context ? this.command.getCost(context) : null;
|
||||
}
|
||||
|
||||
resolve(
|
||||
context: GeneralActionResolveContext<TriggerState>,
|
||||
args: CommerceInvestmentArgs
|
||||
|
||||
@@ -9,7 +9,7 @@ import {
|
||||
reqGeneralRice,
|
||||
suppliedCity,
|
||||
} from '@sammo-ts/logic/constraints/presets.js';
|
||||
import type { GeneralActionDefinition } from '@sammo-ts/logic/actions/definition.js';
|
||||
import type { ActionCostHint, GeneralActionDefinition } from '@sammo-ts/logic/actions/definition.js';
|
||||
import type { GeneralActionOutcome, GeneralActionResolveContext } from '@sammo-ts/logic/actions/engine.js';
|
||||
import type { TurnCommandEnv } from '@sammo-ts/logic/actions/turn/commandEnv.js';
|
||||
import { tryApplyUniqueLottery } from '@sammo-ts/logic/rewards/uniqueLottery.js';
|
||||
@@ -76,6 +76,12 @@ export class ActionDefinition<
|
||||
];
|
||||
}
|
||||
|
||||
getCostHint(ctx: ConstraintContext, view: StateView): ActionCostHint | null {
|
||||
const context = buildDomesticContextFromView<TriggerState>(ctx, view);
|
||||
const cost = context ? this.command.getCost(context).gold : 0;
|
||||
return context ? { rice: cost } : null;
|
||||
}
|
||||
|
||||
resolve(
|
||||
context: GeneralActionResolveContext<TriggerState>,
|
||||
_args: SettlementArgs
|
||||
|
||||
@@ -8,7 +8,7 @@ import {
|
||||
reqGeneralRice,
|
||||
suppliedCity,
|
||||
} from '@sammo-ts/logic/constraints/presets.js';
|
||||
import type { GeneralActionDefinition } from '@sammo-ts/logic/actions/definition.js';
|
||||
import type { ActionCostHint, GeneralActionDefinition } from '@sammo-ts/logic/actions/definition.js';
|
||||
import type { GeneralActionOutcome, GeneralActionResolveContext } from '@sammo-ts/logic/actions/engine.js';
|
||||
import type { TurnCommandEnv } from '@sammo-ts/logic/actions/turn/commandEnv.js';
|
||||
import { tryApplyUniqueLottery } from '@sammo-ts/logic/rewards/uniqueLottery.js';
|
||||
@@ -91,6 +91,12 @@ export class ActionDefinition<
|
||||
];
|
||||
}
|
||||
|
||||
getCostHint(ctx: ConstraintContext, view: StateView): ActionCostHint | null {
|
||||
const context = buildDomesticContextFromView<TriggerState>(ctx, view);
|
||||
const cost = context ? this.command.getCost(context).gold : 0;
|
||||
return context ? { rice: cost } : null;
|
||||
}
|
||||
|
||||
resolve(
|
||||
context: GeneralActionResolveContext<TriggerState>,
|
||||
_args: TrustActionArgs
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { JosaUtil, type RandomGenerator } from '@sammo-ts/common';
|
||||
import { GeneralActionPipeline, type GeneralActionModule } from '@sammo-ts/logic/actionModules/general.js';
|
||||
import type { GeneralActionDefinition } from '@sammo-ts/logic/actions/definition.js';
|
||||
import type { ActionCostHint } from '@sammo-ts/logic/actions/definition.js';
|
||||
import type {
|
||||
GeneralActionEffect,
|
||||
GeneralActionOutcome,
|
||||
@@ -391,6 +392,10 @@ export class StrategyActionDefinition<
|
||||
return [notBeNeutral(), occupiedCity(), suppliedCity(), reqGeneralGold(() => gold), reqGeneralRice(() => rice)];
|
||||
}
|
||||
|
||||
getCostHint(): ActionCostHint {
|
||||
return this.command.getCost();
|
||||
}
|
||||
|
||||
buildConstraints(_ctx: ConstraintContext, _args: StrategyArgs): Constraint[] {
|
||||
const { gold, rice } = this.command.getCost();
|
||||
return [
|
||||
|
||||
@@ -2,7 +2,7 @@ import type { GeneralTriggerState, Nation } from '@sammo-ts/logic/domain/entitie
|
||||
import type { Constraint, ConstraintContext, StateView } from '@sammo-ts/logic/constraints/types.js';
|
||||
import { allow, compareValues, unknownOrDeny } from '@sammo-ts/logic/constraints/helpers.js';
|
||||
import { beChief, occupiedCity, reqNationGold, reqNationRice } from '@sammo-ts/logic/constraints/presets.js';
|
||||
import type { GeneralActionDefinition } from '@sammo-ts/logic/actions/definition.js';
|
||||
import type { ActionCostHint, GeneralActionDefinition } from '@sammo-ts/logic/actions/definition.js';
|
||||
import type { GeneralActionOutcome, GeneralActionResolveContext } from '@sammo-ts/logic/actions/engine.js';
|
||||
import { createLogEffect, createNationPatchEffect } from '@sammo-ts/logic/actions/engine.js';
|
||||
import { LogCategory, LogFormat, LogScope } from '@sammo-ts/logic/logging/types.js';
|
||||
@@ -104,6 +104,10 @@ export const createEventResearchCommand = (
|
||||
return PRE_REQ_TURN;
|
||||
}
|
||||
|
||||
getCostHint(): ActionCostHint {
|
||||
return { gold: COST, rice: COST };
|
||||
}
|
||||
|
||||
resolve(
|
||||
context: GeneralActionResolveContext<TriggerState>,
|
||||
_args: Record<string, never>
|
||||
|
||||
Reference in New Issue
Block a user