extends GutTest const GameScene = preload("res://scenes/Game.tscn") const RunSettingsType = preload("res://scripts/domain/run/run_settings.gd") const ItemDefinitionType = preload("res://scripts/domain/items/item_definition.gd") const ItemInstanceType = preload("res://scripts/domain/items/item_instance.gd") const PHYLACTERY_ID: StringName = &"misc_phylactere_narratif" func test_classic_death_ends_actions_shows_death_panel_and_preserves_the_run_slot() -> void: var game := await _game(false) _kill_player_through_real_enemy_turn(game) var panel := game.get_node("HUD/DeathPanel") as PanelContainer assert_true(game.get_run_state().is_game_over) assert_eq(game.get_run_state().slot_policy, &"preserve") assert_true(panel.visible) assert_string_contains((panel.get_node("Body") as RichTextLabel).get_parsed_text(), "Classique") assert_true(game.get_run_state().recent_events(game.get_run_state().log.size()).any(func(event: GameEvent) -> bool: return event.kind == &"run_ended")) assert_eq(game.submit_test_action(Vector2i.RIGHT), []) func test_permadeath_death_retires_the_run_slot_and_reports_the_mode() -> void: var game := await _game(true) _kill_player_through_real_enemy_turn(game) var panel := game.get_node("HUD/DeathPanel") as PanelContainer assert_true(game.get_run_state().is_game_over) assert_eq(game.get_run_state().slot_policy, &"retire") assert_true(panel.visible) assert_string_contains((panel.get_node("Body") as RichTextLabel).get_parsed_text(), "permanente") assert_true(game.get_run_state().recent_events(game.get_run_state().log.size()).any(func(event: GameEvent) -> bool: return event.kind == &"permadeath_run_retired")) func test_qualified_narrative_resurrection_continues_the_real_game_without_showing_death_panel() -> void: var game := await _game(true) var state := game.get_game_state() game.get_run_state().inventory.add_item(ItemInstanceType.new(ItemDefinitionType.from_catalog(game.spell_catalog, PHYLACTERY_ID))) var end_before := game.get_dialogue_player().attributes.get_attribute(&"end") _kill_player_through_real_enemy_turn(game) var panel := game.get_node("HUD/DeathPanel") as PanelContainer assert_false(game.get_run_state().is_game_over) assert_eq(game.get_run_state().slot_policy, &"active") assert_false(panel.visible) assert_eq(state.player.hit_points, maxi(1, int(state.player.max_hit_points * 0.25))) assert_eq(game.get_dialogue_player().attributes.get_attribute(&"end"), end_before - 1) assert_true(game.get_dialogue_player().flags.get(&"marked_by_death", false)) assert_false(game.get_run_state().inventory.items.any(func(item: ItemInstance) -> bool: return item.definition.id == PHYLACTERY_ID)) assert_true(game.get_run_state().recent_events(game.get_run_state().log.size()).any(func(event: GameEvent) -> bool: return event.kind == &"narrative_resurrection")) func _kill_player_through_real_enemy_turn(game: Game) -> void: var state := game.get_game_state() var enemy: ActorState = state.enemies[&"goblin"] enemy.cell = state.player.cell + Vector2i.RIGHT enemy.weapon_damage = state.player.hit_points enemy.damage_variance = 0 enemy.accuracy = 30 game.submit_test_interact() func _game(permadeath: bool) -> Game: var game := GameScene.instantiate() as Game game.configure_new_run(RunSettingsType.new("F6-E2E", &"crawler", permadeath), "F6 Hero", &"vanguard") add_child_autofree(game) await get_tree().process_frame return game