def main(): team_no = 0 lang = Language.CN cv = HeroMatchCV() o = CNOutput() bp = BanPick() available, teams = cv.find_heroes() print('Available: {}'.format(len(available))) print('Teams: {}'.format(teams)) teammates = teams[team_no] match_ups = teams[1 - team_no] match_ups, teammates = bp.remove_none(match_ups, teammates) r = bp.recommend(match_ups, teammates, available) if r is not None: _, _, _, t_1, t_2 = r t_1 = bp.convert_table_lang(t_1, lang) t_2 = bp.convert_table_lang(t_2, lang) bp.print_recommend(t_1, t_2) o.recommend(match_ups, teammates, available) r = bp.win_rate(match_ups, teammates, lang=lang) if r is not None: _, _, _, table = r table = bp.convert_table_lang(table, lang) bp.print_table(table, headers=['Name', 'Value', 'Reason']) o.win_rate(match_ups, teammates)
class CNOutput(object): def __init__(self): self.lang = Language.CN self.name_key = 'cn_name' self.bp = BanPick() def get_abbrev_name(self, hero): names = CN_ABBREV_DICT[hero] min_len = 10 abbrev = '' for name in names: if min_len > len(name): abbrev = name min_len = len(name) elif min_len == len(name) and ord(name[0]) > 255: abbrev = name min_len = len(name) return abbrev def recommend(self, match_ups, teammates, available=None): if len(match_ups) == 5 and len(teammates) == 5: return _h_v, reasons, v_list, _, _ = self.bp.recommend( match_ups, teammates, available) msgs = [] msg = '推荐:' h_list = [] for i in range(15): h = v_list[i][0] h_list.append(self.get_abbrev_name(h)) msg += ','.join(h_list) msgs.append(msg) print(msg) msg = '不推荐:' h_list = [] for i in range(15): h = v_list[-i - 1][0] h_list.append(self.get_abbrev_name(h)) msg += ','.join(h_list) print(msg) pyperclip.copy(';'.join(msgs)) def win_rate(self, match_ups, teammates): if len(match_ups) != 5 or len(teammates) != 5: return theirs_score, ours_score, wr, table = self.bp.win_rate(match_ups, teammates, lang=self.lang) msg = '胜率:{0:.2f},易发挥:'.format(wr) h_list = [] for i in range(3): h_list.append(self.get_abbrev_name(table[i][0])) msg += ','.join(h_list) print(msg) pyperclip.copy(msg)
def main(): team_no = 0 teams = [[ CNAbbrevHeroes.none, CNAbbrevHeroes.none, CNAbbrevHeroes.none, CNAbbrevHeroes.none, CNAbbrevHeroes.none ], [ CNAbbrevHeroes.none, CNAbbrevHeroes.none, CNAbbrevHeroes.none, CNAbbrevHeroes.none, CNAbbrevHeroes.none ]] bans = [] lang = Language.CN o = CNOutput() bp = BanPick() available = list(bp.data.keys()) for ban in bans: available.remove(ban) for team in teams: for h in team: if h in available: available.remove(h) print('Available: {}'.format(len(available))) print('Teams: {}'.format(teams)) teammates = teams[team_no] match_ups = teams[1 - team_no] match_ups, teammates = bp.remove_none(match_ups, teammates) r = bp.recommend(match_ups, teammates, available) if r is not None: _, _, _, t_1, t_2 = r t_1 = bp.convert_table_lang(t_1, lang) t_2 = bp.convert_table_lang(t_2, lang) bp.print_recommend(t_1, t_2) o.recommend(match_ups, teammates, available) r = bp.win_rate(match_ups, teammates, lang=lang) if r is not None: _, _, _, table = r table = bp.convert_table_lang(table, lang) bp.print_table(table, headers=['Name', 'Value', 'Reason']) o.win_rate(match_ups, teammates)