40 lines
1.5 KiB
GDScript
40 lines
1.5 KiB
GDScript
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_minimap_crops_to_player_camera_fov_and_never_reveals_hidden_threats() -> void:
|
|
var minimap := game.get_node_or_null("HUD/Minimap") as Minimap
|
|
var state := game.get_game_state()
|
|
var hidden_threat_cell := Vector2i(24, 8)
|
|
var enemy := ActorState.new(&"goblin", hidden_threat_cell, 6, 2)
|
|
state.enemies[enemy.id] = enemy
|
|
game.sync_presentation_for_testing()
|
|
|
|
assert_not_null(minimap)
|
|
assert_eq(minimap.get_camera_cell(), state.player.cell)
|
|
assert_true(minimap.get_displayed_cells().has(state.player.cell))
|
|
assert_false(minimap.get_displayed_cells().has(Vector2i(41, 15)))
|
|
assert_eq(minimap.get_cell_visibility_state(Vector2i(41, 15)), &"unknown")
|
|
assert_false(minimap.get_threat_marker_cells().has(hidden_threat_cell))
|
|
|
|
state.player.cell = hidden_threat_cell
|
|
state.update_exploration()
|
|
game.sync_presentation_for_testing()
|
|
|
|
assert_eq(minimap.get_camera_cell(), hidden_threat_cell)
|
|
assert_true(minimap.get_displayed_cells().has(hidden_threat_cell))
|
|
assert_false(minimap.get_displayed_cells().has(Vector2i(4, 7)))
|
|
assert_true(minimap.get_threat_marker_cells().has(hidden_threat_cell))
|
|
|
|
state.visible_cells.erase(hidden_threat_cell)
|
|
state.explored_cells[hidden_threat_cell] = true
|
|
game.sync_presentation_for_testing()
|
|
assert_false(minimap.get_threat_marker_cells().has(hidden_threat_cell))
|