👽 interstellar delivery

This commit is contained in:
anyreso 2024-10-16 21:43:01 +00:00
parent 547c97bfba
commit 97c8292858
257 changed files with 7309 additions and 4637 deletions

View file

@ -1,21 +0,0 @@
# This file is part of open-fpsz.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
extends GutTest
func test_projectile_class() -> void:
var projectile : Projectile = Projectile.new()
assert_true(projectile != null, "Projectile class should be instantiated")
assert_true(projectile.speed == 78.4, "Projectile damage should be initialized to 78.4")
projectile.free()

View file

@ -1,69 +0,0 @@
# This file is part of open-fpsz.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
extends GutTest
var PLAYER : PackedScene = preload("res://entities/player/player.tscn")
var SCOREBOARD : PackedScene = preload("res://interfaces/scoreboard/scoreboard.tscn")
var _subject : DeathmatchScoringComponent
var _scoreboard : Object
var _victim : Player
var _killer : Player
func _setup_player(player_id : int) -> Player:
var player : Player = PLAYER.instantiate()
player.name = str(player_id)
add_child(player) # we can't autofree in this test setup
var participant : MatchParticipant = player.match_participant
player.match_participant.player_id = player_id
_scoreboard.add_participant(participant)
_subject.subscribe_player(player)
_subject._players = self
return player
func before_each() -> void:
_subject = DeathmatchScoringComponent.new()
_scoreboard = double(SCOREBOARD).instantiate()
stub(_scoreboard, 'add_score_to_player')
stub(_scoreboard, 'increment_kill_count')
_subject._scoreboard = _scoreboard
_victim = _setup_player(0)
_killer = _setup_player(1)
func after_each() -> void:
_subject.unsubscribe_player(_victim)
_subject.unsubscribe_player(_killer)
_victim.free()
_killer.free()
_subject.free()
func _kill_player(victim : Player, killer : Player) -> void:
victim.died.emit(victim, killer.match_participant.player_id)
func test_player_gets_no_score_for_self_kill() -> void:
_kill_player(_victim, _victim)
assert_not_called(_scoreboard, 'add_score_to_player')
assert_not_called(_scoreboard, 'increment_kill_count')
func test_killer_gets_score_after_kill() -> void:
_kill_player(_victim, _killer)
assert_called(_scoreboard, 'add_score_to_player', [_killer.match_participant, _subject.ON_KILL_SCORE])
assert_called(_scoreboard, 'increment_kill_count', [_killer.match_participant])
func test_killer_leaves_before_kill() -> void:
remove_child(_killer)
_kill_player(_victim, _killer)
assert_not_called(_scoreboard, 'add_score_to_player')
assert_not_called(_scoreboard, 'increment_kill_count')

View file

