Task #26: upgrade tiers and timed shed stock
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>
This commit is contained in:
parent
6a9575dfe4
commit
91b9e52e96
12 changed files with 531 additions and 137 deletions
|
|
@ -11,7 +11,7 @@ extends SceneTree
|
|||
## and checks that structures, materials, and health carry over.
|
||||
## --cycles=3 sets how many (5 plays the whole vacation, one night plan
|
||||
## each); --build=0 skips building, --guard=0 leaves the night to the
|
||||
## defenses. With materials left after the plan it buys upgrades
|
||||
## defenses. With materials left after the plan it buys upgrade levels
|
||||
## (UPGRADE_ORDER) at the workbench; --upgrades=0 skips them.
|
||||
## --mode=gather plays one day instead: the scarecrow walks (along the navigation
|
||||
## grid) to the nearest gather point with charges, holds interact until it
|
||||
|
|
@ -45,7 +45,8 @@ const BUILD_PLAN := [
|
|||
["automated_defense", Vector2(7.0, -3.5), 0],
|
||||
["automated_defense", Vector2(9.5, -14.0), 0],
|
||||
]
|
||||
## The scripted scarecrow's upgrades, in order, bought with what's left after building.
|
||||
## The scripted scarecrow's upgrades, in order, bought with what's left after building: their
|
||||
## first levels, then (from the days they open) their next ones, lowest level first.
|
||||
const UPGRADE_ORDER: Array[String] = ["corn_shooter", "long_range", "rapid_fire", "heavy_seeds", "pumpkin_bomb",
|
||||
"reinforced_fences", "quick_fear", "wide_fear", "sticky_tar", "straw_stuffing"]
|
||||
const PEN_GATE := Vector2(4.0, -6.0)
|
||||
|
|
@ -300,20 +301,24 @@ func _build_tick(me: Vector2) -> void:
|
|||
_walk_field(Vector2(30.0, -3.0), me)
|
||||
|
||||
|
||||
## Walks to the workbench and buys the next upgrade it can afford. Returns false if there's none.
|
||||
## Walks to the workbench and buys the next upgrade level it can afford (one that's in stock and
|
||||
## open by today), the lowest level first: every first level in UPGRADE_ORDER before any second
|
||||
## one, and so on. Returns false if there's none.
|
||||
func _upgrade_tick(me: Vector2) -> bool:
|
||||
var c := _sim.campaign
|
||||
var pick := ""
|
||||
for id in UPGRADE_ORDER:
|
||||
if Upgrades.blocker(c, id) != "":
|
||||
continue
|
||||
var bench := _sim.interactions.workbench
|
||||
var at := Vector2(bench.global_position.x, bench.global_position.z)
|
||||
if at.distance_to(me) > bench.reach - 0.3:
|
||||
_walk_field(at, me)
|
||||
else:
|
||||
Upgrades.buy(c, id, _sim.structures)
|
||||
return true
|
||||
return false
|
||||
if Upgrades.blocker(c, id) == "" and (pick == "" or Upgrades.level(c.state, id) < Upgrades.level(c.state, pick)):
|
||||
pick = id
|
||||
if pick == "":
|
||||
return false
|
||||
var bench := _sim.interactions.workbench
|
||||
var at := Vector2(bench.global_position.x, bench.global_position.z)
|
||||
if at.distance_to(me) > bench.reach - 0.3:
|
||||
_walk_field(at, me)
|
||||
else:
|
||||
Upgrades.buy(c, pick, _sim.structures)
|
||||
return true
|
||||
|
||||
|
||||
func _gather_day() -> void:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue