game: init: class
This commit is contained in:
parent
2e8eebc788
commit
f11af8336a
17
games/objects/GameMember.py
Normal file
17
games/objects/GameMember.py
Normal file
@ -0,0 +1,17 @@
|
||||
from channels.generic.websocket import AsyncWebsocketConsumer
|
||||
|
||||
from transcendence.abstract.AbstractRoomMember import AbstractRoomMember
|
||||
|
||||
class GameMember(AbstractRoomMember):
|
||||
|
||||
def __init__(self, user_id: int, socket: AsyncWebsocketConsumer):
|
||||
super().__init__(user_id, socket)
|
||||
self.is_a_player = False
|
||||
|
||||
def receive(self, data: dict):
|
||||
if (not self.is_a_player):
|
||||
self.send("You are not a player.")
|
||||
return
|
||||
|
||||
def send_ball(self, ball):
|
||||
pass
|
9
games/objects/GameRoom.py
Normal file
9
games/objects/GameRoom.py
Normal file
@ -0,0 +1,9 @@
|
||||
from transcendence.abstract.AbstractRoom import AbstractRoom
|
||||
|
||||
from .GameRoomManager import GameRoomManager
|
||||
|
||||
class GameRoom(AbstractRoom):
|
||||
|
||||
def __init__(self, game_room_manager: GameRoomManager, game_id: int):
|
||||
super().__init__(game_room_manager)
|
||||
self.game_id = game_id
|
18
games/objects/GameRoomManager.py
Normal file
18
games/objects/GameRoomManager.py
Normal file
@ -0,0 +1,18 @@
|
||||
from transcendence.abstract.AbstractRoomManager import AbstractRoomManager
|
||||
|
||||
from ..models import GameModel
|
||||
|
||||
class GameRoomManager(AbstractRoomManager):
|
||||
|
||||
def get(self, game_id: int):
|
||||
|
||||
for room in self._room_list:
|
||||
if (room.game_id == game_id):
|
||||
return room
|
||||
|
||||
if (GameModel.objects.filter(pk = tournament_id).exists()):
|
||||
room = TournamentRoom(self, game_id)
|
||||
self.append(room)
|
||||
return room
|
||||
|
||||
return None
|
Loading…
Reference in New Issue
Block a user