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:
@@ -2,14 +2,19 @@ import type { GameState, ActiveResearch } from '@ai-tycoon/shared';
|
||||
import { TECH_TREE } from '@ai-tycoon/game-engine';
|
||||
|
||||
export function startResearch(state: GameState, research: ActiveResearch): boolean {
|
||||
if (state.research.activeResearch) return false;
|
||||
|
||||
const node = TECH_TREE.find(n => n.id === research.researchId);
|
||||
if (!node) return false;
|
||||
|
||||
const rpCost = node.cost.researchPoints ?? 0;
|
||||
if (rpCost > state.research.researchPoints) return false;
|
||||
|
||||
if (state.research.activeResearch) {
|
||||
if (state.research.researchQueue.includes(research.researchId)) return false;
|
||||
state.research.researchQueue.push(research.researchId);
|
||||
state.research.researchPoints -= rpCost;
|
||||
return true;
|
||||
}
|
||||
|
||||
state.research.activeResearch = research;
|
||||
state.research.researchPoints -= rpCost;
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user