whatif.py: add --remove for teardown/demolish scenarios

Mirrors --add - removes AMOUNT (default: all) of a building from the
copied spec. Used this to check whether BHP's HWP is still worth
running after its price drop (still +19.8k-28.4k/day marginal,
nowhere near a teardown call) without hand-writing two spec files.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
2026-10-09 10:30:46 +02:00
co-authored by Claude Sonnet 5
parent c4178fe779
commit 59245ee54d
2 changed files with 31 additions and 2 deletions
+12
View File
@@ -23,6 +23,18 @@ def test_apply_add_appends_new_building_with_recipe():
assert spec["buildings"] == [{"building": "CHP", "amount": 1, "recipes": ["MG,S,CU=>IND"]}]
def test_apply_remove_drops_building_entirely_by_default():
spec = {"buildings": [{"building": "HWP", "amount": 1, "recipes": ["AL,STL,HE=>BHP"]}]}
whatif.apply_remove(spec, "HWP")
assert spec["buildings"] == []
def test_apply_remove_partial_amount():
spec = {"buildings": [{"building": "CHP", "amount": 3, "recipes": ["MG,S,CU=>IND"]}]}
whatif.apply_remove(spec, "CHP:1")
assert spec["buildings"] == [{"building": "CHP", "amount": 2, "recipes": ["MG,S,CU=>IND"]}]
def test_apply_infra_adds_delta():
spec = {"infrastructure": {"HB1": 4}}
whatif.apply_infra(spec, "HB1:+1,HB2:+2")