Add event gold pickups
This commit is contained in:
@@ -104,6 +104,7 @@ var battle_events: Array[Dictionary] = []
|
||||
var fired_event_ids := {}
|
||||
var roster_overrides_snapshot := {}
|
||||
var battle_inventory := {}
|
||||
var battle_gold_reward := 0
|
||||
var campaign_flags := {}
|
||||
var campaign_joined_officers := {}
|
||||
var progression_events: Array[Dictionary] = []
|
||||
@@ -170,6 +171,7 @@ func _apply_battle_data(data: Dictionary, roster_overrides := {}) -> void:
|
||||
if typeof(event) == TYPE_DICTIONARY:
|
||||
battle_events.append(event)
|
||||
fired_event_ids.clear()
|
||||
battle_gold_reward = 0
|
||||
progression_events.clear()
|
||||
|
||||
var map_data: Dictionary = data.get("map", {})
|
||||
@@ -1824,6 +1826,10 @@ func set_inventory_snapshot(inventory_snapshot: Dictionary) -> void:
|
||||
_notify_changed()
|
||||
|
||||
|
||||
func get_battle_gold_reward() -> int:
|
||||
return max(0, battle_gold_reward)
|
||||
|
||||
|
||||
func get_terrain_key(cell: Vector2i) -> String:
|
||||
if not is_inside(cell):
|
||||
return "G"
|
||||
@@ -3774,6 +3780,8 @@ func _execute_event_action(action: Dictionary, trigger_unit: Dictionary = {}) ->
|
||||
_grant_event_item(action, trigger_unit)
|
||||
elif action_type == "grant_items":
|
||||
_grant_event_items(action.get("items", []), trigger_unit)
|
||||
elif action_type == "grant_gold":
|
||||
_grant_event_gold(action, trigger_unit)
|
||||
elif action_type == "spawn_deployment":
|
||||
_spawn_event_deployment(action.get("deployment", {}))
|
||||
elif action_type == "spawn_deployments":
|
||||
@@ -3828,6 +3836,21 @@ func _grant_event_item(action: Dictionary, trigger_unit: Dictionary = {}) -> boo
|
||||
return true
|
||||
|
||||
|
||||
func _grant_event_gold(action: Dictionary, trigger_unit: Dictionary = {}) -> bool:
|
||||
var amount := maxi(0, int(action.get("amount", action.get("gold", 0))))
|
||||
if amount <= 0:
|
||||
push_error("Skipping event gold grant with invalid amount in %s." % battle_id)
|
||||
return false
|
||||
battle_gold_reward += amount
|
||||
var text := str(action.get("text", "")).strip_edges()
|
||||
if text.is_empty():
|
||||
text = "Received %d gold." % amount
|
||||
_emit_log(text)
|
||||
if not trigger_unit.is_empty() and bool(trigger_unit.get("alive", false)):
|
||||
_emit_combat_feedback(trigger_unit, "+%dG" % amount, "gold")
|
||||
return true
|
||||
|
||||
|
||||
func _set_event_ai_target_priority(action: Dictionary) -> void:
|
||||
var unit_ids := _event_action_unit_ids(action)
|
||||
if unit_ids.is_empty():
|
||||
|
||||
@@ -278,7 +278,7 @@ func apply_battle_result(battle_state) -> Dictionary:
|
||||
inventory = battle_state.get_inventory_snapshot()
|
||||
|
||||
completed_scenarios.append(battle_state.battle_id)
|
||||
reward_gold = int(rewards.get("gold", 0))
|
||||
reward_gold = int(rewards.get("gold", 0)) + int(battle_state.get_battle_gold_reward())
|
||||
gold += reward_gold
|
||||
|
||||
for item_id in rewards.get("items", []):
|
||||
|
||||
Reference in New Issue
Block a user