Randoloot/tests/ships/research_progression_test.gd
2026-10-27 22:20:01 +01:00

68 lines
2.9 KiB
GDScript

extends Node
const LAB := preload("res://scripts/planets/laboratory.gd")
const ALIEN := preload("res://scripts/planets/alien_research.gd")
func _ready() -> void:
GameState.start_new_run()
var captain := GameState.captain
var progress: Resource = captain.expedition
progress.freighter_rooms.expansion_1 = "laboratory"
for cost in LAB.COSTS.values():
for key in cost: captain.minerals[key] = 10000
progress.analysis_samples = 10000
LAB.ensure_offers(progress)
assert(progress.laboratory_offers.size() == 3)
assert(captain.level == 1)
var original_offers: Array = progress.laboratory_offers.duplicate()
captain.level = 80
LAB.ensure_offers(progress)
assert(progress.laboratory_offers == original_offers)
captain.level = 1
progress.laboratory_offers.assign(["virus"])
assert(LAB.start(captain,"virus"))
assert(progress.laboratory_remaining == 600)
LAB.advance(progress,599)
assert(not progress.laboratory_unlocks.get("virus",false))
LAB.advance(progress,1)
assert(progress.laboratory_unlocks.virus)
for id in LAB.IDS:
if progress.laboratory_unlocks.get(id,false): continue
progress.laboratory_offers.assign([id])
assert(LAB.start(captain,id))
LAB.advance(progress,600)
assert(progress.laboratory_unlocks.size() == 23)
captain.level = 1
assert(ALIEN.purchase(progress,"general"))
assert(not ALIEN.learned("general"))
assert(not ALIEN.purchase(progress,"hull"))
ALIEN.advance(progress,599)
assert(not ALIEN.learned("general"))
ALIEN.advance(progress,1)
assert(ALIEN.learned("general"))
assert(not ALIEN.purchase(progress,"hull_a"), "Parent technology still required")
for id in ALIEN.ACTIVE_IDS:
if id == "general": continue
var before: int = progress.analysis_samples
assert(ALIEN.purchase(progress,id))
assert(progress.analysis_samples == before-ALIEN.cost(id))
assert(not ALIEN.purchase(progress,id))
ALIEN.advance(progress,600)
assert(ALIEN.learned(id))
assert(ALIEN.learned_count(progress) == 28)
assert(progress.analysis_samples == 10000-715)
# No partial completion or lost duration on Resource serialization.
progress.alien_skills.erase("shields_b_next_next_next")
assert(captain.level == 1)
assert(ALIEN.purchase(progress,"shields_b_next_next_next"))
ALIEN.advance(progress,123.5)
assert(ResourceSaver.save(progress,"user://research_timer.tres") == OK)
var restored: Resource = ResourceLoader.load("user://research_timer.tres","",ResourceLoader.CACHE_MODE_IGNORE_DEEP)
assert(restored.alien_project == "shields_b_next_next_next")
assert(restored.alien_remaining == 476.5)
ALIEN.advance(restored,476.4)
assert(not restored.alien_skills.get("shields_b_next_next_next",false))
ALIEN.advance(restored,0.1)
assert(restored.alien_skills.shields_b_next_next_next)
print("RESEARCH PROGRESSION PASS: all 23+28 discoveries at captain level 1; level-independent offers, 600-second timers, single projects, costs, exact save/load continuation")
get_tree().quit()