This commit is contained in:
Tomasz Boruc 2026-10-16 22:36:15 +02:00
parent a3e470ce9a
commit 72839139eb
6 changed files with 38 additions and 18 deletions

View File

@ -6,10 +6,10 @@ const COLORS := {"iron": Color("c5b5a0"), "titanium": Color("9ecbe9"), "uranium"
const IDS := ["parts", "ammunition", "missile", "energy_bank", "irradiated_ammunition"] const IDS := ["parts", "ammunition", "missile", "energy_bank", "irradiated_ammunition"]
const DATA := { const DATA := {
"parts": {"name": "Części", "amount": 1, "cost": {"titanium": 1, "iron": 1, "aluminium": 1}}, "parts": {"name": "Części", "amount": 1, "cost": {"titanium": 1, "iron": 1, "aluminium": 1}},
"ammunition": {"name": "Amunicja", "amount": 10, "cost": {"titanium": 1, "sulfur": 1}}, "ammunition": {"name": "Amunicja", "amount": 50, "cost": {"titanium": 1, "sulfur": 1}},
"missile": {"name": "Rakieta", "amount": 1, "cost": {"iron": 1, "sulfur": 1, "uranium": 1}}, "missile": {"name": "Rakieta", "amount": 1, "cost": {"iron": 1, "sulfur": 1, "uranium": 1}},
"energy_bank": {"name": "Powerbank", "amount": 1, "cost": {"iron": 1, "aluminium": 1}}, "energy_bank": {"name": "Powerbank", "amount": 1, "cost": {"iron": 1, "aluminium": 1}},
"irradiated_ammunition": {"name": "Amunicja radiacyjna", "amount": 10, "cost": {"titanium": 1, "uranium": 1}}, "irradiated_ammunition": {"name": "Amunicja radiacyjna", "amount": 50, "cost": {"titanium": 1, "uranium": 1}},
} }
static func icon(id: String) -> Texture2D: static func icon(id: String) -> Texture2D:

View File

@ -8,7 +8,7 @@ const RECIPES := preload("res://scripts/items/crafting_recipes.gd")
const CARGO_SIZE := 20 const CARGO_SIZE := 20
const WEAPON_SLOT_COUNT := 3 const WEAPON_SLOT_COUNT := 3
const STARTING_MISSILE_AMMUNITION := 2 const STARTING_MISSILE_AMMUNITION := 2
const MISSILE_BUY_BASE_COST := 10 const MISSILE_BUY_BASE_COST := 30
const MISSILE_DEFINITIONS := [preload("res://resources/items/missile_launcher.tres"), preload("res://resources/items/unguided_missile.tres")] const MISSILE_DEFINITIONS := [preload("res://resources/items/missile_launcher.tres"), preload("res://resources/items/unguided_missile.tres")]
const MODULE_SLOT_COUNT := 5 const MODULE_SLOT_COUNT := 5
const EXTENSION_SLOT_COUNT := 5 const EXTENSION_SLOT_COUNT := 5
@ -17,7 +17,8 @@ const MODULE_NAMES := ["Tarcze", "Pancerz", "Silnik", "Reaktor", "Komputer"]
const STARTING_AMMUNITION := 50 const STARTING_AMMUNITION := 50
const AMMUNITION_CRAFT_AMOUNT := 10 const AMMUNITION_CRAFT_AMOUNT := 10
const AMMUNITION_BUY_AMOUNT := 100 const AMMUNITION_BUY_AMOUNT := 100
const AMMUNITION_BUY_BASE_COST := 20 const AMMUNITION_BUY_BASE_COST := 60
const IRRADIATED_AMMUNITION_BUY_BASE_COST := 50
var extension_cooldowns: Dictionary = {} var extension_cooldowns: Dictionary = {}
var energy_banks := 0 var energy_banks := 0
@ -414,7 +415,7 @@ func can_buy_irradiated_ammunition() -> bool:
return GameState.captain.credits >= get_irradiated_ammunition_buy_cost() return GameState.captain.credits >= get_irradiated_ammunition_buy_cost()
func get_irradiated_ammunition_buy_cost() -> int: func get_irradiated_ammunition_buy_cost() -> int:
return GameState.captain.discounted_price(15 * maxi(1, GameState.system_level)) return GameState.captain.discounted_price(IRRADIATED_AMMUNITION_BUY_BASE_COST * maxi(1, GameState.system_level))
func buy_irradiated_ammunition() -> bool: func buy_irradiated_ammunition() -> bool:
if not can_buy_irradiated_ammunition(): if not can_buy_irradiated_ammunition():

View File

@ -7,11 +7,22 @@ extends PanelContainer
@onready var credits_label: Label = $Contents/Wallet/Credits @onready var credits_label: Label = $Contents/Wallet/Credits
var _captain: CaptainProgress var _captain: CaptainProgress
var _level_up_button: Button
func _ready() -> void: func _ready() -> void:
_build_portrait() _build_portrait()
_captain = GameState.captain _captain = GameState.captain
_captain.normalize_skill_ranks() _captain.normalize_skill_ranks()
_level_up_button = Button.new()
_level_up_button.name = "LevelUpButton"
_level_up_button.text = "Nowy poziom"
_level_up_button.custom_minimum_size.y = 32
_level_up_button.focus_mode = Control.FOCUS_NONE
preload("res://scripts/ui/hud_button_style.gd").apply(_level_up_button, Color("efb568"))
$Contents.add_child(_level_up_button)
_level_up_button.pressed.connect(func() -> void:
get_node("../../CaptainSkills").call("open_management")
)
_captain.changed.connect(_refresh) _captain.changed.connect(_refresh)
player.get_node("ShipInventory").connect("inventory_changed", _refresh) player.get_node("ShipInventory").connect("inventory_changed", _refresh)
for label in [level_label, xp_label, credits_label]: for label in [level_label, xp_label, credits_label]:
@ -26,6 +37,11 @@ func _refresh() -> void:
xp_bar.max_value = _captain.get_xp_required() xp_bar.max_value = _captain.get_xp_required()
xp_bar.value = _captain.experience xp_bar.value = _captain.experience
credits_label.text = "Kredyty: %d" % _captain.credits credits_label.text = "Kredyty: %d" % _captain.credits
var available := _captain.learning_points > 0
if _level_up_button.visible != available:
_level_up_button.visible = available
reset_size.call_deferred()
_level_up_button.tooltip_text = "Wybierz umiejętność · oczekujące awanse: %d" % _captain.learning_points
func _build_portrait() -> void: func _build_portrait() -> void:
custom_minimum_size = Vector2(244, 0) custom_minimum_size = Vector2(244, 0)

View File

@ -71,9 +71,7 @@ func _refresh() -> void:
_refresh_pending = false _refresh_pending = false
_captain.prepare_skill_offers() _captain.prepare_skill_offers()
_rebuild_bar() _rebuild_bar()
if not _captain.skill_offers.is_empty() and not bool(player.get("_is_destroyed")): if _screen.visible:
open_management()
elif _screen.visible:
_build_management() _build_management()
func open_management() -> void: func open_management() -> void:

View File

@ -89,7 +89,7 @@ func _position_at_planet() -> void:
func _refresh_ammunition_service() -> void: func _refresh_ammunition_service() -> void:
if _gamma_buy != null: if _gamma_buy != null:
_gamma_buy.text = "KUP 10 NAPROMIENIOWANEJ — %d KREDYTÓW" % (_inventory.get_irradiated_ammunition_buy_cost() if _inventory else 15 * maxi(1, GameState.system_level)) _gamma_buy.text = "KUP 10 NAPROMIENIOWANEJ — %d KREDYTÓW" % (_inventory.get_irradiated_ammunition_buy_cost() if _inventory else ShipInventory.IRRADIATED_AMMUNITION_BUY_BASE_COST * maxi(1, GameState.system_level))
_gamma_buy.disabled = _inventory == null or not _inventory.can_buy_irradiated_ammunition() _gamma_buy.disabled = _inventory == null or not _inventory.can_buy_irradiated_ammunition()
_missile_button.disabled = _inventory == null or not _inventory.can_buy_missile() _missile_button.disabled = _inventory == null or not _inventory.can_buy_missile()
_missile_button.text = "KUP +1 RAKIETĘ — %d KREDYTÓW" % (_inventory.get_missile_buy_cost() if _inventory else ShipInventory.MISSILE_BUY_BASE_COST) _missile_button.text = "KUP +1 RAKIETĘ — %d KREDYTÓW" % (_inventory.get_missile_buy_cost() if _inventory else ShipInventory.MISSILE_BUY_BASE_COST)

View File

@ -19,9 +19,9 @@ func _ready() -> void:
var inventory: ShipInventory = ship.get_node("ShipInventory") var inventory: ShipInventory = ship.get_node("ShipInventory")
for rank in range(1, 4): for rank in range(1, 4):
captain.skills["business_shark"] = rank captain.skills["business_shark"] = rank
assert(inventory.get_ammunition_buy_cost() == [18, 14, 8][rank - 1]) assert(inventory.get_ammunition_buy_cost() == [54, 42, 24][rank - 1])
assert(inventory.get_missile_buy_cost() == [9, 7, 4][rank - 1]) assert(inventory.get_missile_buy_cost() == [27, 21, 12][rank - 1])
assert(inventory.get_irradiated_ammunition_buy_cost() == [14, 11, 6][rank - 1]) assert(inventory.get_irradiated_ammunition_buy_cost() == [45, 35, 20][rank - 1])
captain.skills["efficient_magazine"] = rank captain.skills["efficient_magazine"] = rank
captain._ammo_credit.clear() captain._ammo_credit.clear()
inventory.ammunition = 100 inventory.ammunition = 100
@ -112,13 +112,13 @@ func _ready() -> void:
captain.credits = 1000 captain.credits = 1000
assert(inventory.buy_ammunition()) assert(inventory.buy_ammunition())
assert(captain.credits == 992) assert(captain.credits == 976)
_test_mining(game, ship) _test_mining(game, ship)
inventory.ammunition = 0 inventory.ammunition = 0
inventory.irradiated_ammunition = 0 inventory.irradiated_ammunition = 0
assert(not inventory.consume_ammunition() and not inventory.consume_irradiated_ammunition()) assert(not inventory.consume_ammunition() and not inventory.consume_irradiated_ammunition())
# Real level-up pauses, preserves the offers on reopen, and advances queued choices. # Level-ups wait for the captain button, then advance queued choices while paused.
captain.skills.clear() captain.skills.clear()
captain.normalize_equipped_skills() captain.normalize_equipped_skills()
captain.skill_cooldowns.clear() captain.skill_cooldowns.clear()
@ -127,20 +127,25 @@ func _ready() -> void:
await get_tree().process_frame await get_tree().process_frame
await get_tree().process_frame await get_tree().process_frame
var ui := game.get_node("HUD/CaptainSkills") var ui := game.get_node("HUD/CaptainSkills")
assert(get_tree().paused and captain.learning_points == 2) assert(not get_tree().paused and captain.learning_points == 2)
assert(ui.get("_screen").visible) assert(not ui.get("_screen").visible)
var level_button := game.get_node("HUD/HUDRoot/CaptainPanel/Contents/LevelUpButton") as Button
assert(level_button.visible and level_button.text == "Nowy poziom")
var offers := captain.skill_offers.duplicate() var offers := captain.skill_offers.duplicate()
ui.open_management() level_button.pressed.emit()
assert(get_tree().paused and ui.get("_screen").visible)
assert(offers == captain.skill_offers and offers.size() == 3) assert(offers == captain.skill_offers and offers.size() == 3)
ui._close() ui._close()
assert(get_tree().paused) assert(get_tree().paused)
var selected: String = offers[0] var selected: String = offers[0]
ui._choose(selected) ui._choose(selected)
assert(captain.get_skill_rank(selected) == 1 and get_tree().paused) assert(captain.get_skill_rank(selected) == 1 and get_tree().paused and captain.learning_points == 1)
await get_tree().process_frame await get_tree().process_frame
assert(ui.get("_screen").visible and captain.skill_offers.size() == 3)
ui._choose(captain.skill_offers[0]) ui._choose(captain.skill_offers[0])
assert(not get_tree().paused and captain.learning_points == 0) assert(not get_tree().paused and captain.learning_points == 0)
await get_tree().process_frame await get_tree().process_frame
assert(not level_button.visible and not ui.get("_screen").visible)
ui.open_management() ui.open_management()
assert(get_tree().paused) assert(get_tree().paused)
captain.skill_cooldowns["reactor_overload"] = 17.0 captain.skill_cooldowns["reactor_overload"] = 17.0