extends Node const GENERATOR := preload("res://scripts/levels/system_generator.gd") const BALANCE := preload("res://scripts/levels/level_balance.gd") func _ready() -> void: assert(GENERATOR.STAR_TEXTURES.size() == 15) assert(GENERATOR.PLANET_TEXTURES.size() == 125) for texture in GENERATOR.STAR_TEXTURES + GENERATOR.PLANET_TEXTURES: assert(texture.resource_path.begins_with("res://assets/planet_sun/")) assert(texture.get_size() == Vector2(512, 512), "Low-resolution celestial texture: " + texture.resource_path) for texture in GENERATOR.ALIEN_SHIPS.TEXTURES: var image := texture.get_image() assert(image.get_size() == Vector2i(256, 256)) assert(image.get_pixel(0, 0).a == 0.0 and image.get_pixel(255, 255).a == 0.0) assert(image.get_used_rect().has_area()) for point in BALANCE.COUNT_POINTS: assert(BALANCE.enemy_count(int(point.x)) == int(point.y)) var previous_count := 0 for level in range(1, BALANCE.MAX_LEVEL + 1): var count := BALANCE.enemy_count(level) assert(count >= previous_count and count <= 40) assert(BALANCE.enemy_tiers(level).size() == count) assert(BALANCE.enemy_tiers(level).count(2) == 1) previous_count = count var observed_counts: Dictionary = {} var observed_ship_types: Dictionary = {} for level in [1, 10, 50, 60, 61, 100, 120]: for seed_value in range(1, 61): var data := GENERATOR.generate(level, seed_value) var ship_type: int = data["enemy_texture_index"] assert(ship_type >= 0 and ship_type < GENERATOR.ALIEN_SHIPS.TEXTURES.size()) observed_ship_types[ship_type] = true assert(data == GENERATOR.generate(level, seed_value)) assert(data["star_position"] == Vector2.ZERO) assert(GENERATOR.STAR_TEXTURES.has(data["star_texture"])) assert(data["player_start"].distance_to(Vector2.ZERO) <= 300.0) var planets: Array[Dictionary] = data["planets"] assert(planets.size() >= 1 and planets.size() <= 5) observed_counts[planets.size()] = true var protected_count := 0 for planet in planets: assert(GENERATOR.PLANET_TEXTURES.has(planet["texture"])) if planet["protected"]: protected_count += 1 var position: Vector2 = planet["position"] assert(position.length() > 900) assert(absf(position.x) + float(planet["radius"]) < 2580) assert(absf(position.y) + float(planet["radius"]) < 1780) assert(protected_count == 1) assert(planets[data["protected_index"]]["protected"]) var enemies: Array[Dictionary] = data["enemies"] assert(enemies.size() == BALANCE.enemy_count(level)) assert(enemies.filter(func(enemy: Dictionary) -> bool: return enemy["tier"] == 2).size() == 1) for index in enemies.size(): assert(enemies[index]["texture_index"] == ship_type) var position: Vector2 = enemies[index]["position"] assert(position.length() >= GENERATOR.SAFE_ZONE_RADIUS) assert(position.distance_to(data["player_start"]) >= 940.0) assert(absf(position.x) <= 2380 and absf(position.y) <= 1580) for other_index in range(index + 1, enemies.size()): assert(position.distance_to(enemies[other_index]["position"]) >= GENERATOR.ENEMY_MIN_SEPARATION) assert(enemies[index]["tier"] == BALANCE.enemy_tiers(level)[index]) assert(observed_counts.size() == 5) assert(observed_ship_types.size() == GENERATOR.ALIEN_SHIPS.TEXTURES.size()) print("SYSTEM_GENERATION_TEST: PASS (420 layouts, deterministic retries, planets, safe spawn and level balance 1–120)")