73 lines
3.6 KiB
GDScript
73 lines
3.6 KiB
GDScript
extends Node
|
|
const RECIPES := preload("res://scripts/items/crafting_recipes.gd")
|
|
func _ready() -> void:
|
|
GameState.start_new_run()
|
|
var captain := GameState.captain
|
|
for key in RECIPES.MINERALS: captain.minerals[key] = 1000
|
|
var game := preload("res://scenes/game/game.tscn").instantiate()
|
|
add_child(game)
|
|
await get_tree().process_frame
|
|
var hud := game.get_node("HUD/HUDRoot")
|
|
assert(hud.get_node_or_null("CraftingWindow") == null)
|
|
assert(hud.get_node("TopNavigation").get_child_count() == 1)
|
|
var manager := game.get_node("PlanetExpeditions")
|
|
manager.open_freighter()
|
|
var screen: Control = manager.screen
|
|
var inventory: ShipInventory = game.player.get_node("ShipInventory")
|
|
screen._select_section("workshop")
|
|
assert(screen._drawer.find_child("workshopTab",true,false) == null)
|
|
for id in RECIPES.IDS:
|
|
var stock := inventory.get_crafted_stock(id)
|
|
var before: Dictionary = captain.minerals.duplicate()
|
|
var button: Button = screen._content.find_child("Craft_"+id,true,false)
|
|
assert(button != null and not button.disabled)
|
|
assert(button.text == "+1")
|
|
button.pressed.emit()
|
|
assert(inventory.get_crafted_stock(id) == stock+int(RECIPES.DATA[id].amount))
|
|
for key in RECIPES.DATA[id].cost:
|
|
assert(captain.minerals[key] == before[key]-int(RECIPES.DATA[id].cost[key]))
|
|
var ten: Button = screen._content.find_child("Craft10_"+id,true,false)
|
|
assert(ten.text == "+10" and not ten.disabled)
|
|
stock = inventory.get_crafted_stock(id)
|
|
before = captain.minerals.duplicate()
|
|
ten.pressed.emit()
|
|
assert(inventory.get_crafted_stock(id) == stock+10*int(RECIPES.DATA[id].amount))
|
|
for key in RECIPES.DATA[id].cost:
|
|
assert(captain.minerals[key] == before[key]-10*int(RECIPES.DATA[id].cost[key]))
|
|
captain.minerals.sulfur = 3
|
|
screen._refresh()
|
|
assert(not screen._content.find_child("Craft_missile",true,false).disabled)
|
|
assert(screen._content.find_child("Craft10_missile",true,false).disabled)
|
|
var missiles_before := inventory.missile_ammunition
|
|
screen._craft_supply("missile",10)
|
|
assert(inventory.missile_ammunition == missiles_before and captain.minerals.sulfur == 3)
|
|
captain.minerals.sulfur = 0
|
|
screen._refresh()
|
|
assert(screen._content.find_child("Craft_missile",true,false).disabled)
|
|
screen._select_section("storage")
|
|
var before_ammo := inventory.ammunition
|
|
screen._craft_supply("ammunition")
|
|
assert(inventory.ammunition == before_ammo)
|
|
screen._construct_room("expansion_3")
|
|
assert(screen._content.find_child("Stock_ammunition",true,false) != null)
|
|
assert(screen._content.find_child("Stock_credits",true,false) != null)
|
|
assert(screen._content.find_child("Stock_silicon",true,false) != null)
|
|
assert(screen._content.find_child("Stock_samples",true,false) != null)
|
|
for index in inventory.cargo.size(): inventory.cargo[index] = null
|
|
for index in 3:
|
|
var item := preload("res://scripts/items/item_generator.gd").generate_for_definition(preload("res://resources/items/reinforced_shield.tres"),index+1)
|
|
assert(inventory.add_item(item))
|
|
screen._refresh()
|
|
assert(screen._content.find_child("ShipSlots",true,false).get_child_count() == 20)
|
|
assert(screen._content.find_child("FreighterSlots",true,false).get_child_count() == 20)
|
|
screen._transfer_all(false)
|
|
assert(inventory.get_cargo_used() == 0 and captain.expedition.freighter_storage.size() == 3)
|
|
screen._transfer_all(true)
|
|
assert(inventory.get_cargo_used() == 3 and captain.expedition.freighter_storage.is_empty())
|
|
screen.closed.emit()
|
|
game.queue_free()
|
|
await get_tree().process_frame
|
|
await get_tree().process_frame
|
|
print("FREIGHTER PRODUCTION PASS: HUD crafting removed, no section tabs, all 5 recipes, exact costs, stock, unavailable craft, resource overview, slot grids, bulk transfers")
|
|
get_tree().quit()
|