@ -14,112 +14,47 @@
# along with this program. If not, see <https://www.gnu.org/licenses/>.
extends GutTest
var FLAG : PackedScene = preload("res://entities/flag/flag.tscn")
var PLAYER : PackedScene = preload("res://entities/player/player.tscn")
const FLAG : PackedScene = preload("res://entities/flag/flag.tscn")
var _subject : Flag
var _carry : FlagCarryComponent
func before_each() -> void:
_subject = FLAG.instantiate()
_carry = FlagCarryComponent.new()
watch_signals(_subject)
add_child_autofree(_subject)
add_child_autofree(_carry)
func _is_mesh_visible() -> bool:
var mesh : Node3D = _subject.find_child("Mesh")
return mesh.is_visible()
func test_flag_default_state() -> void:
assert_eq(_subject.state, Flag.FlagState.ON_STAND)
func test_that_flag_is_on_stand_by_default() -> void:
assert_eq(_subject.flag_state, Flag.FlagState.ON_STAND)
func test_flag_default_visibility() -> void:
assert_true(_subject.is_visible())
func test_that_mesh_is_visible_by_default() -> void:
assert_true(_is_mesh_visible())
func test_grab_flag() -> void:
_carry.grab(_subject)
assert_signal_emitted_with_parameters(_subject, 'grabbed', [_carry])
assert_eq(_subject.state, Flag.FlagState.TAKEN)
assert_eq(_subject.last_carrier, null)
assert_false(_subject.is_visible())
func test_drop_flag() -> void:
test_grab_flag()
_carry.drop()
assert_signal_emitted_with_parameters(_subject, 'dropped', [_carry])
assert_eq(_subject.state, Flag.FlagState.DROPPED)
assert_eq(_subject.last_carrier, _carry)
assert_true(_subject.is_visible())
func test_that_flag_on_stand_can_be_grabbed() -> void:
_subject.flag_state = Flag.FlagState.ON_STAND
assert_true(_subject.state != _subject.FlagState.TAKEN)
func test_that_flag_grab_hides_flag() -> void:
test_grab_flag()
assert_false(_subject.is_visible())
func test_that_dropped_flag_can_be_grabbed() -> void:
_subject.flag_state = Flag.FlagState.DROPPED
assert_true(_subject.state != _subject.FlagState.TAKEN)
func test_that_taken_flag_cannot_be_grabbed() -> void:
_subject.flag_state = Flag.FlagState.TAKEN
assert_false(_subject.state != _subject.FlagState.TAKEN)
func test_that_on_stand_flag_grab_emits_grab_signal_and_changes_state() -> void:
_subject.flag_state = Flag.FlagState.ON_STAND
var player : Player = PLAYER.instantiate()
_subject.grab(player)
assert_signal_emitted_with_parameters(_subject, 'grabbed', [player])
assert_eq(_subject.flag_state, Flag.FlagState.TAKEN)
assert_eq(_subject.last_carrier, player)
player.free()
func test_that_dropped_flag_grab_emits_grab_signal_and_changes_state() -> void:
_subject.flag_state = Flag.FlagState.DROPPED
var player : Player = PLAYER.instantiate()
_subject.grab(player)
assert_signal_emitted_with_parameters(_subject, 'grabbed', [player])
assert_eq(_subject.flag_state, Flag.FlagState.TAKEN)
assert_eq(_subject.last_carrier, player)
player.free()
func test_that_taken_flag_grab_does_not_emit_grab_signal_and_keeps_state() -> void:
_subject.flag_state = Flag.FlagState.TAKEN
_subject.grab(null) # doesn't matter that it's null in this case
assert_signal_not_emitted(_subject, 'grabbed')
assert_eq(_subject.flag_state, Flag.FlagState.TAKEN)
assert_null(_subject.last_carrier)
func test_that_flag_grab_hides_mesh() -> void:
var player : Player = PLAYER.instantiate()
_subject.grab(player)
assert_false(_is_mesh_visible())
player.free()
func test_that_taken_flag_drop_emits_signal_and_changes_state() -> void:
var player : Player = PLAYER.instantiate()
_subject.grab(player)
_subject.drop(player)
assert_signal_emitted_with_parameters(_subject, 'dropped', [player])
assert_eq(_subject.flag_state, Flag.FlagState.DROPPED)
player.free()
func test_that_on_stand_flag_drop_does_not_emit_signals_and_keeps_state() -> void:
var player : Player = PLAYER.instantiate()
_subject.drop(player)
assert_signal_not_emitted(_subject, 'dropped')
assert_eq(_subject.flag_state, Flag.FlagState.ON_STAND)
player.free()
func test_that_flag_drop_shows_mesh() -> void:
var player : Player = PLAYER.instantiate()
_subject.grab(player)
_subject.drop(player)
assert_true(_is_mesh_visible())
player.free()
func test_that_impossible_regrab_does_not_emit_regrabbed_signal() -> void:
var player : Player = PLAYER.instantiate()
_subject.grab(player)
_subject.grab(player)
assert_signal_not_emitted(_subject, 'regrabbed')
player.free()
func test_that_regrab_by_same_player_emits_regrabbed_signal() -> void:
var player : Player = PLAYER.instantiate()
_subject.grab(player)
_subject.drop(player)
_subject.grab(player)
assert_signal_emitted_with_parameters(_subject, 'regrabbed', [player])
player.free()
func test_that_regrab_by_different_player_does_not_emit_regrabbed_signal() -> void:
var player : Player = PLAYER.instantiate()
var different_player : Player = PLAYER.instantiate()
_subject.grab(player)
_subject.drop(player)
_subject.grab(different_player)
assert_signal_not_emitted(_subject, 'regrabbed')
player.free()
different_player.free()
func test_grab_taken_flag() -> void:
test_grab_flag()
var _new_carry = FlagCarryComponent.new()
add_child_autofree(_new_carry)
_new_carry.grab(_subject)
assert_null(_new_carry._flag)
assert_eq(_carry._flag, _subject)

50
tests/test_health.gd Normal file
View file

