43 lines
2.3 KiB
GDScript
43 lines
2.3 KiB
GDScript
extends Node
|
|
const LAB := preload("res://scripts/planets/laboratory.gd")
|
|
const SKILLS := preload("res://scripts/captain/captain_skills.gd")
|
|
func _ready() -> void:
|
|
var captain := preload("res://scripts/captain/captain_progress.gd").new()
|
|
var progress: Resource = captain.expedition
|
|
progress.laboratory_offers.assign(["machine_gun"])
|
|
assert(not LAB.start(captain,"machine_gun"))
|
|
for key in LAB.COSTS.machine_gun: captain.minerals[key] = int(LAB.COSTS.machine_gun[key])
|
|
assert(LAB.start(captain,"machine_gun"))
|
|
assert(progress.laboratory_unlocks.get("machine_gun",false))
|
|
assert(progress.laboratory_remaining == 0 and progress.laboratory_project.is_empty())
|
|
for key in LAB.COSTS.machine_gun: assert(captain.minerals[key] == 0)
|
|
assert(not LAB.start(captain,"machine_gun"))
|
|
assert(not LAB.start(captain,"unknown_project"))
|
|
progress.laboratory_project = "beam_laser"
|
|
progress.laboratory_remaining = 450.0
|
|
progress.laboratory_duration = 600.0
|
|
assert(ResourceSaver.save(progress,"user://legacy_lab.tres") == OK)
|
|
var restored: Resource = ResourceLoader.load("user://legacy_lab.tres","",ResourceLoader.CACHE_MODE_IGNORE_DEEP)
|
|
LAB.ensure_offers(restored)
|
|
assert(restored.laboratory_unlocks.get("beam_laser",false))
|
|
assert(restored.laboratory_project.is_empty() and restored.laboratory_remaining == 0)
|
|
assert(restored.laboratory_offers.size() == 3)
|
|
assert(not LAB.advance(restored,100))
|
|
captain.skills = {"scientist":3,"gunsmith":2}
|
|
captain.learning_points = 1
|
|
captain.skill_offers.assign(["scientist","gunsmith","miner"])
|
|
captain.prepare_skill_offers()
|
|
assert(not SKILLS.IDS.has("scientist") and not SKILLS.DATA.has("scientist"))
|
|
assert(not captain.skills.has("scientist") and captain.skills.gunsmith == 2)
|
|
assert(captain.learning_points == 4 and not captain.skill_offers.has("scientist"))
|
|
captain.normalize_skill_ranks()
|
|
assert(captain.learning_points == 4,"Refund only once")
|
|
assert(not captain.can_train("scientist"))
|
|
var panel := preload("res://scripts/planets/laboratory_panel.gd").new()
|
|
panel.captain = captain
|
|
add_child(panel)
|
|
assert(panel.find_children("Research_*","Button",true,false).size() == 3)
|
|
assert(panel.find_children("*","ProgressBar",true,false).is_empty())
|
|
print("INSTANT_LABORATORY_TEST: PASS (immediate unlock, exact cost, invalid/duplicate guards, old project, removed skill, one-time refund, UI)")
|
|
get_tree().quit()
|