Merge task #26: upgrade tiers and timed shed stock
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> # Conflicts: # game/scripts/coop_session.gd
This commit is contained in:
commit
787b36a1c2
12 changed files with 531 additions and 137 deletions
|
|
@ -211,8 +211,8 @@ func _empty_pouches() -> void:
|
|||
## #16: a pouch per scarecrow, one shared shed. P1 standing in the shed banks only P1's own pouch
|
||||
## (not what P2 carries); P2 banks its own by walking in; each pays for what it builds or buys
|
||||
## from its own pouch and the shed, never the other's pouch (the host pays P2's requests from
|
||||
## P2's); and one Bigger pouch grows both pouches. The partner's HUD, menus, and build mode go
|
||||
## by P2's pouch.
|
||||
## P2's); and one Bigger pouch grows both pouches, as does its level 2, which P2's request buys
|
||||
## once its day comes (#26). The partner's HUD, menus, and build mode go by P2's pouch.
|
||||
func _own_pouches() -> void:
|
||||
var res := host.campaign.state.resources
|
||||
r.check(client.resource_hud != null and client.resource_hud.slot == 1 and client.upgrade_panel.slot == 1 and client.shed_panel.slot == 1
|
||||
|
|
@ -290,6 +290,34 @@ func _own_pouches() -> void:
|
|||
r.check(res.pouch_capacity > room and res.pouch_room(0) == res.pouch_capacity - 3 and res.pouch_room(1) == res.pouch_capacity
|
||||
and _mine().pouch_capacity == res.pouch_capacity and _mine().pouch_room(1) == res.pouch_capacity,
|
||||
"one Bigger pouch grows both pouches (%d -> %d units, on both farms)" % [room, res.pouch_capacity])
|
||||
# Its level 2 (#26): the partner's request buys the next level, once that level's day comes;
|
||||
# the level reaches both farms, and the partner hears the jingle.
|
||||
var day := host.campaign.state.night
|
||||
var l2 := Upgrades.cost(host.config, "pouch_upgrade", 2)
|
||||
var grow := roundi(Upgrades.per_level(host.config.upgrades["pouch_upgrade"]["add"], 2))
|
||||
room = res.pouch_capacity
|
||||
_empty_pouches()
|
||||
res.shed = {"wood": 0, "scrap": 0, "straw": 0, "alien_goop": 0}
|
||||
res.shed.merge(l2, true)
|
||||
_pump(SETTLE)
|
||||
client.upgrade_panel._buy("pouch_upgrade")
|
||||
_pump(SETTLE * 2)
|
||||
r.check(Upgrades.level(host.campaign.state, "pouch_upgrade") == 1 and res.shed == l2.merged({"wood": 0, "scrap": 0, "straw": 0, "alien_goop": 0}),
|
||||
"the partner can't buy level 2 before day 8 (the host refuses: '%s')" % Upgrades.blocker(host.campaign, "pouch_upgrade", 1))
|
||||
host.campaign.state.night = 8 # (put back below, before any night)
|
||||
_pump(SETTLE)
|
||||
client.upgrade_panel.refresh()
|
||||
var row := client.upgrade_panel._rows["pouch_upgrade"] as Button
|
||||
r.check(not row.disabled and row.text.begins_with("Bigger pouch II —") and row.text.contains(ResourceStore.describe(l2)),
|
||||
"from day 8 the partner's menu offers Bigger pouch II for %s ('%s')" % [ResourceStore.describe(l2), row.text])
|
||||
var jingles := int(client.audio.played.get("upgrade", 0))
|
||||
client.upgrade_panel._buy("pouch_upgrade")
|
||||
_pump(SETTLE * 2)
|
||||
r.check(Upgrades.level(host.campaign.state, "pouch_upgrade") == 2 and Upgrades.level(client.campaign.state, "pouch_upgrade") == 2
|
||||
and res.shed_total() == 0 and res.pouch_capacity == room + grow and _mine().pouch_capacity == res.pouch_capacity,
|
||||
"P2 buys level 2: level 2 on both farms, the pouches %d -> %d units" % [room, res.pouch_capacity])
|
||||
r.check(int(client.audio.played.get("upgrade", 0)) == jingles + 1, "with the purchase's jingle on the partner's side")
|
||||
host.campaign.state.night = day
|
||||
_empty_pouches()
|
||||
_pump(6)
|
||||
|
||||
|
|
@ -364,6 +392,8 @@ func _shops() -> void:
|
|||
var id := "shurikens"
|
||||
var w := ScarecrowCombat.WEAPON_IDS.find(id)
|
||||
var cost: Dictionary = host.config.costs[id]
|
||||
var day := host.campaign.state.night
|
||||
host.campaign.state.night = Upgrades.from_day(host.config, id) # in stock (#26; put back below)
|
||||
client.player.global_position = at_counter
|
||||
_pump(20)
|
||||
_tap_interact()
|
||||
|
|
@ -386,6 +416,7 @@ func _shops() -> void:
|
|||
r.check(int(client.audio.played.get("upgrade", 0)) == jingles + 1, "with the purchase's jingle on the partner's side")
|
||||
client.shed_panel.close()
|
||||
host.campaign.state.upgrades.erase(id)
|
||||
host.campaign.state.night = day
|
||||
_empty_pouches()
|
||||
client.player.global_position = Vector3(0.5, 0.0, 6.0)
|
||||
_pump(SETTLE)
|
||||
|
|
|
|||
|
|
@ -12,9 +12,11 @@ extends RefCounted
|
|||
## supply shed's own shop (#6): weapons (corn_shooter, pumpkin_bomb) bought at its counter
|
||||
## (ShedCounter), not the workbench, with the walk-in pouch deposit unaffected. And a pouch per
|
||||
## scarecrow (#16): filled, deposited, and spent from by its own avatar slot, one shared capacity.
|
||||
## And upgrade levels and timed shed stock (#26, _tiers and _stock).
|
||||
|
||||
const P := CampaignController.Phase
|
||||
const DT := 1.0 / 60.0
|
||||
const TIERS_SAVE := "user://test_economy_tiers.json"
|
||||
|
||||
|
||||
func run(r: GameTestRunner) -> void:
|
||||
|
|
@ -24,6 +26,8 @@ func run(r: GameTestRunner) -> void:
|
|||
_goop_persistence(r)
|
||||
_pouch_upgrade(r)
|
||||
await _hidden_items(r)
|
||||
await _tiers(r)
|
||||
await _stock(r)
|
||||
var farm := (load("res://game/scenes/farm.tscn") as PackedScene).instantiate() as Node3D
|
||||
r.root.add_child(farm)
|
||||
await r.process_frame
|
||||
|
|
@ -162,7 +166,8 @@ func _pouch_upgrade(r: GameTestRunner) -> void:
|
|||
"Bigger pouch raises capacity from 8 to 16 (%s)" % msg)
|
||||
r.check(s.resources.pouch_room(0) == 16 and s.resources.pouch_room(1) == 16, "for both scarecrows' pouches (#16: one shared capacity)")
|
||||
r.check(s.resources.shed_total() == 0, "it costs the configured materials")
|
||||
r.check(Upgrades.buy(c, "pouch_upgrade").contains("already done"), "it can only be bought once")
|
||||
r.check(Upgrades.buy(c, "pouch_upgrade").contains("level 2 opens on day 8") and s.resources.pouch_capacity == 16,
|
||||
"its next level waits for day 8")
|
||||
# It carries into the next morning (same mechanic as straw_stuffing/scarecrow_max_hp).
|
||||
while s.phase != P.MORNING:
|
||||
c.advance_phase()
|
||||
|
|
@ -248,6 +253,177 @@ func _hidden_items(r: GameTestRunner) -> void:
|
|||
"a retry (restoring the morning snapshot) drops the failed night's own goop, un-revealing it, but keeps the earlier completed night's")
|
||||
|
||||
|
||||
## Upgrade levels (#26): the workbench's stat upgrades have 3 levels; Sprint, the weapons, and
|
||||
## Radar one. Level L costs costs[id] x upgrade_cost_growth^(L - 1), each material rounded up,
|
||||
## and opens on day upgrade_level_days[L - 1] (8 for level 2, 16 for level 3). Each buy() takes
|
||||
## one level, and every owned level's effect applies (heavy seeds: 2, 3, 4 damage; rapid fire's
|
||||
## multipliers multiply). upgrades_bought counts every level. The menu names the next level
|
||||
## ("Heavy seeds II") with its text and cost, says when it opens, and shows "Max" at the end.
|
||||
## Levels survive a save, the next morning, and a retry, and an old save's {"rapid_fire": 1}
|
||||
## loads as level 1.
|
||||
func _tiers(r: GameTestRunner) -> void:
|
||||
var c := r.make_campaign((load("res://game/resources/game_config.tres") as GameConfig).duplicate(true) as GameConfig)
|
||||
var cfg := c.config
|
||||
var s := c.state
|
||||
var tiered := 0
|
||||
for id: String in cfg.upgrades:
|
||||
if Upgrades.max_level(cfg, id) == 3:
|
||||
tiered += 1
|
||||
r.check(tiered == 9 and Upgrades.max_level(cfg, "sprint") == 1 and Upgrades.max_level(cfg, "corn_shooter") == 1
|
||||
and Upgrades.max_level(cfg, "alien_ray") == 1 and Upgrades.max_level(cfg, "radar") == 1,
|
||||
"the nine stat upgrades have 3 levels; Sprint, the weapons, and Radar one (%d with 3)" % tiered)
|
||||
# Costs grow.
|
||||
var grows := true
|
||||
for id: String in cfg.upgrades:
|
||||
var base := Upgrades.cost(cfg, id, 1)
|
||||
grows = grows and base == cfg.costs.get(id, {})
|
||||
for m in base:
|
||||
var l2 := int(Upgrades.cost(cfg, id, 2)[m])
|
||||
var l3 := int(Upgrades.cost(cfg, id, 3)[m])
|
||||
grows = grows and l2 == ceili(int(base[m]) * cfg.upgrade_cost_growth - 0.0001) and l3 == ceili(int(base[m]) * pow(cfg.upgrade_cost_growth, 2) - 0.0001)
|
||||
grows = grows and int(base[m]) < l2 and l2 < l3
|
||||
r.check(grows, "level 1 costs costs[id]; each next level %.1fx the one before, each material rounded up" % cfg.upgrade_cost_growth)
|
||||
var keep: Dictionary = cfg.costs["heavy_seeds"]
|
||||
cfg.costs["heavy_seeds"] = {"scrap": 10, "straw": 25}
|
||||
r.check(Upgrades.cost(cfg, "heavy_seeds", 2) == {"scrap": 18, "straw": 45} and Upgrades.cost(cfg, "heavy_seeds", 3) == {"scrap": 33, "straw": 81},
|
||||
"e.g. 10 scrap, 25 straw: then 18, 45; then 33 (32.4 rounded up), 81 (not 82 from 25 x 3.24's float error)")
|
||||
cfg.costs["heavy_seeds"] = keep
|
||||
|
||||
# Day gates and stacking effects, in the menu too.
|
||||
var panel := UpgradePanel.new()
|
||||
r.root.add_child(panel)
|
||||
await r.process_frame
|
||||
panel.setup(c, null, null)
|
||||
c.begin_day()
|
||||
s.resources.shed = {"wood": 999, "scrap": 999, "straw": 999, "alien_goop": 0}
|
||||
s.upgrades["corn_shooter"] = 1
|
||||
panel.refresh()
|
||||
var row := panel._rows["heavy_seeds"] as Button
|
||||
r.check(row.text == "Heavy seeds I — Each kernel does 2 damage (%s)" % ResourceStore.describe(Upgrades.cost(cfg, "heavy_seeds", 1)) and not row.disabled,
|
||||
"the menu offers level I: '%s'" % row.text)
|
||||
var damage := cfg.shot_damage
|
||||
r.check(Upgrades.buy(c, "heavy_seeds").contains("done:") and Upgrades.level(s, "heavy_seeds") == 1
|
||||
and roundi(Upgrades.value(cfg, s, "shot_damage")) == damage + 1, "level 1 on day 1: kernels do %d damage" % (damage + 1))
|
||||
r.check(Upgrades.blocker(c, "heavy_seeds") == "Level 2 opens on day 8" and Upgrades.buy(c, "heavy_seeds") == "Heavy seeds: level 2 opens on day 8"
|
||||
and Upgrades.level(s, "heavy_seeds") == 1, "level 2 can't be bought before day 8")
|
||||
panel.refresh()
|
||||
r.check(row.disabled and row.text.begins_with("Heavy seeds II — Each kernel does 3 damage (%s)" % ResourceStore.describe(Upgrades.cost(cfg, "heavy_seeds", 2)))
|
||||
and row.text.ends_with("Level 2 opens on day 8"), "the menu shows level II, its cost, and when it opens: '%s'" % row.text)
|
||||
s.night = 7
|
||||
r.check(Upgrades.blocker(c, "heavy_seeds") == "Level 2 opens on day 8", "(not on day 7 either)")
|
||||
s.night = 8
|
||||
var shed := s.resources.shed.duplicate()
|
||||
var l2 := Upgrades.cost(cfg, "heavy_seeds", 2)
|
||||
var msg := Upgrades.buy(c, "heavy_seeds")
|
||||
var paid := true
|
||||
for m in l2:
|
||||
paid = paid and int(shed[m]) - int(s.resources.shed[m]) == int(l2[m])
|
||||
r.check(msg == "Heavy seeds II done: each kernel does 3 damage" and Upgrades.level(s, "heavy_seeds") == 2 and paid
|
||||
and roundi(Upgrades.value(cfg, s, "shot_damage")) == damage + 2, "on day 8, level 2 for %s: kernels do %d ('%s')" % [ResourceStore.describe(l2), damage + 2, msg])
|
||||
r.check(Upgrades.blocker(c, "heavy_seeds") == "Level 3 opens on day 16", "level 3 waits for day 16")
|
||||
s.night = 16
|
||||
r.check(Upgrades.buy(c, "heavy_seeds").contains("done:") and Upgrades.level(s, "heavy_seeds") == 3
|
||||
and roundi(Upgrades.value(cfg, s, "shot_damage")) == damage + 3, "on day 16, level 3: kernels do %d" % (damage + 3))
|
||||
r.check(Upgrades.blocker(c, "heavy_seeds") == "Done" and Upgrades.buy(c, "heavy_seeds") == "Heavy seeds: already done"
|
||||
and Upgrades.level(s, "heavy_seeds") == 3, "and that's the last")
|
||||
panel.refresh()
|
||||
r.check(row.disabled and row.text == "Heavy seeds III — Each kernel does 4 damage (Max)", "the menu says Max: '%s'" % row.text)
|
||||
var mult: Variant = cfg.upgrades["rapid_fire"]["mult"]
|
||||
Upgrades.buy(c, "rapid_fire")
|
||||
Upgrades.buy(c, "rapid_fire")
|
||||
var rate := cfg.fire_rate * Upgrades.per_level(mult, 1) * Upgrades.per_level(mult, 2)
|
||||
r.check(Upgrades.level(s, "rapid_fire") == 2 and is_equal_approx(Upgrades.value(cfg, s, "fire_rate"), rate),
|
||||
"rapid fire's levels multiply: level 2 fires %.2f a second (%.2f x %.2f x %.2f)" % [Upgrades.value(cfg, s, "fire_rate"), cfg.fire_rate,
|
||||
Upgrades.per_level(mult, 1), Upgrades.per_level(mult, 2)])
|
||||
var hp := s.scarecrow_max_hp
|
||||
var cap := s.resources.pouch_capacity
|
||||
var stuffing := 0
|
||||
var pouch := 0
|
||||
for lvl in [1, 2, 3]:
|
||||
Upgrades.buy(c, "straw_stuffing")
|
||||
Upgrades.buy(c, "pouch_upgrade")
|
||||
stuffing += roundi(Upgrades.per_level(cfg.upgrades["straw_stuffing"]["add"], lvl))
|
||||
pouch += roundi(Upgrades.per_level(cfg.upgrades["pouch_upgrade"]["add"], lvl))
|
||||
r.check(Upgrades.level(s, "straw_stuffing") == 3 and s.scarecrow_max_hp == hp + stuffing and s.scarecrow_hp == s.scarecrow_max_hp,
|
||||
"three levels of straw stuffing: +%d max health" % stuffing)
|
||||
r.check(Upgrades.level(s, "pouch_upgrade") == 3 and s.resources.pouch_capacity == cap + pouch, "three levels of the bigger pouch: %d units" % s.resources.pouch_capacity)
|
||||
r.check(int(s.night_events.get("upgrades_bought", 0)) == 11, "upgrades bought counts every level (%d)" % int(s.night_events.get("upgrades_bought", 0)))
|
||||
var done := 0
|
||||
for id: String in panel._rows:
|
||||
done += 1 if Upgrades.maxed(cfg, s, id) else 0
|
||||
panel.refresh()
|
||||
r.check(done == 3 and panel._title.text.ends_with("(3 of %d done)" % panel._rows.size()), "the title counts the ones at their last level: '%s'" % panel._title.text)
|
||||
panel.queue_free()
|
||||
|
||||
# Levels persist: through a save, into the next morning, and in a retry from that morning.
|
||||
var levels := s.upgrades.duplicate()
|
||||
s.night = 1 # (back to the first day, so the vacation doesn't end below)
|
||||
var back := FarmState.from_dict(JSON.parse_string(JSON.stringify(s.to_dict(), "", true, true)))
|
||||
r.check(back != null and back.upgrades == levels and Upgrades.level(back, "heavy_seeds") == 3, "levels survive a save (JSON)")
|
||||
while s.phase != P.MORNING:
|
||||
c.advance_phase()
|
||||
r.check(c.state.upgrades == levels, "and carry into the next morning")
|
||||
c.begin_day()
|
||||
c.advance_phase() # DAY -> DUSK
|
||||
c.advance_phase() # DUSK -> NIGHT
|
||||
r.check(c.retry_night() and c.state != s and c.state.upgrades == levels and c.state.resources.pouch_capacity == cap + pouch,
|
||||
"and a retry from that morning keeps them")
|
||||
# A save from before levels: {"rapid_fire": 1} is level 1.
|
||||
var old := c.state.to_dict()
|
||||
old["upgrades"] = {"corn_shooter": 1, "rapid_fire": 1}
|
||||
var was := SaveGame.read(TIERS_SAVE).state if SaveGame.write(old, TIERS_SAVE) == OK else null
|
||||
SaveGame.delete(TIERS_SAVE)
|
||||
r.check(was != null and Upgrades.level(was, "rapid_fire") == 1 and Upgrades.owned(was, "rapid_fire")
|
||||
and is_equal_approx(Upgrades.value(cfg, was, "fire_rate"), cfg.fire_rate * Upgrades.per_level(mult, 1))
|
||||
and Upgrades.next_cost(cfg, was, "rapid_fire") == Upgrades.cost(cfg, "rapid_fire", 2),
|
||||
"an old save's {\"rapid_fire\": 1} loads as level 1, with level 2 next")
|
||||
c.queue_free()
|
||||
|
||||
|
||||
## Timed shed stock (#26): each shed item arrives on its day ("from_day"; day N is the day before
|
||||
## night N) and can't be bought before it. Its row shows just its name, greyed, and "Arrives on
|
||||
## day N"; a hidden one shows "?" and its day until it arrives, then the bare "?" until revealed.
|
||||
func _stock(r: GameTestRunner) -> void:
|
||||
var c := r.make_campaign((load("res://game/resources/game_config.tres") as GameConfig).duplicate(true) as GameConfig)
|
||||
var cfg := c.config
|
||||
var s := c.state
|
||||
var days := {}
|
||||
for id in Upgrades.ORDER:
|
||||
if Upgrades.shop_of(cfg, id) == "shed":
|
||||
days[id] = Upgrades.from_day(cfg, id)
|
||||
r.check(days == {"corn_shooter": 1, "shurikens": 2, "pumpkin_bomb": 3, "potato_cannon": 6, "radar": 8, "propane_torch": 10, "alien_ray": 14},
|
||||
"the shed's stock days: %s" % days)
|
||||
var panel := UpgradePanel.new()
|
||||
r.root.add_child(panel)
|
||||
await r.process_frame
|
||||
panel.setup(c, null, null, "shed")
|
||||
c.begin_day()
|
||||
s.resources.shed = {"wood": 999, "scrap": 999, "straw": 999, "alien_goop": 999}
|
||||
panel.refresh()
|
||||
var row := panel._rows["potato_cannon"] as Button
|
||||
r.check(Upgrades.blocker(c, "potato_cannon") == "Arrives on day 6" and Upgrades.buy(c, "potato_cannon") == "Potato cannon: arrives on day 6"
|
||||
and not Upgrades.owned(s, "potato_cannon") and not Upgrades.arrived(s, cfg, "potato_cannon"), "on day 1 the potato cannon isn't in stock and can't be bought")
|
||||
r.check(row.disabled and row.text == "Potato cannon Arrives on day 6", "its row shows just its name, greyed, and its day: '%s'" % row.text)
|
||||
r.check((panel._rows["alien_ray"] as Button).text == "? Arrives on day 14" and (panel._rows["alien_ray"] as Button).disabled,
|
||||
"a hidden item not in stock shows '?' and its day: '%s'" % (panel._rows["alien_ray"] as Button).text)
|
||||
r.check(not (panel._rows["corn_shooter"] as Button).disabled and Upgrades.blocker(c, "corn_shooter") == "", "the corn shooter is in stock on day 1")
|
||||
s.night = 5
|
||||
r.check(Upgrades.blocker(c, "potato_cannon") == "Arrives on day 6" and Upgrades.blocker(c, "pumpkin_bomb") == "", "(day 5: not yet; the pumpkin bombs, from day 3, are)")
|
||||
s.night = 6
|
||||
panel.refresh()
|
||||
r.check(Upgrades.arrived(s, cfg, "potato_cannon") and Upgrades.blocker(c, "potato_cannon") == "" and not row.disabled
|
||||
and row.text.begins_with("Potato cannon — "), "on day 6 it's in stock: '%s'" % row.text)
|
||||
r.check(Upgrades.buy(c, "potato_cannon").contains("done:") and Upgrades.owned(s, "potato_cannon"), "and can be bought")
|
||||
panel.refresh()
|
||||
r.check(row.disabled and row.text.ends_with(" (Done)"), "a one-off says Done: '%s'" % row.text)
|
||||
s.night = 14
|
||||
panel.refresh()
|
||||
r.check((panel._rows["alien_ray"] as Button).text == "?" and Upgrades.blocker(c, "alien_ray") == "Not discovered yet",
|
||||
"in stock but not discovered yet, it's a bare '?'")
|
||||
panel.queue_free()
|
||||
c.queue_free()
|
||||
|
||||
|
||||
func _layout(r: GameTestRunner, sim: FarmSim) -> void:
|
||||
var by_material := {}
|
||||
var names := {}
|
||||
|
|
@ -426,7 +602,7 @@ func _stuffing(r: GameTestRunner, sim: FarmSim, player: PlayerCharacter) -> void
|
|||
var it := sim.interactions
|
||||
var bench := it.workbench
|
||||
var menu := sim.upgrade_panel
|
||||
var add := int(sim.config.upgrades["straw_stuffing"]["add"])
|
||||
var add := roundi(Upgrades.per_level(sim.config.upgrades["straw_stuffing"]["add"], 1))
|
||||
var msgs: Array[String] = []
|
||||
it.message.connect(func(t: String, _col: Color) -> void: msgs.append(t))
|
||||
menu.message.connect(func(t: String, _col: Color) -> void: msgs.append(t))
|
||||
|
|
@ -447,7 +623,8 @@ func _stuffing(r: GameTestRunner, sim: FarmSim, player: PlayerCharacter) -> void
|
|||
r.check(Upgrades.owned(s, "straw_stuffing") and s.scarecrow_max_hp == max_hp + add and s.scarecrow_hp == s.scarecrow_max_hp,
|
||||
"Straw stuffing: +%d max HP (%s)" % [add, msgs[-1]])
|
||||
r.check(s.resources.shed == {"wood": 0, "scrap": 0, "straw": 0} and s.resources.pouch["wood"] == 0, "it costs 12 straw and 4 wood")
|
||||
r.check(row.disabled and row.text.contains("Done"), "it can only be bought once")
|
||||
r.check(row.disabled and row.text.begins_with("Straw stuffing II —") and row.text.contains("Level 2 opens on day 8"),
|
||||
"the row offers level II, closed until day 8: '%s'" % row.text)
|
||||
_press(sim)
|
||||
r.check(not menu.is_open and not player.rooted, "interact again closes the menu")
|
||||
_press(sim)
|
||||
|
|
|
|||
|
|
@ -110,7 +110,8 @@ func _waves(plan: NightPlan) -> int:
|
|||
return waves
|
||||
|
||||
|
||||
## The upgrades change the systems they're about, can't be bought twice or at night, and persist.
|
||||
## The upgrades (level 1 of each) change the systems they're about, can't be bought twice (a
|
||||
## one-off) or before their day (a next level) or at night, and persist.
|
||||
func _upgrades(r: GameTestRunner, sim: FarmSim, player: PlayerCharacter) -> void:
|
||||
var c := sim.campaign
|
||||
var s := c.state
|
||||
|
|
@ -131,13 +132,17 @@ func _upgrades(r: GameTestRunner, sim: FarmSim, player: PlayerCharacter) -> void
|
|||
var shed := s.resources.shed_total()
|
||||
var spent := 0
|
||||
r.check(not player.can_sprint(), "(no sprint before the Sprint upgrade)")
|
||||
var day := s.night
|
||||
s.night = 14 # every shed item is in stock by day 14 (#26's from_day)
|
||||
for id in Upgrades.ORDER:
|
||||
spent += _sum(Upgrades.cost(cfg, id))
|
||||
var text := Upgrades.buy(c, id, st)
|
||||
r.check(Upgrades.owned(s, id) and text.contains("done:"), "bought %s: '%s'" % [id, text])
|
||||
r.check(s.resources.shed_total() == shed - spent, "all %d cost %d materials together" % [Upgrades.ORDER.size(), spent])
|
||||
r.check(Upgrades.level(s, id) == 1 and text.contains("done:"), "bought %s: '%s'" % [id, text])
|
||||
s.night = day
|
||||
r.check(s.resources.shed_total() == shed - spent, "all %d cost %d materials together (level 1 each)" % [Upgrades.ORDER.size(), spent])
|
||||
r.check(player.can_sprint(), "sprint: the scarecrow can sprint")
|
||||
r.check(Upgrades.buy(c, "rapid_fire", st).contains("already done"), "an upgrade can't be bought twice")
|
||||
r.check(Upgrades.buy(c, "sprint", st).contains("already done") and Upgrades.buy(c, "rapid_fire", st).contains("level 2 opens on day 8")
|
||||
and Upgrades.level(s, "rapid_fire") == 1, "a one-off can't be bought twice, and an upgrade's level 2 waits for day 8")
|
||||
r.check(sim.combat.interval_ticks() < int(before["interval"]) and sim.combat.shot_damage() == int(before["damage"]) + 1,
|
||||
"rapid fire and heavy seeds: a shot every %d ticks (was %d), %d damage" % [sim.combat.interval_ticks(), before["interval"], sim.combat.shot_damage()])
|
||||
r.check(is_equal_approx(sim.scarecrow.fear_radius(), float(before["radius"]) * 1.3) and is_equal_approx(sim.scarecrow.fear_cooldown(), float(before["cooldown"]) * 0.8),
|
||||
|
|
@ -180,7 +185,7 @@ func _upgrades(r: GameTestRunner, sim: FarmSim, player: PlayerCharacter) -> void
|
|||
var bought := s.upgrades.duplicate()
|
||||
while s.phase != P.NIGHT:
|
||||
c.advance_phase()
|
||||
r.check(Upgrades.blocker(c, "rapid_fire") == "Done" and Upgrades.buy(c, "long_range", st).contains("already done"), "(owned ones stay owned at night)")
|
||||
r.check(Upgrades.blocker(c, "sprint") == "Done" and Upgrades.buy(c, "radar", st).contains("already done"), "(owned ones stay owned at night)")
|
||||
s.upgrades.erase("sticky_tar")
|
||||
r.check(Upgrades.blocker(c, "sticky_tar") == "The work area is for daytime", "nothing can be bought at night")
|
||||
s.upgrades["sticky_tar"] = 1
|
||||
|
|
|
|||
|
|
@ -27,6 +27,10 @@ func run(r: GameTestRunner) -> void:
|
|||
|
||||
radar._process(0.0)
|
||||
r.check(radar != null and not radar.visible, "the radar minimap is hidden before the Radar item is bought")
|
||||
shed_panel.refresh()
|
||||
r.check(s.night == 1 and Upgrades.blocker(c, "radar") == "Arrives on day 8" and (shed_panel._rows["radar"] as Button).text == "? Arrives on day 8",
|
||||
"on day 1 it isn't in stock: its row shows '?' and the day it arrives ('%s')" % (shed_panel._rows["radar"] as Button).text)
|
||||
s.night = 8 # (#26's from_day; this suite plays no night)
|
||||
r.check(Upgrades.blocker(c, "radar") == "Not discovered yet", "radar is unbuyable with no Alien Goop collected: '%s'" % Upgrades.blocker(c, "radar"))
|
||||
shed_panel.refresh()
|
||||
r.check((shed_panel._rows["radar"] as Button).text == "?", "radar's shed row shows only '?' before it's revealed")
|
||||
|
|
|
|||
|
|
@ -135,6 +135,7 @@ func _unlocks(r: GameTestRunner, farm: Node3D, sim: FarmSim) -> void:
|
|||
var combat := sim.combat
|
||||
var st := sim.structures
|
||||
c.begin_day()
|
||||
s.night = 14 # every shed item is in stock by day 14 (#26's from_day; nothing here plays a night)
|
||||
s.resources.shed = {"wood": 99, "scrap": 99, "straw": 99}
|
||||
r.check(not combat.equip(W.CORN_SHOOTER) and combat.weapon == W.PITCHFORK, "the corn shooter can't be taken up before it's bought")
|
||||
r.check(Upgrades.blocker(c, "rapid_fire") == "Needs the corn shooter first" and Upgrades.buy(c, "heavy_seeds", st).contains("needs the corn shooter")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue