def serialize(self) -> bytes: result = utils.int_to_byte(len(self.players)) for player in self.players: result += utils.int_to_byte( player.player_id) + player.score.to_bytes( 2, byteorder='big', signed=True) return result
def serialize(self) -> bytes: result = utils.int_to_byte(self.player_id) + utils.int_to_byte( len(self.players)) for player_info in self.players: result += utils.int_to_byte( player_info.player_id) + utils.int_to_byte(player_info.ready) b = player_info.name.encode('utf-8') result += utils.int_to_byte(len(b)) + b return result
def serialize(self) -> bytes: result = utils.int_to_byte(self.player_id) + self.score.to_bytes( 2, byteorder='big', signed=True) result += utils.int_to_byte(len(self.placed_tiles)) for tile in self.placed_tiles: result += utils.int_to_byte(tile.position) + utils.int_to_byte( tile.points) b = tile.letter.encode('utf-8') result += utils.int_to_byte(len(b)) + b return result
def serialize(self) -> bytes: result = utils.int_to_byte(len(self.tile_placements)) for tile in self.tile_placements: result += utils.int_to_byte(tile.position) + utils.int_to_byte( tile.id) if tile.letter is None: result += b'\x00' else: letter = tile.letter.encode('utf-8') result += utils.int_to_byte(len(letter)) + letter return result
def serialize(self) -> bytes: result = utils.int_to_byte(self.turn_player_id) result += utils.int_to_byte(self.tiles_left) + utils.int_to_byte( len(self.tiles)) for tile in self.tiles: result += utils.int_to_byte(tile.id) + utils.int_to_byte( tile.points) if tile.letter is None: result += b'\x00' else: b = tile.letter.encode('utf-8') result += utils.int_to_byte(len(b)) + b result += utils.int_to_byte(len(self.player_tile_counts)) for player in self.player_tile_counts: result += utils.int_to_byte(player.id) + utils.int_to_byte( player.tile_count) return result
def serialize(self) -> bytes: return utils.int_to_byte(len(self.tile_ids)) + bytes(self.tile_ids)
def serialize(self) -> bytes: b = self.name.encode('utf-8') return utils.int_to_byte(len(b)) + b
def serialize(self) -> bytes: b = self.text.encode('utf-8') return utils.int_to_byte(self.player_id) + len(b).to_bytes( 2, byteorder='big') + b
def serialize(self) -> bytes: return utils.int_to_byte(self.player_id)