- The monthly budget breaks each expense into the resource bought, its quantity and the average price paid: tile improvements already did, and now every upkeep row (buildings, units, works, transport) does too. - Private producers settle their daily wear from their own cash and borrow the shortfall from the central bank, so their cash never goes negative. - Producers fund their own construction and upgrades on the same credit; the treasury pays only for public works, roads and railways, and no private purchase is filed as a public tile-improvement expense. - The server settles the world until every commodity holds within 10% over a trailing seven days instead of a fixed 150, capped by --warmup (0 skips it). - The shipped month report carries its label again, so the budget header and pager name the month.
40 lines
1.7 KiB
JavaScript
40 lines
1.7 KiB
JavaScript
import { TestCase } from "./framework/test_case.js";
|
|
import { smallState } from "./framework/helpers.js";
|
|
import { HOURS_PER_DAY } from "../shared/game_state/constants.js";
|
|
|
|
// The opening settle: the server runs the world forward until commodity prices
|
|
// hold steady, so a fresh game is not served mid-shakeout.
|
|
export class WarmupTest extends TestCase {
|
|
test_prices_are_not_steady_before_the_window_is_full() {
|
|
const state = smallState();
|
|
this.assertFalse(state.pricesAreSteady(7, 0.1), "a fresh market has no history to judge");
|
|
}
|
|
|
|
test_settling_stops_once_prices_hold_steady() {
|
|
const state = smallState();
|
|
const days = state.warmUpToStability({ maxDays: 90 });
|
|
this.assertLess(days, 90, "it stopped early rather than at the cap");
|
|
this.assertGreaterOrEqual(days, 7, "it ran at least the seven-day window");
|
|
this.assertTrue(state.pricesAreSteady(7, 0.1), "prices are steady when it decides to stop");
|
|
}
|
|
|
|
test_settling_stops_at_the_cap_when_it_never_steadies() {
|
|
const state = smallState();
|
|
const days = state.warmUpToStability({ maxDays: 3 });
|
|
this.assertEqual(days, 3, "the cap bounds a world that never settles");
|
|
this.assertEqual(state.totalHours, 3 * HOURS_PER_DAY, "three days were actually run");
|
|
}
|
|
|
|
test_a_zero_cap_skips_the_settle() {
|
|
const state = smallState();
|
|
this.assertEqual(state.warmUpToStability({ maxDays: 0 }), 0, "nothing is run");
|
|
this.assertEqual(state.totalHours, 0, "the clock did not move");
|
|
}
|
|
|
|
test_a_fixed_warm_up_still_runs_the_exact_days() {
|
|
const state = smallState();
|
|
state.warmUp(5);
|
|
this.assertEqual(state.totalHours, 5 * HOURS_PER_DAY, "a fixed settle runs every day asked for");
|
|
}
|
|
}
|