Merge task #11: Animal Pen boundary is player-built
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
commit
43300a15de
9 changed files with 163 additions and 96 deletions
|
|
@ -92,7 +92,6 @@
|
||||||
[ext_resource type="PackedScene" uid="uid://t72a771keby1" path="res://assets/farm/ithappy/farm/prefabs/assets/prop/chair_001.tscn" id="212_chair_001"]
|
[ext_resource type="PackedScene" uid="uid://t72a771keby1" path="res://assets/farm/ithappy/farm/prefabs/assets/prop/chair_001.tscn" id="212_chair_001"]
|
||||||
[ext_resource type="PackedScene" uid="uid://ceco5h6fe6hyu" path="res://assets/farm/ithappy/farm/prefabs/assets/prop/table_002.tscn" id="213_table_002"]
|
[ext_resource type="PackedScene" uid="uid://ceco5h6fe6hyu" path="res://assets/farm/ithappy/farm/prefabs/assets/prop/table_002.tscn" id="213_table_002"]
|
||||||
[ext_resource type="PackedScene" uid="uid://c5dpfl620ystw" path="res://assets/farm/ithappy/farm/prefabs/assets/prop/bucket_001.tscn" id="214_bucket_001"]
|
[ext_resource type="PackedScene" uid="uid://c5dpfl620ystw" path="res://assets/farm/ithappy/farm/prefabs/assets/prop/bucket_001.tscn" id="214_bucket_001"]
|
||||||
[ext_resource type="PackedScene" uid="uid://dm7inst25lj00" path="res://assets/farm/ithappy/farm/prefabs/assets/prop/fence_024.tscn" id="215_fence_024"]
|
|
||||||
[ext_resource type="PackedScene" uid="uid://dw1k3ilpn8nll" path="res://assets/farm/ithappy/farm/prefabs/assets/prop/coop_002.tscn" id="217_coop_002"]
|
[ext_resource type="PackedScene" uid="uid://dw1k3ilpn8nll" path="res://assets/farm/ithappy/farm/prefabs/assets/prop/coop_002.tscn" id="217_coop_002"]
|
||||||
[ext_resource type="PackedScene" uid="uid://cr17qkqcl5n5k" path="res://assets/farm/ithappy/farm/prefabs/assets/animal/chicken_001.tscn" id="218_chicken_001"]
|
[ext_resource type="PackedScene" uid="uid://cr17qkqcl5n5k" path="res://assets/farm/ithappy/farm/prefabs/assets/animal/chicken_001.tscn" id="218_chicken_001"]
|
||||||
[ext_resource type="PackedScene" uid="uid://b1awnl6wg6nur" path="res://assets/farm/ithappy/farm/prefabs/assets/animal/chicken_003.tscn" id="219_chicken_003"]
|
[ext_resource type="PackedScene" uid="uid://b1awnl6wg6nur" path="res://assets/farm/ithappy/farm/prefabs/assets/animal/chicken_003.tscn" id="219_chicken_003"]
|
||||||
|
|
@ -2313,75 +2312,6 @@ display_name = "Animal Pen"
|
||||||
size = Vector2(14, 10)
|
size = Vector2(14, 10)
|
||||||
tint = Color(0.85, 0.55, 0.3, 1)
|
tint = Color(0.85, 0.55, 0.3, 1)
|
||||||
|
|
||||||
[node name="fence_024_1" parent="Zones/AnimalPen" unique_id=1446580389 instance=ExtResource("215_fence_024")]
|
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -6, 0, -5)
|
|
||||||
|
|
||||||
[node name="fence_024_2" parent="Zones/AnimalPen" unique_id=1858327670 instance=ExtResource("215_fence_024")]
|
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -6, 0, 5)
|
|
||||||
|
|
||||||
[node name="fence_024_3" parent="Zones/AnimalPen" unique_id=1072155173 instance=ExtResource("215_fence_024")]
|
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -4, 0, -5)
|
|
||||||
|
|
||||||
[node name="fence_024_4" parent="Zones/AnimalPen" unique_id=2082000001 instance=ExtResource("215_fence_024")]
|
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -4, 0, 5)
|
|
||||||
|
|
||||||
[node name="fence_024_5" parent="Zones/AnimalPen" unique_id=1226141495 instance=ExtResource("215_fence_024")]
|
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -2, 0, -5)
|
|
||||||
|
|
||||||
[node name="fence_024_6" parent="Zones/AnimalPen" unique_id=1100914280 instance=ExtResource("215_fence_024")]
|
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -2, 0, 5)
|
|
||||||
|
|
||||||
[node name="fence_024_7" parent="Zones/AnimalPen" unique_id=13821588 instance=ExtResource("215_fence_024")]
|
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -5)
|
|
||||||
|
|
||||||
[node name="fence_024_8" parent="Zones/AnimalPen" unique_id=1576318148 instance=ExtResource("215_fence_024")]
|
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 5)
|
|
||||||
|
|
||||||
[node name="fence_024_9" parent="Zones/AnimalPen" unique_id=625414246 instance=ExtResource("215_fence_024")]
|
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 2, 0, -5)
|
|
||||||
|
|
||||||
[node name="fence_024_10" parent="Zones/AnimalPen" unique_id=638219621 instance=ExtResource("215_fence_024")]
|
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 2, 0, 5)
|
|
||||||
|
|
||||||
[node name="fence_024_11" parent="Zones/AnimalPen" unique_id=1078283597 instance=ExtResource("215_fence_024")]
|
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 4, 0, -5)
|
|
||||||
|
|
||||||
[node name="fence_024_12" parent="Zones/AnimalPen" unique_id=961024064 instance=ExtResource("215_fence_024")]
|
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 4, 0, 5)
|
|
||||||
|
|
||||||
[node name="fence_024_13" parent="Zones/AnimalPen" unique_id=796402607 instance=ExtResource("215_fence_024")]
|
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 6, 0, -5)
|
|
||||||
|
|
||||||
[node name="fence_024_14" parent="Zones/AnimalPen" unique_id=2086364847 instance=ExtResource("215_fence_024")]
|
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 6, 0, 5)
|
|
||||||
|
|
||||||
[node name="fence_024_15" parent="Zones/AnimalPen" unique_id=2064386247 instance=ExtResource("215_fence_024")]
|
|
||||||
transform = Transform3D(0, 0, 1, 0, 1, 0, -1, 0, 0, -7, 0, -4)
|
|
||||||
|
|
||||||
[node name="fence_024_16" parent="Zones/AnimalPen" unique_id=349303733 instance=ExtResource("215_fence_024")]
|
|
||||||
transform = Transform3D(0, 0, 1, 0, 1, 0, -1, 0, 0, 7, 0, -4)
|
|
||||||
|
|
||||||
[node name="fence_024_17" parent="Zones/AnimalPen" unique_id=164449478 instance=ExtResource("215_fence_024")]
|
|
||||||
transform = Transform3D(0, 0, 1, 0, 1, 0, -1, 0, 0, -7, 0, -2)
|
|
||||||
|
|
||||||
[node name="fence_024_18" parent="Zones/AnimalPen" unique_id=1944845284 instance=ExtResource("215_fence_024")]
|
|
||||||
transform = Transform3D(0, 0, 1, 0, 1, 0, -1, 0, 0, 7, 0, -2)
|
|
||||||
|
|
||||||
[node name="fence_024_19" parent="Zones/AnimalPen" unique_id=909623837 instance=ExtResource("215_fence_024")]
|
|
||||||
transform = Transform3D(0, 0, 1, 0, 1, 0, -1, 0, 0, -7, 0, 0)
|
|
||||||
|
|
||||||
[node name="fence_024_20" parent="Zones/AnimalPen" unique_id=631815421 instance=ExtResource("215_fence_024")]
|
|
||||||
transform = Transform3D(0, 0, 1, 0, 1, 0, -1, 0, 0, -7, 0, 2)
|
|
||||||
|
|
||||||
[node name="fence_024_21" parent="Zones/AnimalPen" unique_id=709037316 instance=ExtResource("215_fence_024")]
|
|
||||||
transform = Transform3D(0, 0, 1, 0, 1, 0, -1, 0, 0, 7, 0, 2)
|
|
||||||
|
|
||||||
[node name="fence_024_22" parent="Zones/AnimalPen" unique_id=1495963615 instance=ExtResource("215_fence_024")]
|
|
||||||
transform = Transform3D(0, 0, 1, 0, 1, 0, -1, 0, 0, -7, 0, 4)
|
|
||||||
|
|
||||||
[node name="fence_024_23" parent="Zones/AnimalPen" unique_id=753148669 instance=ExtResource("215_fence_024")]
|
|
||||||
transform = Transform3D(0, 0, 1, 0, 1, 0, -1, 0, 0, 7, 0, 4)
|
|
||||||
|
|
||||||
[node name="coop_002_1" parent="Zones/AnimalPen" unique_id=1811355265 instance=ExtResource("217_coop_002")]
|
[node name="coop_002_1" parent="Zones/AnimalPen" unique_id=1811355265 instance=ExtResource("217_coop_002")]
|
||||||
transform = Transform3D(-1, 0, 0, 0, 1, 0, 0, 0, -1, -5.3, 0, -3.4)
|
transform = Transform3D(-1, 0, 0, 0, 1, 0, 0, 0, -1, -5.3, 0, -3.4)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -57,8 +57,9 @@ extends Resource
|
||||||
## the "farm stripped" check (D2).
|
## the "farm stripped" check (D2).
|
||||||
@export_range(0, 500) var start_crops: int = 30
|
@export_range(0, 500) var start_crops: int = 30
|
||||||
@export_range(0, 100) var start_animals: int = 8
|
@export_range(0, 100) var start_animals: int = 8
|
||||||
## Structures standing when the vacation starts ({"type", "x", "z", "rot"}): the animal pen's gate.
|
## Structures standing when the vacation starts ({"type", "x", "z", "rot"}). Empty: the animal
|
||||||
@export var start_structures: Array[Dictionary] = [{"type": "gate", "x": 4.0, "z": -6.0, "rot": 2}]
|
## pen is fully player-built (its fence/gate ring is no longer a scene prop or a free starter).
|
||||||
|
@export var start_structures: Array[Dictionary] = []
|
||||||
|
|
||||||
@export_group("Theft rules")
|
@export_group("Theft rules")
|
||||||
## D5: fear makes carriers drop their loot, not only killing them.
|
## D5: fear makes carriers drop their loot, not only killing them.
|
||||||
|
|
|
||||||
77
game/tests/pen_ring.gd
Normal file
77
game/tests/pen_ring.gd
Normal file
|
|
@ -0,0 +1,77 @@
|
||||||
|
class_name PenRing
|
||||||
|
extends RefCounted
|
||||||
|
## Positions for the Animal Pen's player-built fence/gate boundary (task #11): the same 24-piece
|
||||||
|
## layout the deleted fence_024 props and the removed GameConfig.start_structures starting gate
|
||||||
|
## used to occupy, around FarmZone.Kind.ANIMAL_PEN's rect (center (-3, -6), 14 x 10 m, world x
|
||||||
|
## -10..4, z -11..-1). Built through StructureSystem's normal validate/place path, at normal
|
||||||
|
## cost. Shared by test setups that need the pen closed the way it used to be out of the box
|
||||||
|
## (test_targets.gd, test_roster.gd); test_structures.gd's dedicated player-built-pen-boundary
|
||||||
|
## test builds the same layout by hand (with checks) instead of calling build_full().
|
||||||
|
|
||||||
|
## North and south runs: 7 fences each, 2 m apart, covering the full 14 m side.
|
||||||
|
const RUN_XS: Array[float] = [-9.0, -7.0, -5.0, -3.0, -1.0, 1.0, 3.0]
|
||||||
|
const NORTH_Z := -11.0
|
||||||
|
const SOUTH_Z := -1.0
|
||||||
|
## West and east runs: 5 slots each, 2 m apart, covering the full 10 m side. The east run's
|
||||||
|
## middle slot is the gate (where the old starting gate stood), so animals can be led in.
|
||||||
|
const SIDE_ZS: Array[float] = [-10.0, -8.0, -6.0, -4.0, -2.0]
|
||||||
|
const WEST_X := -10.0
|
||||||
|
const EAST_X := 4.0
|
||||||
|
const GATE_Z := -6.0
|
||||||
|
const GATE_ROT := 2
|
||||||
|
## Pen center: within StructureSystem.build_range (9 m) of every slot below, so one point works
|
||||||
|
## as the "scarecrow" distance check in validate() for the whole ring.
|
||||||
|
const NEAR := Vector2(-3.0, -6.0)
|
||||||
|
|
||||||
|
|
||||||
|
## The 23 fence slots (the east run's middle slot skipped: that one's the gate's), each a
|
||||||
|
## [x: float, z: float, rot: int] triple.
|
||||||
|
static func fence_slots() -> Array:
|
||||||
|
var out: Array = []
|
||||||
|
for x in RUN_XS:
|
||||||
|
out.append([x, NORTH_Z, 0])
|
||||||
|
out.append([x, SOUTH_Z, 0])
|
||||||
|
for z in SIDE_ZS:
|
||||||
|
out.append([WEST_X, z, GATE_ROT])
|
||||||
|
if z != GATE_Z:
|
||||||
|
out.append([EAST_X, z, GATE_ROT])
|
||||||
|
return out
|
||||||
|
|
||||||
|
|
||||||
|
## Builds the full ring (gate first, so it gets structure id 1, the way the old starting gate
|
||||||
|
## did) at normal cost, through the normal validate/place path. Grants and restores shed
|
||||||
|
## resources around it so callers don't need to pre-fund it. Returns the gate's id (-1 if the
|
||||||
|
## farm's layout ever drifts enough that validate() refuses a slot -- logged as a warning rather
|
||||||
|
## than failing outright, since this is setup, not the check itself).
|
||||||
|
static func build_full(sim: FarmSim) -> int:
|
||||||
|
var s := sim.campaign.state
|
||||||
|
var st := sim.structures
|
||||||
|
var keep: Dictionary = s.resources.shed.duplicate()
|
||||||
|
s.resources.shed = {"wood": 999, "scrap": 999, "straw": 999}
|
||||||
|
var gate_id := _place(st, "gate", EAST_X, GATE_Z, GATE_ROT)
|
||||||
|
for slot in fence_slots():
|
||||||
|
_place(st, "fence", slot[0], slot[1], slot[2])
|
||||||
|
s.resources.shed = keep
|
||||||
|
return gate_id
|
||||||
|
|
||||||
|
|
||||||
|
## Just the gate, at normal cost (granting and restoring shed resources around it): for tests that
|
||||||
|
## only need a single structure near the pen (matching nav.structure_at lookups at its old spot),
|
||||||
|
## not a closed pen -- e.g. test_roster.gd's fence-breaker test, where a full ring of equally-
|
||||||
|
## "guarding" structures (FarmSim._breaker_goals) would change its two-barriers-then-the-
|
||||||
|
## scarecrow narrative.
|
||||||
|
static func build_gate_only(sim: FarmSim) -> int:
|
||||||
|
var s := sim.campaign.state
|
||||||
|
var keep: Dictionary = s.resources.shed.duplicate()
|
||||||
|
s.resources.shed = {"wood": 999, "scrap": 999, "straw": 999}
|
||||||
|
var gate_id := _place(sim.structures, "gate", EAST_X, GATE_Z, GATE_ROT)
|
||||||
|
s.resources.shed = keep
|
||||||
|
return gate_id
|
||||||
|
|
||||||
|
|
||||||
|
static func _place(st: StructureSystem, type: String, x: float, z: float, rot: int) -> int:
|
||||||
|
var why := st.validate(type, x, z, rot, NEAR)
|
||||||
|
if why != "":
|
||||||
|
push_warning("PenRing: %s at (%s, %s) refused: %s" % [type, x, z, why])
|
||||||
|
return -1
|
||||||
|
return st.place(type, x, z, rot)
|
||||||
1
game/tests/pen_ring.gd.uid
Normal file
1
game/tests/pen_ring.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
uid://cxr4cikm6ieph
|
||||||
|
|
@ -78,7 +78,7 @@ func _day(r: GameTestRunner, sim: FarmSim, player: PlayerCharacter, hud: PhaseHu
|
||||||
sim.structures.damage(fence, 6)
|
sim.structures.damage(fence, 6)
|
||||||
s.scarecrow_hp = 7
|
s.scarecrow_hp = 7
|
||||||
player.global_position = AWAY
|
player.global_position = AWAY
|
||||||
r.check(sim.structures.count() == _start_structures + 2, "built a fence and an automated defense (next to the pen's gate)")
|
r.check(sim.structures.count() == _start_structures + 2, "built a fence and an automated defense")
|
||||||
var arrived: Array[int] = []
|
var arrived: Array[int] = []
|
||||||
sim.waves.arrived.connect(func(h: int, _at: Vector2) -> void: arrived.append(h))
|
sim.waves.arrived.connect(func(h: int, _at: Vector2) -> void: arrived.append(h))
|
||||||
_step_until(sim, P.DUSK)
|
_step_until(sim, P.DUSK)
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
extends RefCounted
|
extends RefCounted
|
||||||
## FarmState: creation from config (all three asset categories and the pen's gate), exact
|
## FarmState: creation from config (all three asset categories, and no starting structures --
|
||||||
## to_dict/from_dict round trips (also through JSON), rejection of invalid data, snapshot
|
## the pen is fully player-built), exact to_dict/from_dict round trips (also through JSON),
|
||||||
## independence, and night loss records for every category.
|
## rejection of invalid data, snapshot independence, and night loss records for every category.
|
||||||
|
|
||||||
|
|
||||||
func run(r: GameTestRunner) -> void:
|
func run(r: GameTestRunner) -> void:
|
||||||
|
|
@ -14,8 +14,8 @@ func run(r: GameTestRunner) -> void:
|
||||||
r.check(s.animals == cfg.start_animals and s.animals_total == cfg.start_animals, "animals start at the configured count")
|
r.check(s.animals == cfg.start_animals and s.animals_total == cfg.start_animals, "animals start at the configured count")
|
||||||
var stock := cfg.start_wood + cfg.start_scrap + cfg.start_straw
|
var stock := cfg.start_wood + cfg.start_scrap + cfg.start_straw
|
||||||
r.check(s.supplies == stock and s.supplies_total == stock and not s.shed_raided, "supplies are the shed's starting stock (%d)" % stock)
|
r.check(s.supplies == stock and s.supplies_total == stock and not s.shed_raided, "supplies are the shed's starting stock (%d)" % stock)
|
||||||
r.check(s.structures.size() == cfg.start_structures.size() and s.structures[0]["type"] == "gate"
|
r.check(s.structures.size() == cfg.start_structures.size() and s.structures.is_empty() and s.next_structure_id == 1,
|
||||||
and s.structures[0]["hp"] == cfg.gate_hp and s.next_structure_id == 2, "the pen's gate stands from the start")
|
"no structures stand at the start: the pen is fully player-built")
|
||||||
r.check(s.is_valid(), "a new farm is valid")
|
r.check(s.is_valid(), "a new farm is valid")
|
||||||
|
|
||||||
# A state with every field away from its default.
|
# A state with every field away from its default.
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,11 @@ func run(r: GameTestRunner) -> void:
|
||||||
player.global_position = AWAY
|
player.global_position = AWAY
|
||||||
sim.campaign.begin_day()
|
sim.campaign.begin_day()
|
||||||
sim.campaign.state.resources.shed = {"wood": 60, "scrap": 60, "straw": 60}
|
sim.campaign.state.resources.shed = {"wood": 60, "scrap": 60, "straw": 60}
|
||||||
|
# _breakers expects a single gate guarding the pen (not the full ring: with every ring piece
|
||||||
|
# a real structure, _breaker_goals() would treat each as "guarding" and the fence-breaker
|
||||||
|
# narrative -- exactly two guarding barriers, then the scarecrow -- no longer holds).
|
||||||
|
PenRing.build_gate_only(sim)
|
||||||
|
_settle(sim)
|
||||||
_table(r, sim)
|
_table(r, sim)
|
||||||
_crows(r, sim, player)
|
_crows(r, sim, player)
|
||||||
_thieves(r, sim, player)
|
_thieves(r, sim, player)
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,8 @@
|
||||||
extends RefCounted
|
extends RefCounted
|
||||||
## Construction on the real farm, with FarmSim stepped by hand: placement rules (each reason),
|
## Construction on the real farm, with FarmSim stepped by hand: placement rules (each reason),
|
||||||
## build mode driven by gamepad input (build, dismantle, leave), paying and recording, the sliced
|
## the player-built Animal Pen boundary (open with nothing built, open with a gap, shut once the
|
||||||
## flow-field rebuild, gates (the scarecrow passes, enemies can't), a walled-in thief breaking
|
## ring is complete), build mode driven by gamepad input (build, dismantle, leave), paying and
|
||||||
|
## recording, the sliced flow-field rebuild, gates (the scarecrow passes, enemies can't), a walled-in thief breaking
|
||||||
## out through a fence (barrier routing), slowing traps (speed, triggers), the automated
|
## out through a fence (barrier routing), slowing traps (speed, triggers), the automated
|
||||||
## defense (range), damage and breaking (breach), repair (cost, any phase), dismantling (refund),
|
## defense (range), damage and breaking (breach), repair (cost, any phase), dismantling (refund),
|
||||||
## persistence and retry, and an A/B night: the same attack on an open and on a fenced crop field.
|
## persistence and retry, and an A/B night: the same attack on an open and on a fenced crop field.
|
||||||
|
|
@ -25,10 +26,11 @@ func run(r: GameTestRunner) -> void:
|
||||||
c.begin_day()
|
c.begin_day()
|
||||||
_rich(c)
|
_rich(c)
|
||||||
_validation(r, sim)
|
_validation(r, sim)
|
||||||
|
_pen_boundary(r, sim)
|
||||||
_place_and_rebuild(r, sim)
|
_place_and_rebuild(r, sim)
|
||||||
_build_mode(r, sim, player)
|
_build_mode(r, sim, player)
|
||||||
await _gate(r, sim, player)
|
await _gate(r, sim, player)
|
||||||
_breakout(r, sim, player)
|
await _breakout(r, sim, player)
|
||||||
_trap(r, sim)
|
_trap(r, sim)
|
||||||
_turret(r, sim)
|
_turret(r, sim)
|
||||||
_repair_and_dismantle(r, sim, player)
|
_repair_and_dismantle(r, sim, player)
|
||||||
|
|
@ -52,7 +54,7 @@ func _validation(r: GameTestRunner, sim: FarmSim) -> void:
|
||||||
["at the barn doors", "fence", Vector2(1.0, -19.5), 0, "Keep the barn doors clear"],
|
["at the barn doors", "fence", Vector2(1.0, -19.5), 0, "Keep the barn doors clear"],
|
||||||
["on a crop row", "fence", sim.loot.home[1], 2, "Not on the crops"],
|
["on a crop row", "fence", sim.loot.home[1], 2, "Not on the crops"],
|
||||||
["in the house", "automated_defense", Vector2(20.5, -26.0), 0, "Blocked"],
|
["in the house", "automated_defense", Vector2(20.5, -26.0), 0, "Blocked"],
|
||||||
["on the pen fence", "fence", Vector2(-3.0, -11.0), 0, "Blocked"],
|
["on the pen's edge (no more fence_024 colliders)", "fence", Vector2(-3.0, -11.0), 0, ""],
|
||||||
]
|
]
|
||||||
for case in cases:
|
for case in cases:
|
||||||
var why := st.validate(case[1], case[2].x, case[2].y, case[3], case[2] + Vector2(2.0, 2.0))
|
var why := st.validate(case[1], case[2].x, case[2].y, case[3], case[2] + Vector2(2.0, 2.0))
|
||||||
|
|
@ -76,6 +78,40 @@ func _validation(r: GameTestRunner, sim: FarmSim) -> void:
|
||||||
_to_day(sim)
|
_to_day(sim)
|
||||||
|
|
||||||
|
|
||||||
|
## Task #11: the Animal Pen's boundary is no longer a scene prop (fence_024) or a free starting
|
||||||
|
## gate -- it's built the same way as any other fence/gate, at normal cost, through the normal
|
||||||
|
## validate/place path. With nothing built the pen is open; closing all but its gate slot still
|
||||||
|
## leaves that one gap open; filling it with a gate shuts the pen. This also leaves the ring
|
||||||
|
## standing (gate included) for the rest of the suite, the way the deleted props and the removed
|
||||||
|
## starting gate used to.
|
||||||
|
func _pen_boundary(r: GameTestRunner, sim: FarmSim) -> void:
|
||||||
|
var st := sim.structures
|
||||||
|
var s := sim.campaign.state
|
||||||
|
r.check(sim.animals.pen_open, "with no fence_024 props and no starting gate, the pen starts open")
|
||||||
|
var slots := PenRing.fence_slots()
|
||||||
|
var wood0 := int(s.resources.shed["wood"])
|
||||||
|
var refused := []
|
||||||
|
for slot in slots:
|
||||||
|
var why := st.validate("fence", slot[0], slot[1], slot[2], PenRing.NEAR)
|
||||||
|
if why == "":
|
||||||
|
st.place("fence", slot[0], slot[1], slot[2])
|
||||||
|
else:
|
||||||
|
refused.append("(%s, %s): %s" % [slot[0], slot[1], why])
|
||||||
|
r.check(refused.is_empty(), "every fence around the pen rect validates and places (%s)" % [refused])
|
||||||
|
r.check(int(s.resources.shed["wood"]) == wood0 - slots.size() * 2, "%d fences cost 2 wood each" % slots.size())
|
||||||
|
_settle(sim)
|
||||||
|
r.check(sim.animals.pen_open, "the ring minus its gate slot still leaves a gap: the pen is open")
|
||||||
|
var why := st.validate("gate", PenRing.EAST_X, PenRing.GATE_Z, PenRing.GATE_ROT, PenRing.NEAR)
|
||||||
|
r.check(why == "", "a gate validates in the last gap (got '%s')" % why)
|
||||||
|
var wood1 := int(s.resources.shed["wood"])
|
||||||
|
var scrap1 := int(s.resources.shed["scrap"])
|
||||||
|
var gate_id := st.place("gate", PenRing.EAST_X, PenRing.GATE_Z, PenRing.GATE_ROT)
|
||||||
|
r.check(gate_id >= 1 and int(s.resources.shed["wood"]) == wood1 - 4 and int(s.resources.shed["scrap"]) == scrap1 - 1,
|
||||||
|
"the gate costs 4 wood and 1 scrap")
|
||||||
|
_settle(sim)
|
||||||
|
r.check(not sim.animals.pen_open, "a player-built gate in the last gap shuts the pen")
|
||||||
|
|
||||||
|
|
||||||
func _place_and_rebuild(r: GameTestRunner, sim: FarmSim) -> void:
|
func _place_and_rebuild(r: GameTestRunner, sim: FarmSim) -> void:
|
||||||
var st := sim.structures
|
var st := sim.structures
|
||||||
var s := sim.campaign.state
|
var s := sim.campaign.state
|
||||||
|
|
@ -155,15 +191,19 @@ func _gate(r: GameTestRunner, sim: FarmSim, player: PlayerCharacter) -> void:
|
||||||
player.global_position = AWAY
|
player.global_position = AWAY
|
||||||
|
|
||||||
|
|
||||||
## A thief inside the pen, whose only opening is shut by the pen's gate, breaks the gate to get
|
## A thief inside the pen, walled in by its player-built ring, breaks a way out; a replacement
|
||||||
## out; a new gate can go back in the opening.
|
## piece can go back in the breach.
|
||||||
|
## Task #11: escape_field is a global distance-to-the-farm's-outer-edge field, not a "nearest pen
|
||||||
|
## exit" one, and every ring piece costs the same to cross -- so (unlike the old fence_024 wall
|
||||||
|
## with its one gap) the thief isn't guaranteed to break the gate specifically; it breaks whatever
|
||||||
|
## ring piece sits nearest its route to the edge. This checks the general mechanic (a walled-in
|
||||||
|
## thief breaks out, the breach opens the pen, patching it shuts the pen again) against whichever
|
||||||
|
## piece that turns out to be, rather than assuming it's the gate.
|
||||||
func _breakout(r: GameTestRunner, sim: FarmSim, player: PlayerCharacter) -> void:
|
func _breakout(r: GameTestRunner, sim: FarmSim, player: PlayerCharacter) -> void:
|
||||||
var st := sim.structures
|
var st := sim.structures
|
||||||
var es := sim.enemies
|
var es := sim.enemies
|
||||||
player.global_position = AWAY
|
player.global_position = AWAY
|
||||||
var id := sim.nav.structure_at[sim.nav.cell_of(4.0, -6.0)]
|
r.check(not sim.animals.pen_open, "the player-built ring (_pen_boundary) is shutting the pen")
|
||||||
r.check(id >= 1 and sim.campaign.state.structure(id)["type"] == "gate" and not sim.animals.pen_open,
|
|
||||||
"the vacation starts with a gate shutting the pen")
|
|
||||||
var inside := sim.nav.cell_of(-4.0, -6.0)
|
var inside := sim.nav.cell_of(-4.0, -6.0)
|
||||||
r.check(sim.escape_field[inside] < FarmNavigation.UNREACHABLE, "the walled-in pen still has a route out (through the barrier)")
|
r.check(sim.escape_field[inside] < FarmNavigation.UNREACHABLE, "the walled-in pen still has a route out (through the barrier)")
|
||||||
var broken: Array[int] = []
|
var broken: Array[int] = []
|
||||||
|
|
@ -171,18 +211,25 @@ func _breakout(r: GameTestRunner, sim: FarmSim, player: PlayerCharacter) -> void
|
||||||
var h := es.spawn(EnemySystem.TYPE_THIEF, -2.0, -6.0, Vector2.RIGHT)
|
var h := es.spawn(EnemySystem.TYPE_THIEF, -2.0, -6.0, Vector2.RIGHT)
|
||||||
es.state[es.resolve_handle(h)] = T.RETREAT
|
es.state[es.resolve_handle(h)] = T.RETREAT
|
||||||
var reached := _until(sim, func() -> bool: return es.resolve_handle(h) >= 0 and es.state[es.resolve_handle(h)] == T.BREAK, 20.0)
|
var reached := _until(sim, func() -> bool: return es.resolve_handle(h) >= 0 and es.state[es.resolve_handle(h)] == T.BREAK, 20.0)
|
||||||
r.check(reached < 20.0 and es.barrier[es.resolve_handle(h)] == id, "the thief walks to the fence and starts breaking it (%.1f s)" % reached)
|
var id := es.barrier[es.resolve_handle(h)] if reached < 20.0 else -1
|
||||||
|
r.check(reached < 20.0 and id >= 1, "the thief walks to the pen's boundary and starts breaking a way out (%.1f s)" % reached)
|
||||||
|
var piece: Dictionary = sim.campaign.state.structure(id)
|
||||||
|
var type: String = piece.get("type", "fence")
|
||||||
|
var at := Vector2(float(piece.get("x", 0.0)), float(piece.get("z", 0.0)))
|
||||||
|
var rot: int = int(piece.get("rot", 0))
|
||||||
var took := _until(sim, func() -> bool: return broken.has(id), 30.0)
|
var took := _until(sim, func() -> bool: return broken.has(id), 30.0)
|
||||||
var expect := ceilf(float(sim.config.gate_hp) / es.t_structure_damage[EnemySystem.TYPE_THIEF]) * es.t_hit_interval[EnemySystem.TYPE_THIEF]
|
var expect := ceilf(float(st.max_hp(type)) / es.t_structure_damage[EnemySystem.TYPE_THIEF]) * es.t_hit_interval[EnemySystem.TYPE_THIEF]
|
||||||
r.check(took < 30.0 and absf(took - expect) < es.t_hit_interval[EnemySystem.TYPE_THIEF] + 0.5,
|
r.check(took < 30.0 and absf(took - expect) < es.t_hit_interval[EnemySystem.TYPE_THIEF] + 0.5,
|
||||||
"it breaks the gate in about %.0f s (took %.1f s)" % [expect, took])
|
"it breaks the %s in about %.0f s (took %.1f s)" % [type, expect, took])
|
||||||
r.check(sim.nav.structure_at[sim.nav.cell_of(4.0, -6.0)] < 0 and sim.animals.pen_open, "the broken gate is gone from navigation: the pen is open")
|
r.check(sim.nav.structure_at[sim.nav.cell_of(at.x, at.y)] < 0 and sim.animals.pen_open, "the broken piece is gone from navigation: the pen is open")
|
||||||
var out := _until(sim, func() -> bool: return es.resolve_handle(h) == -1, 40.0)
|
var out := _until(sim, func() -> bool: return es.resolve_handle(h) == -1, 40.0)
|
||||||
r.check(out < 40.0, "then it leaves the farm through the breach (%.1f s)" % out)
|
r.check(out < 40.0, "then it leaves the farm through the breach (%.1f s)" % out)
|
||||||
r.check(st.validate("gate", 4.0, -6.0, 2, Vector2(6.0, -6.0)) == "", "a new gate can go in the pen opening")
|
await r.process_frame # the broken piece's view (fences keep real collision) is queue_free()'d, not freed outright
|
||||||
st.place("gate", 4.0, -6.0, 2)
|
var replace_why := st.validate(type, at.x, at.y, rot, PenRing.NEAR)
|
||||||
|
r.check(replace_why == "", "a replacement %s can go back in the breach (got '%s')" % [type, replace_why])
|
||||||
|
st.place(type, at.x, at.y, rot)
|
||||||
_settle(sim)
|
_settle(sim)
|
||||||
r.check(not sim.animals.pen_open, "and shuts the pen again")
|
r.check(not sim.animals.pen_open, "patching the breach shuts the pen again")
|
||||||
|
|
||||||
|
|
||||||
func _trap(r: GameTestRunner, sim: FarmSim) -> void:
|
func _trap(r: GameTestRunner, sim: FarmSim) -> void:
|
||||||
|
|
@ -269,7 +316,7 @@ func _repair_and_dismantle(r: GameTestRunner, sim: FarmSim, player: PlayerCharac
|
||||||
func _persistence(r: GameTestRunner, sim: FarmSim) -> void:
|
func _persistence(r: GameTestRunner, sim: FarmSim) -> void:
|
||||||
var c := sim.campaign
|
var c := sim.campaign
|
||||||
var st := sim.structures
|
var st := sim.structures
|
||||||
var n0 := st.count() # the pen's gate
|
var n0 := st.count() # the player-built pen ring (fences and its gate)
|
||||||
st.place("fence", 8.0, -8.0, 0)
|
st.place("fence", 8.0, -8.0, 0)
|
||||||
st.place("slowing_trap", 10.0, -12.0, 0)
|
st.place("slowing_trap", 10.0, -12.0, 0)
|
||||||
var d := c.state.to_dict()
|
var d := c.state.to_dict()
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,8 @@ func run(r: GameTestRunner) -> void:
|
||||||
player.global_position = AWAY
|
player.global_position = AWAY
|
||||||
sim.loot.loot_event.connect(func(kind: StringName, id: int, _p: Vector3) -> void: _events.append([kind, id]))
|
sim.loot.loot_event.connect(func(kind: StringName, id: int, _p: Vector3) -> void: _events.append([kind, id]))
|
||||||
sim.campaign.begin_day()
|
sim.campaign.begin_day()
|
||||||
|
PenRing.build_full(sim) # the pen is player-built now: close it the way the old starting gate did
|
||||||
|
_settle(sim)
|
||||||
_layout(r, sim)
|
_layout(r, sim)
|
||||||
_pen_by_day(r, sim)
|
_pen_by_day(r, sim)
|
||||||
_animal_theft(r, sim, player)
|
_animal_theft(r, sim, player)
|
||||||
|
|
@ -93,7 +95,11 @@ func _animal_theft(r: GameTestRunner, sim: FarmSim, player: PlayerCharacter) ->
|
||||||
var loot := sim.loot
|
var loot := sim.loot
|
||||||
var s := sim.campaign.state
|
var s := sim.campaign.state
|
||||||
var gate := 1
|
var gate := 1
|
||||||
var h := sim.spawn_thief(C.ANIMAL, GameTestRunner.EDGE["south-west"])
|
# Task #11: the pen's boundary is a full ring of equally-breakable player-built fences now, not
|
||||||
|
# a single gap in an otherwise solid wall, so a thief's nearest crossing depends on where it
|
||||||
|
# comes from. Spawn just outside the gate (not a shared GameTestRunner.EDGE point) so it's
|
||||||
|
# still the nearest barrier, keeping this test's "breaks the gate" narrative.
|
||||||
|
var h := sim.spawn_thief(C.ANIMAL, Vector2(7.0, -6.0))
|
||||||
_step(sim, 1)
|
_step(sim, 1)
|
||||||
var item := es.target[es.resolve_handle(h)]
|
var item := es.target[es.resolve_handle(h)]
|
||||||
r.check(item > 0 and loot.category[item] == C.ANIMAL, "an animal thief claims an animal")
|
r.check(item > 0 and loot.category[item] == C.ANIMAL, "an animal thief claims an animal")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue