61 lines
2.9 KiB
GDScript
61 lines
2.9 KiB
GDScript
extends Node
|
||
|
||
const GENERATOR := preload("res://scripts/levels/system_generator.gd")
|
||
const BALANCE := preload("res://scripts/levels/level_balance.gd")
|
||
|
||
func _ready() -> void:
|
||
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, 1001):
|
||
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, 100, 250, 500, 1000]:
|
||
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(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:
|
||
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)
|
||
if level <= 10:
|
||
assert(enemies[index]["tier"] == (2 if index == 0 else 0))
|
||
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–1000)")
|