def replay(game_info): """回放对局进程""" player_roles = dict() pos_list = [pos for (pos, _, _) in game_info['历次出牌']] pos_list.append(game_info['玩家id']) first_pos = pos_list.index(game_info['地主id']) for index in range(min(3, len(pos_list))): player_roles[pos_list[index]] = (index - first_pos) % 3 for idx, (pos, card_list, remain_count) in enumerate(game_info['历次出牌']): out_cards_group = Card.card_ints_from_others(card_list) out_cards = Card.cards_without_suit(out_cards_group) role = player_roles[pos] if out_cards != '': print('{0} 出牌: {1},剩余{2}张'.format(str_role_dict[role], out_cards, remain_count)) else: print('{0} 出牌: {1},剩余{2}张'.format(str_role_dict[role], 'pass', remain_count)) player_cards_group = Card.card_ints_from_others(game_info['玩家当前牌']) player_cards = Card.cards_without_suit(player_cards_group) role = player_roles[game_info['玩家id']] print('{0}当前牌: {1}'.format(str_role_dict[role], player_cards))
def convert(vpx): """将传入的牌idlist转换为字符串形式""" card_ints = Card.card_ints_from_others(vpx) return Card.cards_without_suit(card_ints)