This commit is contained in:
Forrest 2026-10-04 12:07:36 -04:00
parent 276d43613d
commit 4298caf5cb
552 changed files with 42990 additions and 776 deletions

View file

@ -1,7 +1,8 @@
extends RefCounted
## Outcome rules: scarecrow destruction, a stripped farm (only categories in play count),
## completing the vacation, the failure-before-completion tie policy, failure in every phase,
## and terminal phases staying terminal.
## Outcome rules: scarecrow destruction, a stripped farm (all three categories; only those in
## play count; supplies only when thieves emptied the shed), completing the vacation, the
## failure-before-completion tie policy, failure in every phase, and terminal phases staying
## terminal.
const O := CampaignController.Outcome
const P := CampaignController.Phase
@ -18,20 +19,34 @@ func run(r: GameTestRunner) -> void:
r.check(CampaignController.check_outcome(s, n) == O.GAME_OVER_SCARECROW, "0 HP is a Game Over")
s = FarmState.create(cfg)
s.crops = 0
s.animals_total = 0
s.supplies_total = 0
s.lose_all_crops()
r.check(CampaignController.check_outcome(s, n) == O.GAME_OVER_STRIPPED, "with only crops in play, no crops left is a stripped farm")
s = _all_categories(cfg)
s.crops = 0
s = FarmState.create(cfg)
s.lose_all_crops()
r.check(CampaignController.check_outcome(s, n) == O.CONTINUE, "losing every crop alone does not end the game")
s.animals = 0
s.lose_all_animals()
r.check(CampaignController.check_outcome(s, n) == O.CONTINUE, "losing crops and animals with supplies left does not end the game")
s.supplies = 0
r.check(CampaignController.check_outcome(s, n) == O.GAME_OVER_STRIPPED, "losing every category ends the game")
for m in ResourceStore.MATERIALS:
s.resources.shed[m] = 0
r.check(CampaignController.check_outcome(s, n) == O.CONTINUE, "spending the last supplies doesn't strip the farm")
s.shed_raided = true
s.supplies_in_transit = 5
r.check(CampaignController.check_outcome(s, n) == O.CONTINUE, "a sack of supplies still on the farm keeps it going")
s.supplies_in_transit = 0
r.check(CampaignController.check_outcome(s, n) == O.GAME_OVER_STRIPPED, "losing every category ends the game (thieves emptied the shed)")
s.resources.shed["straw"] = 2
s.settle_supplies()
s.resources.shed["straw"] = 0
r.check(not s.shed_raided and CampaignController.check_outcome(s, n) == O.CONTINUE,
"storing anything clears the raid: spending it again doesn't strip the farm")
s = FarmState.create(cfg)
s.crops_total = 0
s.crops = 0
s.animals_total = 0
s.supplies_total = 0
r.check(not s.is_stripped(), "a farm with nothing in play is not 'stripped'")
s = FarmState.create(cfg)
@ -44,7 +59,7 @@ func run(r: GameTestRunner) -> void:
s.scarecrow_hp = 0
r.check(CampaignController.check_outcome(s, n) == O.GAME_OVER_SCARECROW, "tie: scarecrow destroyed on the final night loses")
s.scarecrow_hp = 1
s.crops = 0
s.strip()
r.check(CampaignController.check_outcome(s, n) == O.GAME_OVER_STRIPPED, "tie: farm stripped on the final night loses")
s.scarecrow_hp = 0
r.check(CampaignController.check_outcome(s, n) == O.GAME_OVER_SCARECROW, "scarecrow destruction is reported before a stripped farm")
@ -54,15 +69,6 @@ func run(r: GameTestRunner) -> void:
_terminal(r)
func _all_categories(cfg: GameConfig) -> FarmState:
var s := FarmState.create(cfg)
s.animals_total = 8
s.animals = 8
s.supplies_total = 50
s.supplies = 50
return s
func _failure_in_every_phase(r: GameTestRunner) -> void:
for phase: CampaignController.Phase in [P.MORNING, P.DAY, P.DUSK, P.NIGHT, P.DAWN]:
var c := r.make_campaign()
@ -75,7 +81,7 @@ func _failure_in_every_phase(r: GameTestRunner) -> void:
"scarecrow destroyed during %s ends the game once" % P.keys()[phase])
c = r.make_campaign()
GameTestRunner.run_until(c, phase)
c.state.crops = 0
c.state.strip()
c.tick(GameTestRunner.TICK)
r.check(c.state.phase == P.GAME_OVER and c.outcome == O.GAME_OVER_STRIPPED,
"farm stripped during %s ends the game" % P.keys()[phase])