Add camp talk supply claims
This commit is contained in:
@@ -3457,6 +3457,9 @@ func _format_camp_conversation_button_text(conversation: Dictionary) -> String:
|
||||
parts.append(speaker)
|
||||
if not summary.is_empty():
|
||||
parts.append(summary)
|
||||
var effects_text := _format_camp_conversation_effects_text(conversation)
|
||||
if not effects_text.is_empty():
|
||||
parts.append(effects_text)
|
||||
return _join_strings(parts, " - ")
|
||||
|
||||
|
||||
@@ -3468,9 +3471,78 @@ func _on_camp_conversation_pressed(conversation_id: String) -> void:
|
||||
_play_ui_confirm()
|
||||
_hide_talk_menu()
|
||||
_show_camp_dialogue(conversation.get("lines", []))
|
||||
_apply_camp_conversation_effects(conversation)
|
||||
_update_hud()
|
||||
|
||||
|
||||
func _format_camp_conversation_effects_text(conversation: Dictionary) -> String:
|
||||
var effects: Array = conversation.get("effects", [])
|
||||
if effects.is_empty():
|
||||
return ""
|
||||
var parts := []
|
||||
for effect in effects:
|
||||
if typeof(effect) != TYPE_DICTIONARY:
|
||||
continue
|
||||
if str(effect.get("type", "")) != "grant_item":
|
||||
continue
|
||||
var item_id := str(effect.get("item_id", ""))
|
||||
var item := state.get_item_def(item_id)
|
||||
if item.is_empty():
|
||||
continue
|
||||
var count := maxi(1, int(effect.get("count", 1)))
|
||||
var count_text := "" if count == 1 else " x%d" % count
|
||||
parts.append("Supply %s%s" % [str(item.get("name", item_id)), count_text])
|
||||
if parts.is_empty():
|
||||
return ""
|
||||
var conversation_id := str(conversation.get("id", ""))
|
||||
var claimed_text := "claimed" if campaign_state.has_claimed_camp_conversation_effects(active_scenario_id, conversation_id) else "available"
|
||||
return "%s (%s)" % [_join_strings(parts, ", "), claimed_text]
|
||||
|
||||
|
||||
func _apply_camp_conversation_effects(conversation: Dictionary) -> void:
|
||||
if battle_started or _is_prebattle_prep_locked():
|
||||
return
|
||||
var conversation_id := str(conversation.get("id", ""))
|
||||
if conversation_id.is_empty():
|
||||
return
|
||||
if campaign_state.has_claimed_camp_conversation_effects(active_scenario_id, conversation_id):
|
||||
return
|
||||
var effects: Array = conversation.get("effects", [])
|
||||
if effects.is_empty():
|
||||
return
|
||||
if campaign_state.try_claim_camp_conversation_effects(active_scenario_id, conversation):
|
||||
state.set_inventory_snapshot(campaign_state.get_inventory_snapshot())
|
||||
_on_log_added(_format_camp_conversation_effect_claim_text(conversation))
|
||||
if talk_menu != null and talk_menu.visible:
|
||||
_rebuild_talk_menu()
|
||||
return
|
||||
_play_ui_cancel()
|
||||
_on_log_added("Could not claim camp supplies.")
|
||||
|
||||
|
||||
func _format_camp_conversation_effect_claim_text(conversation: Dictionary) -> String:
|
||||
var messages := []
|
||||
var effects: Array = conversation.get("effects", [])
|
||||
for effect in effects:
|
||||
if typeof(effect) != TYPE_DICTIONARY:
|
||||
continue
|
||||
if str(effect.get("type", "")) != "grant_item":
|
||||
continue
|
||||
var message := str(effect.get("text", "")).strip_edges()
|
||||
if not message.is_empty():
|
||||
messages.append(message)
|
||||
continue
|
||||
var item_id := str(effect.get("item_id", ""))
|
||||
if item_id.is_empty():
|
||||
continue
|
||||
var count := maxi(1, int(effect.get("count", 1)))
|
||||
var count_text := "" if count == 1 else " x%d" % count
|
||||
messages.append("Camp supplies received: %s%s." % [_item_display_name(item_id), count_text])
|
||||
if messages.is_empty():
|
||||
return "Camp supplies received."
|
||||
return _join_strings(messages, " ")
|
||||
|
||||
|
||||
func _camp_conversation_by_id(conversation_id: String) -> Dictionary:
|
||||
for conversation in _camp_conversation_entries():
|
||||
if str(conversation.get("id", "")) == conversation_id:
|
||||
@@ -4132,7 +4204,7 @@ func _apply_item_button_icon(button: Button, item: Dictionary) -> void:
|
||||
return
|
||||
button.icon = icon
|
||||
button.expand_icon = true
|
||||
button.icon_max_width = 30
|
||||
button.add_theme_constant_override("icon_max_width", 30)
|
||||
|
||||
|
||||
func _on_shop_item_pressed(item_id: String) -> void:
|
||||
|
||||
Reference in New Issue
Block a user