// SPDX-License-Identifier: GPL-3.0-only // Interface of the stadium block expansion: slots A-H, constants, immutable quote and the // quote/commit functions implemented in stadium_blocks.cpp. Block slots are distinct from the // stadium facilities used by the business plan. #pragma once #include "game/desk_actions.hpp" #include "game/weekly.hpp" #include #include #include namespace bmh { // Source choices 8..15 map to eight independent A–H record slots. These must // not be confused with StadiumInvestment's facilities 0..7. enum class StadiumBlockSlot : uint8_t { A = 0, B, C, D, E, F, G, H }; struct StadiumBlockExpansionConstants { std::array price_per_1000{}; std::array weeks{}; std::array max_places{}; }; // The edition's limits (thousands of places per block A-H), unit prices and construction weeks, // exactly as supplied: Diamond 3.7 gives 8/18/8/14 twice = 96,000 places. (1.0.3 to 1.0.12 raised // the limits to 144,000; withdrawn in 1.0.13, see stadium_blocks.cpp.) StadiumBlockExpansionConstants stadium_block_expansion_constants(const LeImage&); // An immutable quote binds the Source owner and every record/table value that // affects the quote. Commit recomputes this value before it touches money. struct StadiumBlockExpansionQuote { int manager = -1; int manager_club = -1; StadiumBlockSlot slot = StadiumBlockSlot::A; uint8_t current_build_weeks = 0; uint8_t current_raw_flags = 0; uint8_t current_capacity_thousands = 0; uint8_t current_future_capacity_thousands = 0; uint32_t total_target_places = 0; uint8_t desired_features = 0; // Source low bits: seats=1, roof=2. int company_price_percent = 0; uint32_t price_per_1000 = 0; uint32_t max_places = 0; uint32_t new_places = 0; uint32_t new_places_cost = 0; uint32_t seats_cost = 0; uint32_t roof_cost = 0; uint32_t undiscounted_cost = 0; uint32_t base_price = 0; uint8_t base_weeks = 0; bool operator==(const StadiumBlockExpansionQuote&) const = default; }; // Pure Source projection. Manual totals need not be multiples of 1000; only the // eventual +54 byte is floored to thousands. The supported source boundary is // 0..427 company percent, 0..255 thousand places, a positive duration, and // trusted table maxima <=255000. Current/target placement must satisfy // current<=target<=maximum; busy blocks, unknown idle feature bits, owner // mismatches, disabled existing features, malformed constants and any // intermediate that overflows Source's signed 32-bit arithmetic have no quote. // A valid zero-price quote remains previewable; commit refuses to construct it. std::optional quote_stadium_block_expansion( const GameState& g, int manager, StadiumBlockSlot slot, uint32_t total_target_places, uint8_t desired_features, int company_price_percent, const StadiumBlockExpansionConstants& constants); // Commit an already resolved tip decision exactly once. `Declined` proceeds at // the base quote; `Accepted` uses its precomputed price and weeks. A zero-price // quote never constructs. Notice exceptions propagate so the caller can restore // its full transaction checkpoint. bool build_stadium_block_expansion( GameState& g, int manager, StadiumBlockSlot slot, const StadiumBlockExpansionConstants& constants, const StadiumBlockExpansionQuote& quote, const StandBlockOffer& resolved_offer, WatcomRandom& rand, const ConstructionNoticeHook& payment_notice = {}, const SeasonTicketCompensationNoticeHook& compensation_notice = {}); } // namespace bmh