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

@ -25,7 +25,7 @@ class Player(Spectator):
self.position: Position = Position(0.5, 0)
self.nb_goal: int = 0
self.score: list[int] = []
self.rail: Segment = rail
@ -112,13 +112,23 @@ class Player(Spectator):
print("bozoman")
self.game.leave(self)
def add_goal(self):
timestamp = self.game.model.add_goal(self.user_id)
self.score.append(timestamp)
print(self.score)
return timestamp
def to_dict(self) -> dict:
data = {
"username": self.username,
"user_id": self.user_id,
"position": self.position.to_dict(),
"nb_goal": self.nb_goal,
"score": [*self.score],
"rail": self.rail.to_dict(),