Server-authoritative Godot 4.6 strategy game. Includes the headless WebSocket game server, the browser client, and Nix packaging (server and web-export derivations plus a NixOS module) for deployment.
48 lines
1.2 KiB
GDScript
48 lines
1.2 KiB
GDScript
extends TestCase
|
|
|
|
## Covers UnitPath's visibility rules. Path nodes need to be in the tree so
|
|
## their _ready hook runs.
|
|
|
|
|
|
func _make_path() -> UnitPath:
|
|
var path: UnitPath = UnitPath.new()
|
|
tree.root.add_child(path)
|
|
return path
|
|
|
|
|
|
func test_starts_without_path_and_hidden() -> void:
|
|
var path := _make_path()
|
|
assert_false(path.has_path())
|
|
assert_false(path.visible)
|
|
path.free()
|
|
|
|
|
|
func test_set_path_needs_two_points() -> void:
|
|
var path := _make_path()
|
|
path.set_path(PackedVector2Array([Vector2.ZERO]))
|
|
assert_false(path.has_path())
|
|
path.set_path(PackedVector2Array([Vector2.ZERO, Vector2.ONE]))
|
|
assert_true(path.has_path())
|
|
path.free()
|
|
|
|
|
|
func test_path_visible_only_when_selected() -> void:
|
|
var path := _make_path()
|
|
path.set_path(PackedVector2Array([Vector2.ZERO, Vector2.ONE]))
|
|
assert_false(path.visible)
|
|
path.set_selected(true)
|
|
assert_true(path.visible)
|
|
path.set_selected(false)
|
|
assert_false(path.visible)
|
|
path.free()
|
|
|
|
|
|
func test_clear_path_hides_it() -> void:
|
|
var path := _make_path()
|
|
path.set_path(PackedVector2Array([Vector2.ZERO, Vector2.ONE]))
|
|
path.set_selected(true)
|
|
path.clear_path()
|
|
assert_false(path.has_path())
|
|
assert_false(path.visible)
|
|
path.free()
|