Add post-move attack targeting hints
This commit is contained in:
@@ -117,6 +117,95 @@ func _check_scene_post_move_menu_flow(failures: Array[String]) -> void:
|
||||
if not scene.state.get_selected_unit().is_empty() or scene._has_pending_move():
|
||||
failures.append("post-move Wait should clear selection and pending metadata")
|
||||
|
||||
_check_scene_post_move_attack_targeting(failures)
|
||||
|
||||
scene.free()
|
||||
|
||||
|
||||
func _check_scene_post_move_attack_targeting(failures: Array[String]) -> void:
|
||||
var scene = BattleSceneScript.new()
|
||||
scene._create_hud()
|
||||
if not scene.state.load_battle("res://data/scenarios/001_yellow_turbans.json"):
|
||||
failures.append("could not load opening battle for attack targeting flow")
|
||||
scene.free()
|
||||
return
|
||||
scene.battle_started = true
|
||||
scene.campaign_complete_screen = false
|
||||
scene.briefing_panel.visible = false
|
||||
scene.result_panel.visible = false
|
||||
scene._clear_pending_move_state()
|
||||
|
||||
var enemy: Dictionary = scene.state.get_unit("yellow_turban_1")
|
||||
enemy["pos"] = Vector2i(3, 3)
|
||||
enemy["hp"] = 24
|
||||
enemy["def"] = 1
|
||||
var cao_cao: Dictionary = scene.state.get_unit("cao_cao")
|
||||
cao_cao["agi"] = 999
|
||||
cao_cao["atk"] = 60
|
||||
scene.state.rng.seed = 1
|
||||
|
||||
scene.state.battle_events.append({
|
||||
"id": "pending_attack_gold",
|
||||
"once": true,
|
||||
"when": {
|
||||
"type": "unit_reaches_tile",
|
||||
"unit_ids": ["cao_cao"],
|
||||
"pos": [2, 3]
|
||||
},
|
||||
"actions": [{"type": "grant_gold", "amount": 33}]
|
||||
})
|
||||
|
||||
if not scene.state.select_unit("cao_cao"):
|
||||
failures.append("could not select Cao Cao for attack targeting flow")
|
||||
scene.free()
|
||||
return
|
||||
scene._refresh_ranges()
|
||||
scene._handle_board_click(_screen_for_cell(Vector2i(2, 3)))
|
||||
if not scene._has_pending_move() or scene.post_move_menu == null or not scene.post_move_menu.visible:
|
||||
failures.append("attack targeting setup should leave the post-move menu visible")
|
||||
if scene.basic_attack_targeting:
|
||||
failures.append("attack targeting should be off before pressing Attack")
|
||||
if not scene.attack_cells.is_empty():
|
||||
failures.append("attack range should stay hidden before pressing Attack")
|
||||
if scene.state.get_battle_gold_reward() != 0:
|
||||
failures.append("attack setup should not commit pending move events early")
|
||||
|
||||
scene._on_post_move_attack_pressed()
|
||||
if not scene.basic_attack_targeting:
|
||||
failures.append("Attack should enter target selection mode")
|
||||
if scene.post_move_menu != null and scene.post_move_menu.visible:
|
||||
failures.append("post-move menu should hide while selecting an attack target")
|
||||
if scene.targeting_hint_panel == null or not scene.targeting_hint_panel.visible:
|
||||
failures.append("targeting hint panel should be visible during attack targeting")
|
||||
if not scene.attack_cells.has(Vector2i(3, 3)):
|
||||
failures.append("attack targeting should highlight the adjacent enemy cell")
|
||||
var markers := scene._attack_target_marker_entries()
|
||||
if markers.size() != 1 or markers[0].get("cell", Vector2i.ZERO) != Vector2i(3, 3):
|
||||
failures.append("attack target markers should include only the reachable enemy: %s" % str(markers))
|
||||
|
||||
scene._on_targeting_back_pressed()
|
||||
cao_cao = scene.state.get_unit("cao_cao")
|
||||
if scene.basic_attack_targeting or not scene._has_pending_move() or scene.post_move_menu == null or not scene.post_move_menu.visible:
|
||||
failures.append("Back should return to the post-move action menu")
|
||||
if cao_cao.get("pos", Vector2i.ZERO) != Vector2i(2, 3) or not bool(cao_cao.get("moved", false)) or bool(cao_cao.get("acted", false)):
|
||||
failures.append("Back should preserve the pending moved unit without acting")
|
||||
|
||||
scene._on_post_move_attack_pressed()
|
||||
var enemy_hp_before := int(enemy.get("hp", 0))
|
||||
scene._handle_board_click(_screen_for_cell(Vector2i(3, 3)))
|
||||
cao_cao = scene.state.get_unit("cao_cao")
|
||||
enemy = scene.state.get_unit("yellow_turban_1")
|
||||
if scene._has_pending_move() or scene.basic_attack_targeting:
|
||||
failures.append("attack click should clear pending move and targeting state")
|
||||
if not scene.state.get_selected_unit().is_empty():
|
||||
failures.append("attack click should clear selected unit after acting")
|
||||
if cao_cao.get("pos", Vector2i.ZERO) != Vector2i(2, 3) or not bool(cao_cao.get("moved", false)) or not bool(cao_cao.get("acted", false)):
|
||||
failures.append("attack click should commit the moved attacker action")
|
||||
if int(enemy.get("hp", 0)) >= enemy_hp_before and bool(enemy.get("alive", true)):
|
||||
failures.append("attack click should damage or defeat the target")
|
||||
if scene.state.get_battle_gold_reward() != 33:
|
||||
failures.append("attack click should commit deferred movement event before resolving attack")
|
||||
|
||||
scene.free()
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user