Something went wrong. Try again.
[Mirror] Libreopolis is a cross-platform city simulation game fully compatible with SimCity 2000. gitlab.com/conasg/libreopolis
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556// Integration: with finance ENABLED, the treasury settles each year — funds move at the Dec→Jan// boundary by Σ revenue/(12·divisor) over the verified 16-record budget. Checks the live wiring// (accrual + year-end), not bit-exactness of the tax base (the R/C/I assessment pass is unported, so// tax income tracks the saved base — see the phase body / DEVELOPMENT_TODO).#include "sc2k/sim/simulation.hpp"#include "sc2k/io/sc2_file.hpp"#include <cstdio>#include "test_paths.hpp"
using namespace sc2k;
#include "test_harness.hpp"
int main() { City c; auto r = io::load_sc2((city_file("TOKYO.SC2")), c); if (!r.ok) { std::printf("finance: skipped (%s)\n", r.error.c_str()); return 0; }
const long f0 = c.funds(); Simulation sim(c); sim.set_finance_enabled(true); // finance only (growth off) → the settlement is deterministic
// Walk months, watching for the year-end jump in funds. long settleDelta = 0; int yearEnds = 0, startMonth = sim.month(); long prev = c.funds(); for (int i = 0; i < 25 * 14; ++i) { // > 1 full year, so a Dec→Jan boundary is crossed sim.tick(); if (sim.clock() % 25 == 0) { // a month just rolled if (c.funds() != prev) { ++yearEnds; settleDelta = c.funds() - prev; } prev = c.funds(); } } const long f1 = c.funds(); std::printf("finance: TOKYO funds %ld -> %ld over 14 months (start month %d); year-end settles=%d, delta=%ld\n", f0, f1, startMonth, yearEnds, settleDelta);
CHECK(f1 != f0); // the treasury moved CHECK(yearEnds >= 1); // at least one Dec→Jan settlement happened // Sanity: a single year's settlement for a real city is a meaningful but bounded sum. CHECK(settleDelta != 0 && (settleDelta > -50000000 && settleDelta < 50000000));
if (failures == 0) { std::printf("finance: all checks passed\n"); return 0; } std::printf("finance: %d failure(s)\n", failures); return 1;}