Clarify battle HUD action affordances
This commit is contained in:
@@ -2117,12 +2117,13 @@ func _format_unit_focus_text(unit: Dictionary, prefix: String) -> String:
|
||||
int(unit.get("int", 0)),
|
||||
int(unit.get("agi", 0))
|
||||
])
|
||||
lines.append("MOV %d %s RNG %d-%d" % [
|
||||
lines.append("Move %d (%s) Attack range %d-%d" % [
|
||||
int(unit.get("move", 0)),
|
||||
_format_move_type(str(unit.get("move_type", "foot"))),
|
||||
int(unit.get("min_range", 1)),
|
||||
int(unit.get("range", 1))
|
||||
])
|
||||
lines.append(_unit_action_status_text(unit))
|
||||
var terrain_text := _unit_current_terrain_text(unit)
|
||||
if not terrain_text.is_empty():
|
||||
lines.append(terrain_text)
|
||||
@@ -2132,6 +2133,45 @@ func _format_unit_focus_text(unit: Dictionary, prefix: String) -> String:
|
||||
return _join_strings(lines, "\n")
|
||||
|
||||
|
||||
func _unit_action_status_text(unit: Dictionary) -> String:
|
||||
var unit_id := str(unit.get("id", ""))
|
||||
if unit_id.is_empty():
|
||||
return "Action: Unavailable"
|
||||
var team := str(unit.get("team", ""))
|
||||
if team != BattleState.TEAM_PLAYER:
|
||||
return "Action: Enemy AI"
|
||||
if not bool(unit.get("controllable", true)):
|
||||
return "Action: Protected escort"
|
||||
if not bool(unit.get("alive", true)) or not bool(unit.get("deployed", true)):
|
||||
return "Action: Unavailable"
|
||||
if bool(unit.get("acted", false)):
|
||||
return "Action: Done"
|
||||
if not state.can_player_act():
|
||||
return "Action: Waiting turn"
|
||||
var actions: Array[String] = []
|
||||
if not bool(unit.get("moved", false)) and not state.get_movement_range(unit_id).is_empty():
|
||||
actions.append("Move")
|
||||
if not state.get_attack_cells(unit_id).is_empty():
|
||||
actions.append("Attack")
|
||||
var skill_id := state.get_first_usable_skill_id(unit_id)
|
||||
if not skill_id.is_empty() and not state.get_skill_cells(unit_id, skill_id).is_empty():
|
||||
actions.append("Tactic")
|
||||
if _unit_has_usable_item_target(unit_id):
|
||||
actions.append("Item")
|
||||
if not bool(unit.get("moved", false)):
|
||||
actions.append("Equip")
|
||||
actions.append("Wait")
|
||||
var suffix := " (moved)" if bool(unit.get("moved", false)) else ""
|
||||
return "Action: %s%s" % [_join_strings(actions, ", "), suffix]
|
||||
|
||||
|
||||
func _unit_has_usable_item_target(unit_id: String) -> bool:
|
||||
for item_id in state.get_usable_item_ids():
|
||||
if not state.get_item_target_cells(unit_id, str(item_id)).is_empty():
|
||||
return true
|
||||
return false
|
||||
|
||||
|
||||
func _unit_role_text(unit: Dictionary) -> String:
|
||||
var class_id := str(unit.get("class_id", ""))
|
||||
if class_id.contains("cavalry"):
|
||||
|
||||
Reference in New Issue
Block a user