Archived
Some game actions work
This commit is contained in:
@@ -81,11 +81,19 @@ class ClientController(ClientControllerInterface):
|
||||
if self.player.team != self.game_controller.game.turn:
|
||||
return await self.send_error("it is not your turn to play!")
|
||||
if message.type == "action":
|
||||
print("message.data_type")
|
||||
if message.data_type == "buy":
|
||||
for c in message.data:
|
||||
await self.player.buy_card(c)
|
||||
## TODO : pydantic type check for message.data
|
||||
await self.player.buy_cards(message.data)
|
||||
elif message.data_type == "play_cards":
|
||||
await self.player.play_cards(message.data)
|
||||
elif message.data_type == "discard":
|
||||
await self.player.discard_cards(message.data)
|
||||
elif message.data_type == "draw":
|
||||
await self.player.draw(message.data)
|
||||
elif message.data_type == "end_turn":
|
||||
|
||||
await self.player.end_turn()
|
||||
|
||||
@vibe_check(LoginMessage)
|
||||
async def login_context(self, message: LoginMessage):
|
||||
@@ -149,4 +157,3 @@ class ClientController(ClientControllerInterface):
|
||||
self.player.ready = bool(message.data)
|
||||
if all(p.ready for p in self.game_controller.game.players):
|
||||
await self.game_controller.start_game()
|
||||
self.on_message = self.game_context
|
||||
|
||||
@@ -106,6 +106,8 @@ class GameController(GameControllerInterface):
|
||||
|
||||
async def start_game(self):
|
||||
await self.game.start_game()
|
||||
for c in self.clients:
|
||||
c.on_message = c.game_context
|
||||
await self.broadcast(
|
||||
Message(type="context", data_type="game_context_id", data="game")
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user