Product selection message handler

This commit is contained in:
Eden Kirin
2023-05-11 15:08:24 +02:00
parent 69e087c0c9
commit 9151aa3e1e
8 changed files with 113 additions and 89 deletions

View File

@ -10,7 +10,6 @@ from hopper.models.product import Product
class GameSettings:
MOVE_DELAY: float = 0.5 # seconds
PURCHASE_START_DELAY: float = 2 # seconds
PURCHASE_FINISHED_DELAY: float = 2 # seconds
@dataclass

View File

@ -33,11 +33,6 @@ class GameDumpDto(BaseModel):
layers: list[LayerDto]
class ProductPurchaseTimerDto(BaseModel):
time_left: int
player: PlayerDto
class PlayerReachedDestinationDto(BaseModel):
player: PlayerDto
@ -55,19 +50,19 @@ class WSMessage(GenericModel):
def to_str(self) -> str:
return json.dumps(self.dict())
@classmethod
@property
def message_type(cls) -> str:
return cls.__fields__["message"].default
class WSGameDumpMessage(WSMessage):
message: str = "game_dump"
data: GameDumpDto
class WSProductPurchaseTimerTickMessage(WSMessage):
message: str = "product_purchase_timer_tick"
data: ProductPurchaseTimerDto
class WSProductPurchaseDoneMessage(WSMessage):
message: str = "product_purchase_done"
class WSProductSelectionDoneMessage(WSMessage):
message: str = "product_selection_done"
class WSPlayerReachedDestinationMessage(WSMessage):