feat: let trusted villagers ask the player directly as standing grows
This commit is contained in:
@@ -0,0 +1,70 @@
|
||||
extends GutTest
|
||||
|
||||
const PlayerQuestSystemScript := preload("res://simulation/quests/PlayerQuestSystem.gd")
|
||||
|
||||
|
||||
func test_personal_request_needs_standing_tier_and_gratitude() -> void:
|
||||
var system := PlayerQuestSystemScript.new()
|
||||
var opportunity := _open_opportunity()
|
||||
var pantry := _pantry()
|
||||
|
||||
assert_false(system.can_request_personally(opportunity))
|
||||
for _grant in 6:
|
||||
system.standing.grant_standing(3.0, opportunity.get_interested_npc_id())
|
||||
assert_true(
|
||||
system.can_request_personally(opportunity),
|
||||
"Known Hand standing plus personal gratitude should make the NPC ask you directly"
|
||||
)
|
||||
var quest := system.consider_opportunity_opened(opportunity, null, 10, true)
|
||||
assert_not_null(quest)
|
||||
assert_eq(quest.get_requester_npc_id(), opportunity.get_interested_npc_id())
|
||||
|
||||
|
||||
func test_no_personal_request_below_trust_threshold() -> void:
|
||||
var system := PlayerQuestSystemScript.new()
|
||||
var opportunity := _open_opportunity()
|
||||
system.standing.grant_standing(16.0, opportunity.get_interested_npc_id())
|
||||
system.standing.data["gratitude"][opportunity.get_interested_npc_id()] = 0.4
|
||||
|
||||
assert_false(system.can_request_personally(opportunity))
|
||||
|
||||
|
||||
func test_standing_tier_progression() -> void:
|
||||
var standing := PlayerStandingRecord.create()
|
||||
assert_eq(standing.get_tier(), PlayerStandingRecord.TIER_STRANGER)
|
||||
standing.grant_standing(14.0, 3)
|
||||
assert_eq(standing.get_tier(), PlayerStandingRecord.TIER_STRANGER)
|
||||
standing.grant_standing(2.0, 3)
|
||||
assert_eq(standing.get_tier(), PlayerStandingRecord.TIER_KNOWN_HAND)
|
||||
assert_eq(standing.get_tier_name(), "Known Hand")
|
||||
standing.grant_standing(20.0, 3)
|
||||
assert_eq(standing.get_tier(), PlayerStandingRecord.TIER_TRUSTED)
|
||||
|
||||
|
||||
func test_standing_serialization_round_trip() -> void:
|
||||
var standing := PlayerStandingRecord.create()
|
||||
standing.grant_standing(35.0, 3)
|
||||
var restored := PlayerStandingRecord.from_dictionary(standing.to_dictionary())
|
||||
assert_not_null(restored)
|
||||
assert_eq(restored.get_standing(), 35.0)
|
||||
assert_eq(restored.get_tier(), PlayerStandingRecord.TIER_TRUSTED)
|
||||
assert_eq(restored.get_gratitude(3), 0.1)
|
||||
|
||||
|
||||
func _open_opportunity() -> OpportunityStateRecord:
|
||||
return OpportunityStateRecord.create(
|
||||
0,
|
||||
10,
|
||||
5,
|
||||
3,
|
||||
1.0,
|
||||
SimulationIds.OPPORTUNITY_RESTOCK_EMPTY_PANTRY,
|
||||
SimulationIds.STORAGE_VILLAGE_PANTRY,
|
||||
SimulationIds.RESOURCE_FOOD
|
||||
)
|
||||
|
||||
|
||||
func _pantry() -> StorageStateRecord:
|
||||
return StorageStateRecord.create(
|
||||
SimulationIds.STORAGE_VILLAGE_PANTRY, {SimulationIds.RESOURCE_FOOD: 0.0}, 100.0
|
||||
)
|
||||
@@ -0,0 +1 @@
|
||||
uid://b2jmmtiyvaqll
|
||||
Reference in New Issue
Block a user