Zmiany
This commit is contained in:
parent
a3e470ce9a
commit
72839139eb
@ -6,10 +6,10 @@ const COLORS := {"iron": Color("c5b5a0"), "titanium": Color("9ecbe9"), "uranium"
|
||||
const IDS := ["parts", "ammunition", "missile", "energy_bank", "irradiated_ammunition"]
|
||||
const DATA := {
|
||||
"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}},
|
||||
"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:
|
||||
|
||||
@ -8,7 +8,7 @@ const RECIPES := preload("res://scripts/items/crafting_recipes.gd")
|
||||
const CARGO_SIZE := 20
|
||||
const WEAPON_SLOT_COUNT := 3
|
||||
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 MODULE_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 AMMUNITION_CRAFT_AMOUNT := 10
|
||||
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 energy_banks := 0
|
||||
@ -414,7 +415,7 @@ func can_buy_irradiated_ammunition() -> bool:
|
||||
return GameState.captain.credits >= get_irradiated_ammunition_buy_cost()
|
||||
|
||||
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:
|
||||
if not can_buy_irradiated_ammunition():
|
||||
|
||||
@ -7,11 +7,22 @@ extends PanelContainer
|
||||
@onready var credits_label: Label = $Contents/Wallet/Credits
|
||||
|
||||
var _captain: CaptainProgress
|
||||
var _level_up_button: Button
|
||||
|
||||
func _ready() -> void:
|
||||
_build_portrait()
|
||||
_captain = GameState.captain
|
||||
_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)
|
||||
player.get_node("ShipInventory").connect("inventory_changed", _refresh)
|
||||
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.value = _captain.experience
|
||||
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:
|
||||
custom_minimum_size = Vector2(244, 0)
|
||||
|
||||
@ -71,9 +71,7 @@ func _refresh() -> void:
|
||||
_refresh_pending = false
|
||||
_captain.prepare_skill_offers()
|
||||
_rebuild_bar()
|
||||
if not _captain.skill_offers.is_empty() and not bool(player.get("_is_destroyed")):
|
||||
open_management()
|
||||
elif _screen.visible:
|
||||
if _screen.visible:
|
||||
_build_management()
|
||||
|
||||
func open_management() -> void:
|
||||
|
||||
@ -89,7 +89,7 @@ func _position_at_planet() -> void:
|
||||
|
||||
func _refresh_ammunition_service() -> void:
|
||||
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()
|
||||
_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)
|
||||
|
||||
@ -19,9 +19,9 @@ func _ready() -> void:
|
||||
var inventory: ShipInventory = ship.get_node("ShipInventory")
|
||||
for rank in range(1, 4):
|
||||
captain.skills["business_shark"] = rank
|
||||
assert(inventory.get_ammunition_buy_cost() == [18, 14, 8][rank - 1])
|
||||
assert(inventory.get_missile_buy_cost() == [9, 7, 4][rank - 1])
|
||||
assert(inventory.get_irradiated_ammunition_buy_cost() == [14, 11, 6][rank - 1])
|
||||
assert(inventory.get_ammunition_buy_cost() == [54, 42, 24][rank - 1])
|
||||
assert(inventory.get_missile_buy_cost() == [27, 21, 12][rank - 1])
|
||||
assert(inventory.get_irradiated_ammunition_buy_cost() == [45, 35, 20][rank - 1])
|
||||
captain.skills["efficient_magazine"] = rank
|
||||
captain._ammo_credit.clear()
|
||||
inventory.ammunition = 100
|
||||
@ -112,13 +112,13 @@ func _ready() -> void:
|
||||
|
||||
captain.credits = 1000
|
||||
assert(inventory.buy_ammunition())
|
||||
assert(captain.credits == 992)
|
||||
assert(captain.credits == 976)
|
||||
_test_mining(game, ship)
|
||||
inventory.ammunition = 0
|
||||
inventory.irradiated_ammunition = 0
|
||||
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.normalize_equipped_skills()
|
||||
captain.skill_cooldowns.clear()
|
||||
@ -127,20 +127,25 @@ func _ready() -> void:
|
||||
await get_tree().process_frame
|
||||
await get_tree().process_frame
|
||||
var ui := game.get_node("HUD/CaptainSkills")
|
||||
assert(get_tree().paused and captain.learning_points == 2)
|
||||
assert(ui.get("_screen").visible)
|
||||
assert(not get_tree().paused and captain.learning_points == 2)
|
||||
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()
|
||||
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)
|
||||
ui._close()
|
||||
assert(get_tree().paused)
|
||||
var selected: String = offers[0]
|
||||
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
|
||||
assert(ui.get("_screen").visible and captain.skill_offers.size() == 3)
|
||||
ui._choose(captain.skill_offers[0])
|
||||
assert(not get_tree().paused and captain.learning_points == 0)
|
||||
await get_tree().process_frame
|
||||
assert(not level_button.visible and not ui.get("_screen").visible)
|
||||
ui.open_management()
|
||||
assert(get_tree().paused)
|
||||
captain.skill_cooldowns["reactor_overload"] = 17.0
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user