Use fancy new match syntax
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
1c1ca14fe7
commit
2761172a7c
@ -82,25 +82,29 @@ class Model:
|
|||||||
})
|
})
|
||||||
return
|
return
|
||||||
|
|
||||||
if payload['type'] == 'set-name':
|
match payload:
|
||||||
self.clients[client_id].name = payload['name']
|
case {'type': 'set-name', 'name': name}:
|
||||||
await self.broadcast(client_id, {
|
self.clients[client_id].name = name
|
||||||
'type': 'set-name',
|
await self.broadcast(client_id, {
|
||||||
'name': payload['name']
|
'type': 'set-name',
|
||||||
})
|
'name': name
|
||||||
elif payload['type'] == 'chat':
|
})
|
||||||
await self.broadcast(client_id, {
|
|
||||||
'type': 'chat',
|
case {'type': 'chat', 'message': message}:
|
||||||
'message': payload['message']
|
await self.broadcast(client_id, {
|
||||||
})
|
'type': 'chat',
|
||||||
elif payload['type'] == 'roll':
|
'message': message
|
||||||
self.board = self.board_generator.generate_board()
|
})
|
||||||
await self.broadcast(client_id, {
|
|
||||||
'type': 'roll',
|
case {'type': 'roll'}:
|
||||||
'board': self.board
|
self.board = self.board_generator.generate_board()
|
||||||
})
|
await self.broadcast(client_id, {
|
||||||
else:
|
'type': 'roll',
|
||||||
print("Unhandled!")
|
'board': self.board
|
||||||
|
})
|
||||||
|
|
||||||
|
case _:
|
||||||
|
print(' Unhandled!')
|
||||||
|
|
||||||
def get_state_dto(self, client_id: int) -> Any:
|
def get_state_dto(self, client_id: int) -> Any:
|
||||||
return {
|
return {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user