feat(items): add RoomChest with spawn and receive logic

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Steven Wroblewski
2026-05-09 01:04:34 +02:00
parent 4e4743f14f
commit b9c73b80ea
3 changed files with 143 additions and 0 deletions
+48
View File
@@ -35,3 +35,51 @@ func test_room_chest_config_patient_cabinet_stethoscope_outfit_layer_two() -> vo
assert_eq(stethoscope.item_id, "stethoscope")
assert_eq(stethoscope.item_type, ChestItemData.ItemType.OUTFIT)
assert_eq(stethoscope.outfit_layer, 2)
func test_are_items_spawned_false_initially() -> void:
var chest: RoomChest = RoomChest.new()
chest.chest_id = "reception_desk"
add_child_autofree(chest)
assert_false(chest.are_items_spawned())
func test_get_spawned_count_zero_initially() -> void:
var chest: RoomChest = RoomChest.new()
chest.chest_id = "reception_desk"
add_child_autofree(chest)
assert_eq(chest.get_spawned_count(), 0)
func test_get_item_config_count_matches_config() -> void:
var chest: RoomChest = RoomChest.new()
chest.chest_id = "reception_desk"
add_child_autofree(chest)
assert_eq(chest.get_item_config_count(), 3)
func test_spawn_items_creates_correct_count() -> void:
var chest: RoomChest = RoomChest.new()
chest.chest_id = "reception_desk"
add_child_autofree(chest)
chest.spawn_items()
assert_eq(chest.get_spawned_count(), 3)
func test_double_spawn_is_noop() -> void:
var chest: RoomChest = RoomChest.new()
chest.chest_id = "reception_desk"
add_child_autofree(chest)
chest.spawn_items()
chest.spawn_items()
assert_eq(chest.get_spawned_count(), 3)
func test_receive_item_decrements_spawned_count() -> void:
var chest: RoomChest = RoomChest.new()
chest.chest_id = "reception_desk"
add_child_autofree(chest)
chest.spawn_items()
var item: HoldableItem = chest._spawned_items[0] as HoldableItem
chest.receive_item(item)
assert_eq(chest.get_spawned_count(), 2)