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
|
|
@ -338,31 +338,58 @@ Implemented in Step 5. The numbers are in `GameConfig`; the gather points are li
|
||||||
|
|
||||||
## Upgrades
|
## Upgrades
|
||||||
|
|
||||||
Implemented in Step 10. Bought once each, by day, from the menu at the work area's tool table. The
|
Implemented in Step 10; levels and timed stock in #26. Bought by day from two menus: the work
|
||||||
menu works with mouse, keyboard (arrows and Enter), or gamepad (d-pad and A). Close it with
|
area's tool table sells the stat upgrades and Sprint, and the supply shed's counter sells the
|
||||||
Escape / B, interact again, or by walking off. The scarecrow stands still while it's open.
|
weapons and items. The menus work with mouse, keyboard (arrows and Enter), or gamepad (d-pad and
|
||||||
|
A). Close one with Escape / B, interact again, or by walking off. The scarecrow stands still while
|
||||||
|
it's open. "Day N" is the day before night N.
|
||||||
|
|
||||||
| Track | Upgrade | Effect | Cost |
|
**Workbench upgrades have three levels.** Each level is bought separately, and the levels stack.
|
||||||
|---|---|---|---|
|
Level 1 can be bought from day 1, level 2 from day 8, and level 3 from day 16
|
||||||
| Weapon | Corn shooter | The gun: corn kernels from afar (below) | 10 scrap, 4 wood |
|
(`upgrade_level_days`). Each level costs 1.8 times the one before (`upgrade_cost_growth`), each
|
||||||
| Weapon | Rapid fire | The corn shooter fires a third faster (needs the corn shooter) | 12 scrap, 8 wood |
|
material rounded up.
|
||||||
| Weapon | Heavy seeds | Each kernel does 2 damage (needs the corn shooter) | 14 scrap, 10 straw |
|
|
||||||
| Weapon | Pumpkin bombs | Thrown bombs that burst over 3 m, one every 4 s (below) | 12 straw, 6 scrap |
|
|
||||||
| Fear | Wide fear | Fear reaches 30% farther | 20 straw, 4 wood |
|
|
||||||
| Fear | Quick fear | Fear recharges 20% faster | 16 straw, 6 scrap |
|
|
||||||
| Scarecrow | Straw stuffing | +2 max health | 12 straw, 4 wood |
|
|
||||||
| Scarecrow | Sprint | Hold Shift / L3 to sprint: 1.6 times as fast for 3 s, then 10 s to recharge | 8 wood, 6 straw |
|
|
||||||
| Defenses | Reinforced fences | Fences and gates +50% health (standing ones keep their share) | 20 wood, 6 scrap |
|
|
||||||
| Defenses | Long-range defenses | Automated defenses reach 30% farther | 14 scrap, 10 wood |
|
|
||||||
| Defenses | Sticky tar | Slowing traps hold 50% longer | 14 straw, 6 scrap |
|
|
||||||
|
|
||||||
- **Cost:** all eleven cost 222 materials (74 scrap, 58 wood, 90 straw), drawing on the same
|
| Track | Upgrade | Level 1 | Level 2 | Level 3 |
|
||||||
stock as building. Measured (before Sprint and the weapons were added): the scripted
|
|---|---|---|---|---|
|
||||||
scarecrow, building its plan, could afford 6 of the 8 over the five days.
|
| Weapon | Rapid fire (needs the corn shooter) | fires 3x faster; 8 wood, 12 scrap, 12 straw | another 25% faster (3.75x); 15 wood, 22 scrap, 22 straw | another 25% (4.69x); 26 wood, 39 scrap, 39 straw |
|
||||||
|
| Weapon | Heavy seeds (needs the corn shooter) | 2 damage a kernel; 14 scrap, 10 straw | 3 damage; 26 scrap, 18 straw | 4 damage; 46 scrap, 33 straw |
|
||||||
|
| Fear | Wide fear | reaches 30% farther; 4 wood, 20 straw | another 15% (1.5x); 8 wood, 36 straw | another 15% (1.72x); 13 wood, 65 straw |
|
||||||
|
| Fear | Quick fear | recharges 20% faster; 6 scrap, 16 straw | another 10% (0.72x the wait); 11 scrap, 29 straw | another 10% (0.65x); 20 scrap, 52 straw |
|
||||||
|
| Scarecrow | Straw stuffing | +2 max health; 4 wood, 12 straw | +2 more; 8 wood, 22 straw | +2 more; 13 wood, 39 straw |
|
||||||
|
| Scarecrow | Bigger pouch | +8 (16 units); 10 wood, 8 straw | +4 (20 units); 18 wood, 15 straw | +4 (24 units); 33 wood, 26 straw |
|
||||||
|
| Defenses | Reinforced fences | fences and gates +50% health; 20 wood, 6 scrap | another 25% (1.88x); 36 wood, 11 scrap | another 25% (2.34x); 65 wood, 20 scrap |
|
||||||
|
| Defenses | Long-range defenses | automated defenses reach 30% farther; 10 wood, 14 scrap | another 15% (1.5x); 18 wood, 26 scrap | another 15% (1.72x); 33 wood, 46 scrap |
|
||||||
|
| Defenses | Sticky tar | slowing traps hold 50% longer; 6 scrap, 14 straw | another 25% (1.88x); 11 scrap, 26 straw | another 25% (2.34x); 20 scrap, 46 straw |
|
||||||
|
|
||||||
|
Sprint is bought once: hold Shift / L3 to run 80% faster for 4 s, then 10 s to recharge
|
||||||
|
(8 wood, 6 straw).
|
||||||
|
|
||||||
|
**The shed's stock arrives on set days** (`from_day`). Each item is bought once.
|
||||||
|
|
||||||
|
| Day | Item | Cost |
|
||||||
|
|---|---|---|
|
||||||
|
| 1 | Corn shooter: the gun, corn kernels from afar | 4 wood, 10 scrap |
|
||||||
|
| 2 | Shurikens: fast, cheap throws | 6 scrap, 4 straw |
|
||||||
|
| 3 | Pumpkin bombs: thrown, they burst over 3 m, one every 4 s | 6 scrap, 12 straw |
|
||||||
|
| 6 | Potato cannon: a slow, heavy shot from afar | 8 wood, 14 scrap |
|
||||||
|
| 8 | Radar: a minimap of nearby enemies (hidden until Alien Goop is collected) | 6 wood, 8 scrap |
|
||||||
|
| 10 | Propane torch: a band of flame ahead while held | 6 wood, 12 scrap, 4 straw |
|
||||||
|
| 14 | Alien ray: a piercing beam while held (hidden until Alien Goop is collected) | 10 scrap, 6 Alien Goop |
|
||||||
|
|
||||||
|
- **The menus:** a row shows the next level's name, what it does, and its cost, such as "Rapid
|
||||||
|
fire II". A row that can't be bought yet says why: "Need 2 scrap more", "Level 2 opens on day
|
||||||
|
8", or "The work area is for daytime". At the last level it says "Max" (a one-off says
|
||||||
|
"Done"). A shed item before its day shows only its name and "Arrives on day 6". A hidden item
|
||||||
|
shows "?" until it's revealed, plus its arrival day if it hasn't arrived.
|
||||||
|
- **Cost:** everything together costs about 1,390 materials: the nine upgrades' levels cost
|
||||||
|
206, 378, and 674, and the one-offs cost 130. They draw on the same stock as building.
|
||||||
- **Needs:** rapid fire and heavy seeds can't be bought before the corn shooter ("Needs the corn
|
- **Needs:** rapid fire and heavy seeds can't be bought before the corn shooter ("Needs the corn
|
||||||
shooter first").
|
shooter first").
|
||||||
- **Persistence:** upgrades carry over between nights and come back with a retry. The automated
|
- **Persistence:** levels carry over between nights, are saved, and come back with a retry. A
|
||||||
defense's shots don't get heavy seeds.
|
save from before levels loads each upgrade at level 1. The automated defense's shots don't get
|
||||||
|
heavy seeds.
|
||||||
|
- **Co-op:** either player can buy the next level. Player 2's purchase is made by the host, paid
|
||||||
|
from player 2's pouch and then the shed.
|
||||||
|
|
||||||
## Construction
|
## Construction
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -101,6 +101,7 @@ costs = {
|
||||||
}
|
}
|
||||||
upgrades = {
|
upgrades = {
|
||||||
"alien_ray": {
|
"alien_ray": {
|
||||||
|
"from_day": 14,
|
||||||
"hidden": true,
|
"hidden": true,
|
||||||
"name": "Alien ray",
|
"name": "Alien ray",
|
||||||
"shop": "shed",
|
"shop": "shed",
|
||||||
|
|
@ -108,59 +109,68 @@ upgrades = {
|
||||||
"track": "Weapon"
|
"track": "Weapon"
|
||||||
},
|
},
|
||||||
"corn_shooter": {
|
"corn_shooter": {
|
||||||
|
"from_day": 1,
|
||||||
"name": "Corn shooter",
|
"name": "Corn shooter",
|
||||||
"shop": "shed",
|
"shop": "shed",
|
||||||
"text": "A gun that fires corn kernels, from afar",
|
"text": "A gun that fires corn kernels, from afar",
|
||||||
"track": "Weapon"
|
"track": "Weapon"
|
||||||
},
|
},
|
||||||
"heavy_seeds": {
|
"heavy_seeds": {
|
||||||
"add": 1,
|
"add": [1, 1, 1],
|
||||||
|
"levels": 3,
|
||||||
"name": "Heavy seeds",
|
"name": "Heavy seeds",
|
||||||
"requires": "corn_shooter",
|
"requires": "corn_shooter",
|
||||||
"stat": "shot_damage",
|
"stat": "shot_damage",
|
||||||
"text": "Each kernel does 2 damage",
|
"texts": ["Each kernel does 2 damage", "Each kernel does 3 damage", "Each kernel does 4 damage"],
|
||||||
"track": "Weapon"
|
"track": "Weapon"
|
||||||
},
|
},
|
||||||
"long_range": {
|
"long_range": {
|
||||||
"mult": 1.3,
|
"levels": 3,
|
||||||
|
"mult": [1.3, 1.15, 1.15],
|
||||||
"name": "Long-range defenses",
|
"name": "Long-range defenses",
|
||||||
"stat": "turret_range",
|
"stat": "turret_range",
|
||||||
"text": "Turrets reach 30% farther",
|
"texts": ["Turrets reach 30% farther", "Turrets reach another 15% farther", "Turrets reach 15% farther again"],
|
||||||
"track": "Defenses"
|
"track": "Defenses"
|
||||||
},
|
},
|
||||||
"potato_cannon": {
|
"potato_cannon": {
|
||||||
|
"from_day": 6,
|
||||||
"name": "Potato cannon",
|
"name": "Potato cannon",
|
||||||
"shop": "shed",
|
"shop": "shed",
|
||||||
"text": "A slow heavy potato shot that hits hard from afar",
|
"text": "A slow heavy potato shot that hits hard from afar",
|
||||||
"track": "Weapon"
|
"track": "Weapon"
|
||||||
},
|
},
|
||||||
"pouch_upgrade": {
|
"pouch_upgrade": {
|
||||||
"add": 8,
|
"add": [8, 4, 4],
|
||||||
|
"levels": 3,
|
||||||
"name": "Bigger pouch",
|
"name": "Bigger pouch",
|
||||||
"stat": "pouch_capacity",
|
"stat": "pouch_capacity",
|
||||||
"text": "+8 pouch capacity (16 total)",
|
"texts": ["+8 pouch capacity (16 total)", "+4 pouch capacity (20 total)", "+4 pouch capacity (24 total)"],
|
||||||
"track": "Scarecrow"
|
"track": "Scarecrow"
|
||||||
},
|
},
|
||||||
"propane_torch": {
|
"propane_torch": {
|
||||||
|
"from_day": 10,
|
||||||
"name": "Propane torch",
|
"name": "Propane torch",
|
||||||
"shop": "shed",
|
"shop": "shed",
|
||||||
"text": "A jet of flame that burns everything in a band ahead of you while held",
|
"text": "A jet of flame that burns everything in a band ahead of you while held",
|
||||||
"track": "Weapon"
|
"track": "Weapon"
|
||||||
},
|
},
|
||||||
"pumpkin_bomb": {
|
"pumpkin_bomb": {
|
||||||
|
"from_day": 3,
|
||||||
"name": "Pumpkin bombs",
|
"name": "Pumpkin bombs",
|
||||||
"shop": "shed",
|
"shop": "shed",
|
||||||
"text": "Throw a pumpkin that bursts, hurting everything within 3 m (one every 4 s)",
|
"text": "Throw a pumpkin that bursts, hurting everything within 3 m (one every 4 s)",
|
||||||
"track": "Weapon"
|
"track": "Weapon"
|
||||||
},
|
},
|
||||||
"quick_fear": {
|
"quick_fear": {
|
||||||
"mult": 0.8,
|
"levels": 3,
|
||||||
|
"mult": [0.8, 0.9, 0.9],
|
||||||
"name": "Quick fear",
|
"name": "Quick fear",
|
||||||
"stat": "fear_cooldown",
|
"stat": "fear_cooldown",
|
||||||
"text": "Fear recharges 20% faster",
|
"texts": ["Fear recharges 20% faster", "Fear recharges another 10% faster", "Fear recharges 10% faster again"],
|
||||||
"track": "Fear"
|
"track": "Fear"
|
||||||
},
|
},
|
||||||
"radar": {
|
"radar": {
|
||||||
|
"from_day": 8,
|
||||||
"hidden": true,
|
"hidden": true,
|
||||||
"name": "Radar",
|
"name": "Radar",
|
||||||
"shop": "shed",
|
"shop": "shed",
|
||||||
|
|
@ -168,21 +178,24 @@ upgrades = {
|
||||||
"track": "Item"
|
"track": "Item"
|
||||||
},
|
},
|
||||||
"rapid_fire": {
|
"rapid_fire": {
|
||||||
"mult": 3.0,
|
"levels": 3,
|
||||||
|
"mult": [3.0, 1.25, 1.25],
|
||||||
"name": "Rapid fire",
|
"name": "Rapid fire",
|
||||||
"requires": "corn_shooter",
|
"requires": "corn_shooter",
|
||||||
"stat": "fire_rate",
|
"stat": "fire_rate",
|
||||||
"text": "The corn shooter fires 3x faster!!!!!",
|
"texts": ["The corn shooter fires 3x faster!!!!!", "The corn shooter fires another 25% faster", "The corn shooter fires 25% faster again"],
|
||||||
"track": "Weapon"
|
"track": "Weapon"
|
||||||
},
|
},
|
||||||
"reinforced_fences": {
|
"reinforced_fences": {
|
||||||
"mult": 1.5,
|
"levels": 3,
|
||||||
|
"mult": [1.5, 1.25, 1.25],
|
||||||
"name": "Reinforced fences",
|
"name": "Reinforced fences",
|
||||||
"stat": "barrier_hp",
|
"stat": "barrier_hp",
|
||||||
"text": "Fences and gates +50% health",
|
"texts": ["Fences and gates +50% health", "Fences and gates another +25% health", "Fences and gates +25% health again"],
|
||||||
"track": "Defenses"
|
"track": "Defenses"
|
||||||
},
|
},
|
||||||
"shurikens": {
|
"shurikens": {
|
||||||
|
"from_day": 2,
|
||||||
"name": "Shurikens",
|
"name": "Shurikens",
|
||||||
"shop": "shed",
|
"shop": "shed",
|
||||||
"text": "Fast, cheap throws for a quick hit",
|
"text": "Fast, cheap throws for a quick hit",
|
||||||
|
|
@ -194,24 +207,27 @@ upgrades = {
|
||||||
"track": "Scarecrow"
|
"track": "Scarecrow"
|
||||||
},
|
},
|
||||||
"sticky_tar": {
|
"sticky_tar": {
|
||||||
"mult": 1.5,
|
"levels": 3,
|
||||||
|
"mult": [1.5, 1.25, 1.25],
|
||||||
"name": "Sticky tar",
|
"name": "Sticky tar",
|
||||||
"stat": "trap_slow_time",
|
"stat": "trap_slow_time",
|
||||||
"text": "Tar patches hold 50% longer",
|
"texts": ["Tar patches hold 50% longer", "Tar patches hold another 25% longer", "Tar patches hold 25% longer again"],
|
||||||
"track": "Defenses"
|
"track": "Defenses"
|
||||||
},
|
},
|
||||||
"straw_stuffing": {
|
"straw_stuffing": {
|
||||||
"add": 2,
|
"add": [2, 2, 2],
|
||||||
|
"levels": 3,
|
||||||
"name": "Straw stuffing",
|
"name": "Straw stuffing",
|
||||||
"stat": "scarecrow_max_hp",
|
"stat": "scarecrow_max_hp",
|
||||||
"text": "+2 max health",
|
"texts": ["+2 max health", "+2 more max health", "+2 more max health"],
|
||||||
"track": "Scarecrow"
|
"track": "Scarecrow"
|
||||||
},
|
},
|
||||||
"wide_fear": {
|
"wide_fear": {
|
||||||
"mult": 1.3,
|
"levels": 3,
|
||||||
|
"mult": [1.3, 1.15, 1.15],
|
||||||
"name": "Wide fear",
|
"name": "Wide fear",
|
||||||
"stat": "fear_radius",
|
"stat": "fear_radius",
|
||||||
"text": "Fear reaches 30% farther",
|
"texts": ["Fear reaches 30% farther", "Fear reaches another 15% farther", "Fear reaches 15% farther again"],
|
||||||
"track": "Fear"
|
"track": "Fear"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -541,9 +541,9 @@ func _do_request(r: Array) -> void:
|
||||||
var id := String(r[1])
|
var id := String(r[1])
|
||||||
if Upgrades.shop_of(c.config, id) == "workbench" and (sim.structures == null or not sim.structures.workbench_available()):
|
if Upgrades.shop_of(c.config, id) == "workbench" and (sim.structures == null or not sim.structures.workbench_available()):
|
||||||
return
|
return
|
||||||
var was := Upgrades.owned(c.state, id)
|
var was := Upgrades.level(c.state, id)
|
||||||
Upgrades.buy(c, id, sim.structures, a.slot) # paid from P2's pouch, then the shed
|
Upgrades.buy(c, id, sim.structures, a.slot) # paid from P2's pouch, then the shed
|
||||||
if not was and Upgrades.owned(c.state, id):
|
if Upgrades.level(c.state, id) > was:
|
||||||
_events.append(["bought", a.slot, id]) # the buyer's game: a new weapon into its hand
|
_events.append(["bought", a.slot, id]) # the buyer's game: a new weapon into its hand
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -110,7 +110,7 @@ extends Resource
|
||||||
@export_range(0, 999) var start_straw: int = 4
|
@export_range(0, 999) var start_straw: int = 4
|
||||||
@export_range(0, 999) var start_alien_goop: int = 0
|
@export_range(0, 999) var start_alien_goop: int = 0
|
||||||
## The scarecrow's pouch holds this many units in total; it empties into the shed on entry.
|
## The scarecrow's pouch holds this many units in total; it empties into the shed on entry.
|
||||||
## Raised to 16 by the Bigger pouch upgrade (Upgrades, "pouch_capacity").
|
## Raised by each level of the Bigger pouch upgrade (Upgrades, "pouch_capacity").
|
||||||
@export_range(1, 200) var pouch_capacity: int = 8
|
@export_range(1, 200) var pouch_capacity: int = 8
|
||||||
## Seconds of holding interact per gather (each takes one charge of the gather point).
|
## Seconds of holding interact per gather (each takes one charge of the gather point).
|
||||||
@export var gather_time: float = 1.5
|
@export var gather_time: float = 1.5
|
||||||
|
|
@ -141,32 +141,59 @@ extends Resource
|
||||||
}
|
}
|
||||||
|
|
||||||
@export_group("Upgrades")
|
@export_group("Upgrades")
|
||||||
## Bought once each by day, for costs[id] (Upgrades), either at the work area's workbench (the
|
## What the two shops sell (Upgrades), by day, for costs[id]: either the work area's workbench
|
||||||
## default shop) or the supply shed's counter ("shop": "shed": weapons and other purchasable
|
## (the default shop) or the supply shed's counter ("shop": "shed": weapons and other purchasable
|
||||||
## items, Upgrades.shop_of, UpgradePanel's shop filter). Each changes one stat: "mult" multiplies
|
## items, Upgrades.shop_of, UpgradePanel's shop filter). The keys:
|
||||||
## it, "add" adds to it. Stats are GameConfig settings, plus scarecrow_max_hp (the scarecrow's, in
|
## "name", "track" (the menu's heading), "text": what it does.
|
||||||
## FarmState) and barrier_hp (fences' and gates' health). One without a stat unlocks something
|
## "stat": the one stat it changes. Stats are GameConfig settings, plus scarecrow_max_hp (the
|
||||||
## instead (sprint: PlayerCharacter; the corn shooter and pumpkin bombs: ScarecrowCombat).
|
## scarecrow's, in FarmState) and barrier_hp (fences' and gates' health). One without a stat
|
||||||
## "requires": another upgrade that must be bought first (from either shop).
|
## unlocks something instead (sprint: PlayerCharacter; the weapons: ScarecrowCombat; radar:
|
||||||
|
## RadarHud).
|
||||||
|
## "mult" multiplies the stat, "add" adds to it: a number (the same every level) or an Array
|
||||||
|
## with one entry per level. Each owned level's entry applies in turn, so they stack.
|
||||||
|
## "levels": how many times it can be bought (1 by default). Level L costs costs[id] x
|
||||||
|
## upgrade_cost_growth^(L - 1) and opens on day upgrade_level_days[L - 1] (or its own
|
||||||
|
## "level_days": [day, ...]).
|
||||||
|
## "texts": one description per level, shown instead of "text" (the menu shows the next one).
|
||||||
|
## "from_day": the day it arrives in stock, before which it can't be bought (1 by default).
|
||||||
|
## Day N is the day before night N (FarmState.night).
|
||||||
|
## "requires": another upgrade that must be bought first (from either shop).
|
||||||
|
## "hidden", "reveal_goop": see hidden_reveal_goop below.
|
||||||
@export var upgrades: Dictionary = {
|
@export var upgrades: Dictionary = {
|
||||||
"corn_shooter": {"name": "Corn shooter", "text": "A gun that fires corn kernels, from afar", "track": "Weapon", "shop": "shed"},
|
"corn_shooter": {"name": "Corn shooter", "text": "A gun that fires corn kernels, from afar", "track": "Weapon", "shop": "shed", "from_day": 1},
|
||||||
"rapid_fire": {"name": "Rapid fire", "text": "The corn shooter fires a third faster", "track": "Weapon", "stat": "fire_rate", "mult": 1.333, "requires": "corn_shooter"},
|
"rapid_fire": {"name": "Rapid fire", "track": "Weapon", "stat": "fire_rate", "mult": [1.333, 1.25, 1.25], "levels": 3, "requires": "corn_shooter",
|
||||||
"heavy_seeds": {"name": "Heavy seeds", "text": "Each kernel does 2 damage", "track": "Weapon", "stat": "shot_damage", "add": 1, "requires": "corn_shooter"},
|
"texts": ["The corn shooter fires a third faster", "The corn shooter fires another 25% faster", "The corn shooter fires 25% faster again"]},
|
||||||
"pumpkin_bomb": {"name": "Pumpkin bombs", "text": "Throw a pumpkin that bursts, hurting everything within 3 m (one every 4 s)", "track": "Weapon", "shop": "shed"},
|
"heavy_seeds": {"name": "Heavy seeds", "track": "Weapon", "stat": "shot_damage", "add": [1, 1, 1], "levels": 3, "requires": "corn_shooter",
|
||||||
"potato_cannon": {"name": "Potato cannon", "text": "A slow heavy potato shot that hits hard from afar", "track": "Weapon", "shop": "shed"},
|
"texts": ["Each kernel does 2 damage", "Each kernel does 3 damage", "Each kernel does 4 damage"]},
|
||||||
"shurikens": {"name": "Shurikens", "text": "Fast, cheap throws for a quick hit", "track": "Weapon", "shop": "shed"},
|
"pumpkin_bomb": {"name": "Pumpkin bombs", "text": "Throw a pumpkin that bursts, hurting everything within 3 m (one every 4 s)", "track": "Weapon", "shop": "shed", "from_day": 3},
|
||||||
"propane_torch": {"name": "Propane torch", "text": "A jet of flame that burns everything in a band ahead of you while held", "track": "Weapon", "shop": "shed"},
|
"potato_cannon": {"name": "Potato cannon", "text": "A slow heavy potato shot that hits hard from afar", "track": "Weapon", "shop": "shed", "from_day": 6},
|
||||||
"alien_ray": {"name": "Alien ray", "text": "A salvaged alien weapon: a long beam that pierces everything in its line while held", "track": "Weapon", "shop": "shed", "hidden": true},
|
"shurikens": {"name": "Shurikens", "text": "Fast, cheap throws for a quick hit", "track": "Weapon", "shop": "shed", "from_day": 2},
|
||||||
"radar": {"name": "Radar", "text": "A minimap showing nearby enemy positions", "track": "Item", "shop": "shed", "hidden": true},
|
"propane_torch": {"name": "Propane torch", "text": "A jet of flame that burns everything in a band ahead of you while held", "track": "Weapon", "shop": "shed", "from_day": 10},
|
||||||
"wide_fear": {"name": "Wide fear", "text": "Fear reaches 30% farther", "track": "Fear", "stat": "fear_radius", "mult": 1.3},
|
"alien_ray": {"name": "Alien ray", "text": "A salvaged alien weapon: a long beam that pierces everything in its line while held", "track": "Weapon", "shop": "shed", "hidden": true, "from_day": 14},
|
||||||
"quick_fear": {"name": "Quick fear", "text": "Fear recharges 20% faster", "track": "Fear", "stat": "fear_cooldown", "mult": 0.8},
|
"radar": {"name": "Radar", "text": "A minimap showing nearby enemy positions", "track": "Item", "shop": "shed", "hidden": true, "from_day": 8},
|
||||||
"straw_stuffing": {"name": "Straw stuffing", "text": "+2 max health", "track": "Scarecrow", "stat": "scarecrow_max_hp", "add": 2},
|
"wide_fear": {"name": "Wide fear", "track": "Fear", "stat": "fear_radius", "mult": [1.3, 1.15, 1.15], "levels": 3,
|
||||||
"pouch_upgrade": {"name": "Bigger pouch", "text": "+8 pouch capacity (16 total)", "track": "Scarecrow", "stat": "pouch_capacity", "add": 8},
|
"texts": ["Fear reaches 30% farther", "Fear reaches another 15% farther", "Fear reaches 15% farther again"]},
|
||||||
|
"quick_fear": {"name": "Quick fear", "track": "Fear", "stat": "fear_cooldown", "mult": [0.8, 0.9, 0.9], "levels": 3,
|
||||||
|
"texts": ["Fear recharges 20% faster", "Fear recharges another 10% faster", "Fear recharges 10% faster again"]},
|
||||||
|
"straw_stuffing": {"name": "Straw stuffing", "track": "Scarecrow", "stat": "scarecrow_max_hp", "add": [2, 2, 2], "levels": 3,
|
||||||
|
"texts": ["+2 max health", "+2 more max health", "+2 more max health"]},
|
||||||
|
"pouch_upgrade": {"name": "Bigger pouch", "track": "Scarecrow", "stat": "pouch_capacity", "add": [8, 4, 4], "levels": 3,
|
||||||
|
"texts": ["+8 pouch capacity (16 total)", "+4 pouch capacity (20 total)", "+4 pouch capacity (24 total)"]},
|
||||||
"sprint": {"name": "Sprint", "text": "Sprint 80% faster for 4 s at a time, every 10 s", "track": "Scarecrow"},
|
"sprint": {"name": "Sprint", "text": "Sprint 80% faster for 4 s at a time, every 10 s", "track": "Scarecrow"},
|
||||||
"reinforced_fences": {"name": "Reinforced fences", "text": "Fences and gates +50% health", "track": "Defenses", "stat": "barrier_hp", "mult": 1.5},
|
"reinforced_fences": {"name": "Reinforced fences", "track": "Defenses", "stat": "barrier_hp", "mult": [1.5, 1.25, 1.25], "levels": 3,
|
||||||
"long_range": {"name": "Long-range defenses", "text": "Turrets reach 30% farther", "track": "Defenses", "stat": "turret_range", "mult": 1.3},
|
"texts": ["Fences and gates +50% health", "Fences and gates another +25% health", "Fences and gates +25% health again"]},
|
||||||
"sticky_tar": {"name": "Sticky tar", "text": "Tar patches hold 50% longer", "track": "Defenses", "stat": "trap_slow_time", "mult": 1.5},
|
"long_range": {"name": "Long-range defenses", "track": "Defenses", "stat": "turret_range", "mult": [1.3, 1.15, 1.15], "levels": 3,
|
||||||
|
"texts": ["Turrets reach 30% farther", "Turrets reach another 15% farther", "Turrets reach 15% farther again"]},
|
||||||
|
"sticky_tar": {"name": "Sticky tar", "track": "Defenses", "stat": "trap_slow_time", "mult": [1.5, 1.25, 1.25], "levels": 3,
|
||||||
|
"texts": ["Tar patches hold 50% longer", "Tar patches hold another 25% longer", "Tar patches hold 25% longer again"]},
|
||||||
}
|
}
|
||||||
|
## Each further level of an upgrade with "levels" costs this many times the one before: level L
|
||||||
|
## costs costs[id] x upgrade_cost_growth^(L - 1), each material rounded up (Upgrades.cost).
|
||||||
|
@export_range(1.0, 5.0, 0.05) var upgrade_cost_growth: float = 1.8
|
||||||
|
## The day each level of an upgrade with "levels" can first be bought: level L from day
|
||||||
|
## upgrade_level_days[L - 1] (the last entry for any level past its end). An upgrade's own
|
||||||
|
## "level_days" overrides it. Day N is the day before night N.
|
||||||
|
@export var upgrade_level_days: Array[int] = [1, 8, 16]
|
||||||
## An upgrade with "hidden": true (e.g. Alien Ray, Radar, #7/#8) shows only a "?" (no name, text,
|
## An upgrade with "hidden": true (e.g. Alien Ray, Radar, #7/#8) shows only a "?" (no name, text,
|
||||||
## or cost) and can't be bought until the player has collected this much Alien Goop in total
|
## or cost) and can't be bought until the player has collected this much Alien Goop in total
|
||||||
## (Upgrades.goop_collected); then it shows and buys normally for its defined cost. Overridable
|
## (Upgrades.goop_collected); then it shows and buys normally for its defined cost. Overridable
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,10 @@
|
||||||
class_name UpgradePanel
|
class_name UpgradePanel
|
||||||
extends CenterContainer
|
extends CenterContainer
|
||||||
## A shop's menu (Upgrades): one row per upgrade or item sold by this instance's shop (shop,
|
## A shop's menu (Upgrades): one row per upgrade or item sold by this instance's shop (shop,
|
||||||
## Upgrades.shop_of), by track, with what it does and what it costs. A done one says so; one you
|
## Upgrades.shop_of), by track, with what its next level does and costs ("Rapid fire II" for one
|
||||||
## can't afford says what's missing. The work area's instance (shop "workbench": player/weapon
|
## with levels). A done one says so ("Max" at the last level); one that can't be bought yet says
|
||||||
|
## why: what's missing, "Level 2 opens on day 8", or, for a shed item not in stock yet, just its
|
||||||
|
## name and "Arrives on day 6". The work area's instance (shop "workbench": player/weapon
|
||||||
## stat and buildable upgrades) opens with interact at the workbench by day; the supply shed's
|
## stat and buildable upgrades) opens with interact at the workbench by day; the supply shed's
|
||||||
## (shop "shed": weapons and other purchasable items) opens with interact at the shed's counter by
|
## (shop "shed": weapons and other purchasable items) opens with interact at the shed's counter by
|
||||||
## day (Interactions). Buy with a click, or the arrows / d-pad and Enter / A. Close it with Close,
|
## day (Interactions). Buy with a click, or the arrows / d-pad and Enter / A. Close it with Close,
|
||||||
|
|
@ -122,18 +124,25 @@ func refresh() -> void:
|
||||||
var u: Dictionary = cfg.upgrades[id]
|
var u: Dictionary = cfg.upgrades[id]
|
||||||
var b := _rows[id] as Button
|
var b := _rows[id] as Button
|
||||||
var why := Upgrades.blocker(campaign, id, slot)
|
var why := Upgrades.blocker(campaign, id, slot)
|
||||||
if Upgrades.owned(s, id):
|
var lvl := Upgrades.level(s, id)
|
||||||
|
var top := Upgrades.max_level(cfg, id)
|
||||||
|
b.disabled = why != ""
|
||||||
|
if lvl >= top:
|
||||||
done += 1
|
done += 1
|
||||||
|
b.text = "%s — %s (%s)" % [Upgrades.name_at(cfg, id, top), Upgrades.text_at(cfg, id, top), "Max" if top > 1 else "Done"]
|
||||||
|
continue
|
||||||
|
var arrival := "" if Upgrades.arrived(s, cfg, id) else "Arrives on day %d" % Upgrades.level_day(cfg, id, 1)
|
||||||
if not Upgrades.revealed(s, cfg, id):
|
if not Upgrades.revealed(s, cfg, id):
|
||||||
# Hidden: no name, description, or cost until its reveal condition is met.
|
# Hidden: no name, description, or cost until its reveal condition is met.
|
||||||
b.text = "?"
|
b.text = "?" if arrival == "" else "? %s" % arrival
|
||||||
b.disabled = true
|
|
||||||
continue
|
continue
|
||||||
var price := "Done" if Upgrades.owned(s, id) else ResourceStore.describe(Upgrades.cost(cfg, id))
|
if arrival != "":
|
||||||
b.text = "%s — %s (%s)" % [u["name"], u["text"], price]
|
b.text = "%s %s" % [u["name"], arrival] # (greyed: disabled)
|
||||||
if why != "" and why != "Done":
|
continue
|
||||||
|
b.text = "%s — %s (%s)" % [Upgrades.name_at(cfg, id, lvl + 1), Upgrades.text_at(cfg, id, lvl + 1),
|
||||||
|
ResourceStore.describe(Upgrades.cost(cfg, id, lvl + 1))]
|
||||||
|
if why != "":
|
||||||
b.text += " %s" % why
|
b.text += " %s" % why
|
||||||
b.disabled = why != ""
|
|
||||||
var place := "Upgrades at the work area" if shop == "workbench" else "Shop at the supply shed"
|
var place := "Upgrades at the work area" if shop == "workbench" else "Shop at the supply shed"
|
||||||
_title.text = "%s (%d of %d done)" % [place, done, _rows.size()]
|
_title.text = "%s (%d of %d done)" % [place, done, _rows.size()]
|
||||||
|
|
||||||
|
|
@ -142,9 +151,9 @@ func _buy(id: String) -> void:
|
||||||
if buy_request.is_valid():
|
if buy_request.is_valid():
|
||||||
buy_request.call(id)
|
buy_request.call(id)
|
||||||
return
|
return
|
||||||
var was := Upgrades.owned(campaign.state, id)
|
var was := Upgrades.level(campaign.state, id)
|
||||||
var text := Upgrades.buy(campaign, id, structures, slot)
|
var text := Upgrades.buy(campaign, id, structures, slot)
|
||||||
if not was and Upgrades.owned(campaign.state, id):
|
if Upgrades.level(campaign.state, id) > was: # a level went through (every one jingles)
|
||||||
bought.emit(id)
|
bought.emit(id)
|
||||||
message.emit(text, Color(0.85, 0.75, 1.0) if text.contains("done:") else Color(1.0, 0.8, 0.5))
|
message.emit(text, Color(0.85, 0.75, 1.0) if text.contains("done:") else Color(1.0, 0.8, 0.5))
|
||||||
_after_buy(id)
|
_after_buy(id)
|
||||||
|
|
|
||||||
|
|
@ -1,32 +1,115 @@
|
||||||
class_name Upgrades
|
class_name Upgrades
|
||||||
extends RefCounted
|
extends RefCounted
|
||||||
## The farm's upgrades and shop items (definitions in GameConfig.upgrades, costs in
|
## The farm's upgrades and shop items (definitions in GameConfig.upgrades, costs in
|
||||||
## GameConfig.costs): bought once each, by day, at one of two shops (shop_of, "workbench" by
|
## GameConfig.costs), bought by day at one of two shops (shop_of, "workbench" by default:
|
||||||
## default: player/weapon stat and buildable upgrades, at the work area; "shed": weapons and
|
## player/weapon stat and buildable upgrades, at the work area; "shed": weapons and other
|
||||||
## other purchasable items, at the supply shed's counter), each its own UpgradePanel instance.
|
## purchasable items, at the supply shed's counter), each its own UpgradePanel instance. Most are
|
||||||
## Bought ones are kept in FarmState.upgrades (id -> 1), so they carry over between nights and
|
## bought once; the workbench's stat upgrades have levels ("levels", #26): each buy() takes one to
|
||||||
## come back with a retry. Systems ask value() for a stat with the owned upgrades applied instead
|
## the next level, which costs upgrade_cost_growth times the one before (cost()) and opens on a
|
||||||
## of reading GameConfig directly: the corn shooter's fire rate and shot damage, fear's radius and
|
## later day (upgrade_level_days, level_day()), and each owned level's effect stacks. Shed items
|
||||||
## cooldown, fences' and gates' health (barrier_hp), the automated defense's range, and the traps'
|
## arrive in stock on set days ("from_day"). Bought ones are kept in FarmState.upgrades
|
||||||
## slow time. Straw stuffing raises the scarecrow's max health (FarmState) when bought, and the
|
## (id -> level), so they carry over between nights and come back with a retry. Systems ask
|
||||||
## Bigger pouch upgrade raises pouch_capacity (ResourceStore, shared: every scarecrow's pouch
|
## value() for a stat with the owned upgrades applied instead of reading GameConfig directly: the
|
||||||
## grows) the same way. The buyer pays from their own pouch and the shed (slot). Sprint, the corn
|
## corn shooter's fire rate and shot damage, fear's radius and cooldown, fences' and gates' health
|
||||||
## shooter, and pumpkin bombs change no stat: owning them unlocks sprinting (PlayerCharacter) and
|
## (barrier_hp), the automated defense's range, and the traps' slow time. Straw stuffing raises
|
||||||
## the two weapons (ScarecrowCombat). Rapid fire and heavy seeds (bought at the workbench) need
|
## the scarecrow's max health (FarmState) when a level is bought, and the Bigger pouch upgrade
|
||||||
## the corn shooter (bought at the shed) first ("requires" crosses shops freely).
|
## raises pouch_capacity (ResourceStore, shared: every scarecrow's pouch grows) the same way. The
|
||||||
|
## buyer pays from their own pouch and the shed (slot). Sprint, the weapons, and radar change no
|
||||||
|
## stat: owning them (owned(): level 1 or more) unlocks sprinting (PlayerCharacter), the weapons
|
||||||
|
## (ScarecrowCombat), and the minimap (RadarHud). Rapid fire and heavy seeds (bought at the
|
||||||
|
## workbench) need the corn shooter (bought at the shed) first ("requires" crosses shops freely).
|
||||||
|
|
||||||
## Menu order, grouped by track.
|
## Menu order, grouped by track.
|
||||||
const ORDER: Array[String] = ["corn_shooter", "rapid_fire", "heavy_seeds", "pumpkin_bomb", "potato_cannon", "shurikens",
|
const ORDER: Array[String] = ["corn_shooter", "rapid_fire", "heavy_seeds", "pumpkin_bomb", "potato_cannon", "shurikens",
|
||||||
"propane_torch", "alien_ray", "radar", "wide_fear", "quick_fear",
|
"propane_torch", "alien_ray", "radar", "wide_fear", "quick_fear",
|
||||||
"straw_stuffing", "pouch_upgrade", "sprint", "reinforced_fences", "long_range", "sticky_tar"]
|
"straw_stuffing", "pouch_upgrade", "sprint", "reinforced_fences", "long_range", "sticky_tar"]
|
||||||
|
const ROMAN: Array[String] = ["", "I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX", "X"]
|
||||||
|
|
||||||
|
|
||||||
|
## The level of an upgrade the farm owns (0: not bought).
|
||||||
|
static func level(state: FarmState, id: String) -> int:
|
||||||
|
return int(state.upgrades.get(id, 0)) if state != null else 0
|
||||||
|
|
||||||
|
|
||||||
|
## Owned at any level (level 1 or more): what "requires" and the unlocks (sprint, the weapons,
|
||||||
|
## radar) ask.
|
||||||
static func owned(state: FarmState, id: String) -> bool:
|
static func owned(state: FarmState, id: String) -> bool:
|
||||||
return int(state.upgrades.get(id, 0)) > 0
|
return level(state, id) > 0
|
||||||
|
|
||||||
|
|
||||||
static func cost(cfg: GameConfig, id: String) -> Dictionary:
|
## How many levels an upgrade has (its "levels", 1 by default).
|
||||||
return cfg.costs.get(id, {})
|
static func max_level(cfg: GameConfig, id: String) -> int:
|
||||||
|
return maxi(1, int(cfg.upgrades.get(id, {}).get("levels", 1)))
|
||||||
|
|
||||||
|
|
||||||
|
## Bought to its last level.
|
||||||
|
static func maxed(cfg: GameConfig, state: FarmState, id: String) -> bool:
|
||||||
|
return level(state, id) >= max_level(cfg, id)
|
||||||
|
|
||||||
|
|
||||||
|
## What buying this level costs: costs[id] for level 1, and upgrade_cost_growth times as much
|
||||||
|
## for each level after it (costs[id] x growth^(level - 1)), each material rounded up.
|
||||||
|
## next_cost() is the one the farm would buy now.
|
||||||
|
static func cost(cfg: GameConfig, id: String, lvl: int = 1) -> Dictionary:
|
||||||
|
var base: Dictionary = cfg.costs.get(id, {})
|
||||||
|
if lvl <= 1:
|
||||||
|
return base
|
||||||
|
var k := pow(cfg.upgrade_cost_growth, lvl - 1)
|
||||||
|
var out := {}
|
||||||
|
for m in base:
|
||||||
|
out[m] = ceili(int(base[m]) * k - 0.0001) # (25 x 1.8^2 is 81.00000000000001)
|
||||||
|
return out
|
||||||
|
|
||||||
|
|
||||||
|
static func next_cost(cfg: GameConfig, state: FarmState, id: String) -> Dictionary:
|
||||||
|
return cost(cfg, id, level(state, id) + 1)
|
||||||
|
|
||||||
|
|
||||||
|
## One level's entry of a per-level definition key ("mult", "add"): a number is the same every
|
||||||
|
## level; an Array has one entry per level (its last entry repeats past its end).
|
||||||
|
static func per_level(entry: Variant, lvl: int, fallback: float = 0.0) -> float:
|
||||||
|
if entry is Array:
|
||||||
|
var a: Array = entry
|
||||||
|
return float(a[clampi(lvl - 1, 0, a.size() - 1)]) if not a.is_empty() else fallback
|
||||||
|
return float(entry) if entry != null else fallback
|
||||||
|
|
||||||
|
|
||||||
|
## What a level does: its "texts" entry, else the one "text".
|
||||||
|
static func text_at(cfg: GameConfig, id: String, lvl: int) -> String:
|
||||||
|
var u: Dictionary = cfg.upgrades.get(id, {})
|
||||||
|
var texts: Array = u.get("texts", [])
|
||||||
|
if not texts.is_empty():
|
||||||
|
return String(texts[clampi(lvl - 1, 0, texts.size() - 1)])
|
||||||
|
return String(u.get("text", ""))
|
||||||
|
|
||||||
|
|
||||||
|
## Its name at a level: "Rapid fire II" (no numeral on an upgrade with a single level).
|
||||||
|
static func name_at(cfg: GameConfig, id: String, lvl: int) -> String:
|
||||||
|
var n := String(cfg.upgrades.get(id, {}).get("name", id))
|
||||||
|
return n if max_level(cfg, id) <= 1 else "%s %s" % [n, roman(lvl)]
|
||||||
|
|
||||||
|
|
||||||
|
static func roman(n: int) -> String:
|
||||||
|
return ROMAN[n] if n >= 0 and n < ROMAN.size() else str(n)
|
||||||
|
|
||||||
|
|
||||||
|
## The day a shop item arrives in stock (its "from_day", 1 by default). Day N is the day before
|
||||||
|
## night N (FarmState.night).
|
||||||
|
static func from_day(cfg: GameConfig, id: String) -> int:
|
||||||
|
return int(cfg.upgrades.get(id, {}).get("from_day", 1))
|
||||||
|
|
||||||
|
|
||||||
|
## The day a level can first be bought: upgrade_level_days[level - 1] (the last entry for any
|
||||||
|
## level past its end), or the upgrade's own "level_days". Level 1 also waits for from_day.
|
||||||
|
static func level_day(cfg: GameConfig, id: String, lvl: int) -> int:
|
||||||
|
var days: Array = cfg.upgrades.get(id, {}).get("level_days", cfg.upgrade_level_days)
|
||||||
|
var day := int(days[clampi(lvl - 1, 0, days.size() - 1)]) if not days.is_empty() else 1
|
||||||
|
return maxi(day, from_day(cfg, id)) if lvl <= 1 else day
|
||||||
|
|
||||||
|
|
||||||
|
## Whether a shop item has arrived by this farm's day (from_day).
|
||||||
|
static func arrived(state: FarmState, cfg: GameConfig, id: String) -> bool:
|
||||||
|
return state != null and state.night >= level_day(cfg, id, 1)
|
||||||
|
|
||||||
|
|
||||||
## Which shop sells an upgrade: "workbench" (the default: player/weapon stat and buildable
|
## Which shop sells an upgrade: "workbench" (the default: player/weapon stat and buildable
|
||||||
|
|
@ -58,45 +141,52 @@ static func revealed(state: FarmState, cfg: GameConfig, id: String) -> bool:
|
||||||
return goop_collected(state) >= int(u.get("reveal_goop", cfg.hidden_reveal_goop))
|
return goop_collected(state) >= int(u.get("reveal_goop", cfg.hidden_reveal_goop))
|
||||||
|
|
||||||
|
|
||||||
## A stat with every owned upgrade applied (barrier_hp is a multiplier, 1 without upgrades).
|
## A stat with every owned upgrade applied, each of its owned levels in turn (barrier_hp is a
|
||||||
|
## multiplier, 1 without upgrades).
|
||||||
static func value(cfg: GameConfig, state: FarmState, stat: String) -> float:
|
static func value(cfg: GameConfig, state: FarmState, stat: String) -> float:
|
||||||
var v := 1.0 if stat == "barrier_hp" else float(cfg.get(stat))
|
var v := 1.0 if stat == "barrier_hp" else float(cfg.get(stat))
|
||||||
if state == null:
|
if state == null:
|
||||||
return v
|
return v
|
||||||
for id: String in cfg.upgrades:
|
for id: String in cfg.upgrades:
|
||||||
var u: Dictionary = cfg.upgrades[id]
|
var u: Dictionary = cfg.upgrades[id]
|
||||||
if String(u.get("stat", "")) != stat or not owned(state, id):
|
if String(u.get("stat", "")) != stat:
|
||||||
continue
|
continue
|
||||||
if u.has("mult"):
|
for lvl in range(1, mini(level(state, id), max_level(cfg, id)) + 1):
|
||||||
v *= float(u["mult"])
|
if u.has("mult"):
|
||||||
if u.has("add"):
|
v *= per_level(u["mult"], lvl, 1.0)
|
||||||
v += float(u["add"])
|
if u.has("add"):
|
||||||
|
v += per_level(u["add"], lvl, 0.0)
|
||||||
return v
|
return v
|
||||||
|
|
||||||
|
|
||||||
## Why an upgrade can't be bought right now ("" if it can), by the scarecrow in this avatar slot
|
## Why an upgrade's next level can't be bought right now ("" if it can), by the scarecrow in this
|
||||||
## (its pouch and the shed pay).
|
## avatar slot (its pouch and the shed pay).
|
||||||
static func blocker(campaign: CampaignController, id: String, slot: int = 0) -> String:
|
static func blocker(campaign: CampaignController, id: String, slot: int = 0) -> String:
|
||||||
var cfg := campaign.config
|
var cfg := campaign.config
|
||||||
var s := campaign.state
|
var s := campaign.state
|
||||||
if not cfg.upgrades.has(id):
|
if not cfg.upgrades.has(id):
|
||||||
return "No such upgrade"
|
return "No such upgrade"
|
||||||
if owned(s, id):
|
var next := level(s, id) + 1
|
||||||
|
if next > max_level(cfg, id):
|
||||||
return "Done"
|
return "Done"
|
||||||
|
if next == 1 and not arrived(s, cfg, id):
|
||||||
|
return "Arrives on day %d" % level_day(cfg, id, 1)
|
||||||
if not revealed(s, cfg, id):
|
if not revealed(s, cfg, id):
|
||||||
return "Not discovered yet"
|
return "Not discovered yet"
|
||||||
var needs := String(cfg.upgrades[id].get("requires", ""))
|
var needs := String(cfg.upgrades[id].get("requires", ""))
|
||||||
if needs != "" and not owned(s, needs):
|
if needs != "" and not owned(s, needs):
|
||||||
return "Needs the %s first" % String(cfg.upgrades.get(needs, {}).get("name", needs)).to_lower()
|
return "Needs the %s first" % String(cfg.upgrades.get(needs, {}).get("name", needs)).to_lower()
|
||||||
|
if next > 1 and s.night < level_day(cfg, id, next):
|
||||||
|
return "Level %d opens on day %d" % [next, level_day(cfg, id, next)]
|
||||||
if not campaign.is_daytime():
|
if not campaign.is_daytime():
|
||||||
return "The work area is for daytime"
|
return "The work area is for daytime"
|
||||||
if not s.resources.can_afford(cost(cfg, id), slot):
|
if not s.resources.can_afford(cost(cfg, id, next), slot):
|
||||||
return "Need %s more" % ResourceStore.describe(s.resources.missing(cost(cfg, id), slot))
|
return "Need %s more" % ResourceStore.describe(s.resources.missing(cost(cfg, id, next), slot))
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
|
|
||||||
## Buys an upgrade if it can be bought, paid by the scarecrow in this avatar slot (its pouch,
|
## Buys an upgrade's next level if it can be bought, paid by the scarecrow in this avatar slot
|
||||||
## then the shed). Returns the message for the player.
|
## (its pouch, then the shed). Returns the message for the player.
|
||||||
static func buy(campaign: CampaignController, id: String, structures: StructureSystem = null, slot: int = 0) -> String:
|
static func buy(campaign: CampaignController, id: String, structures: StructureSystem = null, slot: int = 0) -> String:
|
||||||
var cfg := campaign.config
|
var cfg := campaign.config
|
||||||
var s := campaign.state
|
var s := campaign.state
|
||||||
|
|
@ -104,16 +194,18 @@ static func buy(campaign: CampaignController, id: String, structures: StructureS
|
||||||
var why := blocker(campaign, id, slot)
|
var why := blocker(campaign, id, slot)
|
||||||
if why != "":
|
if why != "":
|
||||||
return "%s: %s" % [u.get("name", id), why.to_lower() if why != "Done" else "already done"]
|
return "%s: %s" % [u.get("name", id), why.to_lower() if why != "Done" else "already done"]
|
||||||
|
var lvl := level(s, id) + 1
|
||||||
|
var add := roundi(per_level(u.get("add", 0), lvl))
|
||||||
var barrier_before := value(cfg, s, "barrier_hp")
|
var barrier_before := value(cfg, s, "barrier_hp")
|
||||||
s.pay(cost(cfg, id), slot)
|
s.pay(cost(cfg, id, lvl), slot)
|
||||||
s.upgrades[id] = 1
|
s.upgrades[id] = lvl
|
||||||
s.record_event("upgrades_bought")
|
s.record_event("upgrades_bought") # every level counts
|
||||||
match String(u.get("stat", "")):
|
match String(u.get("stat", "")):
|
||||||
"scarecrow_max_hp": # both scarecrows'
|
"scarecrow_max_hp": # both scarecrows'
|
||||||
s.scarecrow_max_hp += int(u.get("add", 0))
|
s.scarecrow_max_hp += add
|
||||||
s.scarecrow_hp += int(u.get("add", 0))
|
s.scarecrow_hp += add
|
||||||
s.partner_max_hp += int(u.get("add", 0))
|
s.partner_max_hp += add
|
||||||
s.partner_hp += int(u.get("add", 0))
|
s.partner_hp += add
|
||||||
"barrier_hp":
|
"barrier_hp":
|
||||||
# Standing fences and gates keep their share of health.
|
# Standing fences and gates keep their share of health.
|
||||||
var k := value(cfg, s, "barrier_hp") / barrier_before
|
var k := value(cfg, s, "barrier_hp") / barrier_before
|
||||||
|
|
@ -121,5 +213,5 @@ static func buy(campaign: CampaignController, id: String, structures: StructureS
|
||||||
if e["type"] == "fence" or e["type"] == "gate":
|
if e["type"] == "fence" or e["type"] == "gate":
|
||||||
e["hp"] = mini(roundi(int(e["hp"]) * k), structures.max_hp(e["type"]) if structures != null else 1 << 20)
|
e["hp"] = mini(roundi(int(e["hp"]) * k), structures.max_hp(e["type"]) if structures != null else 1 << 20)
|
||||||
"pouch_capacity": # the live value lives in ResourceStore (one for every pouch), not read from cfg each time
|
"pouch_capacity": # the live value lives in ResourceStore (one for every pouch), not read from cfg each time
|
||||||
s.resources.pouch_capacity += int(u.get("add", 0))
|
s.resources.pouch_capacity += add
|
||||||
return "%s done: %s" % [u.get("name", id), String(u.get("text", "")).to_lower()]
|
return "%s done: %s" % [name_at(cfg, id, lvl), text_at(cfg, id, lvl).to_lower()]
|
||||||
|
|
|
||||||
|
|
@ -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
|
## #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
|
## (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
|
## 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
|
## P2's); and one Bigger pouch grows both pouches, as does its level 2, which P2's request buys
|
||||||
## by P2's pouch.
|
## once its day comes (#26). The partner's HUD, menus, and build mode go by P2's pouch.
|
||||||
func _own_pouches() -> void:
|
func _own_pouches() -> void:
|
||||||
var res := host.campaign.state.resources
|
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
|
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
|
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,
|
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])
|
"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()
|
_empty_pouches()
|
||||||
_pump(6)
|
_pump(6)
|
||||||
|
|
||||||
|
|
@ -364,6 +392,8 @@ func _shops() -> void:
|
||||||
var id := "shurikens"
|
var id := "shurikens"
|
||||||
var w := ScarecrowCombat.WEAPON_IDS.find(id)
|
var w := ScarecrowCombat.WEAPON_IDS.find(id)
|
||||||
var cost: Dictionary = host.config.costs[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
|
client.player.global_position = at_counter
|
||||||
_pump(20)
|
_pump(20)
|
||||||
_tap_interact()
|
_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")
|
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()
|
client.shed_panel.close()
|
||||||
host.campaign.state.upgrades.erase(id)
|
host.campaign.state.upgrades.erase(id)
|
||||||
|
host.campaign.state.night = day
|
||||||
_empty_pouches()
|
_empty_pouches()
|
||||||
client.player.global_position = Vector3(0.5, 0.0, 6.0)
|
client.player.global_position = Vector3(0.5, 0.0, 6.0)
|
||||||
_pump(SETTLE)
|
_pump(SETTLE)
|
||||||
|
|
|
||||||
|
|
@ -12,9 +12,11 @@ extends RefCounted
|
||||||
## supply shed's own shop (#6): weapons (corn_shooter, pumpkin_bomb) bought at its counter
|
## 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
|
## (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.
|
## 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 P := CampaignController.Phase
|
||||||
const DT := 1.0 / 60.0
|
const DT := 1.0 / 60.0
|
||||||
|
const TIERS_SAVE := "user://test_economy_tiers.json"
|
||||||
|
|
||||||
|
|
||||||
func run(r: GameTestRunner) -> void:
|
func run(r: GameTestRunner) -> void:
|
||||||
|
|
@ -24,6 +26,8 @@ func run(r: GameTestRunner) -> void:
|
||||||
_goop_persistence(r)
|
_goop_persistence(r)
|
||||||
_pouch_upgrade(r)
|
_pouch_upgrade(r)
|
||||||
await _hidden_items(r)
|
await _hidden_items(r)
|
||||||
|
await _tiers(r)
|
||||||
|
await _stock(r)
|
||||||
var farm := (load("res://game/scenes/farm.tscn") as PackedScene).instantiate() as Node3D
|
var farm := (load("res://game/scenes/farm.tscn") as PackedScene).instantiate() as Node3D
|
||||||
r.root.add_child(farm)
|
r.root.add_child(farm)
|
||||||
await r.process_frame
|
await r.process_frame
|
||||||
|
|
@ -162,7 +166,8 @@ func _pouch_upgrade(r: GameTestRunner) -> void:
|
||||||
"Bigger pouch raises capacity from 8 to 16 (%s)" % msg)
|
"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.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(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).
|
# It carries into the next morning (same mechanic as straw_stuffing/scarecrow_max_hp).
|
||||||
while s.phase != P.MORNING:
|
while s.phase != P.MORNING:
|
||||||
c.advance_phase()
|
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")
|
"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:
|
func _layout(r: GameTestRunner, sim: FarmSim) -> void:
|
||||||
var by_material := {}
|
var by_material := {}
|
||||||
var names := {}
|
var names := {}
|
||||||
|
|
@ -426,7 +602,7 @@ func _stuffing(r: GameTestRunner, sim: FarmSim, player: PlayerCharacter) -> void
|
||||||
var it := sim.interactions
|
var it := sim.interactions
|
||||||
var bench := it.workbench
|
var bench := it.workbench
|
||||||
var menu := sim.upgrade_panel
|
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] = []
|
var msgs: Array[String] = []
|
||||||
it.message.connect(func(t: String, _col: Color) -> void: msgs.append(t))
|
it.message.connect(func(t: String, _col: Color) -> void: msgs.append(t))
|
||||||
menu.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,
|
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]])
|
"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(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)
|
_press(sim)
|
||||||
r.check(not menu.is_open and not player.rooted, "interact again closes the menu")
|
r.check(not menu.is_open and not player.rooted, "interact again closes the menu")
|
||||||
_press(sim)
|
_press(sim)
|
||||||
|
|
|
||||||
|
|
@ -110,7 +110,8 @@ func _waves(plan: NightPlan) -> int:
|
||||||
return waves
|
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:
|
func _upgrades(r: GameTestRunner, sim: FarmSim, player: PlayerCharacter) -> void:
|
||||||
var c := sim.campaign
|
var c := sim.campaign
|
||||||
var s := c.state
|
var s := c.state
|
||||||
|
|
@ -131,13 +132,17 @@ func _upgrades(r: GameTestRunner, sim: FarmSim, player: PlayerCharacter) -> void
|
||||||
var shed := s.resources.shed_total()
|
var shed := s.resources.shed_total()
|
||||||
var spent := 0
|
var spent := 0
|
||||||
r.check(not player.can_sprint(), "(no sprint before the Sprint upgrade)")
|
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:
|
for id in Upgrades.ORDER:
|
||||||
spent += _sum(Upgrades.cost(cfg, id))
|
spent += _sum(Upgrades.cost(cfg, id))
|
||||||
var text := Upgrades.buy(c, id, st)
|
var text := Upgrades.buy(c, id, st)
|
||||||
r.check(Upgrades.owned(s, id) and text.contains("done:"), "bought %s: '%s'" % [id, text])
|
r.check(Upgrades.level(s, id) == 1 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])
|
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(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,
|
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()])
|
"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),
|
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()
|
var bought := s.upgrades.duplicate()
|
||||||
while s.phase != P.NIGHT:
|
while s.phase != P.NIGHT:
|
||||||
c.advance_phase()
|
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")
|
s.upgrades.erase("sticky_tar")
|
||||||
r.check(Upgrades.blocker(c, "sticky_tar") == "The work area is for daytime", "nothing can be bought at night")
|
r.check(Upgrades.blocker(c, "sticky_tar") == "The work area is for daytime", "nothing can be bought at night")
|
||||||
s.upgrades["sticky_tar"] = 1
|
s.upgrades["sticky_tar"] = 1
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,10 @@ func run(r: GameTestRunner) -> void:
|
||||||
|
|
||||||
radar._process(0.0)
|
radar._process(0.0)
|
||||||
r.check(radar != null and not radar.visible, "the radar minimap is hidden before the Radar item is bought")
|
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"))
|
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()
|
shed_panel.refresh()
|
||||||
r.check((shed_panel._rows["radar"] as Button).text == "?", "radar's shed row shows only '?' before it's revealed")
|
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 combat := sim.combat
|
||||||
var st := sim.structures
|
var st := sim.structures
|
||||||
c.begin_day()
|
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}
|
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(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")
|
r.check(Upgrades.blocker(c, "rapid_fire") == "Needs the corn shooter first" and Upgrades.buy(c, "heavy_seeds", st).contains("needs the corn shooter")
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ extends SceneTree
|
||||||
## and checks that structures, materials, and health carry over.
|
## and checks that structures, materials, and health carry over.
|
||||||
## --cycles=3 sets how many (5 plays the whole vacation, one night plan
|
## --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
|
## 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.
|
## (UPGRADE_ORDER) at the workbench; --upgrades=0 skips them.
|
||||||
## --mode=gather plays one day instead: the scarecrow walks (along the navigation
|
## --mode=gather plays one day instead: the scarecrow walks (along the navigation
|
||||||
## grid) to the nearest gather point with charges, holds interact until it
|
## 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(7.0, -3.5), 0],
|
||||||
["automated_defense", Vector2(9.5, -14.0), 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",
|
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"]
|
"reinforced_fences", "quick_fear", "wide_fear", "sticky_tar", "straw_stuffing"]
|
||||||
const PEN_GATE := Vector2(4.0, -6.0)
|
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)
|
_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:
|
func _upgrade_tick(me: Vector2) -> bool:
|
||||||
var c := _sim.campaign
|
var c := _sim.campaign
|
||||||
|
var pick := ""
|
||||||
for id in UPGRADE_ORDER:
|
for id in UPGRADE_ORDER:
|
||||||
if Upgrades.blocker(c, id) != "":
|
if Upgrades.blocker(c, id) == "" and (pick == "" or Upgrades.level(c.state, id) < Upgrades.level(c.state, pick)):
|
||||||
continue
|
pick = id
|
||||||
var bench := _sim.interactions.workbench
|
if pick == "":
|
||||||
var at := Vector2(bench.global_position.x, bench.global_position.z)
|
return false
|
||||||
if at.distance_to(me) > bench.reach - 0.3:
|
var bench := _sim.interactions.workbench
|
||||||
_walk_field(at, me)
|
var at := Vector2(bench.global_position.x, bench.global_position.z)
|
||||||
else:
|
if at.distance_to(me) > bench.reach - 0.3:
|
||||||
Upgrades.buy(c, id, _sim.structures)
|
_walk_field(at, me)
|
||||||
return true
|
else:
|
||||||
return false
|
Upgrades.buy(c, pick, _sim.structures)
|
||||||
|
return true
|
||||||
|
|
||||||
|
|
||||||
func _gather_day() -> void:
|
func _gather_day() -> void:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue