UI and other changes

This commit is contained in:
Forrest 2026-10-07 13:41:38 -04:00
parent 87b5c11fcf
commit 215e24e246
79 changed files with 70023 additions and 2201 deletions

View file

@ -29,16 +29,16 @@ func run(r: GameTestRunner) -> void:
sim.loot.loot_event.connect(func(kind: StringName, _id: int, _p: Vector3) -> void:
_events[kind] = int(_events.get(kind, 0)) + 1)
r.info("farm sim loaded in %d ms (nav %d cells)" % [sim.load_msec, sim.nav.cell_count()])
r.check(sim.loot.unit_count == 50 and sim.loot.count(S.HOME, LootSystem.Category.CROP) == 30 and sim.campaign.state.crops == 30
and sim.loot.count(S.DORMANT, LootSystem.Category.CROP) == 20,
"30 crop units start at home, 20 more dormant in the two later fields (#13)")
r.check(sim.loot.unit_count == 90 and sim.loot.count(S.HOME, LootSystem.Category.CROP) == 30 and sim.campaign.state.crops == 30
and sim.loot.count(S.DORMANT, LootSystem.Category.CROP) == 60,
"30 crop units start at home, 60 more dormant in the two later fields (#13)")
# #20: the map reaches z 35 now, so its south edge (3 m out) is at z 38; z 18 is inside the map.
var edge_cells := [Vector2(-16.0, -6.0), Vector2(20.0, 38.0), Vector2(50.0, 0.0), Vector2(-16.0, 10.0)].filter(func(p: Vector2) -> bool:
return sim.escape_field[sim.nav.cell_of(p.x, p.y)] == 0)
r.check(edge_cells.size() == 4 and sim.escape_field[sim.nav.cell_of(10.0, -8.0)] > 0, "the farm's edge, all around, is where carriers escape")
r.check(sim.escape_field[sim.nav.cell_of(20.0, 18.0)] > 0, "(20, 18), where the south edge used to be, is inside the map now")
# #20: a carried or dropped crop shows the plant of its own field.
var tokens := [1, 31, 41].map(func(id: int) -> String: return sim.loot._tokens[id].scene_file_path.get_file().get_basename())
var tokens := [1, 31, 61].map(func(id: int) -> String: return sim.loot._tokens[id].scene_file_path.get_file().get_basename())
r.check(tokens == ["plant_007", "plant_004", "plant_001"], "crop tokens match their crop: sunflower, cabbage, corn (%s)" % [tokens])
_steal_and_drop(r, sim, player)
@ -302,7 +302,7 @@ func _night_arrivals(r: GameTestRunner, sim: FarmSim) -> void:
sim.waves.enabled = false
## #13: the two later fields (lettuce/cabbage, ids 31-40; corn, 41-50) start dormant -- hidden,
## #13: the two later fields (lettuce/cabbage, ids 31-60; corn, 61-90) start dormant -- hidden,
## not claimable, not scored -- and sprout on schedule: field A the morning after night 2, field B
## the morning after night 4. Once sprouted a unit is a crop like any other: visible, stealable by
## a crow, and counted in crops_total and the score.
@ -314,15 +314,15 @@ func _staged_fields(r: GameTestRunner, sim: FarmSim) -> void:
_play_to_next_morning(sim)
r.check(c.state.phase == P.MORNING and c.state.nights_survived == 2, "played to the morning after night 2")
var a_ok := true
for id in range(31, 41):
for id in range(31, 61):
a_ok = a_ok and loot.status[id] == S.HOME and loot._units[id].visible
r.check(a_ok, "field A (lettuce/cabbage, 31..40) sprouted after night 2: visible and home")
r.check(a_ok, "field A (lettuce/cabbage, 31..60) sprouted after night 2: visible and home")
var b_dormant := true
for id in range(41, 51):
for id in range(61, 91):
b_dormant = b_dormant and loot.status[id] == S.DORMANT and not loot._units[id].visible
r.check(b_dormant, "field B (corn, 41..50) is still dormant: hidden, not home")
r.check(c.state.crops_total == 30 + 10, "crops_total grew by field A's 10 units")
r.check(not loot.recover(41) and not loot.is_claimed_by(41, -1), "a dormant unit can't be recovered or claimed")
r.check(b_dormant, "field B (corn, 61..90) is still dormant: hidden, not home")
r.check(c.state.crops_total == 30 + 30, "crops_total grew by field A's 30 units")
r.check(not loot.recover(61) and not loot.is_claimed_by(61, -1), "a dormant unit can't be recovered or claimed")
# A crow can claim (by hand, as other tests here do), steal, and carry off a field-A crop: it
# counts exactly like any other crop.
@ -343,19 +343,19 @@ func _staged_fields(r: GameTestRunner, sim: FarmSim) -> void:
_play_to_next_morning(sim)
r.check(c.state.phase == P.MORNING and c.state.nights_survived == 4, "played to the morning after night 4")
var b_ok := true
for id in range(41, 51):
for id in range(61, 91):
b_ok = b_ok and loot.status[id] == S.HOME and loot._units[id].visible
r.check(b_ok, "field B (corn, 41..50) sprouted after night 4: visible and home")
r.check(c.state.crops_total == 30 + 10 + 10, "crops_total grew by field B's 10 units too")
r.check(b_ok, "field B (corn, 61..90) sprouted after night 4: visible and home")
r.check(c.state.crops_total == 30 + 30 + 30, "crops_total grew by field B's 30 units too")
var before2 := c.state.crops
var h2 := es.spawn(EnemySystem.TYPE_CROW, -20.0, 0.0, Vector2.RIGHT)
var d2 := es.resolve_handle(h2)
loot.holder[41] = h2
r.check(loot.pick_up(41, h2), "field B crop 41 can be claimed and picked up")
es.carry[d2] = 41
loot.escape(41, h2)
r.check(c.state.is_crop_lost(41) and loot.status[41] == S.LOST and c.state.crops == before2 - 1,
loot.holder[61] = h2
r.check(loot.pick_up(61, h2), "field B crop 61 can be claimed and picked up")
es.carry[d2] = 61
loot.escape(61, h2)
r.check(c.state.is_crop_lost(61) and loot.status[61] == S.LOST and c.state.crops == before2 - 1,
"a stolen field-B crop is lost and scored like any other")
es.apply_hit(d2, 99)
_step(sim, 1)
@ -368,7 +368,7 @@ func _staged_fields(r: GameTestRunner, sim: FarmSim) -> void:
r.check(restored.crops_total == c.state.crops_total and restored.nights_survived == c.state.nights_survived,
"crops_total and nights_survived survive a save/JSON round trip")
loot.sync_from_state() # as a real load or retry would trigger
r.check(c.state.crops_total == 50, "sync_from_state() repairs crops_total to the same, fully-sprouted total")
r.check(c.state.crops_total == 90, "sync_from_state() repairs crops_total to the same, fully-sprouted total")
## Advances from wherever the campaign is now to the next morning (one full day/night/dawn cycle),