@ -0,0 +1,50 @@
# This file is part of open-fpsz.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
extends GutTest
var _subject:Health
const TEST_MAX_VALUE:int = 255
func before_each() -> void:
_subject = Health.new()
watch_signals(_subject)
autoqfree(_subject)
func test_that_it_has_max_health_when_ready() -> void:
assert_eq(_subject.value, _subject.max_value)
func test_that_it_takes_damage_from_opponent_team() -> void:
var amount:int = 42
_subject.damage(amount, -1)
assert_eq(_subject.value, TEST_MAX_VALUE - amount)
func test_that_it_can_self_damage() -> void:
var amount:int = 42
_subject.damage(amount, 1)
assert_eq(_subject.value, TEST_MAX_VALUE - amount)
func test_that_it_emits_health_changed_after_damage() -> void:
_subject.damage(42, -1)
assert_signal_emitted(_subject, 'updated')
func test_that_it_emits_signals_when_health_value_is_min_value() -> void:
_subject.damage(TEST_MAX_VALUE, -1)
assert_signal_emitted_with_parameters(_subject, 'killed', [-1])
assert_signal_emitted(_subject, 'exhausted')
func test_that_it_heals_fully() -> void:
_subject.value = 42
_subject.heal()
assert_eq(_subject.value, TEST_MAX_VALUE)

View file

@ -1,68 +0,0 @@
# This file is part of open-fpsz.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
extends GutTest
var _subject : HealthComponent
const TEST_MAX_HEALTH : float = 1.
const TEST_PLAYER_ID : int = 1
const TEST_TEAM_ID : int = 1
func before_each() -> void:
_subject = HealthComponent.new()
watch_signals(_subject)
_subject.max_health = TEST_MAX_HEALTH
var participant : MatchParticipant = MatchParticipant.new()
participant.player_id = TEST_PLAYER_ID
participant.team_id = TEST_TEAM_ID
_subject.match_participant = participant
add_child_autofree(_subject)
func after_each() -> void:
_subject.match_participant.free()
func test_that_it_has_max_health_when_ready() -> void:
assert_eq(_subject.health, _subject.max_health)
func test_that_it_takes_damage_from_opponent_team() -> void:
var damage_amount : float = .1
_subject.damage(damage_amount, -1, -1)
assert_eq(_subject.health, TEST_MAX_HEALTH - damage_amount)
func test_that_it_takes_no_damage_from_same_team() -> void:
var damage_amount : float = .1
_subject.damage(damage_amount, -1, TEST_TEAM_ID)
assert_eq(_subject.health, TEST_MAX_HEALTH)
func test_that_it_can_self_damage() -> void:
var damage_amount : float = .1
_subject.damage(damage_amount, TEST_PLAYER_ID, TEST_TEAM_ID)
assert_eq(_subject.health, TEST_MAX_HEALTH - damage_amount)
func test_that_it_emits_health_changed_after_damage() -> void:
_subject.damage(1, -1, -1)
assert_signal_emitted(_subject, 'health_changed')
func test_that_it_emits_health_zeroed() -> void:
_subject.damage(TEST_MAX_HEALTH, -1, -1)
assert_signal_emitted_with_parameters(_subject, 'health_zeroed', [-1])
func test_that_it_heals_fully() -> void:
_subject.health = .1
_subject.heal_full()
assert_eq(_subject.health, TEST_MAX_HEALTH)
func test_that_it_emits_health_changed_after_heal_full() -> void:
_subject.heal_full()
assert_signal_emitted(_subject, 'health_changed')

View file

