示例#1
0
def JS_TRACKINFO():
    from rich import print
    obj = AR.get("juese_info", UDD["juese_info"])
    zb = AR.get("zhuangbei_kucun", UDD["zhuangbei_kucun"])
    store = {}
    for k, v in zb.items():
        num, _, _ = v
        if k in data.EQU_ID:
            store[data.EQU_ID[k]] = num
    table = RTable(title="练度追踪", caption="*当前可满:以目前的库存最高能满装Rank。\n"
                                         "*下一RANK:要在下一RANK上满装还需要的碎片。", caption_justify="left")
    table.add_column("角色", justify='center')
    table.add_column("进度", justify='center')
    table.add_column("当前可满", justify='center')
    table.add_column("下一RANK", justify='center')
    for k, v in obj.items():
        if not ('track_rank' in v and 'track_zb' in v and 'zb' in v and 'rank' in v):
            continue
        if k not in data.C_ID:
            continue
        cid = data.C_ID[k]
        need_equip_before = data.calc_rankup_equip(cid, v['rank'], [False] * 6, v['track_rank'], v['track_zb'])
        before_store = data.calc_equips_decompose(need_equip_before)
        need_equip_after = data.calc_rankup_equip(cid, v['rank'], v['zb'], v['track_rank'], v['track_zb'])
        after_store = data.calc_equips_decompose(need_equip_after, store=store)
        before_sum = sum(before_store.values())
        after_sum = sum(after_store.values())
        if before_sum == 0:
            continue
        if v['track_rank'] == v['rank']:
            fg = True
            for t1, t2 in zip(v['track_zb'], v['zb']):
                if t1 and (not t2):
                    fg = False
                    break
            if fg:
                continue
        cur_rank = v['rank']
        cur_after_sum = 0
        while cur_rank <= v['track_rank']:
            cur_zb = [True] * 6 if cur_rank < v['track_rank'] else v['track_zb']
            cur_need = data.calc_rankup_equip(cid, v['rank'], v['zb'], cur_rank, cur_zb)
            cur_after = data.calc_equips_decompose(cur_need, store=store)
            cur_after_sum = sum(cur_after.values())
            if cur_after_sum > 0:
                break
            cur_rank += 1
        R = []
        R += [k]
        OG = ROrderGrid(2)
        OG.add(RLRProgress(before_sum - after_sum, before_sum, RValue("R%2d" % v['rank']),
                           RValue("R%2d" % v['track_rank']), width=20, percent=False))
        OG.add(RComment(''.join(['O' if p else '_' for p in v['track_zb']])))
        OG.finish()
        R += [OG]
        cur_rank -= 1
        R += ["Rank " + str(cur_rank)]
        R += ["x" + str(cur_after_sum)]
        table.add_row(*R)
    print(table)
示例#2
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)