extends Node const DATA := preload("res://scripts/planets/alien_research.gd") func _ready() -> void: GameState.start_new_run() var progress: Resource = GameState.captain.expedition progress.analysis_samples = 100 assert(not DATA.purchase(progress, "hull")) assert(DATA.purchase(progress, "general")) assert(progress.analysis_samples == 90) assert(not DATA.purchase(progress, "general")) assert(DATA.purchase(progress, "hull")) assert(progress.analysis_samples == 75) assert(not DATA.purchase(progress, "hull_a")) assert(progress.analysis_samples == 75) assert(is_equal_approx(DATA.bonus(progress, "hull"), 0.1)) progress.alien_skills["hull_a"] = true assert(is_equal_approx(DATA.bonus(progress, "hull"), 0.1)) assert(DATA.learned_count(progress) == 2) progress.analysis_samples = 0 assert(not DATA.purchase(progress, "hull_b")) progress.analysis_samples = 76 assert(ResourceSaver.save(progress, "res://tmp/research_roundtrip.tres") == OK) var restored: Resource = ResourceLoader.load("res://tmp/research_roundtrip.tres", "", ResourceLoader.CACHE_MODE_IGNORE) assert(restored.alien_skills == progress.alien_skills and restored.analysis_samples == 76) DirAccess.remove_absolute("res://tmp/research_roundtrip.tres") var enemy := preload("res://scenes/game/enemy_ship.tscn").instantiate() add_child(enemy) enemy.set_process(false) enemy.set_physics_process(false) enemy.absorption = Vector3.ZERO enemy.shields = 5 enemy.hull = 100 enemy.take_weapon_hit(10, false) assert(is_equal_approx(enemy.hull, 94.5)) progress.analysis_samples = 100 assert(DATA.purchase(progress, "shields")) assert(DATA.purchase(progress, "weapons")) assert(is_equal_approx(enemy.get_shot_damage(), enemy.weapon_damage * 0.9)) enemy.shields = 5.5 enemy.hull = 100 enemy.take_weapon_hit(10, false) assert(is_equal_approx(enemy.hull, 94.5)) enemy.free() var screen := preload("res://scenes/planets/freighter_interior.tscn").instantiate() progress.freighter_rooms["expansion_2"] = "alien_research" add_child(screen) screen._select_section("expansion_2") for frame in 8: await get_tree().process_frame assert(screen._drawer.size.x == 490 and screen._drawer.size.y == 430) var skill_buttons: Array[Node] = screen._content.find_children("*", "Button", true, false) assert(skill_buttons.size() == 28) assert(DATA.parent("weapons_a_next_next") == "weapons_a_next") assert(not DATA.purchase(progress,"weapons_a_next_next_next")) for button in skill_buttons: assert(is_equal_approx(button.size.x, 36) and button.tooltip_text.contains("\n")) assert(button.get_parent().get_global_rect().encloses(button.get_global_rect())) assert(button.get_child_count() <= 3) if "_" in str(button.name) and str(button.name) not in DATA.ACTIVE_IDS: assert(button.disabled and button.get_child_count() == 1) var tooltip: Object = skill_buttons[0]._make_custom_tooltip(skill_buttons[0].tooltip_text) assert(tooltip is PanelContainer) tooltip.free() print("ALIEN_RESEARCH_TEST_OK") if DisplayServer.get_name() != "headless": await RenderingServer.frame_post_draw get_viewport().get_texture().get_image().save_png("res://artifacts/alien_research.png") var motion := InputEventMouseMotion.new() motion.position = skill_buttons[0].get_global_rect().get_center() motion.global_position = motion.position get_viewport().push_input(motion) await get_tree().create_timer(0.9).timeout await RenderingServer.frame_post_draw get_viewport().get_texture().get_image().save_png("res://artifacts/alien_research_hover.png") screen.free() for child in get_children(): child.queue_free() await get_tree().process_frame get_tree().quit()