Add research lab planets and research points (#63)
This commit is contained in:
parent
651f8b787e
commit
3f3a22227d
43 changed files with 459 additions and 30 deletions
|
|
@ -680,6 +680,13 @@ func _confirm_build() -> void:
|
|||
if not GameState.is_planet_conquered(planet.planet_id):
|
||||
build_status.text = "%s is not captured yet" % planet.planet_name
|
||||
return
|
||||
if String(planet.resource_type) == "":
|
||||
# #63: a research_lab planet's whole point is that it yields
|
||||
# nothing to mine - an extractor there would sit on an empty
|
||||
# resource id with no ResourceDefinition, breaking its own
|
||||
# glyph/HUD rendering the moment it produced anything.
|
||||
build_status.text = "%s has nothing to extract" % planet.planet_name
|
||||
return
|
||||
if not GameState.spend(definition.cost):
|
||||
build_status.text = "Not enough rocks (need %d, have %d)" % [definition.cost, GameState.rocks]
|
||||
return
|
||||
|
|
@ -723,14 +730,18 @@ func _refresh_skill_menu(id: String = "") -> void:
|
|||
# leaving the panel blank, which reads as broken.
|
||||
skill_detail.text = "Select a node to see what it unlocks."
|
||||
skill_cost.amount = 0
|
||||
skill_status.text = "Fleet capacity %d" % GameState.max_fleet_size()
|
||||
skill_status.text = "Fleet capacity %d · Research points %d" \
|
||||
% [GameState.max_fleet_size(), GameState.research_points]
|
||||
skill_unlock_button.visible = false
|
||||
return
|
||||
|
||||
var node: Dictionary = GameState.skill_node(id)
|
||||
if node.is_empty():
|
||||
return
|
||||
var points_needed: int = int(node.get("research_points", 0))
|
||||
skill_detail.text = "%s\n%s" % [node.name, node.desc]
|
||||
if points_needed > 0:
|
||||
skill_detail.text += "\nResearch points: %d/%d" % [GameState.research_points, points_needed]
|
||||
skill_cost.amount = int(node.cost)
|
||||
|
||||
if GameState.is_unlocked(id):
|
||||
|
|
@ -742,6 +753,12 @@ func _refresh_skill_menu(id: String = "") -> void:
|
|||
elif not GameState.can_afford(int(node.cost)):
|
||||
skill_status.text = "Not enough rocks - you have %d" % GameState.rocks
|
||||
skill_unlock_button.visible = false
|
||||
elif GameState.research_points < points_needed:
|
||||
# #63: a distinct reason from the ore one above - conflating them
|
||||
# would leave the player trying to fix the wrong shortage.
|
||||
skill_status.text = "Not enough research points - you have %d, need %d" \
|
||||
% [GameState.research_points, points_needed]
|
||||
skill_unlock_button.visible = false
|
||||
else:
|
||||
skill_status.text = ""
|
||||
skill_unlock_button.visible = true
|
||||
|
|
@ -902,7 +919,8 @@ func _refresh_lab() -> void:
|
|||
lab_vessel_labels[i].text = definition.display_name
|
||||
lab_vessel_buttons[i].highlighted = this_vessel == lab_vessel
|
||||
lab_vessel_buttons[i].queue_redraw()
|
||||
lab_vessel_label.text = "%s research" % GameState.vessel_name(lab_vessel)
|
||||
lab_vessel_label.text = "%s research · %d RP" % [
|
||||
GameState.vessel_name(lab_vessel), GameState.research_points]
|
||||
|
||||
var options: Array = _lab_options()
|
||||
for i in range(lab_upgrade_buttons.size()):
|
||||
|
|
@ -914,6 +932,9 @@ func _refresh_lab() -> void:
|
|||
var option: Dictionary = options[i]
|
||||
var price_text: String = _format_costs(option.costs if bool(option.unlock) \
|
||||
else GameState.research_costs(option.id))
|
||||
var point_cost: int = GameState.research_point_cost(String(option.id))
|
||||
if point_cost > 0:
|
||||
price_text += " · %d RP" % point_cost
|
||||
if not bool(option.unlock) and GameState.upgrade_maxed(option.id):
|
||||
price_text = "MAX"
|
||||
var level_note: String = "" if bool(option.unlock) else " %d/%d" % [
|
||||
|
|
@ -932,11 +953,22 @@ func _refresh_lab() -> void:
|
|||
lab_choice = clampi(lab_choice, 0, options.size() - 1)
|
||||
|
||||
var choice: Dictionary = options[lab_choice]
|
||||
var choice_points: int = GameState.research_point_cost(String(choice.id))
|
||||
lab_detail.text = "%s\n%s" % [choice.name, choice.desc]
|
||||
if choice_points > 0:
|
||||
lab_detail.text += "\nResearch points: %d/%d" % [GameState.research_points, choice_points]
|
||||
var queued: Dictionary = GameState.lab_research_order(lab_building_id)
|
||||
lab_buy_button.enabled = queued.is_empty() and (choice.unlock or not GameState.upgrade_maxed(choice.id))
|
||||
if not queued.is_empty():
|
||||
lab_status.text = "%s %d%%" % ["Researching" if bool(queued.started) else "Waiting for resources", int(100.0 * float(queued.elapsed) / maxf(GameState.lab_research_time(), 0.001))]
|
||||
var queued_points: int = GameState.research_point_cost(String(queued.id))
|
||||
if not bool(queued.started) and GameState.research_points < queued_points:
|
||||
# #63: distinct from "Waiting for resources" - flying more ore/gas
|
||||
# to this lab cannot fix a research-point shortfall, only
|
||||
# conquering a research lab elsewhere can.
|
||||
lab_status.text = "Need %d research point%s (have %d)" \
|
||||
% [queued_points, "" if queued_points == 1 else "s", GameState.research_points]
|
||||
else:
|
||||
lab_status.text = "%s %d%%" % ["Researching" if bool(queued.started) else "Waiting for resources", int(100.0 * float(queued.elapsed) / maxf(GameState.lab_research_time(), 0.001))]
|
||||
lab_buy_button.queue_redraw()
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue