fix: address issue with colors on opponent side

This commit is contained in:
Giovani
2021-07-15 20:40:26 -04:00
parent af301c0582
commit e51ec34f01
3 changed files with 102 additions and 83 deletions

View File

@@ -157,7 +157,7 @@ class _NetworkConnectionService():
async def _try_receive_message(cls) -> None:
try:
task = cls._pending_receive_task or asyncio.create_task(cls._websocket.recv())
done, pending = await asyncio.wait({task}, timeout=4e-3) # TODO experiment with the timeout
done, pending = await asyncio.wait({task}, timeout=2e-3) # TODO experiment with the timeout
if task in done:
json_str = await task
@@ -217,18 +217,22 @@ class _NetworkConnectionService():
# DTOs
class PieceDto():
def __init__(self, points: List, center: List) -> None:
def __init__(self, points: List, center: List, base_color: str, inner_color: str, outer_color: str) -> None:
self.points = points
self.center = center
self.base_color = base_color
self.inner_color = inner_color
self.outer_color = outer_color
@staticmethod
def create(data: Dict) -> "PieceDto":
return PieceDto(data["points"], data["center"])
return PieceDto(data["points"], data["center"], data["base_color"], data["inner_color"], data["outer_color"])
class StackDto():
def __init__(self, points: List) -> None:
def __init__(self, points: List, square_colors: List[Dict]) -> None:
self.points = points
self.square_colors = square_colors
@staticmethod
def create(data: Dict) -> "StackDto":
return StackDto(data["points"])
return StackDto(data["points"], data["square_colors"])