勇者之书吧 关注:238贴子:718
  • 3回复贴,共1

勇者之书存档修改脚本

只看楼主收藏回复

修改图



IP属地:湖北1楼2024-11-08 22:52回复
    import sqlite3
    import os
    import getpass
    def insert_ImprintData(db_path,ImprintId):
    # 连接到SQLite数据库
    conn = sqlite3.connect(db_path)
    cursor = conn.cursor()
    try:
    # 检查ImprintId是否已经存在
    cursor.execute("SELECT COUNT(*) FROM ImprintData WHERE ImprintId = ?", (int(ImprintId),))
    count = cursor.fetchone()[0]
    if count > 0:
    print(f"ImprintId {ImprintId} 已经存在,不插入记录")
    return 0
    # 查询ImprintData表中的最大Id
    cursor.execute("SELECT MAX(Id) FROM ImprintData")
    max_id_result = cursor.fetchone()[0]
    if max_id_result is None:
    next_id = 1
    else:
    next_id = max_id_result + 1
    # 插入记录
    record = (
    next_id, 0, ImprintId, 1, 0, b'\x00' * 8, b'\x00', b'\x00', 0, 0, 0
    )
    cursor.execute('''
    INSERT INTO ImprintData (Id, OwnerId, ImprintId, Level, IsNew, Addition, DeBuffs, DeBuffAgrs, IsIdentify, State, BagSlotIndex)
    VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
    ''', record)
    # 提交事务
    conn.commit()
    print(f"纹章{ImprintId}记录插入成功")
    except Exception as e:
    print(f"发生错误: {e}")
    finally:
    # 关闭游标和连接
    cursor.close()
    conn.close()
    def insert_item_data(db_path,ItemId,num):
    # 连接到SQLite数据库
    conn = sqlite3.connect(db_path)
    cursor = conn.cursor()
    try:
    # 检查ItemId 有没有19
    cursor.execute(f"SELECT COUNT(*) FROM ItemData WHERE ItemId = {ItemId}")
    count = cursor.fetchone()[0]
    if count == 0:
    # 查询ItemData的Id最大值
    cursor.execute("SELECT MAX(Id) FROM ItemData")
    max_id = cursor.fetchone()[0]
    if max_id is None:
    new_id = 1
    else:
    new_id = max_id + 1
    # 插入数据
    cursor.execute(f"INSERT INTO ItemData (Id, ItemId, Count, IsNew) VALUES (?, ?, ?, ?)", (new_id, ItemId, num, 0))
    print(f"插入数据: {new_id}, {ItemId}, {num}, 0")
    else:
    print(f"ItemId {ItemId} 已经存在")
    # 提交事务
    conn.commit()
    except Exception as e:
    print(f"发生错误: {e}")
    finally:
    # 关闭游标和连接
    cursor.close()
    conn.close()
    def update_UnitData(db_path):
    conn = sqlite3.connect(db_file)
    cursor = conn.cursor()
    try:
    # 检查LevelProperty是否为0x000000000000000000000000000000000000000000000000000000000000000000000000
    zero_level_property = b'\x00' * 36
    cursor.execute("SELECT InstanceId FROM UnitData WHERE LevelProperty = ?", (zero_level_property,))
    results = cursor.fetchall()
    if results:
    level_property_value = b'0x000643334343434353063306430606060653533343264306530000000000000000000000'
    for instance_id in results:
    cursor.execute("UPDATE UnitData SET LevelProperty = ? WHERE InstanceId = ?", (level_property_value, instance_id[0]))
    # 提交事务
    conn.commit()
    print("等级属性更新成功")
    else:
    print("没有需要更新的等级属性")
    # 更新表UnitData_dg_tmp中所有对象的SkillAddition, SpeedAddition, 和 Shield字段的值为100
    update_query = """
    UPDATE UnitData
    SET SkillAddition = CASE WHEN SkillAddition < 100 THEN 100 ELSE SkillAddition END,
    SpeedAddition = CASE WHEN SpeedAddition < 100 THEN 100 ELSE SpeedAddition END,
    MoraleAddition = CASE WHEN MoraleAddition < 100 THEN 100 ELSE MoraleAddition END,
    Shield = CASE WHEN Shield < 100 THEN 100 ELSE Shield END,
    BaseSkillLevel = CASE WHEN BaseSkillLevel < 3 THEN 3 ELSE BaseSkillLevel END,
    AdvanceSkillLevel = CASE WHEN AdvanceSkillLevel < 3 THEN 3 ELSE AdvanceSkillLevel END,
    AttackFarther = CASE WHEN AttackFarther < 1 THEN 1 ELSE AttackFarther END,
    ActionPointAddition = CASE WHEN ActionPointAddition < 1 THEN 1 ELSE ActionPointAddition END,
    SlotAddition = CASE WHEN SlotAddition < 1 THEN 1 ELSE SlotAddition END;
    """
    # 执行更新查询
    cursor.execute(update_query)
    # 提交事务
    conn.commit()
    print("UnitData人物列表更新完成")
    except sqlite3.Error as e:
    print(f"发生错误: {e}")
    finally:
    # 关闭游标和连接
    cursor.close()
    conn.close()
    def has_single_unit(db_path):
    # 连接到SQLite数据库
    conn = sqlite3.connect(db_path)
    cursor = conn.cursor()
    try:
    # 查询UnitData表中的记录数
    cursor.execute("SELECT COUNT(*) FROM UnitData")
    count = cursor.fetchone()[0]
    # 检查记录数是否为1
    if count == 1:
    return True
    else:
    return False
    except Exception as e:
    print(f"发生错误: {e}")
    return False
    finally:
    # 关闭游标和连接
    cursor.close()
    conn.close()
    # 如果直接运行此脚本,则调用主函数
    if __name__ == "__main__":
    username = getpass.getuser()
    db_file = rf'C:\Users\{username}\AppData\LocalLow\qikemei\The Book Of Warriors\iiiiilllll111iiiii1112'
    imprint_id_list=['75', '249', '608', '53', '20', '602', '113', '607', '611', '247', '253', '18', '19', '917', '610', '232', '605', '71']
    # 检查表UnitData中是否只有一个对象
    if has_single_unit(db_file):
    insert_item_data(db_file,19,3)#世界树果实
    insert_item_data(db_file,16,3)#技能石
    insert_item_data(db_file,13,1)#BOSS石头人
    insert_item_data(db_file,23,1)#BOSS火龙
    insert_item_data(db_file,24,3)#BOSS毒虫
    insert_item_data(db_file,25,1)#BOSS跳鼠
    insert_item_data(db_file,8,9)#BOSS跳鼠
    insert_item_data(db_file,10,30)#勇者密匣
    insert_item_data(db_file,18,30)#神秘树枝
    insert_item_data(db_file,6,30)#升级果实
    for imprint_id in imprint_id_list:
    insert_ImprintData(db_file, imprint_id)
    # insert_ImprintData(db_file,'75')
    print("UnitData人物列表中只有一个对象")
    else:
    print("UnitData人物列表中有多个对象或没有对象")
    update_UnitData(db_file)


    IP属地:湖北2楼2024-11-08 22:54
    回复
      item_data = [
      {"Id": 1, "Name": "鉴定卷轴", "Description": "效果:鉴定纹章或道具"},
      {"Id": 5, "Name": "召唤卷轴", "Description": "效果:下场战斗召唤2名兵(单次使用上限:3)"},
      {"Id": 6, "Name": "升级果实", "Description": "效果:勇者提升1级"},
      {"Id": 7, "Name": "生命药剂", "Description": "效果:恢复100%生命,并且最大生命值+5"},
      {"Id": 8, "Name": "护盾之心", "Description": "效果:每次战斗开始时永久获得20点固定护盾(单勇者使用上限:3)"},
      {"Id": 9, "Name": "群体复活卷轴", "Description": "效果:任意数量勇者免费复活,且获得女神的祝福(全属性+3)"},
      {"Id": 10, "Name": "勇者密匣", "Description": "效果:选择属性获得一个传说纹章"},
      {"Id": 11, "Name": "噩梦密匣", "Description": "效果:随机获得一个未鉴定的噩梦纹章"},
      {"Id": 12, "Name": "移动力卷轴", "Description": "效果:移动距离+1"},
      {"Id": 13, "Name": "BOSS石头人", "Description": "效果:永久召唤【BOSS石头人】为你战斗"},
      {"Id": 14, "Name": "纹章之心", "Description": "效果:纹章槽+1"},
      {"Id": 15, "Name": "战斗秘典", "Description": "效果:增加自身派系的攻击范围"},
      {"Id": 16, "Name": "技能石", "Description": "效果:每回合使用技能次数+1"},
      {"Id": 17, "Name": "BOSS宠物蛋", "Description": "效果:鉴定后随机获得一今BOSS级宠物"},
      {"Id": 18, "Name": "神秘树枝", "Description": "效果:下3次升级时只会出现最高级的属性加点(刷新属性点会消耗1次机会)"},
      {"Id": 19, "Name": "世界树果实", "Description": "效果:升级时所有属性加点有额外加成"},
      {"Id": 20, "Name": "蓝色强化石", "Description": "效果:强化稀有纹章"},
      {"Id": 21, "Name": "紫色强化石", "Description": "效果:强化史诗纹章"},
      {"Id": 22, "Name": "未鉴定的道具", "Description": "效果:可以鉴定出各式各样的道具"},
      {"Id": 23, "Name": "BOSS火龙", "Description": "效果:永久召唤【BOSS火龙】为你战斗"},
      {"Id": 24, "Name": "BOSS毒虫", "Description": "效果:永久召唤【BOSS毒虫】为你战斗"},
      {"Id": 25, "Name": "BOSS跳鼠", "Description": "效果:永久召唤【BOSS跳鼠】为你战斗"},
      {"Id": 29, "Name": "稀有密匣", "Description": "效果:随机获得1个稀有纹章"},
      {"Id": 32, "Name": "力量史诗密匣", "Description": "效果:随机获得1个力量属性的史诗纹章"},
      {"Id": 35, "Name": "魔法史诗密匣", "Description": "效果:随机获得1个魔法属性的史诗纹章"},
      {"Id": 37, "Name": "速度史诗密匣", "Description": "效果:随机获得1个速度属性的史诗纹章"},
      {"Id": 39, "Name": "钱袋", "Description": "效果:立即获得1~100个金币"},
      {"Id": 40, "Name": "强化符咒", "Description": "效果:下一场战斗全属性+2(单勇者使用上限2)"},
      {"Id": 43, "Name": "金箱卷", "Description": "效果:下一场战斗必定出现金色宝箱"},
      {"Id": 44, "Name": "群体强化符光", "Description": "效果:下一场战斗全队全属性+3(使用上限:)"},
      {"Id": 45, "Name": "【虞】人卡", "Description": "效果:召唤神秘商人【虞】"}
      ]


      IP属地:湖北3楼2024-11-08 22:54
      回复
        通过网盘分享的文件:The_Book_Of_Warriors.py
        链接: https://pan.baidu.com/s/1AiZuD1-moLxHyt8_bBudTA?pwd=pbcb 提取码: pbcb


        IP属地:湖北4楼2024-11-08 22:57
        回复