fix: exercise routed input and resolve E binding
This commit is contained in:
@@ -18,6 +18,7 @@ func test_real_game_exposes_door_and_stairs_prompts_with_help_and_event_log() ->
|
||||
assert_eq(hud.get_context_prompt(), "Espace — Ouvrir la porte")
|
||||
assert_eq(prompt_label.text, "Espace — Ouvrir la porte")
|
||||
assert_string_contains(help_label.text, "Déplacer : ZQSD / Flèches")
|
||||
assert_string_contains(help_label.text, "nord-est : pavé num. 9")
|
||||
assert_string_contains(help_label.text, "Interagir : Espace ou E")
|
||||
|
||||
var interact_event := InputEventKey.new()
|
||||
|
||||
@@ -8,22 +8,22 @@ func before_each() -> void:
|
||||
add_child_autofree(game)
|
||||
await get_tree().process_frame
|
||||
|
||||
func test_real_keyboard_input_routes_movement_and_interaction_through_action_router() -> void:
|
||||
func test_input_pipeline_routes_e_interaction_and_movement_through_action_router() -> void:
|
||||
var state := game.get_game_state()
|
||||
var start_cell := state.player.cell
|
||||
|
||||
game._unhandled_input(_key_event(KEY_SPACE))
|
||||
await _dispatch_key(KEY_E)
|
||||
assert_eq(state.map.get_cell(Vector2i(4, 11)), GridMapState.CellKind.FLOOR)
|
||||
assert_eq(game.get_run_state().recent_events(2)[0].kind, &"door_opened")
|
||||
|
||||
game._unhandled_input(_key_event(KEY_DOWN))
|
||||
await _dispatch_key(KEY_DOWN)
|
||||
assert_eq(state.player.cell, start_cell + Vector2i.DOWN)
|
||||
assert_eq(game.get_run_state().recent_events(2)[0].kind, &"moved")
|
||||
|
||||
func test_real_future_command_input_records_unavailable_event_in_the_journal_and_hud() -> void:
|
||||
func test_input_pipeline_routes_unavailable_input_to_the_journal_and_hud() -> void:
|
||||
var event_log := game.get_node("HUD/EventLog") as RichTextLabel
|
||||
|
||||
game._unhandled_input(_key_event(KEY_I))
|
||||
await _dispatch_key(KEY_I)
|
||||
|
||||
var event := game.get_run_state().recent_events(1)[0]
|
||||
assert_eq(event.kind, &"action_unavailable")
|
||||
@@ -31,9 +31,15 @@ func test_real_future_command_input_records_unavailable_event_in_the_journal_and
|
||||
assert_eq(event.turn, 1)
|
||||
assert_string_contains(event_log.get_parsed_text(), "inventory")
|
||||
|
||||
func _key_event(keycode: Key) -> InputEventKey:
|
||||
func _dispatch_key(keycode: Key) -> void:
|
||||
Input.parse_input_event(_key_event(keycode, true))
|
||||
await get_tree().process_frame
|
||||
Input.parse_input_event(_key_event(keycode, false))
|
||||
await get_tree().process_frame
|
||||
|
||||
func _key_event(keycode: Key, pressed: bool) -> InputEventKey:
|
||||
var event := InputEventKey.new()
|
||||
event.keycode = keycode
|
||||
event.physical_keycode = keycode
|
||||
event.pressed = true
|
||||
event.pressed = pressed
|
||||
return event
|
||||
|
||||
@@ -11,6 +11,15 @@ func test_every_declared_input_action_is_registered_and_has_user_facing_help() -
|
||||
assert_gt(InputMap.action_get_events(input_action).size(), 0, "Missing keyboard binding: %s" % input_action)
|
||||
assert_ne(InputBindings.help_name_for(input_action), "", "Missing help name: %s" % input_action)
|
||||
|
||||
func test_interact_and_move_northeast_have_distinct_physical_bindings() -> void:
|
||||
var interact_e := _key_event(KEY_E)
|
||||
var northeast_keypad_9 := _key_event(KEY_KP_9)
|
||||
|
||||
assert_true(InputMap.action_has_event(&"interact", interact_e))
|
||||
assert_true(InputMap.action_has_event(&"move_northeast", northeast_keypad_9))
|
||||
assert_false(InputMap.action_has_event(&"move_northeast", interact_e))
|
||||
assert_false(InputMap.action_has_event(&"interact", northeast_keypad_9))
|
||||
|
||||
func test_action_from_input_maps_the_complete_command_vocabulary() -> void:
|
||||
var router := ActionRouter.new(null)
|
||||
var expected := {
|
||||
@@ -68,3 +77,10 @@ func _action_event(input_action: StringName) -> InputEventAction:
|
||||
event.action = input_action
|
||||
event.pressed = true
|
||||
return event
|
||||
|
||||
func _key_event(keycode: Key) -> InputEventKey:
|
||||
var event := InputEventKey.new()
|
||||
event.keycode = keycode
|
||||
event.physical_keycode = keycode
|
||||
event.pressed = true
|
||||
return event
|
||||
|
||||
@@ -13,6 +13,7 @@ func test_help_band_displays_the_exact_control_labels() -> void:
|
||||
|
||||
assert_not_null(help_label)
|
||||
assert_string_contains(help_label.text, "Déplacer : ZQSD / Flèches")
|
||||
assert_string_contains(help_label.text, "nord-est : pavé num. 9")
|
||||
assert_string_contains(help_label.text, "Interagir : Espace ou E")
|
||||
|
||||
func test_hud_uses_viewport_anchored_panels_with_distinct_stats_and_log_zones() -> void:
|
||||
|
||||
Reference in New Issue
Block a user