Add research queue: queue multiple projects, auto-promote on completion, RP refund on dequeue
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -138,6 +138,8 @@ interface Actions {
|
||||
setProductPricing: (productLineId: string, field: string, value: number) => void;
|
||||
toggleProductLine: (productLineId: string) => void;
|
||||
startResearch: (research: ActiveResearch) => void;
|
||||
queueResearch: (researchId: string) => void;
|
||||
removeFromResearchQueue: (researchId: string) => void;
|
||||
hireDepartment: (departmentId: string, count: number) => void;
|
||||
purchaseDataset: (dataset: OwnedDataset, cost: number) => void;
|
||||
raiseFunding: (roundType: FundingRoundType) => void;
|
||||
@@ -1170,6 +1172,35 @@ export const useGameStore = create<Store>()(
|
||||
};
|
||||
}),
|
||||
|
||||
queueResearch: (researchId) => set((s) => {
|
||||
if (s.research.researchQueue.includes(researchId)) return s;
|
||||
const node = TECH_TREE.find(n => n.id === researchId);
|
||||
if (!node) return s;
|
||||
const rpCost = node.cost.researchPoints ?? 0;
|
||||
if (rpCost > s.research.researchPoints) return s;
|
||||
return {
|
||||
research: {
|
||||
...s.research,
|
||||
researchQueue: [...s.research.researchQueue, researchId],
|
||||
researchPoints: s.research.researchPoints - rpCost,
|
||||
},
|
||||
};
|
||||
}),
|
||||
|
||||
removeFromResearchQueue: (researchId) => set((s) => {
|
||||
const idx = s.research.researchQueue.indexOf(researchId);
|
||||
if (idx === -1) return s;
|
||||
const node = TECH_TREE.find(n => n.id === researchId);
|
||||
const rpRefund = node?.cost.researchPoints ?? 0;
|
||||
return {
|
||||
research: {
|
||||
...s.research,
|
||||
researchQueue: s.research.researchQueue.filter(id => id !== researchId),
|
||||
researchPoints: s.research.researchPoints + rpRefund,
|
||||
},
|
||||
};
|
||||
}),
|
||||
|
||||
hireDepartment: (departmentId, count) => set((s) => {
|
||||
const costPerHire = 2000;
|
||||
const totalCost = costPerHire * count;
|
||||
@@ -1450,7 +1481,12 @@ export const useGameStore = create<Store>()(
|
||||
infraNav: { level: 'clusters' },
|
||||
} as unknown as Store;
|
||||
}
|
||||
return _persisted as Store;
|
||||
const s = _persisted as Record<string, unknown>;
|
||||
const research = s.research as Record<string, unknown>;
|
||||
if (!research.researchQueue) {
|
||||
s.research = { ...research, researchQueue: [] };
|
||||
}
|
||||
return s as unknown as Store;
|
||||
},
|
||||
},
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user