示例#1
0
def transfer_sim_db(dl_sim_db):
    db = DBManager()
    db.transfer(dl_sim_db, SIM_TABLE_LIST)
    db = DBManager(DL9_DB)
    adv_ele_passives, adv_wep_passives, drg_passives = count_fort_passives(
        include_album=True)
    halidom_data = []
    for elebonus, wepbonus in itertools.product(adv_ele_passives.items(),
                                                adv_wep_passives.items()):
        halidom_data.append({
            "form": 1,
            "ele": elebonus[0][0],
            "wep": wepbonus[0][0],
            "hp": elebonus[1][0] + wepbonus[1][0],
            "atk": elebonus[1][1] + wepbonus[1][1],
        })
    for drgbonus in drg_passives.items():
        halidom_data.append({
            "form": 2,
            "ele": drgbonus[0][0],
            "wep": None,
            "hp": drgbonus[1][0],
            "atk": drgbonus[1][1],
        })
    meta = DBTableMetadata("HalidomBonus")
    meta.init_from_row(halidom_data[0], auto_pk=True)
    db.create_table(meta)
    db.insert_many(meta.name, halidom_data)
示例#2
0
def transfer_actions_db(db_file, actions_dir):
    processed = {
        PARTS_INDEX.name: [],
        # PARTS_HITLABEL.name: [],
    }
    tablemetas = {
        PARTS_INDEX.name: PARTS_INDEX,
        # PARTS_HITLABEL.name: PARTS_HITLABEL,
    }
    for filename in tqdm(glob(actions_dir + "/PlayerAction_*.json"),
                         desc="read_actions"):
        action_id = filename.split("_")[-1].replace(".json", "")
        with open(filename, "r") as fn:
            for seq, part in enumerate(json.load(fn)):
                process_action_part(action_id, seq, part, processed,
                                    tablemetas)

    db = DBManager(db_file)
    for tbl, meta in tqdm(tablemetas.items(), desc="load_actions"):
        db.drop_table(tbl)
        db.create_table(meta)
        db.insert_many(tbl, processed[tbl], mode=DBManager.REPLACE)