77 lines
4.1 KiB
GDScript
77 lines
4.1 KiB
GDScript
@tool
|
|
extends Node
|
|
const GENERATOR := preload("res://scripts/items/item_generator.gd")
|
|
const ORBS := preload("res://scripts/items/special_orbs.gd")
|
|
class DockedShip:
|
|
extends Node
|
|
var is_docked := true
|
|
class TestInventory:
|
|
extends Node
|
|
signal inventory_changed
|
|
var cargo: Array[ItemInstance] = []
|
|
var weapon_slots: Array[ItemInstance] = []
|
|
var module_slots: Array[ItemInstance] = []
|
|
var recalculations := 0
|
|
func _recalculate_ship_stats() -> void: recalculations += 1
|
|
func _ready() -> void:
|
|
if not Engine.is_editor_hint(): print("ADVANCEMENT_CHECKS: "+JSON.stringify(run_checks()))
|
|
|
|
func run_checks() -> Dictionary:
|
|
var failures: Array[String] = []
|
|
var ship := DockedShip.new()
|
|
var inventory := TestInventory.new()
|
|
ship.add_child(inventory)
|
|
var progress = preload("res://scripts/planets/planet_progress.gd").new()
|
|
var checked := 0
|
|
for definition in GENERATOR.DEFINITIONS:
|
|
var item := GENERATOR.generate_for_definition(definition,20,2)
|
|
item.special_orbs.assign(["piercing"] if definition.category == ItemDefinition.Category.WEAPON else [])
|
|
var original_orbs := item.special_orbs.duplicate()
|
|
var modifiers := item.additional_modifiers.duplicate()
|
|
var rarity := item.rarity
|
|
var cooldown := item.extension_cooldown
|
|
var passive := item.passive_value
|
|
for modifier in modifiers:
|
|
if modifier != null: modifier.value = -999
|
|
inventory.cargo.assign([item])
|
|
progress.orbs["advancement"] = 2
|
|
if not ORBS.apply(progress,inventory,item,"advancement"): failures.append("Apply failed: "+definition.item_id)
|
|
if item.item_level != 21 or progress.orbs.advancement != 1: failures.append("Level or payment")
|
|
if item.rarity != rarity or item.additional_modifiers.size() != modifiers.size(): failures.append("Changed rarity or count")
|
|
if item.special_orbs != original_orbs: failures.append("Lost special orb")
|
|
if item.extension_cooldown != cooldown or item.passive_value != passive: failures.append("Rerolled unrelated extension ability")
|
|
for index in modifiers.size():
|
|
var old: ItemStatModifier = modifiers[index]
|
|
var current: ItemStatModifier = item.additional_modifiers[index]
|
|
if current.stat_key != old.stat_key or current.affix != old.affix: failures.append("Changed affix type")
|
|
if old.value != -999 or current == old: failures.append("Mutated shared modifier")
|
|
var bounds := current.affix.get_value_range(21)
|
|
if current.value < bounds.x or current.value > bounds.y: failures.append("Wrong value range")
|
|
if not ORBS.apply(progress,inventory,item,"advancement") or item.item_level != 22: failures.append("Cannot repeat")
|
|
if ORBS.apply(progress,inventory,item,"advancement"): failures.append("Used absent orb")
|
|
progress.orbs.advancement = 1
|
|
item.item_level = 999
|
|
if not ORBS.apply(progress,inventory,item,"advancement") or item.item_level != 1000: failures.append("999 to 1000")
|
|
progress.orbs.advancement = 1
|
|
if ORBS.apply(progress,inventory,item,"advancement") or progress.orbs.advancement != 1: failures.append("Exceeded cap or charged rejection")
|
|
checked += 1
|
|
var bank := ItemInstance.new()
|
|
bank.definition = preload("res://resources/items/energy_bank.tres")
|
|
if ORBS.accepts(bank,"advancement"): failures.append("Consumable accepted")
|
|
var unowned := GENERATOR.generate(1)
|
|
if ORBS.apply(progress,inventory,unowned,"advancement"): failures.append("Unowned item accepted")
|
|
var legacy := GENERATOR.generate_for_definition(preload("res://resources/items/plasma_cannon.tres"),5)
|
|
legacy.additional_modifiers.clear()
|
|
var modifier := ItemStatModifier.new()
|
|
modifier.stat_key = "damage_percent"
|
|
modifier.value = -999
|
|
legacy.additional_modifiers.append(modifier)
|
|
inventory.cargo.assign([legacy])
|
|
progress.orbs.advancement = 1
|
|
if not ORBS.apply(progress,inventory,legacy,"advancement") or legacy.additional_modifiers[0].affix == null: failures.append("Legacy affix unresolved")
|
|
var drops: Array[String] = []
|
|
for seed_value in 3: drops.append(preload("res://scripts/game/distant_loot.gd").roll(125,true,seed_value,1.0,0.0)[1].orb)
|
|
if not drops.has("advancement") or not drops.has("piercing") or not drops.has("booster"): failures.append("Boss orb pool")
|
|
ship.free()
|
|
return {"failures":failures,"definitions_checked":checked,"passed":failures.is_empty()}
|