def build_game_update_message(self, player_pos, action, amount, state): player = state["table"].seats.players[player_pos] message = { "message_type": self.GAME_UPDATE_MESSAGE, "action": DataEncoder.encode_action(player, action, amount), "round_state": DataEncoder.encode_round_state(state), "action_histories": DataEncoder.encode_action_histories(state["table"]) } return self.__build_notification_message(message)
def build_game_update_message(self, player_pos, action, amount, state): player = state['table'].seats.players[player_pos] message = { 'message_type': self.GAME_UPDATE_MESSAGE, 'action': DataEncoder.encode_action(player, action, amount), 'round_state': DataEncoder.encode_round_state(state), 'action_histories': DataEncoder.encode_action_histories(state['table']) } return self.__build_notification_message(message)
def test_game_update_message(self): state = self.__setup_state() table = state["table"] player = table.seats.players[1] message = MessageBuilder.build_game_update_message(1, "call", 10, state) msg = message["message"] self.eq("notification", message["type"]) self.eq(MessageBuilder.GAME_UPDATE_MESSAGE, msg["message_type"]) self.eq(DataEncoder.encode_action(player, "call", 10), msg["action"]) self.eq(DataEncoder.encode_round_state(state), msg["round_state"]) self.eq(DataEncoder.encode_action_histories(table), msg["action_histories"])
def test_game_update_message(self): state = self.__setup_state() table = state['table'] player = table.seats.players[1] message = MessageBuilder.build_game_update_message(1, 'call', 10, state) msg = message['message'] self.eq('notification', message['type']) self.eq(MessageBuilder.GAME_UPDATE_MESSAGE, msg['message_type']) self.eq(DataEncoder.encode_action(player, 'call', 10), msg['action']) self.eq(DataEncoder.encode_round_state(state), msg['round_state']) self.eq(DataEncoder.encode_action_histories(table), msg['action_histories'])
def test_encode_action(self): player = setup_player() hsh = DataEncoder.encode_action(player, "raise", 20) self.eq(player.uuid, hsh["player_uuid"]) self.eq("raise", hsh["action"]) self.eq(20, hsh["amount"])
def test_encode_action(self): player = setup_player() hsh = DataEncoder.encode_action(player, 'raise', 20) self.eq(player.uuid, hsh['player_uuid']) self.eq('raise', hsh['action']) self.eq(20, hsh['amount'])