def test_update_game_when_game_finished(self):
        uuid_list = ["hoge", "fuga", "boo"]
        name_list = ["HOGE", "FUGA", "BOO"]
        players_info = Engine.gen_players_info(uuid_list, name_list)
        game_config = Engine.gen_game_config(5, 100, 10, 1)

        engine = Engine.EngineWrapper()
        engine.start_game(players_info, game_config)

        # Fix cards used in the game to make game result deterministic
        engine.current_state['table'].deck = Deck(cheat=True,
                                                  cheat_card_ids=range(6, 11))
        for idx, player in enumerate(
                engine.current_state['table'].seats.players):
            player.hole_card = [
                Card.from_id(idx * 2),
                Card.from_id(idx * 2 + 1)
            ]

        engine.update_game("raise", 99)
        engine.update_game("call", 99)
        original_msgs = engine.update_game("call", 99)
        hoge_msg, fuga_msg, boo_msg = [
            _simplify_messages(msgs)
            for msgs in _classify_messages_by_destination(
                original_msgs, uuid_list)
        ]
        self.eq([MSG_GU, MSG_SS, MSG_SS, MSG_SS, MSG_RF, MSG_GF], hoge_msg)
        self.eq([MSG_GU, MSG_SS, MSG_SS, MSG_SS, MSG_RF, MSG_GF], fuga_msg)
        self.eq([MSG_GU, MSG_SS, MSG_SS, MSG_SS, MSG_RF, MSG_GF], boo_msg)
 def test_gen_game_config(self):
     config = Engine.gen_game_config(5, 100, 10, 1)
     self.eq(5, config['max_round'])
     self.eq(100, config['initial_stack'])
     self.eq(10, config['small_blind'])
     self.eq(1, config['ante'])
     self.eq(1, config['blind_structure'][1]['ante'])
    def test_start_game(self):
        uuid_list = ["hoge", "fuga", "boo"]
        name_list = ["HOGE", "FUGA", "BOO"]
        players_info = Engine.gen_players_info(uuid_list, name_list)
        game_config = Engine.gen_game_config(5, 100, 10, 1)

        engine = Engine.EngineWrapper()
        original_msgs = engine.start_game(players_info, game_config)
        hoge_msg, fuga_msg, boo_msg = [
            _simplify_messages(msgs)
            for msgs in _classify_messages_by_destination(
                original_msgs, uuid_list)
        ]
        self.eq([MSG_RS, MSG_SS, MSG_AK], hoge_msg)
        self.eq([MSG_RS, MSG_SS], fuga_msg)
        self.eq([MSG_RS, MSG_SS], boo_msg)
Пример #4
0
 def define_rule(self, max_round, initial_stack, small_blind, ante,
                 blind_structure):
     self.rule = Engine.gen_game_config(max_round, initial_stack,
                                        small_blind, ante, blind_structure)
 def test_gen_game_config_with_blind_structure(self):
     config = Engine.gen_game_config(5, 100, 10, 1, blind_structure)
     self.eq(1, config['blind_structure'][1]['ante'])
     self.eq(5, config['blind_structure'][2]['ante'])
Пример #6
0
 def define_rule(self, max_round, initial_stack, small_blind, ante, blind_structure):
     self.rule = Engine.gen_game_config(max_round, initial_stack, small_blind, ante, blind_structure)