- 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.
69 lines
2.7 KiB
JavaScript
69 lines
2.7 KiB
JavaScript
import { TestCase } from "./framework/test_case.js";
|
|
import { smallState } from "./framework/helpers.js";
|
|
import { GOVERNMENTS } from "../shared/data.js";
|
|
|
|
const BIG_BUDGET = 1.0e15;
|
|
|
|
export class GameStateGovernmentTest extends TestCase {
|
|
test_every_civilisation_starts_on_the_first_government() {
|
|
const state = smallState();
|
|
this.assertSize(state.governments, GOVERNMENTS.length);
|
|
this.assertEqual(state.getGovernment(0), 0);
|
|
this.assertEqual(state.getGovernment(1), 0);
|
|
this.assertNotNull(state.getGovernmentResource(0));
|
|
}
|
|
|
|
test_request_set_government_changes_and_charges_budget() {
|
|
const state = smallState();
|
|
state.budgets.set(0, BIG_BUDGET);
|
|
const before = state.getBudget(0);
|
|
this.assertTrue(state.requestSetGovernment(0, 1));
|
|
this.assertEqual(state.getGovernment(0), 1);
|
|
this.assertLess(state.getBudget(0), before, "the switch was paid for");
|
|
}
|
|
|
|
test_request_set_government_rejects_current_and_unknown() {
|
|
const state = smallState();
|
|
state.budgets.set(0, BIG_BUDGET);
|
|
this.assertFalse(state.requestSetGovernment(0, 0), "already in power");
|
|
this.assertFalse(state.requestSetGovernment(0, 999), "unknown government");
|
|
this.assertFalse(state.requestSetGovernment(999, 1), "unknown civilisation");
|
|
}
|
|
|
|
test_request_set_government_rejects_when_unaffordable() {
|
|
const state = smallState();
|
|
state.budgets.set(0, 0);
|
|
this.assertFalse(state.requestSetGovernment(0, 1));
|
|
}
|
|
|
|
test_government_effects_are_folded_into_gdp() {
|
|
const state = smallState();
|
|
state.budgets.set(0, BIG_BUDGET);
|
|
const monarchy = state.governments.findIndex((g) => g.id === "monarchy");
|
|
const republicGdp = state.getPlayerGdp(0);
|
|
this.assertTrue(state.requestSetGovernment(0, monarchy));
|
|
this.assertApprox(state.getPlayerGdp(0), (republicGdp * 1.1) / 1.05, 0.01);
|
|
}
|
|
|
|
test_technocracy_produces_research_each_hour() {
|
|
const state = smallState();
|
|
state.budgets.set(0, BIG_BUDGET);
|
|
const technocracy = state.governments.findIndex((g) => g.id === "technocracy");
|
|
this.assertTrue(state.requestSetGovernment(0, technocracy));
|
|
const method = state.technologies.findIndex((t) => t.id === "scientific_method");
|
|
this.assertTrue(state.requestFocusTechnology(0, method));
|
|
this.assertEqual(state.getTechnologyProgress(0), 0);
|
|
state.advanceHour();
|
|
this.assertApprox(state.getTechnologyProgress(0), 3.0);
|
|
}
|
|
|
|
test_snapshot_exposes_government() {
|
|
const state = smallState();
|
|
const snapshot = state.snapshot(0);
|
|
this.assertSize(snapshot.governments, state.governments.length);
|
|
this.assertSize(snapshot.government, state.civilisations.length);
|
|
this.assertHas(snapshot.viewerStats, "government");
|
|
this.assertEqual(snapshot.viewerStats.government, 0);
|
|
}
|
|
}
|