api/cah/constructors.py

59 lines
1.8 KiB
Python
Raw Normal View History

#!/usr/bin/env python3.12
class CAHClient:
def __init__(self,
resource: str,
platform: str,
csid: str,
2024-09-18 19:49:17 -04:00
connected_at: int,
2024-09-19 20:20:16 -04:00
players: list):
self.resource: str = resource
self.platform: str = platform
self.csid: str = csid
2024-09-18 19:49:17 -04:00
self.connected_at: int = connected_at
2024-09-19 20:20:16 -04:00
self.players: list = players
2024-09-18 19:49:17 -04:00
def __iter__(self):
return [value for value in self.__dict__.values() if isinstance(value, int) or isinstance(value, float)].__iter__()
2024-09-19 20:20:16 -04:00
2024-09-18 19:49:17 -04:00
class CAHGame:
def __init__(self,
id: str,
rounds: int,
2024-09-19 20:20:16 -04:00
resources: list[dict],
2024-09-18 19:49:17 -04:00
players: list[dict],
created_at: int,
state: int,
started_at: int,
state_changed_at: int,
):
self.id: str = id
self.rounds: int = rounds
2024-09-19 20:20:16 -04:00
self.resources: list[dict] = resources
2024-09-18 19:49:17 -04:00
self.players: list[dict] = players
self.created_at: int = created_at
self.state: int = state
self.started_at: int = started_at
self.state_changed_at: int = state_changed_at
def __iter__(self):
2024-09-18 21:37:50 -04:00
return [value for value in self.__dict__.values() if isinstance(value, int) or isinstance(value, float)].__iter__()
2024-09-19 20:20:16 -04:00
class CAHPlayer:
def __init__(self,
id: str,
current_game: CAHGame,
platform: str,
related_resource: str,
joined_at: str,
handle: str):
self.id = id
self.current_game = current_game
self.platform = platform
self.related_resource = related_resource
self.joined_at = joined_at
self.handle = handle
2024-09-18 21:37:50 -04:00