feat(state): automation fields on action view model
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import type { GameContent } from '../content/index';
|
||||
import { isAutomationUnlocked } from '../engine/automation';
|
||||
import {
|
||||
canAffordAction,
|
||||
canUnlockAction,
|
||||
@@ -40,6 +41,8 @@ export interface ActionView {
|
||||
yieldsSummary: string | null;
|
||||
kind: ActionColumnKind;
|
||||
loopEnabled: boolean;
|
||||
automationUnlocked: boolean;
|
||||
inAutomationQueue: boolean;
|
||||
}
|
||||
|
||||
export interface ActionGroupView {
|
||||
@@ -84,6 +87,8 @@ export interface GameView {
|
||||
actionProgress: number;
|
||||
queuedActionIds: string[];
|
||||
queuedActionNames: string[];
|
||||
automationQueueIds: string[];
|
||||
automationQueueNames: string[];
|
||||
actions: ActionView[];
|
||||
story: StoryView;
|
||||
actionColumns: ActionColumnView[];
|
||||
@@ -153,6 +158,8 @@ export function toView(state: GameState, content: GameContent): GameView {
|
||||
: 0;
|
||||
const queuedActionIds = [...state.actionQueue];
|
||||
const queuedActionNames = queuedActionIds.map((id) => content.actionsById[id]?.name ?? id);
|
||||
const automationQueueIds = [...state.automationQueue];
|
||||
const automationQueueNames = automationQueueIds.map((id) => content.actionsById[id]?.name ?? id);
|
||||
|
||||
// Build a map of ActionView by id for column assembly
|
||||
const actionViewMap = new Map<string, ActionView>();
|
||||
@@ -172,6 +179,8 @@ export function toView(state: GameState, content: GameContent): GameView {
|
||||
yieldsSummary: formatResourceList(a.yields, content),
|
||||
kind: a.kind,
|
||||
loopEnabled: !!state.enabledLoopActionIds[a.id],
|
||||
automationUnlocked: isAutomationUnlocked(state, content, a.id),
|
||||
inAutomationQueue: state.automationQueue.includes(a.id),
|
||||
};
|
||||
actionViewMap.set(a.id, view);
|
||||
return view;
|
||||
@@ -243,6 +252,8 @@ export function toView(state: GameState, content: GameContent): GameView {
|
||||
actionProgress,
|
||||
queuedActionIds,
|
||||
queuedActionNames,
|
||||
automationQueueIds,
|
||||
automationQueueNames,
|
||||
actions,
|
||||
story,
|
||||
actionColumns,
|
||||
|
||||
Reference in New Issue
Block a user