@ -14,41 +14,65 @@
# along with this program. If not, see <https://www.gnu.org/licenses/>.
extends GutTest
var SCOREBOARD : PackedScene = preload("res://interfaces/scoreboard/scoreboard.tscn")
const SCOREBOARD : PackedScene = preload("res://interfaces/scoreboard/scoreboard.tscn")
var _subject : Scoreboard
var _scoreboard : Scoreboard
func before_each() -> void:
_subject = SCOREBOARD.instantiate()
add_child_autofree(_subject)
_scoreboard = SCOREBOARD.instantiate()
add_child_autoqfree(_scoreboard)
func test_that_new_scoreboard_is_empty() -> void:
assert_eq(_subject._entries, {})
func test_size() -> void:
assert_eq(_scoreboard.size(), 0)
func test_that_added_entry_is_added_correctly() -> void:
var participant : MatchParticipant = MatchParticipant.new()
participant.username = "test_username"
_subject.add_participant(participant)
var entries : Array = _subject._entries.values()
assert_eq(1, entries.size())
var tested_entry : Scoreboard.ScoreboardEntry = entries[0]
assert_eq("test_username", tested_entry.username)
assert_eq(0, tested_entry.kills)
assert_eq(0, tested_entry.score)
participant.free()
# panels
func test_that_scores_are_added_correctly() -> void:
var participant : MatchParticipant = MatchParticipant.new()
_subject.add_participant(participant)
_subject.add_score_to_player(participant, 10)
var tested_entry : Scoreboard.ScoreboardEntry = _subject._entries.values()[0]
assert_eq(10, tested_entry.score)
participant.free()
func test_add_panel() -> void:
_scoreboard.add_panel()
assert_eq(_scoreboard.size(), 1)
func test_that_kill_counts_are_incremented_correctly() -> void:
var participant : MatchParticipant = MatchParticipant.new()
_subject.add_participant(participant)
_subject.increment_kill_count(participant)
var tested_entry : Scoreboard.ScoreboardEntry = _subject._entries.values()[0]
assert_eq(1, tested_entry.kills)
participant.free()
func test_remove_panel() -> void:
var panel : ScorePanel = _scoreboard.add_panel()
_scoreboard.remove_panel(panel)
assert_eq(_scoreboard.size(), 0)
func test_get_panel() -> void:
_scoreboard.add_panel()
var panel : ScorePanel = _scoreboard.get_panel(0)
assert_not_null(panel)
# entries
func test_panel_add_entry() -> void:
var panel : ScorePanel = _scoreboard.add_panel()
var entry : ScorePanelEntry = panel.add_entry(1, "mercury")
assert_not_null(entry)
assert_eq(panel.size(), 1)
func test_panel_remove_entry() -> void:
var panel : ScorePanel = _scoreboard.add_panel()
var entry : ScorePanelEntry = panel.add_entry(1, "mercury")
assert_eq(panel.size(), 1)
panel.remove_entry(entry)
assert_eq(panel.size(), 0)
func test_panel_remove_entry_by_name() -> void:
var panel : ScorePanel = _scoreboard.add_panel()
var entry : ScorePanelEntry = panel.add_entry(1, "mercury")
assert_eq(panel.size(), 1)
assert_true(panel.remove_entry_by_name(entry.name))
assert_eq(panel.size(), 0)
func test_panel_remove_entry_by_peer_id() -> void:
var panel : ScorePanel = _scoreboard.add_panel()
panel.add_entry(1, "mercury")
assert_eq(panel.size(), 1)
assert_true(panel.remove_entry_by_peer_id(1))
assert_eq(panel.size(), 0)
func test_panel_get_entry() -> void:
var panel : ScorePanel = _scoreboard.add_panel()
panel.add_entry(1, "mercury")
var entry : ScorePanelEntry = panel.get_entry(0)
assert_not_null(entry)
assert_eq(entry.name, "1")

View file

@ -0,0 +1,69 @@
# This file is part of open-fpsz.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
extends GutTest
#var PLAYER : PackedScene = preload("res://entities/player/player.tscn")
#var SCOREBOARD : PackedScene = preload("res://interfaces/scoreboard/scoreboard.tscn")
#
#var _subject : DeathmatchScoringComponent
#var _scoreboard : Object
#var _victim : Player
#var _killer : Player
#func _setup_player(player_id : int) -> Player:
#var player : Player = PLAYER.instantiate()
#player.name = str(player_id)
#add_child(player) # we can't autofree in this test setup
#var participant : MatchParticipant = player.match_participant
#player.match_participant.player_id = player_id
#_scoreboard.add_participant(participant)
#_subject.subscribe_player(player)
#_subject._players = self
#return player
#
#func before_each() -> void:
#_subject = DeathmatchScoringComponent.new()
#_scoreboard = double(SCOREBOARD).instantiate()
#stub(_scoreboard, 'add_score_to_player')
#stub(_scoreboard, 'increment_kill_count')
#_subject._scoreboard = _scoreboard
#_victim = _setup_player(0)
#_killer = _setup_player(1)
#
#func after_each() -> void:
#_subject.unsubscribe_player(_victim)
#_subject.unsubscribe_player(_killer)
#_victim.free()
#_killer.free()
#_subject.free()
#
#func _kill_player(victim : Player, killer : Player) -> void:
#victim.died.emit(victim, killer.match_participant.player_id)
#
#func test_player_gets_no_score_for_self_kill() -> void:
#_kill_player(_victim, _victim)
#assert_not_called(_scoreboard, 'add_score_to_player')
#assert_not_called(_scoreboard, 'increment_kill_count')
#
#func test_killer_gets_score_after_kill() -> void:
#_kill_player(_victim, _killer)
#assert_called(_scoreboard, 'add_score_to_player', [_killer.match_participant, _subject.ON_KILL_SCORE])
#assert_called(_scoreboard, 'increment_kill_count', [_killer.match_participant])
#
#func test_killer_leaves_before_kill() -> void:
#remove_child(_killer)
#_kill_player(_victim, _killer)
#assert_not_called(_scoreboard, 'add_score_to_player')
#assert_not_called(_scoreboard, 'increment_kill_count')

