示例#1
0
def ZB_ST_ADVICE(args, verbose=True):
    from rich import print
    max_tu = get_arg(args, "--max-tu", None)
    if max_tu is not None:
        max_tu = int(max_tu)
    min_rare = int(get_arg(args, "--min-rare", "0"))
    max_rare = int(get_arg(args, "--max-rare", "6"))
    num_w = float(get_arg(args, "--num-w", "0.1"))
    need_equip = {}
    js_need = {}
    zb_js = {}
    juese = AR.get("juese_info", UDD["juese_info"])
    for k, v in juese.items():
        if k in data.C_ID and "track_rank" in v and "track_zb" in v \
                and "rank" in v and "zb" in v:
            ne = data.calc_rankup_equip(data.C_ID[k], v["rank"], v["zb"],
                                        v["track_rank"], v["track_zb"])
            for n in list(ne.keys()):
                lv = data.EInfo[n]['plevel']
                if lv < min_rare or lv > max_rare:
                    ne.pop(n)
            ne2 = data.calc_equips_decompose(ne)
            for n in ne2:
                js_need.setdefault(k, {})
                js_need[k].setdefault(n, 0)
                js_need[k][n] += ne2[n]
                zb_js.setdefault(n, {})
                zb_js[n].setdefault(k, 0)
                zb_js[n][k] += ne2[n]
            data.dict_plus(need_equip, ne, False)
    store = {}
    if not has_arg(args, "--no-store"):

        zb = AR.get("zhuangbei_kucun", UDD["zhuangbei_kucun"])
        for k, v in zb.items():
            num, _, _ = v
            if k in data.EQU_ID:
                store[data.EQU_ID[k]] = num
        lack = data.calc_equips_decompose(need_equip, store)
    else:
        lack = data.calc_equips_decompose(need_equip)

    prob_map = data.make_normal_map_prob(max_tu)
    map_js = {}
    for k, v in zb_js.items():
        if k not in prob_map:
            continue
        m = prob_map[k]
        for _, (A, B) in m:
            mid = f"{A}-{B}"
            map_js.setdefault(mid, {})
            data.dict_plus(map_js[mid], v, False)
    out_map = None
    try:
        out_map, result_int = data.make_map_advice(lack, prob_map, num_w)
    except Exception as e:
        print(e)
        if num_w > 0:
            print("可能是混合整数搜索失败!你可能需要安装cvxopt依赖")
            out_map, result_int = data.make_map_advice(lack, prob_map, 0)

    mul = int(get_arg(args, "--n", "1"))
    if mul > 1:
        result_int = 0
        keys = list(out_map.keys())
        for i in keys:
            out_map[i] = int(round(out_map[i] / mul))
            if out_map[i] == 0:
                out_map.pop(i)
                continue
            result_int += out_map[i]
    out_sorted = sorted(out_map, reverse=True, key=lambda x: out_map[x])
    if not verbose:
        return out_sorted, out_map
    table = RTable(title="刷取建议",
                   caption=RText("倍率:") + RValue("【", mul, "】") +
                   RText(' 总次数:') + RValue(int(result_int)),
                   box=rbox.HEAVY_EDGE,
                   show_lines=True)
    js_flag = has_arg(args, "--js")
    zb_flag = has_arg(args, "--zb")
    store_flag = has_arg(args, "--no-store")
    table.add_column("图号", justify="center")
    table.add_column("次数", justify="center")
    if js_flag or zb_flag:
        table.add_column("详细信息", justify="center")
    for out in out_sorted:
        row = []
        row += [out]
        row += [f"x{out_map[out]}"]
        if zb_flag:
            RR = ROrderGrid(4)
            A, B = out.split('-')
            A = int(A)
            B = int(B)
            rew = data.calc_normal_reward(A, B)
            for r in rew:
                if r["rid"] in lack:
                    col = []
                    col += [data.ID_EQU[r['rid']]]
                    col += [RValue(f"x{lack[r['rid']]}")]
                    if not store_flag:
                        col[-1] += f"\t库存:{store.get(r['rid'], 0)}"
                    col += ["----------"]
                    sss = []
                    if js_flag:
                        sss += []
                        cur = zb_js[r['rid']]
                        for nam in sorted(cur,
                                          reverse=True,
                                          key=lambda x: cur[x]):
                            sss += ["%s x%d" % (nam, cur[nam])]
                        col += ['\n'.join(sss)]
                    ROT = ROneTable(*col)
                    RR.add(ROT)
            RR.finish()
            row += [RR]
        elif js_flag:
            cur = map_js[out]
            cur_sort = sorted(cur, reverse=True, key=lambda x: cur[x])
            sss = []
            for p in cur_sort:
                sss += ["%s x%d" % (p, cur[p])]
            row += ["\n".join(sss)]
        table.add_row(*row)
    print(table)
示例#2
0
def ZB_ST_LACK(args):
    from rich import print
    need_equip = {}
    juese = AR.get("juese_info", UDD["juese_info"])
    for k, v in juese.items():
        if k in data.C_ID and "track_rank" in v and "track_zb" in v \
                and "rank" in v and "zb" in v:
            ne = data.calc_rankup_equip(data.C_ID[k], v["rank"], v["zb"],
                                        v["track_rank"], v["track_zb"])
            data.dict_plus(need_equip, ne, False)
    if has_arg(args, "--item"):
        lack = need_equip
    else:
        if not has_arg(args, "--no-store"):
            store = {}
            zb = AR.get("zhuangbei_kucun", UDD["zhuangbei_kucun"])
            for k, v in zb.items():
                num, _, _ = v
                if k in data.EQU_ID:
                    store[data.EQU_ID[k]] = num
            lack = data.calc_equips_decompose(need_equip, store)
        else:
            lack = data.calc_equips_decompose(need_equip)
    show = defaultdict(list)
    for equ in lack:
        show[data.EInfo[equ]['plevel']] += [equ]
    LABEL = {
        1: '铁',
        2: '铜',
        3: '银',
        4: '金',
        5: '紫',
        6: '红',
    }
    min_rare = int(get_arg(args, "--min-rare", "0"))
    max_rare = int(get_arg(args, "--max-rare", "6"))
    max_tu = get_arg(args, "--max-tu", None)
    if max_tu is not None:
        max_tu = int(max_tu)
    normal = data.make_normal_map_prob(max_tu)
    for k in sorted(show, reverse=True):
        if k < min_rare or k > max_rare:
            continue
        table = RTable(title="稀有度:" + LABEL[k],
                       show_lines=True,
                       box=rbox.HEAVY_EDGE)
        table.add_column("装备", justify="center")
        table.add_column("缺失", justify="center")
        if has_arg(args, "--normal"):
            table.add_column("刷取区域", justify="center")
        for equ in show[k]:
            row = [data.ID_EQU[equ], f"x{lack[equ]}"]
            if has_arg(args, "--normal"):
                if equ not in normal:
                    row += ['']
                else:
                    RR = ROrderGrid(8)
                    lst = normal[equ]
                    for prob, (A, B) in lst:
                        RR.add(ROneTable(f"{A}-{B}", f"{prob}%"))
                    RR.finish()
                    row += [RR]
            table.add_row(*row)
        print(table)