game: add: goal statistic

This commit is contained in:
2024-02-26 17:11:31 +01:00
committed by AdrienLSH
parent d961130de3
commit b9de0f3619
15 changed files with 335 additions and 82 deletions

View File

@ -97,6 +97,13 @@ class Game(AbstractRoom):
for member in members:
member.send(detail, data)
def goal(self, goal_taker: Player):
timestamp = goal_taker.add_goal()
self.broadcast("goal", {"player_id": goal_taker.user_id,
"timestamp": timestamp})
def get_player_by_user_id(self, user_id: int) -> Player:
for player in self.players:
if (player.user_id == user_id):
@ -144,11 +151,10 @@ class Game(AbstractRoom):
connected_players: list[Player] = self.get_players_connected()
if (self.model.started):
print(len(connected_players))
if (len(connected_players) == 1):
last_player: Player = connected_players[0]
print("finish")
self.finish(last_player)
#self.finish(last_player)
return
self._update_player(player)