import { useGameStore } from '@/store'; import { formatMoney, formatPercent, formatNumber, FUNDING_ROUNDS } from '@ai-tycoon/shared'; import type { FundingRoundType } from '@ai-tycoon/shared'; import { TrendingUp, DollarSign, PiggyBank, BarChart3, Rocket, Check, X as XIcon } from 'lucide-react'; import { AreaChart, Area, XAxis, YAxis, ResponsiveContainer, LineChart, Line, Tooltip } from 'recharts'; import { canRaiseFunding } from '@ai-tycoon/game-engine'; import type { GameState } from '@ai-tycoon/shared'; export function FinancePage() { const money = useGameStore((s) => s.economy.money); const revenuePerTick = useGameStore((s) => s.economy.revenuePerTick); const expensesPerTick = useGameStore((s) => s.economy.expensesPerTick); const funding = useGameStore((s) => s.economy.funding); const history = useGameStore((s) => s.economy.financialHistory); const infrastructure = useGameStore((s) => s.infrastructure); const talent = useGameStore((s) => s.talent); const raiseFunding = useGameStore((s) => s.raiseFunding); const totalRevenue = useGameStore((s) => s.economy.totalRevenue); const subscribers = useGameStore((s) => s.market.consumers.totalSubscribers); const reputationScore = useGameStore((s) => s.reputation.score); const state = useGameStore.getState(); const gameStateForFunding: GameState = { meta: state.meta, economy: state.economy, infrastructure: state.infrastructure, compute: state.compute, research: state.research, models: state.models, market: state.market, competitors: state.competitors, talent: state.talent, data: state.data, reputation: state.reputation, achievements: state.achievements, }; const fundingStatus = canRaiseFunding(gameStateForFunding); const netIncome = revenuePerTick - expensesPerTick; const burnRate = expensesPerTick > revenuePerTick ? expensesPerTick - revenuePerTick : 0; const runway = burnRate > 0 ? money / burnRate : Infinity; let infraCosts = 0; for (const cluster of infrastructure.clusters) { for (const campus of cluster.campuses) { for (const dc of campus.dataCenters) { infraCosts += dc.energyCostPerTick + dc.maintenanceCostPerTick; } } } const talentCosts = talent.totalSalaryPerTick; return (
No funding rounds completed yet.
) : (