Resolve pending gameplay tickets
This commit is contained in:
parent
ec20778215
commit
c2ebbfaa2d
28 changed files with 618 additions and 188 deletions
|
|
@ -383,7 +383,7 @@ func _show_building_info(type: String) -> void:
|
|||
GameState.resource_name(planet.resource_type), planet.planet_name])
|
||||
elif can_build and definition.unique and GameState.has_building_of_type(type):
|
||||
lines.append("WARNING: only one may exist - this destroys your current one.")
|
||||
if can_build and not GameState.can_afford_resources(costs):
|
||||
if can_build and not GameState.can_afford_resources(costs, fleet.get_centroid()):
|
||||
can_build = false
|
||||
pending_build_type = type if can_build else ""
|
||||
build_menu.show_info(definition.display_name, "\n\n".join(lines), costs, can_build)
|
||||
|
|
@ -416,7 +416,7 @@ func _confirm_build() -> void:
|
|||
if String(planet.resource_type) == "":
|
||||
build_menu.set_status("%s has nothing to extract" % planet.planet_name)
|
||||
return
|
||||
if not GameState.spend_resources(GameState.building_costs(type)):
|
||||
if not GameState.spend_resources(GameState.building_costs(type), fleet.get_centroid()):
|
||||
build_menu.set_status(_cannot_afford(type))
|
||||
return
|
||||
GameState.add_extractor(planet.planet_name, planet.position,
|
||||
|
|
@ -424,7 +424,7 @@ func _confirm_build() -> void:
|
|||
build_menu.close_menu()
|
||||
return
|
||||
if definition.unique and GameState.has_building_of_type(type):
|
||||
if not GameState.can_afford_resources(GameState.building_costs(type)):
|
||||
if not GameState.can_afford_resources(GameState.building_costs(type), fleet.get_centroid()):
|
||||
build_menu.set_status(_cannot_afford(type))
|
||||
return
|
||||
GameState.remove_buildings_of_type(type)
|
||||
|
|
@ -437,14 +437,14 @@ func _cannot_afford(type: String) -> String:
|
|||
for resource_type in GameState.building_costs(type):
|
||||
var id: String = String(resource_type)
|
||||
var want: int = int(GameState.building_costs(type)[resource_type])
|
||||
var have: int = GameState.available_resource(id)
|
||||
var have: int = GameState.available_resource_at(id, fleet.get_centroid())
|
||||
if have < want:
|
||||
missing.append("%s (need %d, have %d)" % [GameState.resource_name(id), want, have])
|
||||
return "" if missing.is_empty() else "Not enough %s" % " and ".join(missing)
|
||||
|
||||
|
||||
func _try_place(type: String) -> void:
|
||||
if not GameState.spend_resources(GameState.building_costs(type)):
|
||||
if not GameState.spend_resources(GameState.building_costs(type), fleet.get_centroid()):
|
||||
build_menu.set_status(_cannot_afford(type))
|
||||
return
|
||||
building_field.place(type, fleet.get_centroid())
|
||||
|
|
@ -452,7 +452,12 @@ func _try_place(type: String) -> void:
|
|||
|
||||
|
||||
func _on_unlock_requested(id: String) -> void:
|
||||
if not GameState.unlock(id):
|
||||
var research_building: Dictionary = GameState.find_building(skill_menu.building_id)
|
||||
if research_building.is_empty():
|
||||
skill_menu.set_status("The research building is no longer available")
|
||||
return
|
||||
var payment_position: Variant = research_building.get("position", null)
|
||||
if not GameState.unlock(id, payment_position):
|
||||
skill_menu.refresh(id)
|
||||
return
|
||||
if int(GameState.skill_node(id).get("fleet_bonus", 0)) > 0:
|
||||
|
|
|
|||
Loading…
Reference in a new issue