Workbench stat upgrades get 3 levels: level L costs costs[id] x
upgrade_cost_growth (1.8) ^ (L - 1), each material rounded up, and opens on
day upgrade_level_days[L - 1] ([1, 8, 16]). Each owned level's "mult"/"add"
entry stacks. Level 1 keeps the user's values and costs (rapid fire 3.0x).
Shed items arrive on set days ("from_day"): corn shooter 1, shurikens 2,
pumpkin bombs 3, potato cannon 6, radar 8, propane torch 10, alien ray 14.
- Upgrades: level(), max_level(), maxed(), cost(cfg, id, level),
next_cost(), per_level(), text_at(), name_at() (roman numerals),
from_day(), level_day(), arrived(). owned() stays "level >= 1". blocker()
adds "Arrives on day N" and "Level N opens on day D"; buy() takes the next
level and applies that level's side effect; upgrades_bought counts every
level. FarmState.upgrades keeps id -> level, so saves don't change shape.
- UpgradePanel: "Rapid fire II" with the next level's text and cost, the
blocker reason, "Max" at the last level; a shed item before its day shows
its name greyed with "Arrives on day N" ("?" plus the day if hidden). The
title counts items at their last level. Every level bought jingles.
- Co-op: the host sends "bought" for any level (no wire change; PROTOCOL
stays 5).
- soak_night.gd buys the lowest next level first across UPGRADE_ORDER.
- Tests: level costs, day gates, stacking, from_day, save/morning/retry/co-op,
an old {"rapid_fire": 1} save as level 1. Existing tests set the day where
they buy stock that now arrives later.
- RULES.md Upgrades: per-level effects and costs, stock schedule.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
77 lines
4.3 KiB
GDScript
77 lines
4.3 KiB
GDScript
extends RefCounted
|
|
## Task #8: Radar, a hidden Supply Shed item (minimap reveal, Decision 16). Hidden (a "?" row,
|
|
## unbuyable) until enough Alien Goop is collected, like the Alien Ray; buyable once revealed; the
|
|
## RadarHud minimap stays hidden until it's bought, then shows a dot for every alive enemy within
|
|
## GameConfig.radar_range of the local scarecrow (farther ones excluded) plus the scarecrow
|
|
## itself; ownership survives a FarmState JSON round trip (FarmState.upgrades is saved).
|
|
|
|
const DT := 1.0 / 60.0
|
|
const SPOT := Vector2(8.0, -10.0) # open ground between the pen, the shed, and the field
|
|
|
|
|
|
func run(r: GameTestRunner) -> void:
|
|
var farm := (load("res://game/scenes/farm.tscn") as PackedScene).instantiate() as Node3D
|
|
r.root.add_child(farm)
|
|
await r.process_frame
|
|
await r.physics_frame
|
|
var sim := farm.get_node("FarmSim") as FarmSim
|
|
sim.set_physics_process(false)
|
|
sim.waves.enabled = false
|
|
var player := farm.get_node("Player") as PlayerCharacter
|
|
player.global_position = Vector3(SPOT.x, 0.0, SPOT.y)
|
|
var radar := farm.get_node("Hud/RadarHud") as RadarHud
|
|
var shed_panel := farm.get_node("Hud/ShedPanel") as UpgradePanel
|
|
var c := sim.campaign
|
|
var s := c.state
|
|
var cfg := sim.config
|
|
|
|
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")
|
|
|
|
c.begin_day()
|
|
s.resources.shed = {"wood": 50, "scrap": 50, "straw": 50, "alien_goop": 0}
|
|
r.check(not Upgrades.revealed(s, cfg, "radar"), "still not revealed with zero goop collected")
|
|
s.night_events["gathered_alien_goop"] = cfg.hidden_reveal_goop # enough to reveal it, like the Alien Ray
|
|
r.check(Upgrades.revealed(s, cfg, "radar"), "revealed once hidden_reveal_goop (%d) is collected" % cfg.hidden_reveal_goop)
|
|
shed_panel.refresh()
|
|
r.check((shed_panel._rows["radar"] as Button).text.begins_with("Radar —"), "radar's shed row shows its name once revealed: '%s'" % (shed_panel._rows["radar"] as Button).text)
|
|
var text := Upgrades.buy(c, "radar", sim.structures)
|
|
r.check(Upgrades.owned(s, "radar") and text.contains("done:"), "radar bought: '%s'" % text)
|
|
|
|
radar._process(0.0)
|
|
r.check(radar.visible, "the radar minimap shows once the Radar item is bought")
|
|
|
|
var es := sim.enemies
|
|
var near_thief := es.spawn(EnemySystem.TYPE_THIEF, SPOT.x + 5.0, SPOT.y, Vector2.LEFT)
|
|
var near_crow := es.spawn(EnemySystem.TYPE_CROW, SPOT.x, SPOT.y - 6.0, Vector2.UP)
|
|
var far_breaker := es.spawn(EnemySystem.TYPE_BREAKER, SPOT.x + cfg.radar_range + 20.0, SPOT.y, Vector2.LEFT)
|
|
radar._refresh()
|
|
r.check(radar.dot_count() == 2, "two alive enemies within radar_range are plotted (got %d)" % radar.dot_count())
|
|
r.check(radar.player_plotted, "the scarecrow itself is plotted on the minimap")
|
|
var types: Array = []
|
|
for dot: Dictionary in radar.dots:
|
|
types.append(int(dot["type"]))
|
|
types.sort()
|
|
r.check(types == [EnemySystem.TYPE_THIEF, EnemySystem.TYPE_CROW],
|
|
"the plotted dots are the near thief and crow, not the far-off breaker (got %s)" % [types])
|
|
|
|
# Killing the two in-range enemies drops the plotted count back to zero.
|
|
es.apply_hit(es.resolve_handle(near_thief), 99)
|
|
es.apply_hit(es.resolve_handle(near_crow), 99)
|
|
radar._refresh()
|
|
r.check(radar.dot_count() == 0, "no dots once the in-range enemies are dead (the far breaker was never counted)")
|
|
es.apply_hit(es.resolve_handle(far_breaker), 99)
|
|
|
|
# Ownership survives a save round trip (FarmState.to_dict/from_dict, same as SaveGame does through JSON).
|
|
var round_tripped := FarmState.from_dict(JSON.parse_string(JSON.stringify(s.to_dict())))
|
|
r.check(round_tripped != null and Upgrades.owned(round_tripped, "radar"), "radar ownership survives a FarmState JSON round trip")
|
|
|
|
farm.queue_free()
|
|
await r.process_frame
|