35 lines
1.8 KiB
GDScript
35 lines
1.8 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 RunSettingsType = preload("res://scripts/domain/run/run_settings.gd")
|
|
const RunStateType = preload("res://scripts/domain/run/run_state.gd")
|
|
const SafeRoomServiceType = preload("res://scripts/domain/world/safe_room_service.gd")
|
|
|
|
const ASCII_CATALOG_PATH := "res://data/ascii"
|
|
|
|
func test_safe_room_contract_accepts_a_generated_non_surface_floor() -> void:
|
|
var catalog := ContentCatalogType.load_from_directory(ASCII_CATALOG_PATH)
|
|
var floor := FloorGeneratorType.generate("SAFE-SERVICE", 4, catalog)
|
|
|
|
assert_eq(Array(SafeRoomServiceType.validate_floor(floor)), [])
|
|
assert_gt(floor.safe_rooms().size(), 0)
|
|
for room: RoomState in floor.safe_rooms():
|
|
assert_true(SafeRoomServiceType.is_safe_room(room))
|
|
assert_true(SafeRoomServiceType.can_rest(floor, room.bounds.get_center()))
|
|
|
|
func test_bobka_ration_is_repeatable_and_free() -> void:
|
|
var catalog := ContentCatalogType.load_from_directory(ASCII_CATALOG_PATH)
|
|
var run := RunStateType.new("SAFE-RATION", RunSettingsType.new("SAFE-RATION"))
|
|
run.content_catalog = catalog
|
|
run.gold = 47
|
|
var gold_before := run.gold
|
|
|
|
var first: Array[GameEvent] = SafeRoomServiceType.give_bobka_ration(run, &"npc_bobka_00")
|
|
var second: Array[GameEvent] = SafeRoomServiceType.give_bobka_ration(run, &"npc_bobka_00")
|
|
|
|
assert_eq(run.inventory.count_by_definition(&"consumable_ration"), 2)
|
|
assert_eq(run.gold, gold_before)
|
|
assert_eq(first.map(func(event: GameEvent) -> StringName: return event.kind), [&"item_granted", &"bobka_ration_given"])
|
|
assert_eq(second.map(func(event: GameEvent) -> StringName: return event.kind), [&"item_granted", &"bobka_ration_given"])
|