diff --git a/systems/scoreboard/scoreboard.gd b/systems/scoreboard/scoreboard.gd
index 718d414..138ca4c 100644
--- a/systems/scoreboard/scoreboard.gd
+++ b/systems/scoreboard/scoreboard.gd
@@ -1,14 +1,28 @@
-class_name Scoreboard extends Node
+# 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 .
+class_name Scoreboard extends Node2D
# define the properties
-@export var num_teams: int = 1
-@export var num_players_per_team: int = 1
+@export var _num_teams: int = 1
+@export var _num_players_per_team: int = 1
# define the scoreboard dictionary
var scoreboard := {}
# initialize the scoreboard
-func _init() -> void:
+func _init(num_teams: int = _num_teams, num_players_per_team: int = _num_players_per_team) -> void:
scoreboard = {}
for team in range(1, num_teams + 1):
scoreboard[team] = {}
diff --git a/tests/test_systems_scoreboard.gd b/tests/test_systems_scoreboard.gd
new file mode 100644
index 0000000..69733af
--- /dev/null
+++ b/tests/test_systems_scoreboard.gd
@@ -0,0 +1,60 @@
+# 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 .
+extends GutTest
+
+var scoreboard : Scoreboard
+
+func before_all():
+ # test init with params
+ scoreboard = Scoreboard.new(1,2)
+ # check if `num_teams` is correctly initialized
+ assert_true(scoreboard.scoreboard.size() == 1)
+ # check if `num_players_per_team` is correctly initialized
+ assert_true(scoreboard.scoreboard[1].size() == 2)
+ scoreboard.queue_free()
+
+ # test default init
+ scoreboard = Scoreboard.new()
+ # check if `num_teams` is correctly initialized
+ assert_true(scoreboard.scoreboard.size() == 1)
+ # check if `num_players_per_team` is correctly initialized
+ assert_true(scoreboard.scoreboard[1].size() == 1)
+
+func test_update_score():
+ # update offense score for team 1, player 1 by 5 points
+ scoreboard.update_score(1, 1, 5, 'O')
+ # check player score
+ var player_score = scoreboard.get_player_score(1, 1)
+ assert_true(player_score['O'] == 5)
+
+func test_get_player_score():
+ # update offense score for team 1, player 1 by 5 points
+ scoreboard.update_score(1, 1, 5, 'O')
+ var player_score = scoreboard.get_player_score(1, 1)
+ # check player score
+ assert_true(player_score['O'] == 10)
+
+func test_get_team_score():
+ # update offense score for team 1, player 1 by 5 points
+ scoreboard.update_score(1, 1, 5, 'O')
+ # update defense score for team 1, player 1 by 5 points
+ scoreboard.update_score(1, 1, 5, 'D')
+ var team_score = scoreboard.get_team_score(1)
+ # check team score
+ assert_true(team_score['O'] == 15)
+ assert_true(team_score['D'] == 5)
+
+func after_all():
+ scoreboard.queue_free()