core: fix: matchmaking and game
This commit is contained in:
@ -17,9 +17,9 @@ if TYPE_CHECKING:
|
||||
|
||||
class PongPlayer(APlayer):
|
||||
|
||||
def __init__(self, game: PongGame, user_id: int, socket: WebsocketConsumer, rail: Segment) -> None:
|
||||
def __init__(self, game: PongGame, user: User, socket: WebsocketConsumer, rail: Segment) -> None:
|
||||
|
||||
super().__init__(user_id, socket, game)
|
||||
super().__init__(user, socket, game)
|
||||
|
||||
self.position: Position = Position(0.5, 0)
|
||||
|
||||
@ -29,8 +29,6 @@ class PongPlayer(APlayer):
|
||||
|
||||
self.game: PongGame
|
||||
|
||||
self.username: str = User.objects.get(pk = self.user_id).username
|
||||
|
||||
def eliminate(self):
|
||||
|
||||
self.disconnect(1000)
|
||||
@ -43,7 +41,7 @@ class PongPlayer(APlayer):
|
||||
|
||||
if (detail is None):
|
||||
return
|
||||
|
||||
|
||||
if (detail == "update_my_paddle_pos"):
|
||||
self.update_position(data)
|
||||
|
||||
@ -119,8 +117,8 @@ class PongPlayer(APlayer):
|
||||
def to_dict(self) -> dict:
|
||||
|
||||
data = {
|
||||
"username": self.username,
|
||||
"id": self.user_id,
|
||||
"username": self.user.username,
|
||||
"id": self.user.pk,
|
||||
"position": self.position.to_dict(),
|
||||
"score": self.score,
|
||||
|
||||
|
Reference in New Issue
Block a user