feat: let the player live as a citizen with needs and carried inventory
This commit is contained in:
@@ -19,11 +19,9 @@ func _run() -> void:
|
||||
var bush := (
|
||||
main_scene.get_node("JajceWorld/WorldObjects/ResourceNodes/BerryBush_01") as ResourceNode
|
||||
)
|
||||
var tree := main_scene.get_node("JajceWorld/WorldObjects/ResourceNodes/Tree_01") as ResourceNode
|
||||
simulation_manager.set_process(false)
|
||||
|
||||
var bush_state: ResourceStateRecord = simulation_manager.get_resource_state(bush.node_id)
|
||||
var tree_state: ResourceStateRecord = simulation_manager.get_resource_state(tree.node_id)
|
||||
bush_state.set_amount_remaining(1.0)
|
||||
_check(
|
||||
simulation_manager.reserve_resource(bush.node_id, 999),
|
||||
@@ -38,8 +36,11 @@ func _run() -> void:
|
||||
"Player should deplete the nearby bush"
|
||||
)
|
||||
_check(
|
||||
is_equal_approx(simulation_manager.village.food, food_before + 1.0),
|
||||
"Village should receive exactly the bush's remaining food"
|
||||
is_equal_approx(
|
||||
simulation_manager.get_player_state().get_inventory_amount(SimulationIds.RESOURCE_FOOD),
|
||||
1.0
|
||||
),
|
||||
"Player harvesting should carry exactly the bush's remaining food"
|
||||
)
|
||||
_check(bush_state.get_reserved_by() == -1, "Depletion should release the NPC reservation")
|
||||
var player_extraction: EconomicEventRecord
|
||||
@@ -56,8 +57,14 @@ func _run() -> void:
|
||||
_check(player_depletion != null, "Player depletion should create a structured event")
|
||||
if player_extraction != null:
|
||||
_check(
|
||||
player_extraction.get_world_position().is_equal_approx(bush_event_position),
|
||||
"Player extraction should preserve the resource interaction position"
|
||||
(
|
||||
player_extraction.get_world_position().is_equal_approx(bush_event_position)
|
||||
and (
|
||||
StringName(player_extraction.data["destination_id"])
|
||||
== SimulationIds.PLAYER_INVENTORY_ID
|
||||
)
|
||||
),
|
||||
"Player extraction should preserve the interaction position and name the carried inventory"
|
||||
)
|
||||
if player_depletion != null:
|
||||
_check(
|
||||
@@ -65,45 +72,54 @@ 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()
|
||||
pantry_state.deposit(SimulationIds.RESOURCE_FOOD, pantry_state.get_available_capacity() - 0.5)
|
||||
player.global_position = pantry.get_interaction_position()
|
||||
player.try_interact()
|
||||
_check(
|
||||
(
|
||||
is_equal_approx(simulation_manager.village.food, food_before + 1.0)
|
||||
and is_equal_approx(
|
||||
simulation_manager.get_player_state().get_inventory_amount(
|
||||
SimulationIds.RESOURCE_FOOD
|
||||
),
|
||||
0.0
|
||||
)
|
||||
),
|
||||
"Depositing at the pantry should move carried food into the village and empty the player"
|
||||
)
|
||||
|
||||
var pantry_food_before := pantry_state.get_amount(SimulationIds.RESOURCE_FOOD)
|
||||
player.try_interact()
|
||||
_check(
|
||||
(
|
||||
pantry_state.get_amount(SimulationIds.RESOURCE_FOOD) < pantry_food_before
|
||||
and simulation_manager.get_player_state().get_hunger() < 40.0
|
||||
),
|
||||
"Player should eat from the typed pantry StorageNode and ease their hunger"
|
||||
)
|
||||
|
||||
pantry_state.deposit(SimulationIds.RESOURCE_FOOD, pantry_state.get_available_capacity())
|
||||
simulation_manager.economy.sync_resource(SimulationIds.RESOURCE_FOOD)
|
||||
bush_state.set_amount_remaining(1.0)
|
||||
player.global_position = bush.interaction_point.global_position
|
||||
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)
|
||||
),
|
||||
"Player harvesting should leave overflow at its source when storage fills"
|
||||
)
|
||||
|
||||
pantry_state.deposit(SimulationIds.RESOURCE_FOOD, 3.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()
|
||||
_check(
|
||||
pantry_state.get_amount(SimulationIds.RESOURCE_FOOD) < pantry_food_before,
|
||||
"Player should eat from the typed pantry StorageNode"
|
||||
(
|
||||
is_equal_approx(bush_state.get_amount_remaining(), 0.0)
|
||||
and is_equal_approx(pantry_state.get_available_capacity(), 0.0)
|
||||
and is_equal_approx(
|
||||
simulation_manager.get_player_state().get_inventory_amount(
|
||||
SimulationIds.RESOURCE_FOOD
|
||||
),
|
||||
1.0
|
||||
)
|
||||
),
|
||||
"Player harvesting into a full pantry should leave the unaccepted overflow carried"
|
||||
)
|
||||
var guard_site := (
|
||||
main_scene.get_node("JajceWorld/WorldObjects/ActivitySites/GuardPost") as ActivitySite
|
||||
|
||||
Reference in New Issue
Block a user