Files
Battle-for-Tismo/tests/monthly_test.js
T
adrien ede258d39f Added warfare depth, focused research and a reworked HUD
- Tile improvements (fortifications, radar towers, coastal cannons), trenches,
  zone of control, support-unit capture and launch transports, with parabolic
  barrage arcs drawn between attacker and target.
- Focused research that pours points straight into the chosen technology, with
  per-technology progress kept when the focus changes, plus repeatable levels.
- Popularity reworked to integer points, war and pillage effects, minority
  policies and month-over-month arrows on the nation summary.
- City progress bars, square improvement buttons, a technology tab of wide
  short cards with progress bars, transport cargo readout and double-click to
  open a city panel.
2026-09-21 01:07:36 +02:00

47 lines
2.0 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";
export class MonthlyTest extends TestCase {
test_january_2000_has_no_month_to_compare_against() {
const state = smallState();
this.assertNull(state.monthlyStats, "the first month starts with no baseline");
const snapshot = state.snapshot(0);
this.assertSize(snapshot.monthly, 0, "the snapshot ships an empty baseline in January");
}
test_a_rolled_over_month_becomes_the_baseline() {
const state = smallState();
// January has 31 days; stepping past its last hour rolls the month over.
for (let i = 0; i < 31 * HOURS_PER_DAY; i++) state.tickHour();
this.assertNotNull(state.monthlyStats, "February has January to compare against");
this.assertSize(
state.monthlyStats,
state.civilisations.length,
"every nation carries a baseline"
);
for (const entry of state.monthlyStats) {
this.assertTrue(typeof entry.population === "number", "the population is captured");
this.assertTrue(typeof entry.gdp === "number", "the GDP is captured");
this.assertTrue(typeof entry.gdpPerCapita === "number", "the GDP/capita is captured");
this.assertTrue(typeof entry.popularity === "number", "the popularity is captured");
this.assertTrue(typeof entry.budget === "number", "the budget is captured");
}
const snapshot = state.snapshot(0);
this.assertSize(snapshot.monthly, state.civilisations.length, "the snapshot ships the baseline");
}
test_the_baseline_is_the_month_that_just_ended() {
const state = smallState();
const startPopulation = state.snapshot(0).viewerStats.population;
for (let i = 0; i < 31 * HOURS_PER_DAY; i++) state.tickHour();
// The baseline is the reading at the start of January, not the live one.
this.assertApprox(
state.monthlyStats[0].population,
startPopulation,
1e-6,
"the baseline is January's opening figure"
);
}
}