feat(items): add ChestItemData resource and RoomChestConfig static config

TDD: 4 tests written first (FAIL), then implemented — all 151 tests pass.
This commit is contained in:
Steven Wroblewski
2026-05-09 00:58:32 +02:00
parent 9786cf5895
commit b97b110876
3 changed files with 129 additions and 0 deletions
+7
View File
@@ -0,0 +1,7 @@
## ChestItemData — configuration for a single item slot inside a RoomChest.
class_name ChestItemData extends Resource
@export var item_id: String = ""
@export var item_type: String = "holdable"
@export var outfit_layer: int = 1
@export var spawn_offset: Vector2 = Vector2.ZERO
+100
View File
@@ -0,0 +1,100 @@
## RoomChestConfig — static item configuration for all room chests.
## Maps chest_id strings to ChestItemData arrays. No assets needed: item_id strings only.
class_name RoomChestConfig
static func get_items(chest_id: String) -> Array[ChestItemData]:
match chest_id:
"reception_desk":
return _make([
["clipboard", "holdable", 1, Vector2(-70.0, -60.0)],
["pen", "holdable", 1, Vector2(0.0, -80.0)],
["bandage", "holdable", 1, Vector2(70.0, -60.0)],
])
"giftshop_shelf":
return _make([
["gift_box", "holdable", 1, Vector2(-70.0, -60.0)],
["ribbon", "holdable", 1, Vector2(0.0, -80.0)],
["balloon", "holdable", 1, Vector2(70.0, -60.0)],
])
"restaurant_counter":
return _make([
["teacup", "holdable", 1, Vector2(-70.0, -60.0)],
["plate", "holdable", 1, Vector2(0.0, -80.0)],
["spoon", "holdable", 1, Vector2(70.0, -60.0)],
])
"emergency_cabinet":
return _make([
["bandage_roll", "holdable", 1, Vector2(-70.0, -60.0)],
["syringe", "holdable", 1, Vector2(0.0, -80.0)],
["ice_pack", "holdable", 1, Vector2(70.0, -60.0)],
])
"xray_cabinet":
return _make([
["xray_sheet", "holdable", 1, Vector2(-70.0, -60.0)],
["lead_apron", "outfit", 1, Vector2(0.0, -80.0)],
["marker", "holdable", 1, Vector2(70.0, -60.0)],
])
"pharmacy_medicine":
return _make([
["pill_bottle", "holdable", 1, Vector2(-50.0, -60.0)],
["syrup", "holdable", 1, Vector2(50.0, -60.0)],
])
"pharmacy_tools":
return _make([
["mortar", "holdable", 1, Vector2(-50.0, -60.0)],
["spatula", "holdable", 1, Vector2(50.0, -60.0)],
])
"lab_bench":
return _make([
["test_tube", "holdable", 1, Vector2(-70.0, -60.0)],
["pipette", "holdable", 1, Vector2(0.0, -80.0)],
["microscope_slide", "holdable", 1, Vector2(70.0, -60.0)],
])
"patient_cabinet":
return _make([
["thermometer", "holdable", 1, Vector2(-70.0, -60.0)],
["stethoscope", "outfit", 2, Vector2(0.0, -80.0)],
["pillow", "holdable", 1, Vector2(70.0, -60.0)],
])
"ultrasound_cart":
return _make([
["gel_tube", "holdable", 1, Vector2(-70.0, -60.0)],
["probe", "holdable", 1, Vector2(0.0, -80.0)],
["towel", "holdable", 1, Vector2(70.0, -60.0)],
])
"delivery_cabinet":
return _make([
["swaddle", "outfit", 1, Vector2(-70.0, -60.0)],
["scissors", "holdable", 1, Vector2(0.0, -80.0)],
["cord_clamp", "holdable", 1, Vector2(70.0, -60.0)],
])
"nursery_shelf":
return _make([
["bottle", "holdable", 1, Vector2(-70.0, -60.0)],
["rattle", "holdable", 1, Vector2(0.0, -80.0)],
["blanket", "outfit", 1, Vector2(70.0, -60.0)],
])
"garden_table":
return _make([
["teapot", "holdable", 1, Vector2(-50.0, -60.0)],
["cake", "holdable", 1, Vector2(50.0, -60.0)],
])
"garden_storage":
return _make([
["confetti", "holdable", 1, Vector2(-50.0, -60.0)],
["party_hat", "outfit", 1, Vector2(50.0, -60.0)],
])
return []
static func _make(data: Array) -> Array[ChestItemData]:
var result: Array[ChestItemData] = []
for entry: Array in data:
var d: ChestItemData = ChestItemData.new()
d.item_id = entry[0]
d.item_type = entry[1]
d.outfit_layer = entry[2]
d.spawn_offset = entry[3]
result.append(d)
return result
+22
View File
@@ -0,0 +1,22 @@
## Tests for ChestItemData resource and RoomChestConfig static config.
extends GutTest
func test_chest_item_data_default_item_type_is_holdable() -> void:
var d: ChestItemData = ChestItemData.new()
assert_eq(d.item_type, "holdable")
func test_chest_item_data_default_outfit_layer_is_one() -> void:
var d: ChestItemData = ChestItemData.new()
assert_eq(d.outfit_layer, 1)
func test_room_chest_config_reception_desk_has_three_items() -> void:
var items: Array[ChestItemData] = RoomChestConfig.get_items("reception_desk")
assert_eq(items.size(), 3)
func test_room_chest_config_unknown_id_returns_empty() -> void:
var items: Array[ChestItemData] = RoomChestConfig.get_items("does_not_exist")
assert_eq(items.size(), 0)