fdc8e544ae
Turborepo monorepo with three packages: - packages/shared: TypeScript types for all 14 game systems + balance constants + formatting utils - packages/game-engine: Pure TS simulation engine with tick processor, economy, infrastructure, compute, research, market, and reputation systems - apps/web: React + Vite + Tailwind + Zustand frontend with sidebar dashboard layout, new game screen, dashboard with charts, infrastructure management, and model training pages Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
30 lines
882 B
TypeScript
30 lines
882 B
TypeScript
import type { GameState, ResearchState, ComputeState } from '@ai-tycoon/shared';
|
|
|
|
export function processResearch(state: GameState, compute: ComputeState): ResearchState {
|
|
const active = state.research.activeResearch;
|
|
if (!active) return state.research;
|
|
|
|
const researcherBoost = state.talent.departments.research.headcount *
|
|
state.talent.departments.research.effectiveness;
|
|
const speedMultiplier = 1 + researcherBoost * 0.1;
|
|
|
|
const newProgress = active.progressTicks + speedMultiplier;
|
|
|
|
if (newProgress >= active.totalTicks) {
|
|
return {
|
|
...state.research,
|
|
completedResearch: [...state.research.completedResearch, active.researchId],
|
|
activeResearch: null,
|
|
researchPoints: state.research.researchPoints + 1,
|
|
};
|
|
}
|
|
|
|
return {
|
|
...state.research,
|
|
activeResearch: {
|
|
...active,
|
|
progressTicks: newProgress,
|
|
},
|
|
};
|
|
}
|