70 lines
3.2 KiB
GDScript
70 lines
3.2 KiB
GDScript
extends Node
|
|
const RULES := preload("res://scripts/planets/poi_rules.gd")
|
|
const CAPTAIN := preload("res://scripts/captain/captain_progress.gd")
|
|
|
|
func _ready() -> void:
|
|
var captain := CAPTAIN.new()
|
|
var state: Resource = captain.expedition
|
|
var profile := {"id":"test","name":"Test","seed":42,"difficulty":0.0,"landing_damage":0,"oxygen":98,"temperature":30,"flora":0}
|
|
var rng := RandomNumberGenerator.new()
|
|
rng.seed = 42
|
|
GameState.system_level = 20
|
|
assert(state.begin_visit(profile))
|
|
var samples_before := 0
|
|
for kind in RULES.STAGES:
|
|
for stage in 3:
|
|
var success := false
|
|
for attempt in 100:
|
|
state.lander_hp = 100
|
|
var poi := {"kind":kind,"stage":stage,"complete":false}
|
|
var result: Dictionary = state.resolve_poi(captain,poi,rng)
|
|
if not result.success: continue
|
|
success = true
|
|
assert(poi.stage == stage+1 and poi.complete == (stage==2))
|
|
if kind == "ruins":
|
|
assert(result.module.item_level == 21+stage and result.materials.is_empty())
|
|
else: assert(result.module == null)
|
|
if kind == "deposit":
|
|
for key in result.materials: assert(key in ["silicon","copper","nickel","tungsten","mercury"])
|
|
if kind == "cave":
|
|
assert(result.materials == {"samples":[1,2,4][stage]})
|
|
samples_before += [1,2,4][stage]
|
|
if kind == "village" and stage == 1:
|
|
assert(result.materials.experience == ceili(captain.get_xp_required()*0.1))
|
|
if stage == 2: assert(state.resolve_poi(captain,poi,rng).is_empty())
|
|
break
|
|
assert(success)
|
|
var ammo := int(state.cargo.ammunition)
|
|
var xp := int(state.cargo.experience)
|
|
var credits := int(state.cargo.credits)
|
|
assert(state.analysis_samples == 0 and captain.credits == 0)
|
|
state.finish_visit(captain,true)
|
|
assert(state.analysis_samples == samples_before and samples_before == 7)
|
|
assert(state.delivered_ammunition == ammo and captain.experience == xp and captain.credits == credits)
|
|
for key in ["samples","credits","experience","ammunition","missile","irradiated_ammunition"]: assert(not captain.minerals.has(key))
|
|
state.finish_visit(captain,true)
|
|
assert(state.analysis_samples == 7 and captain.credits == credits)
|
|
assert(state.begin_visit(profile))
|
|
state.add_material("samples",4)
|
|
state.add_material("experience",999)
|
|
state.add_material("ammunition",99)
|
|
state.finish_visit(captain,false)
|
|
assert(state.analysis_samples == 7 and captain.experience == xp and state.delivered_ammunition == ammo)
|
|
for seed_value in 100:
|
|
for stage in 3:
|
|
var easy := RandomNumberGenerator.new()
|
|
var hard := RandomNumberGenerator.new()
|
|
easy.seed = seed_value
|
|
hard.seed = seed_value
|
|
var a := RULES.reward("warehouse",stage,easy,{"difficulty":0.0},captain)
|
|
var b := RULES.reward("warehouse",stage,hard,{"difficulty":1.0},captain)
|
|
for key in a:
|
|
assert(b[key] == a[key]*(3 if key in ["iron","titanium","aluminium","uranium","sulfur"] else 1))
|
|
var saved := "user://poi_samples_test.tres"
|
|
assert(ResourceSaver.save(captain,saved) == OK)
|
|
var loaded: Resource = ResourceLoader.load(saved,"",ResourceLoader.CACHE_MODE_IGNORE)
|
|
assert(loaded.expedition.analysis_samples == 7)
|
|
DirAccess.remove_absolute(saved)
|
|
print("POI REWARDS PASS: all 15 stages, exact module levels, rare deposits, ammo scaling, EXP, samples, return/loss, persistence, duplicate claims")
|
|
get_tree().quit()
|