S6.2: 30x20 demo map and chest interaction #11
@@ -0,0 +1,71 @@
|
||||
# S6.2 — Carte démo 30×20, porte guidée et coffre ouvrable
|
||||
|
||||
- **Worktree :** `/home/hectelyon/Documents/Projects/ProjetsPersos/DungeonCrawlerWorld/.worktrees/s6-2`
|
||||
- **Spécification :** `.claude/work/dcw-s6-visual-readability/spec.md`, `SLICE-6-2-demo-map.md`
|
||||
- **Périmètre :** carte de démonstration, interactions porte/coffre/escalier et leurs tests. Aucun loot, inventaire, niveau supplémentaire ou asset nouveau.
|
||||
|
||||
## Livraison
|
||||
|
||||
- La carte initiale est une grille **30×20** de salles et couloirs. Le joueur commence en `(4, 12)`, devant la porte fermée `(4, 11)` ; le coffre est en `(4, 7)`, et l'escalier en `(18, 4)`.
|
||||
- Un coffre fermé est maintenant non praticable et opaque. Tenter d'y entrer renvoie donc `blocked`, sans tour ennemi.
|
||||
- `GameState.get_context_target()` et `InteractionResolver` partagent `InteractionResolver.TARGET_OFFSETS`. La priorité est : sortie déjà atteinte, escalier sous le joueur, coffre (sous le joueur ou dans l'ordre des offsets), porte, puis aucune interaction.
|
||||
- `Espace` et `E` ouvrent un coffre ciblé : `CHEST` devient `FLOOR`, le résultat est `chest_opened` avec le texte exact `You open the chest.`, l'exploration/FOV est recalculée et une seule réponse ennemie normale au plus est ajoutée.
|
||||
- Le HUD affiche exactement `Espace — Ouvrir le coffre` tant que le coffre est la cible de contexte. La documentation décrit aussi le comportement et l'absence volontaire de loot/inventaire.
|
||||
- Le parcours réel E2E utilise des `InputEvent` : porte (`E`, en conservant ainsi une preuve du binding alternatif), blocage sur coffre fermé, coffre (`Espace`, avec assertion explicite de `chest_opened` puis `FLOOR`), puis escalier (Espace).
|
||||
|
||||
## Couverture TDD
|
||||
|
||||
### RED historique reconstruit et durable
|
||||
|
||||
La preuve RED manquante a été reconstruite sur le baseline **`b5eaf0e`**, dans un worktree détaché, avant tout changement de production. Le test minimal crée une case `CHEST` adjacente et exige que `state.try_interact()` retourne `results[0].kind == &"chest_opened"`. Il échoue bien (statut 1) avec :
|
||||
|
||||
```text
|
||||
[STRING_NAME(nothing_to_interact)] expected to equal [STRING_NAME(chest_opened)]
|
||||
```
|
||||
|
||||
La source exacte et le journal GUT assaini sont versionnés ici afin que cette preuve reste consultable :
|
||||
|
||||
- `tdd-red-chest-contract-b5eaf0e.gd` ;
|
||||
- `tdd-red-chest-contract-b5eaf0e.txt`.
|
||||
|
||||
`./scripts/test-unit.sh` ne découvre volontairement que `res://tests/unit`; la reconstruction temporaire a donc été exécutée directement avec GUT et `-gdir=res://tests/tdd_red`, comme indiqué dans le journal. Le test GREEN permanent correspondant est `tests/unit/test_chest_interaction.gd`.
|
||||
|
||||
Les tests ajoutés couvrent les conditions des micro-tâches :
|
||||
|
||||
- M1 : dimensions 30×20, spawn et positions/route porte-coffre-escalier (`test_demo_map.gd`) ;
|
||||
- M2 : coffre fermé non praticable et mouvement bloqué sans réponse ennemie (`test_chest_interaction.gd`) ;
|
||||
- M3 : texte et durée du prompt coffre (`test_hud_chest_prompt.gd`) ;
|
||||
- M4 : `chest_opened`, texte exact, remplacement par sol, FOV et unique réponse ennemie (`test_chest_interaction.gd`) ;
|
||||
- M5 : scène `Game.tscn` et événements clavier réels pour le parcours intégral (`test_demo_map_chest_e2e.gd`) ; `E` reste vérifié sur la porte et `Espace` ouvre explicitement le coffre avec les assertions `chest_opened` et `FLOOR`.
|
||||
|
||||
`test_combat_hud_e2e.gd` rétablit les invariants de régression retirés lors de l'adaptation 30×20 : mur et porte bloqués sans tour ennemi, cellule joueur inchangée, dégâts/HP joueur et feedback visuel, messages du journal, HP et résumé de combat avant/après coup, puis suppression de la cible et résumé final après défaite.
|
||||
|
||||
Les tests existants adaptés à l'extension 30×20 conservent leurs invariants fonctionnels (combat, audio, FOV, caméra, HUD, porte et escalier) sans dépendre de l'ancien layout 12×10.
|
||||
|
||||
## Vérification finale
|
||||
|
||||
Exécutée avec Godot **4.5.0** (`/snap/bin/godot4`) :
|
||||
|
||||
```text
|
||||
./scripts/test-unit.sh PASS — 33 tests, 163 assertions
|
||||
./scripts/test-e2e.sh PASS — 12 tests, 147 assertions
|
||||
./scripts/run-visual-check.sh PASS — Xvfb, deux captures PNG 1280×720
|
||||
./scripts/verify.sh PASS — unit + E2E + visual
|
||||
|
||||
git diff --check PASS
|
||||
```
|
||||
|
||||
Le contrôle visuel Xvfb a produit et validé les captures ignorées `artifacts/visual-check.png` et `artifacts/visual-check-exit.png` :
|
||||
|
||||
```text
|
||||
initial : dungeon_non_black_pixels=489308, unknown_pixels=366972,
|
||||
unknown_luminance=0.002
|
||||
sortie : dungeon_non_black_pixels=488516, unknown_pixels=196792,
|
||||
unknown_luminance=0.002, detected_explored_luminance=0.815
|
||||
```
|
||||
|
||||
Les avertissements de ressources UID de GUT, `ObjectDB instances leaked at exit`, et les messages `xkbcommon` Compose de Snap/Xvfb sont des diagnostics préexistants/de l'environnement. Ils ne sont pas des `SCRIPT ERROR` ou `Parse Error`; aucune suite ne les a traités comme une erreur applicative.
|
||||
|
||||
## Git
|
||||
|
||||
Rapport finalisé avant le commit local S6.2. Aucun push ni PR.
|
||||
@@ -0,0 +1,23 @@
|
||||
# Historical RED reconstruction source
|
||||
#
|
||||
# Executed unchanged in a detached worktree at b5eaf0e with:
|
||||
# /snap/bin/godot4 --headless --path . -s res://addons/gut/gut_cmdln.gd \
|
||||
# -gdir=res://tests/tdd_red -gexit
|
||||
#
|
||||
# It is preserved as S6.2 TDD evidence rather than placed under tests/, because
|
||||
# its assertion intentionally fails before chest interaction is implemented.
|
||||
extends GutTest
|
||||
|
||||
const GridMapState = preload("res://scripts/domain/grid_map_state.gd")
|
||||
const ActorState = preload("res://scripts/domain/actor_state.gd")
|
||||
const GameState = preload("res://scripts/domain/game_state.gd")
|
||||
|
||||
func test_interacting_with_a_chest_reports_chest_opened() -> void:
|
||||
var chest := Vector2i(3, 2)
|
||||
var map := GridMapState.new(Vector2i(9, 7), GridMapState.CellKind.FLOOR)
|
||||
map.set_cell(chest, GridMapState.CellKind.CHEST)
|
||||
var state := GameState.new(map, ActorState.new(&"player", Vector2i(3, 3), 12, 3), {})
|
||||
|
||||
var results := state.try_interact()
|
||||
|
||||
assert_eq(results[0].kind, &"chest_opened")
|
||||
@@ -0,0 +1,43 @@
|
||||
S6.2 historical TDD RED reconstruction
|
||||
=======================================
|
||||
|
||||
Baseline revision: b5eaf0e
|
||||
Detached worktree: /home/hectelyon/Documents/Projects/ProjetsPersos/DungeonCrawlerWorld/.worktrees/s6-2-chest-red-b5eaf0e
|
||||
Test source preserved beside this log as tdd-red-chest-contract-b5eaf0e.gd.
|
||||
|
||||
Command (run from the detached b5eaf0e worktree):
|
||||
/snap/bin/godot4 --headless --path . -s res://addons/gut/gut_cmdln.gd \
|
||||
-gdir=res://tests/tdd_red -gexit
|
||||
|
||||
Exit status: 1 (expected RED)
|
||||
|
||||
Relevant sanitized GUT output:
|
||||
|
||||
res://tests/tdd_red/test_chest_contract_red.gd
|
||||
* test_interacting_with_a_chest_reports_chest_opened
|
||||
[Failed]: [STRING_NAME(nothing_to_interact)] expected to equal [STRING_NAME(chest_opened)]:
|
||||
at line 15
|
||||
0/1 passed.
|
||||
|
||||
==============================================
|
||||
= Run Summary
|
||||
==============================================
|
||||
|
||||
res://tests/tdd_red/test_chest_contract_red.gd
|
||||
- test_interacting_with_a_chest_reports_chest_opened
|
||||
[Failed]: [STRING_NAME(nothing_to_interact)] expected to equal [STRING_NAME(chest_opened)]:
|
||||
at line 15
|
||||
|
||||
Totals
|
||||
------
|
||||
Scripts 1
|
||||
Tests 1
|
||||
Passing Tests none
|
||||
Failing Tests 1
|
||||
Asserts 0/1
|
||||
|
||||
---- 1 failing tests ----
|
||||
|
||||
Note: ./scripts/test-unit.sh intentionally targets res://tests/unit only, so it
|
||||
cannot execute this temporary res://tests/tdd_red reconstruction. The direct
|
||||
GUT command above is therefore the authoritative RED command.
|
||||
@@ -10,7 +10,7 @@ Godot 4.2+ is required (verified with Godot 4.5). GUT **9.5.0** is vendored and
|
||||
"${GODOT_BIN:-$(command -v godot4 || command -v godot)}" --path .
|
||||
```
|
||||
|
||||
Use WASD / arrow keys (and QZC diagonals). The HUD help band uses the French labels `Déplacer : ZQSD / Flèches` and `Interagir : Espace ou E`; both **Space** and **E** are bound to `interact`. `Game.submit_test_action(Vector2i)` and `Game.submit_test_interact()` are deterministic public E2E seams and follow the same processors as keyboard input. Interacting with an adjacent closed door opens it into floor space, logs the action, refreshes FOV, and gives living enemies exactly one normal response; interacting with no target only logs `nothing_to_interact` and does not consume an enemy turn. Interacting while standing on stairs logs `stairs_used`, sets the demonstration exit state, and gives living enemies exactly one normal response.
|
||||
Use WASD / arrow keys (and QZC diagonals). The HUD help band uses the French labels `Déplacer : ZQSD / Flèches` and `Interagir : Espace ou E`; both **Space** and **E** are bound to `interact`. `Game.submit_test_action(Vector2i)` and `Game.submit_test_interact()` are deterministic public E2E seams and follow the same processors as keyboard input. Interacting with an adjacent closed door opens it into floor space, logs the action, refreshes FOV, and gives living enemies exactly one normal response. A closed chest is likewise non-walkable; interacting with it replaces it with floor, logs `chest_opened` as `You open the chest.`, refreshes FOV, and gives at most one normal enemy response. It deliberately grants no loot or inventory item. Interacting with no target only logs `nothing_to_interact` and does not consume an enemy turn. Interacting while standing on stairs logs `stairs_used`, sets the demonstration exit state, and gives living enemies exactly one normal response.
|
||||
|
||||
## Display, grid, and camera
|
||||
|
||||
@@ -75,7 +75,7 @@ GODOT_BIN=/snap/bin/godot4 timeout 3s /snap/bin/godot4 --headless --path .
|
||||
- `GameState.visible_cells` render at full brightness; cells retained in `explored_cells` have a pale-blue readable overlay (tint luminance ≥ 0.55); unknown cells are distinguishable blue-black.
|
||||
- FOV is map-aware: walls and closed doors are visible but block cells behind them.
|
||||
- `HUD/PlayerHealthLabel`, `HUD/EnemyHealthLabel`, `HUD/CombatSummaryLabel`, and `HUD/EventLog` expose the current combat state. Their historical public paths are retained while viewport-anchored HUD panels separate stats, journal, contextual prompt, and help.
|
||||
- `HUD/ContextPromptLabel` mirrors `GameHud.get_context_prompt()`: a closed door adjacent to the player reads `Espace — Ouvrir la porte`; stairs under the player read `Espace — Descendre l’escalier`; a reached exit reads `Sortie atteinte — prochain étage bientôt disponible`; otherwise it is empty. Using stairs sets only `GameState.exit_reached`, logs `stairs_used`, and leaves the player and current map in place.
|
||||
- `HUD/ContextPromptLabel` mirrors `GameHud.get_context_prompt()`: stairs under the player take priority and read `Espace — Descendre l’escalier`; otherwise an adjacent closed chest reads `Espace — Ouvrir le coffre` before an adjacent closed door can read `Espace — Ouvrir la porte`; a reached exit reads `Sortie atteinte — prochain étage bientôt disponible`; otherwise it is empty. Using stairs sets only `GameState.exit_reached`, logs `stairs_used`, and leaves the player and current map in place.
|
||||
- Every `melee` and `enemy_melee` result is routed to its actor view; the sprite's persistent red tint makes received damage visible.
|
||||
|
||||
## Exports
|
||||
|
||||
@@ -22,7 +22,10 @@ func get_context_target() -> StringName:
|
||||
return &"exit_reached"
|
||||
if map.get_cell(player.cell) == GridMapState.CellKind.STAIRS:
|
||||
return &"stairs"
|
||||
for direction in [Vector2i.UP, Vector2i.RIGHT, Vector2i.DOWN, Vector2i.LEFT, Vector2i(1, -1), Vector2i(1, 1), Vector2i(-1, 1), Vector2i(-1, -1)]:
|
||||
for direction in InteractionResolverType.TARGET_OFFSETS:
|
||||
if map.get_cell(player.cell + direction) == GridMapState.CellKind.CHEST:
|
||||
return &"chest"
|
||||
for direction in InteractionResolverType.TARGET_OFFSETS:
|
||||
if map.get_cell(player.cell + direction) == GridMapState.CellKind.CLOSED_DOOR:
|
||||
return &"closed_door"
|
||||
return &""
|
||||
|
||||
@@ -25,8 +25,8 @@ func is_inside(cell: Vector2i) -> bool:
|
||||
|
||||
func is_walkable(cell: Vector2i) -> bool:
|
||||
var kind := get_cell(cell)
|
||||
return kind == CellKind.FLOOR or kind == CellKind.CHEST or kind == CellKind.STAIRS
|
||||
return kind == CellKind.FLOOR or kind == CellKind.STAIRS
|
||||
|
||||
func is_opaque(cell: Vector2i) -> bool:
|
||||
var kind := get_cell(cell)
|
||||
return kind == CellKind.WALL or kind == CellKind.CLOSED_DOOR
|
||||
return kind == CellKind.WALL or kind == CellKind.CLOSED_DOOR or kind == CellKind.CHEST
|
||||
|
||||
@@ -24,7 +24,14 @@ static func resolve(state: GameState) -> Array[TurnResult]:
|
||||
TurnResolverType.append_enemy_response(state, results)
|
||||
return results
|
||||
|
||||
var door_cell := _find_closed_door(state)
|
||||
var chest_cell := _find_cell_of_kind(state, GridMapState.CellKind.CHEST)
|
||||
if chest_cell.x >= 0:
|
||||
state.map.set_cell(chest_cell, GridMapState.CellKind.FLOOR)
|
||||
results.append(TurnResultType.new(state.player.id, &"chest_opened", state.player.cell, chest_cell, &"", 0, "You open the chest."))
|
||||
TurnResolverType.append_enemy_response(state, results)
|
||||
return results
|
||||
|
||||
var door_cell := _find_cell_of_kind(state, GridMapState.CellKind.CLOSED_DOOR)
|
||||
if door_cell.x >= 0:
|
||||
state.map.set_cell(door_cell, GridMapState.CellKind.FLOOR)
|
||||
results.append(TurnResultType.new(state.player.id, &"door_opened", state.player.cell, door_cell, &"", 0, "You open the door."))
|
||||
@@ -34,9 +41,9 @@ static func resolve(state: GameState) -> Array[TurnResult]:
|
||||
results.append(TurnResultType.new(state.player.id, &"nothing_to_interact", state.player.cell, state.player.cell, &"", 0, "Nothing to interact with."))
|
||||
return results
|
||||
|
||||
static func _find_closed_door(state: GameState) -> Vector2i:
|
||||
static func _find_cell_of_kind(state: GameState, kind: GridMapState.CellKind) -> Vector2i:
|
||||
for offset in TARGET_OFFSETS:
|
||||
var cell := state.player.cell + offset
|
||||
if state.map.get_cell(cell) == GridMapState.CellKind.CLOSED_DOOR:
|
||||
if state.map.get_cell(cell) == kind:
|
||||
return cell
|
||||
return Vector2i(-1, -1)
|
||||
|
||||
+40
-24
@@ -15,6 +15,7 @@ const ActorViewType = preload("res://scripts/presentation/actor_view.gd")
|
||||
@onready var audio_library = $AudioLibrary
|
||||
var game_state: GameState
|
||||
var enemy_views: Dictionary[StringName, ActorView] = {}
|
||||
var last_turn_results: Array[TurnResult] = []
|
||||
|
||||
func _ready() -> void:
|
||||
game_state = _create_initial_state()
|
||||
@@ -51,30 +52,31 @@ func _capture_visual_check(capture_mode: String) -> void:
|
||||
get_tree().quit(0 if result == OK else 1)
|
||||
|
||||
func _prepare_exit_capture_state() -> void:
|
||||
game_state.map.set_cell(Vector2i(2, 1), GridMapStateType.CellKind.FLOOR)
|
||||
game_state.player.cell = Vector2i(9, 7)
|
||||
game_state.map.set_cell(Vector2i(4, 10), GridMapStateType.CellKind.FLOOR)
|
||||
game_state.map.set_cell(Vector2i(4, 7), GridMapStateType.CellKind.FLOOR)
|
||||
game_state.player.cell = Vector2i(18, 4)
|
||||
_process_interact()
|
||||
_sync_camera_to_player()
|
||||
|
||||
func _unhandled_input(event: InputEvent) -> void:
|
||||
if event.is_action_pressed(&"interact"):
|
||||
submit_test_interact()
|
||||
last_turn_results = submit_test_interact()
|
||||
elif event.is_action_pressed(&"move_north"):
|
||||
_process_action(Vector2i.UP)
|
||||
last_turn_results = _process_action(Vector2i.UP)
|
||||
elif event.is_action_pressed(&"move_south"):
|
||||
_process_action(Vector2i.DOWN)
|
||||
last_turn_results = _process_action(Vector2i.DOWN)
|
||||
elif event.is_action_pressed(&"move_west"):
|
||||
_process_action(Vector2i.LEFT)
|
||||
last_turn_results = _process_action(Vector2i.LEFT)
|
||||
elif event.is_action_pressed(&"move_east"):
|
||||
_process_action(Vector2i.RIGHT)
|
||||
last_turn_results = _process_action(Vector2i.RIGHT)
|
||||
elif event.is_action_pressed(&"move_northwest"):
|
||||
_process_action(Vector2i(-1, -1))
|
||||
last_turn_results = _process_action(Vector2i(-1, -1))
|
||||
elif event.is_action_pressed(&"move_northeast"):
|
||||
_process_action(Vector2i(1, -1))
|
||||
last_turn_results = _process_action(Vector2i(1, -1))
|
||||
elif event.is_action_pressed(&"move_southwest"):
|
||||
_process_action(Vector2i(-1, 1))
|
||||
last_turn_results = _process_action(Vector2i(-1, 1))
|
||||
elif event.is_action_pressed(&"move_southeast"):
|
||||
_process_action(Vector2i(1, 1))
|
||||
last_turn_results = _process_action(Vector2i(1, 1))
|
||||
|
||||
func submit_test_action(direction: Vector2i) -> Array[TurnResult]:
|
||||
return _process_action(direction)
|
||||
@@ -139,21 +141,35 @@ func _show_damage_feedback(results: Array[TurnResult]) -> void:
|
||||
player_view.show_damage(result.damage)
|
||||
|
||||
func _create_initial_state() -> GameState:
|
||||
var map := GridMapStateType.new(Vector2i(12, 10), GridMapStateType.CellKind.FLOOR)
|
||||
for x in range(map.size.x):
|
||||
map.set_cell(Vector2i(x, 0), GridMapStateType.CellKind.WALL)
|
||||
map.set_cell(Vector2i(x, map.size.y - 1), GridMapStateType.CellKind.WALL)
|
||||
for y in range(map.size.y):
|
||||
map.set_cell(Vector2i(0, y), GridMapStateType.CellKind.WALL)
|
||||
map.set_cell(Vector2i(map.size.x - 1, y), GridMapStateType.CellKind.WALL)
|
||||
map.set_cell(Vector2i(1, 2), GridMapStateType.CellKind.WALL)
|
||||
map.set_cell(Vector2i(2, 1), GridMapStateType.CellKind.CLOSED_DOOR)
|
||||
map.set_cell(Vector2i(8, 3), GridMapStateType.CellKind.CHEST)
|
||||
map.set_cell(Vector2i(9, 7), GridMapStateType.CellKind.STAIRS)
|
||||
var player := ActorStateType.new(&"player", Vector2i(2, 2), 12, 3)
|
||||
var goblin := ActorStateType.new(&"goblin", Vector2i(4, 2), 6, 2)
|
||||
var map := GridMapStateType.new(Vector2i(30, 20), GridMapStateType.CellKind.WALL)
|
||||
_carve_room(map, Rect2i(2, 12, 6, 5))
|
||||
_carve_room(map, Rect2i(2, 4, 7, 7))
|
||||
_carve_room(map, Rect2i(10, 2, 10, 6))
|
||||
_carve_room(map, Rect2i(21, 5, 7, 8))
|
||||
_carve_vertical_corridor(map, 4, 10, 12)
|
||||
_carve_horizontal_corridor(map, 8, 10, 6)
|
||||
_carve_horizontal_corridor(map, 18, 21, 6)
|
||||
_carve_vertical_corridor(map, 18, 4, 6)
|
||||
map.set_cell(Vector2i(4, 11), GridMapStateType.CellKind.CLOSED_DOOR)
|
||||
map.set_cell(Vector2i(4, 7), GridMapStateType.CellKind.CHEST)
|
||||
map.set_cell(Vector2i(18, 4), GridMapStateType.CellKind.STAIRS)
|
||||
var player := ActorStateType.new(&"player", Vector2i(4, 12), 12, 3)
|
||||
var goblin := ActorStateType.new(&"goblin", Vector2i(24, 8), 6, 2)
|
||||
return GameStateType.new(map, player, {&"goblin": goblin})
|
||||
|
||||
func _carve_room(map: GridMapState, room: Rect2i) -> void:
|
||||
for y in range(room.position.y, room.end.y):
|
||||
for x in range(room.position.x, room.end.x):
|
||||
map.set_cell(Vector2i(x, y), GridMapStateType.CellKind.FLOOR)
|
||||
|
||||
func _carve_horizontal_corridor(map: GridMapState, from_x: int, to_x: int, y: int) -> void:
|
||||
for x in range(from_x, to_x + 1):
|
||||
map.set_cell(Vector2i(x, y), GridMapStateType.CellKind.FLOOR)
|
||||
|
||||
func _carve_vertical_corridor(map: GridMapState, x: int, from_y: int, to_y: int) -> void:
|
||||
for y in range(from_y, to_y + 1):
|
||||
map.set_cell(Vector2i(x, y), GridMapStateType.CellKind.FLOOR)
|
||||
|
||||
func _configure_camera() -> void:
|
||||
var map_size := game_state.map.size * TILE_SIZE
|
||||
camera.limit_left = $World.position.x
|
||||
|
||||
@@ -2,6 +2,7 @@ class_name GameHud
|
||||
extends CanvasLayer
|
||||
|
||||
const DOOR_PROMPT := "Espace — Ouvrir la porte"
|
||||
const CHEST_PROMPT := "Espace — Ouvrir le coffre"
|
||||
const STAIRS_PROMPT := "Espace — Descendre l’escalier"
|
||||
const EXIT_REACHED_PROMPT := "Sortie atteinte — prochain étage bientôt disponible"
|
||||
|
||||
@@ -32,6 +33,8 @@ func get_context_prompt() -> String:
|
||||
if _state == null:
|
||||
return ""
|
||||
match _state.get_context_target():
|
||||
&"chest":
|
||||
return CHEST_PROMPT
|
||||
&"closed_door":
|
||||
return DOOR_PROMPT
|
||||
&"stairs":
|
||||
|
||||
@@ -9,27 +9,26 @@ func before_each() -> void:
|
||||
await get_tree().process_frame
|
||||
|
||||
func test_configured_input_event_uses_the_same_action_path_as_submit_test_action() -> void:
|
||||
var state := game.get_game_state()
|
||||
var input_event := InputEventKey.new()
|
||||
input_event.physical_keycode = KEY_DOWN
|
||||
input_event.pressed = true
|
||||
game._unhandled_input(input_event)
|
||||
|
||||
assert_eq(game.get_game_state().player.cell, Vector2i(2, 3))
|
||||
assert_eq(game.get_node("HUD/EventLog").get_parsed_text(), "You move to (2, 3).\nThe goblin moves.\n")
|
||||
assert_eq(state.player.cell, Vector2i(4, 13))
|
||||
assert_eq(game.get_node("HUD/EventLog").get_parsed_text(), "You move to (4, 13).\nThe goblin moves.\n")
|
||||
|
||||
var submitted_game := GameScene.instantiate() as Game
|
||||
add_child_autofree(submitted_game)
|
||||
await get_tree().process_frame
|
||||
var test_results := submitted_game.submit_test_action(Vector2i.DOWN)
|
||||
|
||||
assert_eq(submitted_game.get_game_state().player.cell, Vector2i(2, 3))
|
||||
assert_eq(submitted_game.get_game_state().player.cell, Vector2i(4, 13))
|
||||
assert_eq(test_results.size(), 2)
|
||||
assert_eq(test_results[0].kind, &"moved")
|
||||
assert_eq(test_results[0].from_cell, Vector2i(2, 2))
|
||||
assert_eq(test_results[0].to_cell, Vector2i(2, 3))
|
||||
assert_eq(test_results[0].from_cell, Vector2i(4, 12))
|
||||
assert_eq(test_results[0].to_cell, Vector2i(4, 13))
|
||||
assert_eq(test_results[1].kind, &"enemy_moved")
|
||||
assert_eq(test_results[1].from_cell, Vector2i(4, 2))
|
||||
assert_eq(test_results[1].to_cell, Vector2i(3, 2))
|
||||
|
||||
func test_real_game_scene_completes_walking_combat_and_defeat_route() -> void:
|
||||
assert_not_null(game.get_node_or_null("World/MapRenderer"))
|
||||
@@ -47,22 +46,30 @@ func test_real_game_scene_completes_walking_combat_and_defeat_route() -> void:
|
||||
var enemy_view := game.get_node("World/Enemies/Goblin") as ActorView
|
||||
assert_eq(hud.combat_summary, "Target: Goblin HP: 6/6")
|
||||
assert_eq(hud.combat_summary_label.text, "Target: Goblin HP: 6/6")
|
||||
|
||||
# The new spawn is beside a wall and a closed door; neither consumes a turn.
|
||||
var start := state.player.cell
|
||||
var wall := game.submit_test_action(Vector2i.LEFT)
|
||||
var wall := game.submit_test_action(Vector2i(-1, -1))
|
||||
assert_eq(wall.size(), 1)
|
||||
assert_eq(wall[0].kind, &"blocked")
|
||||
assert_eq(state.player.cell, start)
|
||||
var door := game.submit_test_action(Vector2i.UP)
|
||||
assert_eq(door.size(), 1)
|
||||
assert_eq(door[0].kind, &"blocked")
|
||||
assert_eq(state.player.cell, start)
|
||||
assert_string_contains(game.get_node("HUD/EventLog").get_parsed_text(), "blocked")
|
||||
assert_string_contains(hud.event_log.get_parsed_text(), "Your way is blocked.")
|
||||
|
||||
# Move the existing goblin onto the adapted combat lane after the map assertions.
|
||||
state.enemies[&"goblin"].cell = start + Vector2i(2, 0)
|
||||
var movement := game.submit_test_action(Vector2i.RIGHT)
|
||||
assert_eq(movement[0].kind, &"moved")
|
||||
assert_eq(state.player.cell, start + Vector2i.RIGHT)
|
||||
assert_eq(movement[1].kind, &"enemy_melee")
|
||||
assert_eq(player_view.last_damage, 2)
|
||||
assert_string_contains(game.get_node("HUD/EventLog").get_parsed_text(), "You move")
|
||||
assert_string_contains(game.get_node("HUD/PlayerHealthLabel").text, "10/12")
|
||||
assert_string_contains(hud.event_log.get_parsed_text(), "You move to (5, 12).")
|
||||
assert_string_contains(hud.event_log.get_parsed_text(), "The goblin hits you for 2.")
|
||||
|
||||
var first_melee := game.submit_test_action(Vector2i.RIGHT)
|
||||
assert_eq(first_melee[0].kind, &"melee")
|
||||
assert_eq(first_melee[1].kind, &"enemy_melee")
|
||||
@@ -72,6 +79,7 @@ func test_real_game_scene_completes_walking_combat_and_defeat_route() -> void:
|
||||
assert_eq(hud.combat_summary, "Target: Goblin HP: 3/6")
|
||||
assert_eq(hud.combat_summary_label.text, "Target: Goblin HP: 3/6")
|
||||
assert_string_contains(hud.event_log.get_parsed_text(), "You strike the goblin for 3.")
|
||||
|
||||
var lethal_melee := game.submit_test_action(Vector2i.RIGHT)
|
||||
assert_eq(lethal_melee[0].kind, &"melee")
|
||||
assert_eq(lethal_melee[1].kind, &"enemy_defeated")
|
||||
@@ -82,4 +90,4 @@ func test_real_game_scene_completes_walking_combat_and_defeat_route() -> void:
|
||||
assert_eq(game.get_node("HUD/EnemyHealthLabel").text, "No active target")
|
||||
assert_eq(hud.combat_summary, "No active target")
|
||||
assert_eq(hud.combat_summary_label.text, "No active target")
|
||||
assert_string_contains(game.get_node("HUD/EventLog").get_parsed_text(), "defeated")
|
||||
assert_string_contains(hud.event_log.get_parsed_text(), "The goblin is defeated.")
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
extends GutTest
|
||||
|
||||
const GameScene = preload("res://scenes/Game.tscn")
|
||||
var game: Game
|
||||
|
||||
func before_each() -> void:
|
||||
game = GameScene.instantiate()
|
||||
add_child_autofree(game)
|
||||
await get_tree().process_frame
|
||||
|
||||
func test_real_input_opens_door_then_chest_and_preserves_stairs_route() -> void:
|
||||
var state := game.get_game_state()
|
||||
var hud := game.get_node("HUD") as GameHud
|
||||
var prompt_label := game.get_node("HUD/ContextPromptLabel") as Label
|
||||
var event_log := game.get_node("HUD/EventLog") as RichTextLabel
|
||||
state.enemies.erase(&"goblin")
|
||||
|
||||
assert_eq(state.map.size, Vector2i(30, 20))
|
||||
assert_eq(prompt_label.text, "Espace — Ouvrir la porte")
|
||||
game._unhandled_input(_key_event(KEY_E))
|
||||
assert_eq(game.last_turn_results[0].kind, &"door_opened")
|
||||
assert_eq(state.map.get_cell(Vector2i(4, 11)), GridMapState.CellKind.FLOOR)
|
||||
|
||||
for keycode in [KEY_UP, KEY_UP, KEY_UP, KEY_UP]:
|
||||
game._unhandled_input(_key_event(keycode))
|
||||
assert_eq(state.player.cell, Vector2i(4, 8))
|
||||
assert_eq(prompt_label.text, "Espace — Ouvrir le coffre")
|
||||
game._unhandled_input(_key_event(KEY_UP))
|
||||
assert_eq(state.player.cell, Vector2i(4, 8))
|
||||
assert_eq(state.map.get_cell(Vector2i(4, 7)), GridMapState.CellKind.CHEST)
|
||||
assert_string_contains(event_log.get_parsed_text(), "Your way is blocked.")
|
||||
|
||||
game._unhandled_input(_key_event(KEY_SPACE))
|
||||
assert_eq(game.last_turn_results[0].kind, &"chest_opened")
|
||||
assert_eq(state.map.get_cell(Vector2i(4, 7)), GridMapState.CellKind.FLOOR)
|
||||
assert_eq(hud.get_context_prompt(), "")
|
||||
assert_string_contains(event_log.get_parsed_text(), "You open the chest.")
|
||||
game._unhandled_input(_key_event(KEY_UP))
|
||||
assert_eq(state.player.cell, Vector2i(4, 7))
|
||||
|
||||
for keycode in [KEY_UP, KEY_RIGHT, KEY_RIGHT, KEY_RIGHT, KEY_RIGHT, KEY_RIGHT, KEY_RIGHT, KEY_RIGHT, KEY_RIGHT, KEY_RIGHT, KEY_RIGHT, KEY_RIGHT, KEY_RIGHT, KEY_RIGHT, KEY_RIGHT, KEY_UP, KEY_UP]:
|
||||
game._unhandled_input(_key_event(keycode))
|
||||
assert_eq(state.player.cell, Vector2i(18, 4))
|
||||
assert_eq(prompt_label.text, "Espace — Descendre l’escalier")
|
||||
game._unhandled_input(_key_event(KEY_SPACE))
|
||||
assert_true(state.exit_reached)
|
||||
assert_string_contains(event_log.get_parsed_text(), "You descend the stairs.")
|
||||
|
||||
func _key_event(keycode: Key) -> InputEventKey:
|
||||
var event := InputEventKey.new()
|
||||
event.keycode = keycode
|
||||
event.physical_keycode = keycode
|
||||
event.pressed = true
|
||||
return event
|
||||
@@ -0,0 +1 @@
|
||||
uid://dtkblrbmeb1u6
|
||||
@@ -17,7 +17,7 @@ func test_real_game_keyboard_space_and_test_seam_open_door_then_allow_walking_th
|
||||
var hud := game.get_node("HUD") as GameHud
|
||||
var prompt_label := game.get_node("HUD/ContextPromptLabel") as Label
|
||||
var event_log := game.get_node("HUD/EventLog") as RichTextLabel
|
||||
var door_cell := Vector2i(2, 1)
|
||||
var door_cell := Vector2i(4, 11)
|
||||
game._unhandled_input(_key_event(KEY_SPACE))
|
||||
|
||||
assert_eq(state.map.get_cell(door_cell), GridMapState.CellKind.FLOOR)
|
||||
|
||||
@@ -15,14 +15,18 @@ func test_real_input_event_completes_door_to_stairs_exit_without_replacing_the_c
|
||||
var event_log := game.get_node("HUD/EventLog") as RichTextLabel
|
||||
var initial_map := state.map
|
||||
var initial_map_size := state.map.size
|
||||
state.enemies.erase(&"goblin")
|
||||
|
||||
game._unhandled_input(_key_event(KEY_SPACE))
|
||||
assert_eq(state.map.get_cell(Vector2i(2, 1)), GridMapState.CellKind.FLOOR)
|
||||
|
||||
for keycode in [KEY_UP, KEY_DOWN, KEY_DOWN, KEY_DOWN, KEY_DOWN, KEY_DOWN, KEY_DOWN, KEY_DOWN, KEY_DOWN, KEY_RIGHT, KEY_RIGHT, KEY_RIGHT, KEY_RIGHT, KEY_RIGHT, KEY_RIGHT, KEY_RIGHT]:
|
||||
assert_eq(state.map.get_cell(Vector2i(4, 11)), GridMapState.CellKind.FLOOR)
|
||||
for keycode in [KEY_UP, KEY_UP, KEY_UP, KEY_UP]:
|
||||
game._unhandled_input(_key_event(keycode))
|
||||
assert_eq(state.player.cell, Vector2i(4, 8))
|
||||
game._unhandled_input(_key_event(KEY_E))
|
||||
for keycode in [KEY_UP, KEY_UP, KEY_RIGHT, KEY_RIGHT, KEY_RIGHT, KEY_RIGHT, KEY_RIGHT, KEY_RIGHT, KEY_RIGHT, KEY_RIGHT, KEY_RIGHT, KEY_RIGHT, KEY_RIGHT, KEY_RIGHT, KEY_RIGHT, KEY_RIGHT, KEY_UP, KEY_UP]:
|
||||
game._unhandled_input(_key_event(keycode))
|
||||
|
||||
assert_eq(state.player.cell, Vector2i(9, 7))
|
||||
assert_eq(state.player.cell, Vector2i(18, 4))
|
||||
assert_eq(hud.get_context_prompt(), "Espace — Descendre l’escalier")
|
||||
game._unhandled_input(_key_event(KEY_E))
|
||||
|
||||
@@ -33,8 +37,8 @@ func test_real_input_event_completes_door_to_stairs_exit_without_replacing_the_c
|
||||
assert_string_contains(event_log.get_parsed_text(), "You descend the stairs.")
|
||||
assert_same(state.map, initial_map)
|
||||
assert_eq(state.map.size, initial_map_size)
|
||||
assert_eq(state.map.get_cell(Vector2i(9, 7)), GridMapState.CellKind.STAIRS)
|
||||
assert_eq(state.player.cell, Vector2i(9, 7))
|
||||
assert_eq(state.map.get_cell(Vector2i(18, 4)), GridMapState.CellKind.STAIRS)
|
||||
assert_eq(state.player.cell, Vector2i(18, 4))
|
||||
|
||||
func _key_event(keycode: Key) -> InputEventKey:
|
||||
var event := InputEventKey.new()
|
||||
|
||||
@@ -11,21 +11,22 @@ func before_each() -> void:
|
||||
func test_real_game_updates_fog_after_public_action_and_preserves_opaque_fov() -> void:
|
||||
var renderer := game.get_node("World/MapRenderer") as MapRenderer
|
||||
var state := game.get_game_state()
|
||||
var opaque_obstacle := Vector2i(1, 2)
|
||||
var cell_behind_obstacle := Vector2i(0, 2)
|
||||
var opaque_obstacle := Vector2i(4, 11)
|
||||
var cell_behind_obstacle := Vector2i(4, 10)
|
||||
assert_true(state.visible_cells.has(opaque_obstacle))
|
||||
assert_false(state.visible_cells.has(cell_behind_obstacle))
|
||||
|
||||
var results := game.submit_test_action(Vector2i.DOWN)
|
||||
game.submit_test_interact()
|
||||
var results := game.submit_test_action(Vector2i.UP)
|
||||
|
||||
assert_eq(results[0].kind, &"moved")
|
||||
assert_true(state.explored_cells.has(Vector2i(8, 2)))
|
||||
assert_false(state.visible_cells.has(Vector2i(8, 2)))
|
||||
assert_eq(renderer.get_cell_visibility_state(Vector2i(8, 2)), &"explored")
|
||||
assert_eq(renderer.get_cell_render_color(Vector2i(8, 2)), renderer.EXPLORED_DIM_COLOR)
|
||||
assert_true(state.visible_cells.has(Vector2i(2, 9)))
|
||||
assert_eq(renderer.get_cell_visibility_state(Vector2i(2, 9)), &"visible")
|
||||
assert_eq(renderer.get_cell_render_color(Vector2i(2, 9)), Color.WHITE)
|
||||
assert_false(state.explored_cells.has(Vector2i(10, 9)))
|
||||
assert_eq(renderer.get_cell_visibility_state(Vector2i(10, 9)), &"unknown")
|
||||
assert_eq(renderer.get_cell_render_color(Vector2i(10, 9)), renderer.UNKNOWN_COLOR)
|
||||
assert_true(state.explored_cells.has(Vector2i(1, 12)))
|
||||
assert_false(state.visible_cells.has(Vector2i(1, 12)))
|
||||
assert_eq(renderer.get_cell_visibility_state(Vector2i(1, 12)), &"explored")
|
||||
assert_eq(renderer.get_cell_render_color(Vector2i(1, 12)), renderer.EXPLORED_DIM_COLOR)
|
||||
assert_true(state.visible_cells.has(Vector2i(4, 17)))
|
||||
assert_eq(renderer.get_cell_visibility_state(Vector2i(4, 17)), &"visible")
|
||||
assert_eq(renderer.get_cell_render_color(Vector2i(4, 17)), Color.WHITE)
|
||||
assert_false(state.explored_cells.has(Vector2i(29, 19)))
|
||||
assert_eq(renderer.get_cell_visibility_state(Vector2i(29, 19)), &"unknown")
|
||||
assert_eq(renderer.get_cell_render_color(Vector2i(29, 19)), renderer.UNKNOWN_COLOR)
|
||||
|
||||
@@ -22,13 +22,14 @@ func test_real_game_exposes_door_and_stairs_prompts_with_help_and_event_log() ->
|
||||
|
||||
var interact_event := InputEventKey.new()
|
||||
interact_event.keycode = KEY_SPACE
|
||||
interact_event.physical_keycode = KEY_SPACE
|
||||
interact_event.pressed = true
|
||||
game._unhandled_input(interact_event)
|
||||
assert_eq(hud.get_context_prompt(), "Espace — Ouvrir la porte")
|
||||
assert_eq(state.map.get_cell(Vector2i(2, 1)), GridMapState.CellKind.CLOSED_DOOR)
|
||||
assert_eq(hud.get_context_prompt(), "")
|
||||
assert_eq(state.map.get_cell(Vector2i(4, 11)), GridMapState.CellKind.FLOOR)
|
||||
|
||||
state.map.set_cell(Vector2i(2, 1), GridMapState.CellKind.FLOOR)
|
||||
state.player.cell = Vector2i(9, 7)
|
||||
state.map.set_cell(Vector2i(4, 11), GridMapState.CellKind.FLOOR)
|
||||
state.player.cell = Vector2i(18, 4)
|
||||
hud.refresh(state)
|
||||
assert_eq(hud.get_context_prompt(), "Espace — Descendre l’escalier")
|
||||
assert_eq(prompt_label.text, "Espace — Descendre l’escalier")
|
||||
|
||||
@@ -28,6 +28,8 @@ func after_each() -> void:
|
||||
func test_real_game_resolves_combat_with_empty_audio_home() -> void:
|
||||
var audio = game.get_node("AudioLibrary")
|
||||
|
||||
var state := game.get_game_state()
|
||||
state.enemies[&"goblin"].cell = state.player.cell + Vector2i(2, 0)
|
||||
game.submit_test_action(Vector2i.RIGHT)
|
||||
var first_melee := game.submit_test_action(Vector2i.RIGHT)
|
||||
var lethal_melee := game.submit_test_action(Vector2i.RIGHT)
|
||||
@@ -58,6 +60,8 @@ func test_external_nominal_and_invalid_wavs_do_not_affect_combat() -> void:
|
||||
invalid_file.store_string("truncated WAV")
|
||||
invalid_file.close()
|
||||
|
||||
var state := game.get_game_state()
|
||||
state.enemies[&"goblin"].cell = state.player.cell + Vector2i(2, 0)
|
||||
game.submit_test_action(Vector2i.RIGHT)
|
||||
var first_melee := game.submit_test_action(Vector2i.RIGHT)
|
||||
var lethal_melee := game.submit_test_action(Vector2i.RIGHT)
|
||||
|
||||
@@ -17,8 +17,8 @@ func test_real_game_scene_exposes_readable_fov_zoom_and_compact_hud() -> void:
|
||||
|
||||
assert_eq(results[0].kind, &"moved")
|
||||
assert_eq(camera.zoom, Vector2(2.0, 2.0))
|
||||
assert_gte(renderer.get_cell_render_color(Vector2i(8, 2)).get_luminance(), 0.55)
|
||||
assert_eq(renderer.get_cell_render_color(Vector2i(10, 9)), renderer.UNKNOWN_COLOR)
|
||||
assert_gte(renderer.get_cell_render_color(Vector2i(4, 12)).get_luminance(), 0.55)
|
||||
assert_eq(renderer.get_cell_render_color(Vector2i(29, 19)), renderer.UNKNOWN_COLOR)
|
||||
for panel_name in [&"StatsPanel", &"LogPanel", &"PromptPanel", &"HelpPanel"]:
|
||||
var panel := hud.get_node("ResponsiveLayout/" + String(panel_name)) as PanelContainer
|
||||
assert_false(panel.get_global_rect().intersects(central_play_area), "%s obscures the central play area" % panel_name)
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
extends GutTest
|
||||
|
||||
const GridMapState = preload("res://scripts/domain/grid_map_state.gd")
|
||||
const ActorState = preload("res://scripts/domain/actor_state.gd")
|
||||
const GameState = preload("res://scripts/domain/game_state.gd")
|
||||
|
||||
func _state_with_chest(chest: Vector2i, player: Vector2i = Vector2i(3, 3)) -> GameState:
|
||||
var map := GridMapState.new(Vector2i(9, 7), GridMapState.CellKind.FLOOR)
|
||||
map.set_cell(chest, GridMapState.CellKind.CHEST)
|
||||
return GameState.new(map, ActorState.new(&"player", player, 12, 3), {&"goblin": ActorState.new(&"goblin", Vector2i(7, 3), 6, 2)})
|
||||
|
||||
func test_closed_chest_is_not_walkable_and_movement_is_blocked_without_an_enemy_turn() -> void:
|
||||
var state := _state_with_chest(Vector2i(4, 3))
|
||||
|
||||
var results := state.try_player_action(Vector2i.RIGHT)
|
||||
|
||||
assert_false(state.map.is_walkable(Vector2i(4, 3)))
|
||||
assert_eq(results.size(), 1)
|
||||
assert_eq(results[0].kind, &"blocked")
|
||||
assert_eq(state.player.cell, Vector2i(3, 3))
|
||||
|
||||
func test_chest_is_the_context_target_before_doors_but_stairs_keep_priority() -> void:
|
||||
var state := _state_with_chest(Vector2i(3, 2))
|
||||
state.map.set_cell(Vector2i(4, 3), GridMapState.CellKind.CLOSED_DOOR)
|
||||
assert_eq(state.get_context_target(), &"chest")
|
||||
|
||||
state.map.set_cell(state.player.cell, GridMapState.CellKind.STAIRS)
|
||||
assert_eq(state.get_context_target(), &"stairs")
|
||||
|
||||
func test_opening_chest_replaces_it_with_floor_refreshes_fov_and_gets_one_enemy_response() -> void:
|
||||
var chest := Vector2i(3, 2)
|
||||
var revealed := Vector2i(3, 1)
|
||||
var state := _state_with_chest(chest)
|
||||
state.map.set_cell(revealed, GridMapState.CellKind.FLOOR)
|
||||
assert_false(state.visible_cells.has(revealed))
|
||||
|
||||
var results := state.try_interact()
|
||||
var enemy_response_count := 0
|
||||
for result in results:
|
||||
if String(result.kind).begins_with("enemy_"):
|
||||
enemy_response_count += 1
|
||||
|
||||
assert_eq(results[0].kind, &"chest_opened")
|
||||
assert_eq(results[0].message, "You open the chest.")
|
||||
assert_eq(results[0].to_cell, chest)
|
||||
assert_eq(state.map.get_cell(chest), GridMapState.CellKind.FLOOR)
|
||||
assert_true(state.map.is_walkable(chest))
|
||||
assert_true(state.visible_cells.has(revealed))
|
||||
assert_eq(enemy_response_count, 1)
|
||||
@@ -0,0 +1 @@
|
||||
uid://b13pnjogahauk
|
||||
@@ -12,6 +12,8 @@ func test_combat_routes_damage_feedback_and_exposes_current_target_summary() ->
|
||||
var hud := game.get_node("HUD") as GameHud
|
||||
var player_view := game.get_node("World/Player") as ActorView
|
||||
var enemy_view := game.get_node("World/Enemies/Goblin") as ActorView
|
||||
var state := game.get_game_state()
|
||||
state.enemies[&"goblin"].cell = state.player.cell + Vector2i(2, 0)
|
||||
|
||||
assert_eq(hud.combat_summary, "Target: Goblin HP: 6/6")
|
||||
game.submit_test_action(Vector2i.RIGHT)
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
extends GutTest
|
||||
|
||||
const GameScene = preload("res://scenes/Game.tscn")
|
||||
|
||||
func test_initial_demo_map_is_30_by_20_with_a_known_door_chest_and_stairs_route() -> void:
|
||||
var game := GameScene.instantiate() as Game
|
||||
add_child_autofree(game)
|
||||
await get_tree().process_frame
|
||||
var state := game.get_game_state()
|
||||
|
||||
assert_eq(state.map.size, Vector2i(30, 20))
|
||||
assert_eq(state.player.cell, Vector2i(4, 12))
|
||||
assert_eq(state.map.get_cell(Vector2i(4, 11)), GridMapState.CellKind.CLOSED_DOOR)
|
||||
assert_eq(state.map.get_cell(Vector2i(4, 7)), GridMapState.CellKind.CHEST)
|
||||
assert_eq(state.map.get_cell(Vector2i(18, 4)), GridMapState.CellKind.STAIRS)
|
||||
for cell in [Vector2i(4, 10), Vector2i(4, 8), Vector2i(4, 6), Vector2i(10, 4), Vector2i(17, 4)]:
|
||||
assert_true(state.map.is_walkable(cell), "Expected the demo route to include %s." % cell)
|
||||
@@ -0,0 +1 @@
|
||||
uid://v5xlp310damm
|
||||
@@ -32,8 +32,8 @@ func test_camera_tracks_player_after_a_valid_action_and_uses_map_limits() -> voi
|
||||
assert_eq(MapRendererType.TILE_SIZE, Vector2i(32, 32))
|
||||
assert_eq(camera.limit_left, 32)
|
||||
assert_eq(camera.limit_top, 48)
|
||||
assert_eq(camera.limit_right, 416)
|
||||
assert_eq(camera.limit_bottom, 368)
|
||||
assert_eq(camera.limit_right, 992)
|
||||
assert_eq(camera.limit_bottom, 688)
|
||||
|
||||
game.submit_test_action(Vector2i.DOWN)
|
||||
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
extends GutTest
|
||||
|
||||
const GameScene = preload("res://scenes/Game.tscn")
|
||||
|
||||
func test_hud_shows_exact_chest_prompt_only_while_the_chest_is_a_context_target() -> void:
|
||||
var game := GameScene.instantiate() as Game
|
||||
add_child_autofree(game)
|
||||
await get_tree().process_frame
|
||||
var state := game.get_game_state()
|
||||
var hud := game.get_node("HUD") as GameHud
|
||||
|
||||
state.map.set_cell(Vector2i(4, 11), GridMapState.CellKind.FLOOR)
|
||||
state.player.cell = Vector2i(4, 8)
|
||||
hud.refresh(state)
|
||||
assert_eq(hud.get_context_prompt(), "Espace — Ouvrir le coffre")
|
||||
|
||||
state.player.cell = Vector2i(4, 10)
|
||||
hud.refresh(state)
|
||||
assert_eq(hud.get_context_prompt(), "")
|
||||
@@ -0,0 +1 @@
|
||||
uid://bibs6suuqqgne
|
||||
@@ -11,7 +11,7 @@ func before_each() -> void:
|
||||
func test_context_prompt_describes_an_adjacent_closed_door_without_mutating_the_map() -> void:
|
||||
var hud := game.get_node("HUD") as GameHud
|
||||
var state := game.get_game_state()
|
||||
var door_cell := Vector2i(2, 1)
|
||||
var door_cell := Vector2i(4, 11)
|
||||
|
||||
assert_eq(hud.get_context_prompt(), "Espace — Ouvrir la porte")
|
||||
assert_eq(state.map.get_cell(door_cell), GridMapState.CellKind.CLOSED_DOOR)
|
||||
@@ -20,8 +20,8 @@ func test_context_prompt_describes_stairs_under_player_and_nothing_else() -> voi
|
||||
var hud := game.get_node("HUD") as GameHud
|
||||
var state := game.get_game_state()
|
||||
|
||||
state.map.set_cell(Vector2i(2, 1), GridMapState.CellKind.FLOOR)
|
||||
state.player.cell = Vector2i(9, 7)
|
||||
state.map.set_cell(Vector2i(4, 11), GridMapState.CellKind.FLOOR)
|
||||
state.player.cell = Vector2i(18, 4)
|
||||
hud.refresh(state)
|
||||
assert_eq(hud.get_context_prompt(), "Espace — Descendre l’escalier")
|
||||
|
||||
|
||||
@@ -10,17 +10,18 @@ func before_each() -> void:
|
||||
|
||||
func test_game_synchronizes_renderer_visibility_states_after_movement() -> void:
|
||||
var renderer := game.get_node("World/MapRenderer") as MapRenderer
|
||||
assert_eq(renderer.get_cell_visibility_state(Vector2i(2, 2)), &"visible")
|
||||
assert_eq(renderer.get_cell_visibility_state(Vector2i(1, 12)), &"visible")
|
||||
|
||||
game.submit_test_action(Vector2i.DOWN)
|
||||
game.submit_test_interact()
|
||||
game.submit_test_action(Vector2i.UP)
|
||||
|
||||
assert_eq(renderer.get_cell_visibility_state(Vector2i(8, 2)), &"explored")
|
||||
assert_eq(renderer.get_cell_visibility_state(Vector2i(2, 9)), &"visible")
|
||||
assert_eq(renderer.get_cell_visibility_state(Vector2i(10, 9)), &"unknown")
|
||||
assert_eq(renderer.get_cell_render_color(Vector2i(8, 2)), renderer.EXPLORED_DIM_COLOR)
|
||||
assert_eq(renderer.get_cell_visibility_state(Vector2i(1, 12)), &"explored")
|
||||
assert_eq(renderer.get_cell_visibility_state(Vector2i(4, 17)), &"visible")
|
||||
assert_eq(renderer.get_cell_visibility_state(Vector2i(29, 19)), &"unknown")
|
||||
assert_eq(renderer.get_cell_render_color(Vector2i(1, 12)), renderer.EXPLORED_DIM_COLOR)
|
||||
assert_gte(renderer.EXPLORED_DIM_COLOR.get_luminance(), 0.55)
|
||||
assert_eq(renderer.get_cell_render_color(Vector2i(2, 9)), Color.WHITE)
|
||||
assert_eq(renderer.get_cell_render_color(Vector2i(10, 9)), renderer.UNKNOWN_COLOR)
|
||||
assert_eq(renderer.get_cell_render_color(Vector2i(4, 17)), Color.WHITE)
|
||||
assert_eq(renderer.get_cell_render_color(Vector2i(29, 19)), renderer.UNKNOWN_COLOR)
|
||||
assert_ne(renderer.UNKNOWN_COLOR, renderer.EXPLORED_DIM_COLOR)
|
||||
assert_lt(renderer.UNKNOWN_COLOR.get_luminance(), 0.1)
|
||||
assert_gt(renderer.UNKNOWN_COLOR.b, renderer.UNKNOWN_COLOR.r)
|
||||
|
||||
@@ -56,8 +56,8 @@ func test_stairs_usage_refreshes_exact_exit_prompt_and_writes_the_journal() -> v
|
||||
var hud := game.get_node("HUD") as GameHud
|
||||
var prompt_label := game.get_node("HUD/ContextPromptLabel") as Label
|
||||
var event_log := game.get_node("HUD/EventLog") as RichTextLabel
|
||||
state.map.set_cell(Vector2i(2, 1), GridMapState.CellKind.FLOOR)
|
||||
state.player.cell = Vector2i(9, 7)
|
||||
state.map.set_cell(Vector2i(4, 11), GridMapState.CellKind.FLOOR)
|
||||
state.player.cell = Vector2i(18, 4)
|
||||
|
||||
var results := game.submit_test_interact()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user