69 lines
3.0 KiB
GDScript
69 lines
3.0 KiB
GDScript
extends Node
|
|
const GAME := preload("res://scenes/game/game.tscn")
|
|
|
|
func _ready() -> void:
|
|
GameState.start_new_run()
|
|
GameState.system_seed = 314159
|
|
var game := GAME.instantiate()
|
|
assert(game.BOSS_SPAWN_DISTANCE >= 1800.0)
|
|
add_child(game)
|
|
game.set_physics_process(false)
|
|
var player: CharacterBody2D = game.get_node("PlayerShip")
|
|
player.set_physics_process(false)
|
|
player.get_node("WeaponController").set_physics_process(false)
|
|
var enemies: Array[Node] = []
|
|
for enemy in get_tree().get_nodes_in_group("enemies"):
|
|
if game.is_ancestor_of(enemy):
|
|
assert(enemy.loot_tier != 2)
|
|
enemy.set_physics_process(false)
|
|
enemies.append(enemy)
|
|
assert(enemies.size() == 4)
|
|
assert(not game.is_boss_alive())
|
|
for index in enemies.size() - 1:
|
|
enemies[index].take_damage(100000.0)
|
|
game._physics_process(0.0)
|
|
assert(game.get_remaining_enemies() == 1 and not game._boss_spawned)
|
|
# Spawn positions remain clear and at the same distance near map edges.
|
|
for position in [Vector2.ZERO, Vector2(2500, 1700), Vector2(-2500, 1700), Vector2(2500, -1700), Vector2(-2500, -1700)]:
|
|
player.position = position
|
|
var candidate: Vector2 = game._find_boss_spawn_position()
|
|
assert(is_equal_approx(candidate.distance_to(position), game.BOSS_SPAWN_DISTANCE))
|
|
assert(absf(candidate.x) <= game.WORLD_SIZE.x * 0.5 - game.BOSS_SPAWN_MARGIN)
|
|
assert(absf(candidate.y) <= game.WORLD_SIZE.y * 0.5 - game.BOSS_SPAWN_MARGIN)
|
|
assert(candidate.length() >= 300.0)
|
|
for planet in game.system_data["planets"]:
|
|
assert(candidate.distance_to(planet["position"]) >= planet["radius"] + 130.0)
|
|
player.position = Vector2(700, 500)
|
|
enemies.back().take_damage(100000.0)
|
|
player.set("_is_destroyed", true)
|
|
game._physics_process(0.0)
|
|
assert(not game._boss_spawned)
|
|
player.set("_is_destroyed", false)
|
|
game._physics_process(0.0)
|
|
assert(game._boss_spawned and game.get_remaining_enemies() == 1)
|
|
assert(game.is_boss_alive())
|
|
assert(not game.system_cleared and not game.services_menu.visible)
|
|
var boss: CharacterBody2D
|
|
for enemy in get_tree().get_nodes_in_group("enemies"):
|
|
if game.is_ancestor_of(enemy) and enemy.loot_tier == 2:
|
|
assert(boss == null)
|
|
boss = enemy
|
|
assert(boss != null)
|
|
boss.set_physics_process(false)
|
|
assert(is_equal_approx(boss.position.distance_to(player.position), game.BOSS_SPAWN_DISTANCE))
|
|
game._physics_process(0.0)
|
|
assert(game.get_remaining_enemies() == 1)
|
|
assert(not game.open_wormhole())
|
|
boss.take_damage(100000.0)
|
|
game._physics_process(0.0)
|
|
assert(game.system_cleared and game.get_remaining_enemies() == 0)
|
|
assert(not game.is_boss_alive())
|
|
game._physics_process(0.0)
|
|
assert(game.get_remaining_enemies() == 0)
|
|
for definition in preload("res://scripts/items/item_generator.gd").DEFINITIONS:
|
|
var category_index := ShipInventory.MODULE_CATEGORIES.find(definition.category)
|
|
if category_index >= 0:
|
|
assert(definition.display_name == ShipInventory.MODULE_NAMES[category_index])
|
|
print("BOSS_SPAWN_TEST: PASS delayed boss, elites, no early completion, distance, safe placement, single spawn, dead player, item names")
|
|
get_tree().quit()
|