pseudo mvc

This commit is contained in:
2024-03-26 17:35:48 +01:00
parent 01fd2d63f5
commit 85308a8007
4 changed files with 23 additions and 6 deletions
+1
View File
@@ -1 +1,2 @@
from controller.client import Client
from controller.game import GameController
+11
View File
@@ -0,0 +1,11 @@
from netcode import WSServer
class GameController:
server: WSServer
def __init__(self, server: WSServer):
self.server = server
def start_game(self):
pass
+8 -2
View File
@@ -2,6 +2,7 @@
from typing import List, Callable, Coroutine, Any
from game import Card, Team
from controller import GameController
class Game:
@@ -16,17 +17,22 @@ class Game:
default_health = 80
broadcast: Callable[[str], Coroutine[Any, Any, Any]]
controller: GameController
def __init__(self):
def __init__(self, controller):
self.market_stack = []
self.market = []
self.gem_stack = []
self.teams = []
self.started = False
self.controller = controller
def create_team(self):
if self.started:
return False
team = Team(health=self.default_health)
self.teams.append(team)
def start_game(self):
pass
+3 -4
View File
@@ -4,12 +4,11 @@ from game import Game
from netcode.ws_server import WebSocketServerProtocol
from netcode import WSServer
from controller import Client
from controller import Client, GameController
gameServer = WSServer()
hero_game = Game()
hero_game.broadcast = gameServer.broadcast
controller = GameController(gameServer)
hero_game = Game(controller)
playerServer = WSServer()