67
tests/test_teams.gd Normal file
View file

@ -0,0 +1,67 @@
# This file is part of open-fpsz.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
extends GutTest
var _teams : Teams
func before_each() -> void:
_teams = Teams.new()
autofree(_teams)
func test_size() -> void:
assert_eq(_teams.size(), 0)
func test_set_team() -> void:
var team_name : String = "team0"
_teams[team_name] = Team.new(team_name)
assert_eq(_teams.size(), 1)
func test_get_team() -> void:
test_set_team()
var team0 : Team = _teams["team0"]
assert_not_null(team0)
func test_add_team() -> void:
_teams.add_team("team0")
assert_eq(_teams.size(), 1)
func test_erase_team() -> void:
test_add_team()
_teams.erase("team0")
assert_eq(_teams.size(), 0)
func test_add_teams() -> void:
_teams.add_teams(["team0", "team1"])
assert_eq(_teams.size(), 2)
# Team
func test_team_size() -> void:
test_add_team()
var team : Team = _teams["team0"]
assert_eq(team.size(), 0)
func test_team_signals() -> void:
test_add_team()
var team : Team = _teams["team0"]
watch_signals(team)
var player : Player = Player.new()
team.add(player.peer_id, player.username)
assert_signal_emitted(team, "player_added")
assert_eq(team.size(), 1)
team.erase(player.peer_id)
assert_signal_emitted(team, "player_erased")
assert_eq(team.size(), 0)
player.free()

View file

@ -0,0 +1,93 @@
# This file is part of open-fpsz.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
extends GutTest
const SCOREBOARD : PackedScene = preload("res://interfaces/scoreboard/scoreboard.tscn")
var _teams : Teams
var _scoreboard : Scoreboard
func before_each() -> void:
_teams = Teams.new()
_scoreboard = SCOREBOARD.instantiate()
autofree(_teams)
add_child_autoqfree(_scoreboard)
_teams.team_added.connect(_on_team_added)
_teams.team_erased.connect(_on_team_erased)
watch_signals(_teams)
watch_signals(_scoreboard)
func _on_team_added(team_name: String) -> void:
var panel : ScorePanel = _scoreboard.add_panel(team_name)
var team : Team = _teams[team_name]
team.renamed.connect(panel.title.set_text)
team.player_added.connect(_on_team_player_added)
team.player_erased.connect(_on_team_player_erased)
func _on_team_player_added(team_name: String, peer_id: int, username: String) -> void:
var panel : ScorePanel = _scoreboard.panels.get_node(team_name)
panel.add_entry(peer_id, username)
func _on_team_player_erased(team_name: String, peer_id: int) -> void:
var panel : ScorePanel = _scoreboard.panels.get_node(team_name)
panel.remove_entry_by_peer_id(peer_id)
func _on_team_erased(team_name: String) -> void:
var panel : ScorePanel = _scoreboard.panels.get_node(team_name)
_scoreboard.remove_panel(panel)
func test_size() -> void:
assert_eq(_teams.size(), 0)
assert_eq(_scoreboard.size(), 0)
func test_set_team() -> void:
var team_name : String = "team0"
_teams[team_name] = Team.new(team_name)
assert_signal_emitted(_teams, "team_added")
assert_eq(_teams.size(), 1)
assert_eq(_scoreboard.size(), 1)
func test_get_team() -> void:
test_set_team()
var team0 : Team = _teams["team0"]
assert_not_null(team0)
func test_add_team() -> void:
_teams.add_team("team0")
assert_signal_emitted(_teams, "team_added")
assert_eq(_teams.size(), 1)
assert_eq(_scoreboard.size(), 1)
func test_erase_team() -> void:
test_add_team()
_teams.erase("team0")
assert_signal_emitted(_teams, "team_erased")
assert_eq(_teams.size(), 0)
assert_eq(_scoreboard.size(), 0)
func test_team_signals() -> void:
test_add_team()
var team : Team = _teams["team0"]
watch_signals(team)
var player : Player = Player.new()
team.add(player.peer_id, player.username)
assert_signal_emitted(team, "player_added")
assert_eq(team.size(), 1)
assert_eq(_scoreboard.get_panel(0).size(), 1)
team.erase(player.peer_id)
assert_signal_emitted(team, "player_erased")
assert_eq(team.size(), 0)
assert_eq(_scoreboard.get_panel(0).size(), 0)
player.queue_free()