fix: apply map-aware FOV and align actor rendering
This commit is contained in:
@@ -53,3 +53,35 @@ func test_lethal_melee_removes_enemy_and_reports_defeat() -> void:
|
||||
assert_eq(results[0].kind, &"melee")
|
||||
assert_eq(results[1].kind, &"enemy_defeated")
|
||||
assert_false(state.enemies.has(&"goblin"))
|
||||
|
||||
func test_non_adjacent_enemy_moves_toward_player() -> void:
|
||||
var state := make_state()
|
||||
var results := state.try_player_action(Vector2i.DOWN)
|
||||
assert_eq(results[0].kind, &"moved")
|
||||
assert_eq(results[1].kind, &"enemy_moved")
|
||||
assert_eq(results[1].from_cell, Vector2i(4, 2))
|
||||
assert_eq(results[1].to_cell, Vector2i(3, 2))
|
||||
assert_eq(state.enemies[&"goblin"].cell, Vector2i(3, 2))
|
||||
|
||||
func test_compute_visible_cells_keeps_opaque_target_but_hides_cells_behind_it() -> void:
|
||||
var state := make_state()
|
||||
var sight_map := GridMapState.new(Vector2i(7, 5), GridMapState.CellKind.FLOOR)
|
||||
var opaque_cell := Vector2i(3, 2)
|
||||
var hidden_cell := Vector2i(4, 2)
|
||||
sight_map.set_cell(opaque_cell, GridMapState.CellKind.WALL)
|
||||
var visible := state.compute_visible_cells(sight_map, Vector2i(1, 2), 5)
|
||||
assert_true(visible.has(opaque_cell))
|
||||
assert_false(visible.has(hidden_cell))
|
||||
assert_true(visible.has(Vector2i(4, 1)))
|
||||
|
||||
func test_update_exploration_uses_map_aware_fov() -> void:
|
||||
var map := GridMapState.new(Vector2i(7, 5), GridMapState.CellKind.FLOOR)
|
||||
var opaque_cell := Vector2i(3, 2)
|
||||
var hidden_cell := Vector2i(4, 2)
|
||||
map.set_cell(opaque_cell, GridMapState.CellKind.CLOSED_DOOR)
|
||||
var player := ActorState.new(&"player", Vector2i(1, 2), 12, 3)
|
||||
var state := GameState.new(map, player, {})
|
||||
assert_true(state.visible_cells.has(opaque_cell))
|
||||
assert_false(state.visible_cells.has(hidden_cell))
|
||||
assert_true(state.explored_cells.has(opaque_cell))
|
||||
assert_false(state.explored_cells.has(hidden_cell))
|
||||
|
||||
Reference in New Issue
Block a user