feat: give the player a real carried inventory and deposit transactions

This commit is contained in:
2026-08-08 23:59:19 +02:00
parent 9678526c5a
commit 5e6c963d23
12 changed files with 565 additions and 65 deletions
+66 -23
View File
@@ -35,11 +35,17 @@ func _run() -> void:
_check(
is_equal_approx(bush_state.get_amount_remaining(), 0.0),
"Player should deplete the nearby bush"
"Player should deplete the nearby bush into their hands"
)
var carried_after_gather: float = simulation_manager.get_player_state().get_inventory_amount(
SimulationIds.RESOURCE_FOOD
)
_check(
is_equal_approx(simulation_manager.village.food, food_before + 1.0),
"Village should receive exactly the bush's remaining food"
(
is_equal_approx(carried_after_gather, 1.0)
and is_equal_approx(simulation_manager.village.food, food_before)
),
"Gathering should fill the player's hands without bypassing the village store",
)
_check(bush_state.get_reserved_by() == -1, "Depletion should release the NPC reservation")
var player_extraction: EconomicEventRecord
@@ -65,24 +71,41 @@ func _run() -> void:
"Player depletion should preserve the resource interaction position"
)
player.global_position = tree.interaction_point.global_position
var wood_before: float = simulation_manager.village.wood
var tree_before := tree_state.get_amount_remaining()
player.try_interact()
_check(
is_equal_approx(tree_state.get_amount_remaining(), tree_before - tree.yield_per_action),
"Player should extract the tree's configured yield"
)
_check(
is_equal_approx(simulation_manager.village.wood, wood_before + tree.yield_per_action),
"Village should receive exactly the extracted wood"
)
var pantry := (
main_scene.get_node("JajceWorld/WorldObjects/StorageSites/VillagePantry") as StorageNode
)
var pantry_state: StorageStateRecord = simulation_manager.get_pantry()
player.global_position = pantry.get_interaction_position()
player.try_interact()
var food_after_deposit: float = simulation_manager.village.food
_check(
(
is_equal_approx(food_after_deposit, food_before + 1.0)
and is_equal_approx(
simulation_manager.get_player_state().get_inventory_amount(
SimulationIds.RESOURCE_FOOD
),
0.0
)
),
"Depositing at the typed pantry should deliver the carried food to the village",
)
player.global_position = tree.interaction_point.global_position
var wood_before: float = simulation_manager.village.wood
var tree_before := tree_state.get_amount_remaining()
player.try_interact()
var carried_wood: float = simulation_manager.get_player_state().get_inventory_amount(
SimulationIds.RESOURCE_WOOD
)
_check(
(
is_equal_approx(tree_state.get_amount_remaining(), tree_before - tree.yield_per_action)
and is_equal_approx(carried_wood, tree.yield_per_action)
),
"Player should extract the tree's configured yield into their hands",
)
pantry_state.deposit(SimulationIds.RESOURCE_FOOD, pantry_state.get_available_capacity() - 0.5)
simulation_manager.economy.sync_resource(SimulationIds.RESOURCE_FOOD)
bush_state.set_amount_remaining(1.0)
@@ -90,20 +113,40 @@ func _run() -> void:
player.try_interact()
_check(
(
is_equal_approx(bush_state.get_amount_remaining(), 0.5)
and is_equal_approx(pantry_state.get_available_capacity(), 0.0)
is_equal_approx(bush_state.get_amount_remaining(), 0.0)
and is_equal_approx(
simulation_manager.get_player_state().get_inventory_amount(
SimulationIds.RESOURCE_FOOD
),
1.0
)
),
"Player harvesting should leave overflow at its source when storage fills"
"Player gathering should still extract into their hands regardless of storage capacity",
)
pantry_state.deposit(SimulationIds.RESOURCE_FOOD, 3.0)
pantry_state.withdraw(
SimulationIds.RESOURCE_FOOD, pantry_state.get_amount(SimulationIds.RESOURCE_FOOD)
)
pantry_state.deposit(SimulationIds.RESOURCE_FOOD, 5.0)
simulation_manager.economy.sync_resource(SimulationIds.RESOURCE_FOOD)
var pantry_food_before := pantry_state.get_amount(SimulationIds.RESOURCE_FOOD)
player.global_position = pantry.get_interaction_position()
player.try_interact()
var food_after_first_deposit := pantry_state.get_amount(SimulationIds.RESOURCE_FOOD)
var food_carried_after_first: float = (
simulation_manager.get_player_state().get_inventory_amount(SimulationIds.RESOURCE_FOOD)
)
_check(
pantry_state.get_amount(SimulationIds.RESOURCE_FOOD) < pantry_food_before,
"Player should eat from the typed pantry StorageNode"
(
food_after_first_deposit > pantry_food_before
and is_equal_approx(food_carried_after_first, 0.0)
),
"Player should deposit carried food at the typed pantry",
)
player.try_interact()
_check(
pantry_state.get_amount(SimulationIds.RESOURCE_FOOD) < food_after_first_deposit,
"Player should eat from the pantry once their hands are empty",
)
var guard_site := (
main_scene.get_node("JajceWorld/WorldObjects/ActivitySites/GuardPost") as ActivitySite