feat: make pantry crises visible in the world

This commit is contained in:
Rijad Zuzo
2026-07-14 23:54:22 +02:00
parent c722e32a88
commit c23f6887c8
21 changed files with 800 additions and 73 deletions
+52
View File
@@ -124,6 +124,19 @@ func _run() -> void:
main_scene.get_node("UI/VillagePanel/MarginContainer/VillageStatsLabel") as Label
)
var pantry_state: StorageStateRecord = simulation_manager.get_pantry()
var pantry_visual := (
main_scene.get_node("JajceWorld/WorldObjects/StorageSites/VillagePantry/PantryPresentation")
as PantryStockVisual
)
_check(
(
pantry_visual.get_stock_level() == PantryStockVisual.StockLevel.STOCKED
and pantry_visual.get_node("LowStock").visible
and pantry_visual.get_node("FullStock").visible
and not pantry_visual.get_node("EmptyStock").visible
),
"A stocked authoritative pantry should show its physical sacks and berry baskets"
)
contributor.hunger = 85.0
var withdrawn_for_need: float = simulation_manager.economy.withdraw_to_inventory(
contributor,
@@ -133,6 +146,18 @@ func _run() -> void:
_check(withdrawn_for_need > 0.0, "Runtime opportunity setup should empty the real pantry")
var opportunity: OpportunityStateRecord = simulation_manager.get_active_opportunity()
_check(opportunity != null, "Emptying the pantry should open one known shortage need")
if pantry_visual.transition_tween != null:
await pantry_visual.transition_tween.finished
_check(
(
pantry_visual.get_stock_level() == PantryStockVisual.StockLevel.EMPTY
and pantry_visual.get_node("EmptyStock").visible
and not pantry_visual.get_node("LowStock").visible
and contributor_visual.get_node("OpportunityConcernRoot").visible
and not listener_visual.get_node("OpportunityConcernRoot").visible
),
"The real shortage should empty the pantry prop and concern only its interested villager"
)
_check(
(
"Village need" in village_stats_label.text
@@ -169,6 +194,14 @@ func _run() -> void:
),
"Opportunity presentation should resolve from a real pantry deposit"
)
_check(
(
pantry_visual.get_stock_level() == PantryStockVisual.StockLevel.STOCKED
and pantry_visual.get_node("RefillResponse").visible
and not contributor_visual.get_node("OpportunityConcernRoot").visible
),
"Real supply should restore visible stock, play one refill response, and clear concern"
)
_check(
"Village need" not in village_stats_label.text,
"Resolved opportunities should leave the compact village summary"
@@ -198,6 +231,25 @@ func _run() -> void:
_check(player_need_withdrawal > 0.0, "Player resolution setup should reopen a real need")
var player_opportunity: OpportunityStateRecord = simulation_manager.get_active_opportunity()
_check(player_opportunity != null, "A later shortage should open a new opportunity record")
var active_need_json: String = simulation_manager.serialize_state()
var old_contributor_visual := contributor_visual
_check(
simulation_manager.restore_state_from_json(active_need_json),
"The visible shortage should survive a valid schema-v8 restore"
)
await process_frame
contributor_visual = world_view.active_npc_visuals[contributor.id]
player_opportunity = simulation_manager.get_active_opportunity()
_check(
(
contributor_visual != old_contributor_visual
and contributor_visual.get_node("OpportunityConcernRoot").visible
and pantry_visual.get_stock_level() == PantryStockVisual.StockLevel.EMPTY
and pantry_visual.get_node("EmptyStock").visible
and not pantry_visual.get_node("RefillResponse").visible
),
"Restoration should rebuild concern and empty stock without replaying the refill response"
)
var player := main_scene.get_node("Player") as Node3D
var opportunity_bush := (
main_scene.get_node("JajceWorld/WorldObjects/ResourceNodes/BerryBush_01") as ResourceNode