CAH plugin ------ initial work/to be refactored, working through implementation bits

This commit is contained in:
2024-09-19 20:58:33 -04:00
parent a4d9fa797c
commit f20a325a1f
3 changed files with 14 additions and 11 deletions

View File

@ -59,10 +59,10 @@ class CAH(FastAPI):
for __game in self.games:
if __game.id == game:
_game = __game
print(f"Got game!!!\n{game}")
for _player in _game.players:
if _player.get('id') == player:
_game.players.pop(_player)
print(f"Got game!!!\n{_game}\nPlayers: {_game.players}")
for idx, _player in enumerate(_game.players):
if _player.get('handle') == player:
_game.players.pop(idx)
await self.connection_manager.broadcast({
'event': 'player_left',
'ts': int(time.time()),
@ -101,7 +101,7 @@ class CAH(FastAPI):
'event': 'player_joined',
'ts': int(time.time()),
'data': {
'player': player
'player': player.__dict__,
}
}) # Change to broadcast to current game members only
return joined_game
@ -134,6 +134,8 @@ class CAH(FastAPI):
case 'handshake':
await self.cah_handshake(websocket,
data)
case 'refresh':
await self.connection_manager.send_client_and_game_lists(self, websocket)
case 'create_game':
await self.create_game(websocket,
data)
@ -232,6 +234,7 @@ class CAH(FastAPI):
'errorText': f'Player {player} not found in {game}'
}
def get_games(self):
try: