def test_gen_players_info(self): uuid_list = ["hoge", "fuga", "boo"] name_list = ["HOGE", "FUGA", "BOO"] players_info = Engine.gen_players_info(uuid_list, name_list) for idx, (uuid, name) in enumerate(players_info.items()): self.eq(uuid_list[idx], uuid) self.eq(name_list[idx], name)
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 start_game(self): # assert self.rule and len(self.members_info) >= 2 and not self.is_playing_poker uuid_list = [member["uuid"] for member in self.members_info] name_list = [member["name"] for member in self.members_info] players_info = Engine.gen_players_info(uuid_list, name_list) self.ai_players = build_ai_players(self.members_info) self.engine = Engine.EngineWrapper() self.latest_messages = self.engine.start_game(players_info, self.rule) self.is_playing_poker = True self.next_player_uuid = fetch_next_player_uuid(self.latest_messages)
def start_game(self): assert self.rule and len(self.members_info) >= 2 and not self.is_playing_poker uuid_list = [member["uuid"] for member in self.members_info] name_list = [member["name"] for member in self.members_info] players_info = Engine.gen_players_info(uuid_list, name_list) self.ai_players = build_ai_players(self.members_info) self.engine = Engine.EngineWrapper() self.latest_messages = self.engine.start_game(players_info, self.rule) self.is_playing_poker = True self.next_player_uuid = fetch_next_player_uuid(self.latest_messages) self.hand_info = [] self.hand_info_uuids = []
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)