feat: add protected tourist encounters

This commit is contained in:
goose
2026-10-04 11:48:20 -04:00
parent e8082b3ca6
commit 5ef08a6e33
14 changed files with 361 additions and 1 deletions
+65
View File
@@ -0,0 +1,65 @@
extends GutTest
const RunSettingsType = preload("res://scripts/domain/run/run_settings.gd")
const RunStateType = preload("res://scripts/domain/run/run_state.gd")
const FloorStateType = preload("res://scripts/domain/world/floor_state.gd")
const GridMapStateType = preload("res://scripts/domain/grid_map_state.gd")
const ActorStateType = preload("res://scripts/domain/actor_state.gd")
const ContentCatalogType = preload("res://scripts/domain/content/content_catalog.gd")
const TouristServiceType = preload("res://scripts/domain/world/tourist_service.gd")
const AudienceStateType = preload("res://scripts/domain/meta/audience_state.gd")
const ModerationType = preload("res://scripts/domain/meta/moderation.gd")
const FactionWarType = preload("res://scripts/domain/meta/faction_war.gd")
func test_selfie_increases_audience_without_harming_tourist_and_fires_met_once() -> void:
var run := _run_with_tourist()
var views_before := _audience(run).spectacle_score()
var events := TouristServiceType.selfie(run, &"tourist-e2e")
assert_gt(_audience(run).spectacle_score(), views_before)
assert_false(_tourist(run).metadata["ejected"])
assert_eq(_tourist(run).metadata["hidden_health"], 30)
assert_true(events.any(func(event: GameEvent) -> bool: return event.kind == &"tourist_selfie"))
var met_events := TouristServiceType.meet(run, &"tourist-e2e", 4)
assert_true(met_events.any(func(event: GameEvent) -> bool: return event.kind == &"tourist_met"))
assert_false(TouristServiceType.meet(run, &"tourist-e2e", 4).any(func(event: GameEvent) -> bool: return event.kind == &"tourist_met"))
func test_exhausting_hidden_health_ejects_without_real_kill_xp_loot_or_faction_kill() -> void:
var run := _run_with_tourist()
var tourist := _tourist(run)
var player_xp_before: int = int(run.current_floor_state().metadata["player_xp"])
var events: Array[GameEvent] = []
while not bool(tourist.metadata["ejected"]):
events.append_array(TouristServiceType.endanger(run, &"tourist-e2e", 15))
assert_true(tourist.metadata["ejected"])
assert_false(run.current_floor_state().npcs.has(&"tourist-e2e"))
assert_eq(_factions(run).kill_count(&"tourists"), 0)
assert_eq(_moderation(run).strikes(), 1)
assert_eq(run.current_floor_state().metadata["player_xp"], player_xp_before)
assert_false(events.any(func(event: GameEvent) -> bool: return event.kind in [&"actor_died", &"xp_granted", &"loot_dropped"]))
assert_eq(events.filter(func(event: GameEvent) -> bool: return event.kind == &"moderation_strike").size(), 1)
func _run_with_tourist() -> RunState:
var run := RunStateType.new("tourist-service", RunSettingsType.new("tourist-service"))
var floor := FloorStateType.new(GridMapStateType.new(Vector2i(8, 8)), 1, 6)
floor.metadata["player_xp"] = 77
var tourist := ActorStateType.new(&"tourist-e2e", Vector2i(3, 3), 1, 0, &"npc_tourist_influencer")
tourist.metadata = {"is_tourist": true, "hidden_health": 30, "ejected": false}
floor.npcs[tourist.id] = tourist
run.current_floor = 6
run.set_floor_state(floor)
run.content_catalog = ContentCatalogType.load_from_directory("res://data/ascii")
return run
func _tourist(run: RunState) -> ActorState:
return run.current_floor_state().metadata["ejected_tourists"].get(&"tourist-e2e", run.current_floor_state().npcs.get(&"tourist-e2e")) if run.current_floor_state().metadata.has("ejected_tourists") else run.current_floor_state().npcs.get(&"tourist-e2e")
func _audience(run: RunState) -> AudienceState:
return AudienceStateType.new(run.audience_state)
func _moderation(run: RunState) -> Moderation:
return ModerationType.new(run.moderation_state)
func _factions(run: RunState) -> FactionWar:
return FactionWarType.new(run.content_catalog, run.faction_war_state)
+1
View File
@@ -0,0 +1 @@
uid://u1m5nxunev2e