fix: enforce village resource invariants

This commit is contained in:
Rijad Zuzo
2026-07-09 23:10:18 +02:00
parent d6520c426a
commit 5cbab527bf
9 changed files with 136 additions and 42 deletions
@@ -16,6 +16,7 @@ const DINNER_BEGIN := 0.7
const DINNER_END := 0.8
const WORK_BEGIN := 0.28
const WORK_END := 0.85
const UNAVAILABLE_ACTION_SCORE := -1000000.0
func select_action(npc: SimNPC, village: SimVillage, time_of_day: float = 0.5, all_npcs: Array = []) -> ActionSelectionResult:
@@ -181,6 +182,9 @@ func _choose_best_work_action(npc: SimNPC, village: SimVillage, all_npcs: Array)
0.75
)
}
if village.wood < 1.0:
scores[SimulationIds.ACTION_PATROL] = UNAVAILABLE_ACTION_SCORE
scores[SimulationIds.ACTION_STUDY] = UNAVAILABLE_ACTION_SCORE
for familiar_id in npc.familiarity:
if not familiar_id is int:
continue