feat: let the player live as a citizen with needs and carried inventory

This commit is contained in:
Rijad Zuzo
2026-08-11 00:18:39 +02:00
parent f72aa659d2
commit 37f262fb84
20 changed files with 746 additions and 90 deletions
+31 -4
View File
@@ -38,20 +38,32 @@ func _run() -> void:
)
_check(
is_equal_approx(manager.harvest_resource_node(berry), 1.0),
"Player harvesting should supply the real pantry"
"Player harvesting should carry the real finite yield"
)
var carried_food: float = manager.get_player_state().get_inventory_amount(
SimulationIds.RESOURCE_FOOD
)
_check(
is_equal_approx(carried_food, 1.0),
"Player harvesting should move the yield into carried player inventory"
)
_check(
is_equal_approx(manager.deposit_player_inventory(SimulationIds.RESOURCE_FOOD), 1.0),
"Player deposit should supply the real pantry"
)
var supply_event := _latest_event_of_type(manager, SimulationIds.EVENT_RESOURCE_EXTRACTED)
var supply_event := _latest_event_of_type(manager, SimulationIds.EVENT_STORAGE_DEPOSITED)
var supply_event_id := int(supply_event.data["event_id"])
_check(
(
int(supply_event.data["actor_id"]) == SimulationIds.PLAYER_ACTOR_ID
and (StringName(supply_event.data["source_id"]) == SimulationIds.PLAYER_INVENTORY_ID)
and (
StringName(supply_event.data["destination_id"])
== SimulationIds.STORAGE_VILLAGE_PANTRY
)
),
"The player supply should be recorded as a pantry food extraction by the player actor"
"The player supply should be recorded as a pantry food deposit from player inventory"
)
_check(
(
@@ -102,6 +114,7 @@ func _run() -> void:
)
restored.free()
var v12_data: Dictionary = manager.create_state_record().to_dictionary()
berry.queue_free()
manager.free()
@@ -113,7 +126,21 @@ func _run() -> void:
and migrated.simulation.get("next_opportunity_id", -1) >= 0
and not migrated.opportunities.is_empty()
),
"World schema v11 should migrate to v12 without dropping opportunity history"
"World schema v11 should migrate to v13 without dropping opportunity history"
)
v12_data["schema_version"] = SimulationStateRecord.PLAYER_NEEDS_SCHEMA_VERSION
v12_data.erase("player")
var v12_migrated := SimulationStateRecord.from_dictionary(v12_data)
_check(
(
v12_migrated != null
and v12_migrated.player != null
and is_equal_approx(v12_migrated.player.get_hunger(), 40.0)
and is_equal_approx(v12_migrated.player.get_energy(), 100.0)
and v12_migrated.player.get_carried_total() == 0.0
),
"World schema v12 should migrate to v13 with a fresh default player record"
)
_finish()