Files
DungeonCrawlerWorld/tests/integration/test_tourist_generation.gd
T

33 lines
1.2 KiB
GDScript

extends GutTest
const ContentCatalogType = preload("res://scripts/domain/content/content_catalog.gd")
const FloorGeneratorType = preload("res://scripts/domain/world/floor_generator.gd")
const ASCII_CATALOG_PATH := "res://data/ascii"
func test_no_tourists_before_floor_six_across_twenty_five_seeds() -> void:
for seed_index in range(25):
assert_eq(_tourists(_generate(5, "TOUR-EARLY-%d" % seed_index)).size(), 0)
func test_at_most_one_tourist_per_eligible_floor_across_thirty_seeds() -> void:
for seed_index in range(30):
assert_lte(_tourists(_generate(8, "TOUR-CAP-%d" % seed_index)).size(), 1)
func test_tourist_can_spawn_on_floor_six_across_sixty_seed_sample() -> void:
var found := false
for seed_index in range(60):
if not _tourists(_generate(6, "TOUR-SIX-%d" % seed_index)).is_empty():
found = true
break
assert_true(found)
func _generate(floor_number: int, seed: String) -> FloorState:
return FloorGeneratorType.generate(seed, floor_number, ContentCatalogType.load_from_directory(ASCII_CATALOG_PATH))
func _tourists(floor: FloorState) -> Array[ActorState]:
var tourists: Array[ActorState] = []
for npc: ActorState in floor.npcs.values():
if npc.content_id == &"npc_tourist_influencer":
tourists.append(npc)
return tourists