Show side event markers
This commit is contained in:
@@ -1749,6 +1749,67 @@ func get_objective_cell_label(cell: Vector2i) -> String:
|
||||
return _objective_cell_label_for_condition(battle_conditions.get("victory", {}), cell)
|
||||
|
||||
|
||||
func get_event_markers() -> Array[Dictionary]:
|
||||
var result: Array[Dictionary] = []
|
||||
var objective_cells := get_objective_cells()
|
||||
for event in battle_events:
|
||||
var event_id := str(event.get("id", ""))
|
||||
if bool(event.get("once", false)) and fired_event_ids.has(event_id):
|
||||
continue
|
||||
var when: Dictionary = event.get("when", {})
|
||||
if str(when.get("type", "")) != "unit_reaches_tile":
|
||||
continue
|
||||
if not _event_gate_open(when) or not _campaign_flags_match(when.get("campaign_flags", {})):
|
||||
continue
|
||||
if not _event_has_reward_action(event):
|
||||
continue
|
||||
var cells: Array[Vector2i] = []
|
||||
for cell in _condition_cells(when):
|
||||
if not objective_cells.has(cell) and not cells.has(cell):
|
||||
cells.append(cell)
|
||||
if cells.is_empty():
|
||||
continue
|
||||
result.append({
|
||||
"id": event_id,
|
||||
"label": _event_marker_label(event),
|
||||
"kind": _event_marker_kind(event),
|
||||
"cells": cells
|
||||
})
|
||||
return result
|
||||
|
||||
|
||||
func get_event_marker_cells() -> Array[Vector2i]:
|
||||
var result: Array[Vector2i] = []
|
||||
for marker in get_event_markers():
|
||||
var cells = marker.get("cells", [])
|
||||
if typeof(cells) != TYPE_ARRAY:
|
||||
continue
|
||||
for cell in cells:
|
||||
if typeof(cell) == TYPE_VECTOR2I and not result.has(cell):
|
||||
result.append(cell)
|
||||
return result
|
||||
|
||||
|
||||
func get_event_marker_label(cell: Vector2i) -> String:
|
||||
if not is_inside(cell):
|
||||
return ""
|
||||
for marker in get_event_markers():
|
||||
var cells = marker.get("cells", [])
|
||||
if typeof(cells) == TYPE_ARRAY and cells.has(cell):
|
||||
return str(marker.get("label", "전장 표식"))
|
||||
return ""
|
||||
|
||||
|
||||
func get_event_marker_kind(cell: Vector2i) -> String:
|
||||
if not is_inside(cell):
|
||||
return ""
|
||||
for marker in get_event_markers():
|
||||
var cells = marker.get("cells", [])
|
||||
if typeof(cells) == TYPE_ARRAY and cells.has(cell):
|
||||
return str(marker.get("kind", "event"))
|
||||
return ""
|
||||
|
||||
|
||||
func get_objective_progress_lines(include_defeat_risks := false, include_turn_limit := true) -> Array[String]:
|
||||
var result: Array[String] = []
|
||||
_append_condition_progress_lines(battle_conditions.get("victory", {}), result, "victory")
|
||||
@@ -4260,6 +4321,47 @@ func _objective_cell_label_for_after_event(event_id: String, cell: Vector2i) ->
|
||||
return ""
|
||||
|
||||
|
||||
func _event_has_reward_action(event: Dictionary) -> bool:
|
||||
for action in event.get("actions", []):
|
||||
if typeof(action) != TYPE_DICTIONARY:
|
||||
continue
|
||||
var action_type := str((action as Dictionary).get("type", ""))
|
||||
if action_type == "grant_item" or action_type == "grant_items" or action_type == "grant_gold":
|
||||
return true
|
||||
return false
|
||||
|
||||
|
||||
func _event_marker_label(event: Dictionary) -> String:
|
||||
var when: Dictionary = event.get("when", {})
|
||||
var label := _condition_destination_label(when)
|
||||
if label != "전장 표식":
|
||||
return label
|
||||
var kind := _event_marker_kind(event)
|
||||
if kind == "gold":
|
||||
return "군자금"
|
||||
if kind == "supply":
|
||||
return "보급"
|
||||
return "전장 표식"
|
||||
|
||||
|
||||
func _event_marker_kind(event: Dictionary) -> String:
|
||||
var has_item := false
|
||||
var has_gold := false
|
||||
for action in event.get("actions", []):
|
||||
if typeof(action) != TYPE_DICTIONARY:
|
||||
continue
|
||||
var action_type := str((action as Dictionary).get("type", ""))
|
||||
if action_type == "grant_item" or action_type == "grant_items":
|
||||
has_item = true
|
||||
elif action_type == "grant_gold":
|
||||
has_gold = true
|
||||
if has_gold and not has_item:
|
||||
return "gold"
|
||||
if has_item:
|
||||
return "supply"
|
||||
return "event"
|
||||
|
||||
|
||||
func _find_turn_limit(condition_group) -> int:
|
||||
if typeof(condition_group) == TYPE_ARRAY:
|
||||
var best_limit := 0
|
||||
|
||||
Reference in New Issue
Block a user