import { useState } from 'react' import { WEATHER } from '../game/constants' import { dollars, soldBusyness } from '../game/engine' import type { DayConditions, DayResult, Player } from '../game/types' import { Btn, Line } from './Crt' import { Scene } from './Scene' function Row({ label, value, strong }: { label: string; value: string; strong?: boolean }) { return (
{label} {value}
) } export function ReportScreen({ results, players, conditions, onNextDay, onRetire, onBlip, }: { results: DayResult[] players: Player[] conditions: DayConditions onNextDay: () => void onRetire: () => void onBlip: () => void }) { // App remounts this each day, so this starts fresh without a reset effect. const [index, setIndex] = useState(0) const r = results[index] const player = players.find((p) => p.id === r.playerId)! const isLast = index === results.length - 1 const everyoneBroke = players.every((p) => p.bankrupt) const events = [ WEATHER[conditions.weather].label, conditions.heatWave ? 'HEAT WAVE' : null, conditions.streetCrew ? 'STREET CREWS' : null, conditions.storm ? 'THUNDERSTORM' : null, ] .filter(Boolean) .join(' \u00b7 ') return (
$$ LEMONSVILLE DAILY FINANCIAL REPORT $$ DAY {conditions.day} — {player.name} {events} {player.bankrupt && ( <> {player.name}, YOU DO NOT HAVE ENOUGH MONEY LEFT TO STAY IN BUSINESS. )}
{!isLast && ( { onBlip() setIndex(index + 1) }} > NEXT REPORT ({index + 2}/{results.length}) )} {isLast && !everyoneBroke && ( DAY {conditions.day + 1} )} {isLast && ( {everyoneBroke ? 'SEE FINAL STANDINGS' : 'RETIRE'} )}
) }