chore: install gut quality suite
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
extends GutTest
|
||||
|
||||
const SimulationEventLogScript := preload("res://simulation/events/SimulationEventLog.gd")
|
||||
const VillageEconomyScript := preload("res://simulation/economy/VillageEconomy.gd")
|
||||
|
||||
|
||||
func test_storage_never_accepts_more_than_its_capacity() -> void:
|
||||
var storage := StorageStateRecord.create(&"test_storage", {"food": 4.5}, 5.0)
|
||||
|
||||
assert_eq(storage.deposit(SimulationIds.RESOURCE_FOOD, 2.0), 0.5)
|
||||
assert_eq(storage.get_amount(SimulationIds.RESOURCE_FOOD), 5.0)
|
||||
assert_eq(storage.get_available_capacity(), 0.0)
|
||||
|
||||
|
||||
func test_economy_moves_inventory_into_authoritative_storage() -> void:
|
||||
var village := SimVillage.new()
|
||||
village.food = 3.0
|
||||
var economy := VillageEconomyScript.new()
|
||||
economy.configure(village, false)
|
||||
economy.initialize_storage()
|
||||
var npc := SimNPC.new(7, "Tester", SimulationIds.PROFESSION_FARMER, 5.0, 5.0)
|
||||
npc.add_inventory(SimulationIds.RESOURCE_FOOD, 2.0)
|
||||
|
||||
assert_eq(economy.deposit_inventory(npc, SimulationIds.RESOURCE_FOOD), 2.0)
|
||||
assert_eq(npc.get_inventory_amount(SimulationIds.RESOURCE_FOOD), 0.0)
|
||||
assert_eq(economy.get_pantry().get_amount(SimulationIds.RESOURCE_FOOD), 5.0)
|
||||
assert_eq(village.food, 5.0)
|
||||
|
||||
|
||||
func test_event_log_preserves_order_and_derives_consumption_rate() -> void:
|
||||
var event_log := SimulationEventLogScript.new()
|
||||
event_log.record_narrative(10, SimulationIds.EVENT_TASK_STARTED, 4, &"", "Study")
|
||||
event_log.record_economic(
|
||||
20,
|
||||
SimulationIds.EVENT_ITEM_CONSUMED,
|
||||
4,
|
||||
SimulationIds.STORAGE_VILLAGE_PANTRY,
|
||||
&"consumed",
|
||||
SimulationIds.RESOURCE_FOOD,
|
||||
1.0
|
||||
)
|
||||
|
||||
assert_eq(event_log.events.size(), 2)
|
||||
assert_eq(int(event_log.events[0].data["event_id"]), 0)
|
||||
assert_eq(int(event_log.events[1].data["event_id"]), 1)
|
||||
assert_eq(event_log.get_for_actor(4).size(), 2)
|
||||
assert_eq(float(event_log.get_consumption_rates(200)["food_per_day"]), 1.0)
|
||||
Reference in New Issue
Block a user