《上古卷轴5》炼金组合计算脚本
计算炼金药水组合、价格和利润的python脚本。
暂时不包含部分扩展包(DLC)里的材料。
脚本里包含材料的效果和效果价值数据,默认按照人物1级,无任何增益计算,称之为基础数值。
制造出药水后,开背包看看价值,然后找商人看看售价,修改配置文件,切换到透明窗口,F4重新读配置文件,之后,可得到比较准确的药水价值和利润。
上古卷轴5的药水价值为药水的所有效果价值相加,与使用的材料无关。脚本里的效果价值,就是逐个制造单一效果的药剂得到的。数字分别为药水的基础价值,药水的当前价值,药水的售价,买材料的成本,利润
(提高的都是对自己的,有害的都是对敌人的)
脚本生成两个txt文件,分别按照药水价值和利润排序。
脚本不读skyrim5的内存,炼金术等级提高、换装备等,需要及时更新配置文件。
pip install pygame

# -*- coding: UTF-8 -*- # 作者 陈军桦 # 2025年3月10日 alchemy_combine_calc_9.py # 2025年3月11日 alchemy_combine_calc_13.5.py # alchemy_combine_calc_overlay_v0.1.py # 在透明窗口上显示前几个结果的详细信息。 # 打开商人界面或者炼金界面,切换窗口到pygame的透明窗口,不要点击鼠标,否则透明窗口会失去焦点。 F4读取配置文件,计算并显示,F1、F2、F3临时将最上边的材料之一加入黑名单,并重新计算。再按一次F4,关闭显示,下次按F4还会重新读取配置文件、计算、显示。 # 不想要命令行,可以把.py后缀改成.pyw。 # 2025年3月12日 alchemy_combine_calc_overlay_v0.2.py # 用esc退出。 # alchemy_combine_calc_overlay_v0.3.py # 显示效果的幅度和持续时间。 # alchemy_combine_calc_overlay_v0.4.py # 重新把配方按照利润排序写入文件 output_by_profit.txt # alchemy_combine_calc_overlay_v0.5.py # F5 F6 F7临时屏蔽第二个配方中的材料 # F9 F10 F11临时屏蔽第三个配方中的材料 # F8切换透明窗口上显示的配方排序 # output_by_profit.txt 和 output_by_price.txt都会输出 # # alchemy_combine_calc_overlay_v0.6.3.py # 1 2 3 4临时删除透明窗口上相应的配方, # F8只重新排序,不再重新过滤 # v0.2到v0.3时,失误删除了'提高生命上限'的'bonus_material' # alchemy_combine_calc_overlay_v0.7.py # 更改配置文件键值 # 增加对配置文件的容错 # alchemy_combine_calc_overlay_v0.8.py # F12改变显示方式,不显示,只显示一行,显示生效的效果,显示未生效的效果 # 1-9都可以临时删除配方 #2025年3月13日 # alchemy_combine_calc_overlay_v0.9.py # 使用上下按键翻动,delete按键暂时删除最上面的配方,1-9注释掉了,F5 -F7 F8-F11也注释掉了 # 左上角显示当前配方的位置和数量 #2025年3月15日 # alchemy_combine_calc_overlay_v0.10.py # 增加按成本排序 #2025年3月17日 # alchemy_combine_calc_overlay_v0.11.py # 增加按材料利用率排序 # import operator import os config_default={ #人物1级无增益做出的药水价值334 #不打开交易界面,药水在背包里价值504, #打开交易界面,药水的出售价格为230 'value_mutilpy':1, #504/334 'sell_mutilpy':1/3, #230/504 #同样的,从商人那里购买物品的价格默认为商品价值的3倍 'buy_mutilpy':3, #45/15 'material_exclude':[ #"灰烬草种荚","灰烬魔尘","黄色山花","荆棘之心","魔族心脏","气母胶质","深红奈恩根","幽光萌花","巨人的脚趾","巢蚁猎人触角","先祖飞蛾翅膀","人类心脏","人肉","巨人的脚趾","野猪牙","毒茂花" ], #输出的配方,必须同时包含这些效果 #空的不过滤 'effect_include':[ # "增强幻术魔法","加快魔力恢复" ], #输出的配方,必须使用这些材料 #空的不过滤 'material_include':[ # '吊苔','熊爪' ] } config=config_default #以下注释内为alchemy_combine_calc__config.ini文件的示例 ''' [option] #可以写简单的计算式 #药水的基础价值618 #有炼金装备等,药水价值699 #有口才等,商人收购价为246 #键不存在,或者值为空则按照默认值 value_mutilpy=;699/618 #默认为1 sell_mutilpy=;246/699 #默认为1/3 buy_mutilpy= #默认为3 #空白、单引号和双引号会被去掉 #多余的逗号会被忽略 #第二个=等同注释 material_exclude=;" 灰烬草种荚", "灰烬魔尘 ", "黄色山花", " 荆棘之心 ","魔族心脏","气母胶质","深红奈恩根","幽光萌花","巢蚁猎人触角","先祖飞蛾翅膀","人类心脏","人肉","野猪牙","毒茂花","巨人的脚趾",特拉玛根,;吊苔,熊爪,藤蔓丛,树伞菌,鳞片伞菌,长鹿角,丧钟花,诺德藤壶,蓝色蜻蜓,犬根,岩莺的蛋,蓝蝶翅膀,老鹰蛋,鸡蛋 effect_include= = 增强幻术魔法,加快魔力恢复 material_include= ;"Dwarven Oil" ;矮人油 ; ; '吊苔','熊爪' ''' def read_ini(_file_path): _data = {} _current_section = None if not os.path.exists(_file_path): return {} with open(_file_path, 'r', encoding='utf-8') as _file: for _line in _file.readlines(): _line = _line.strip() if _line.startswith(';') or _line.startswith('#'): continue # print(_line) if ';' in _line: _line = _line.split(';')[0] if '#' in _line: _line = _line.split('#')[0] # print(_line) if _line.startswith('[') and _line.endswith(']'): _current_section = _line[1:-1] _data[_current_section] = {} else: if _current_section: _line = _line.split('=') if(len(_line) >= 2): _key = _line[0] _value_str = _line[1] else: _key = _line[0] _value_str = "" _key = _key.strip() while _key.startswith('"') or _key.startswith("'") or _key.endswith('"') or _key.endswith("'"): _key=_value.strip('"').strip("'").strip() if(len(_key) == 0): continue _data[_current_section][_key] = [] for _value in _value_str.split(','): _value=_value.strip() while _value.startswith('"') or _value.startswith("'") or _value.endswith('"') or _value.endswith("'"): _value=_value.strip('"').strip("'").strip() if(len(_value)): _data[_current_section][_key].append(_value) return _data def read_config(): global config global material_exclude_id_list #dict2 = dict1 # 浅拷贝: 引用对象 #dict3 = dict1.copy() # 浅拷贝:深拷贝父对象(一级目录),子对象(二级目录)不拷贝,还是引用 config = {} config.update(config_default) material_exclude_id_list=[] # print(config) _ini = read_ini('alchemy_combine_calc__config.ini') # print("_ini=") # print(_ini) if len(_ini) and 'option' in _ini.keys(): _option = _ini['option'] # print (_option) if 'value_mutilpy' in _option.keys() and len(_option['value_mutilpy']): config['value_mutilpy'] = eval(_option['value_mutilpy'][0]) ################## if 'sell_mutilpy' in _option.keys() and len(_option['sell_mutilpy']): config['sell_mutilpy'] = eval(_option['sell_mutilpy'][0]) ############## if 'buy_mutilpy' in _option.keys() and len(_option['buy_mutilpy']): config['buy_mutilpy'] = eval(_option['buy_mutilpy'][0]) ###################### if 'material_exclude' in _option.keys() and len(_option['material_exclude']): config['material_exclude']=[] for _material_name in _option['material_exclude']: if _material_name not in material_name_to_id_dict.keys(): continue config['material_exclude'].append(_material_name) ######################### if 'effect_include' in _option.keys() and len(_option['effect_include']): config['effect_include']=[] for _effect_name in _option['effect_include']: if _effect_name not in effect_dict.keys(): continue config['effect_include'].append(_effect_name) ######################## if 'material_include' in _option.keys() and len(_option['material_include']): config['material_include']=[] for _material_name in _option['material_include']: if _material_name not in material_name_to_id_dict.keys(): continue config['material_include'].append(_material_name) #################################### material_exclude_id_list=[] for _material_name in config['material_exclude']: _material_id = material_name_to_id_dict[_material_name] material_exclude_id_list.append(_material_id) print("material_exclude") print(config['material_exclude']) print("effect_include") print(config['effect_include']) print("material_include") print(config['material_include']) print("value_mutilpy="+str(config['value_mutilpy'])) print("sell_mutilpy=" + str(config['sell_mutilpy'])) print("buy_mutilpy="+str(config['buy_mutilpy'])) return #不包含部分资料片(DLC)里的材料 material_dict={ '000F11C0':{ 'value':15, 'name':["矮人油","Dwarven Oil"], 'effect_list':["降低魔法抗性","增强幻术魔法","加快魔力恢复","回复魔力"] }, '00106E1B':{ 'value':15, 'name':["阿贝希恩长鳍鱼"], 'effect_list':["降低寒霜抗性","提高潜行能力","降低毒素抗性","增强恢复魔法"] }, '0003AD6A':{ 'value':30, 'name':["冰怨灵的牙","寒霜幽魂牙齿"], 'effect_list':["降低寒霜抗性","提高重甲技能","隐形","降低火焰抗性"] }, '0004DA22':{ 'value':1, 'name':["白帽伞菌"], 'effect_list':["降低寒霜抗性","提高重甲技能","回复魔力","提高魔力上限"] }, '000705B7':{ 'value':5, 'name':["贝瑞特的骨灰"], 'effect_list':["减损体力","提高火焰抗性","增强召唤魔法","降低体力上限"] }, '0005076E':{ 'value':1, 'name':["刺柏浆果","朱尼珀尔果"], 'effect_list':["降低火焰抗性","提高弓箭伤害","加快生命恢复","减缓体力恢复"] }, '0003AD56':{ 'value':10, 'name':["巢螋卵","查鲁斯之卵","巢蚁卵"], 'effect_list':["降低毒素抗性","提高体力上限","减损魔力","隐形"] }, '020183B7':{ 'value':2, 'name':["巢蚁猎人触角"], 'effect_list':["减损体力","增强召唤魔法","减缓魔力恢复","提高附魔效果"] }, '000BB956':{ 'value':1, 'name':["橙色蜻蜓","红蜻蜓"], 'effect_list':["回复体力","降低魔力上限","提高扒窃能力","生命流失"] }, '00083E64':{ 'value':1, 'name':["草籽"], 'effect_list':["提高毒素抗性","降低魔力上限","增强变化魔法","回复魔力"] }, '0006BC10':{ 'value':2, 'name':["长毛象牙粉末","猛犸牙粉"], 'effect_list':["回复体力","提高潜行能力","降低火焰抗性","恐惧"] }, '0006BC0A':{ 'value':2, 'name':["长鹿角"], 'effect_list':["回复体力","提高体力上限","降低速度","减缓体力恢复"] }, '00057F91':{ 'value':1, 'name':["吊苔"], 'effect_list':["减损魔力","提高生命上限","减缓魔力恢复","提高单手伤害"] }, '00034D22':{ 'value':1, 'name':["大蒜"], 'effect_list':["提高毒素抗性","提高体力上限","加快魔力恢复","加快生命恢复"] }, '0401FF75':{ 'value':1, 'name':["帝王伞苔","帕拉索.莫斯皇帝"], 'effect_list':["减损生命","提高魔力上限","加快生命恢复","提高双手伤害"] }, '000727E0':{ 'value':3, 'name':["帝王蝴蝶翅膀","蝴蝶翅膀"], 'effect_list':["回复生命","提高议价能力","体力流失","减损魔力"] }, '020185FB':{ 'value':5, 'name':["毒茂花","毒花"], 'effect_list':["减损生命","降低速度","提高负重","恐惧"] }, '0004DA00':{ 'value':2, 'name':["毒蝇伞","飞天菇菌"], 'effect_list':["提高火焰抗性","提高双手伤害","狂乱","加快体力恢复"] }, '0006BC0B':{ 'value':2, 'name':["短鹿角"], 'effect_list':["降低毒素抗性","增强恢复魔法","体力流失","减损生命"] }, '0003AD6F':{ 'value':3, 'name':["恶鼠尾巴","雪鼠尾巴"], 'effect_list':["减缓体力恢复","降低生命上限","减损生命","提高轻甲技能"] }, '0003AD5D':{ 'value':10, 'name':["伐莫耳","雪精灵耳"], 'effect_list':["减损生命","狂乱","提高毒素抗性","提高开锁能力"] }, '000B08C5':{ 'value':5, 'name':["蜂巢"], 'effect_list':["回复体力","提高格挡效果","提高轻甲技能","降低体力上限"] }, '000A9191':{ 'value':5, 'name':["蜂箱外壳"], 'effect_list':["提高毒素抗性","提高轻甲技能","提高潜行能力","增强毁灭魔法"] }, '0403CD8E':{ 'value':15, 'name':["法萨德燕鸥羽毛"], 'effect_list':["回复生命","提高轻甲技能","治愈疾病","提高魔法抗性"] }, '0003AD73':{ 'value':20, 'name':["光尘"], 'effect_list':["减损魔力","减缓魔力恢复","增强毁灭魔法","提高闪电抗性"] }, '03003545':{ 'value':5, 'name':["鲑鱼卵"], 'effect_list':["回复体力","水下呼吸","提高魔力上限","加快魔力恢复"] }, '00034CDD':{ 'value':5, 'name':["骨粉"], 'effect_list':["减损体力","提高火焰抗性","增强召唤魔法","降低体力上限"] }, '00034D32':{ 'value':1, 'name':["寒霜甘草"], 'effect_list':["提高寒霜抗性","提高潜行能力","降低魔力上限","减缓体力恢复"] }, '00106E1A':{ 'value':15, 'name':["河布丁"], 'effect_list':["减损生命","增强变化魔法","降低速度","提高负重"] }, '0003AD5E':{ 'value':50, 'name':["火盐"], 'effect_list':["降低寒霜抗性","提高火焰抗性","回复魔力","加快魔力恢复"] }, '04016E26':{ 'value':1, 'name':["灰烬草种荚","灰色豆荚"], 'effect_list':["提高火焰抗性","降低闪电抗性","提高开锁能力","提高潜行能力"] }, '0401CD74':{ 'value':20, 'name':["灰烬藤蔓丛","灰烬爬行群"], 'effect_list':["减损体力","隐形","提高火焰抗性","增强毁灭魔法"] }, '0401CD71':{ 'value':20, 'name':["灰烬跳虫胶质","灰烬漏斗果冻"], 'effect_list':["回复生命","提高轻甲技能","提高闪电抗性","降低寒霜抗性"] }, '0401CD6D':{ 'value':20, 'name':["灰烬魔尘"], 'effect_list':["降低体力上限","提高火焰抗性","提高附魔效果","降低魔力上限"] }, '00077E1D':{ 'value':2, 'name':["红山花"], 'effect_list':["回复魔力","降低魔力上限","提高魔力上限","减损生命"] }, '02002A78':{ 'value':2, 'name':["黄色山花","黄山花"], 'effect_list':["提高毒素抗性","增强恢复魔法","提高生命上限","减缓体力恢复"] }, '0006BC04':{ 'value':2, 'name':["剑齿虎牙齿"], 'effect_list':["回复体力","提高重甲技能","提高锻造效果","降低毒素抗性"] }, '0006BC07':{ 'value':2, 'name':["剑齿虎眼"], 'effect_list':["回复体力","降低生命上限","减损魔力","回复生命"] }, '0003AD64':{ 'value':20, 'name':["巨人的脚趾","巨人脚趾"], 'effect_list':["减损体力","提高生命上限","提高负重","减缓体力恢复"] }, '0007E8C1':{ 'value':5, 'name':["巨型青苔","巨型藓"], 'effect_list':["降低闪电抗性","降低生命上限","降低毒素抗性","回复魔力"] }, '0003AD72':{ 'value':15, 'name':["巨魔脂肪"], 'effect_list':["提高毒素抗性","提高双手伤害","狂乱","减损生命"] }, '0006AC4A':{ 'value':1, 'name':["架子湾葡萄"], 'effect_list':["降低魔法抗性","提高魔力上限","加快魔力恢复","降低生命上限"] }, '00052695':{ 'value':1, 'name':["焦黑的恶鼠皮","烧焦雪鼠尾巴"], 'effect_list':["回复体力","治愈疾病","提高毒素抗性","回复生命"] }, '00034D31':{ 'value':10, 'name':["精灵耳"], 'effect_list':["回复魔力","提高弓箭伤害","降低寒霜抗性","提高火焰抗性"] }, '0003AD61':{ 'value':20, 'name':["荆棘之心"], 'effect_list':["回复魔力","提高格挡效果","麻痹","提高魔力上限"] }, '000134AA':{ 'value':1, 'name':["蓟花","蓟丛"], 'effect_list':["提高寒霜抗性","降低体力上限","提高毒素抗性","提高重甲技能"] }, '00023D77':{ 'value':2, 'name':["鸡蛋"], 'effect_list':["提高魔法抗性","减缓魔力恢复","水下呼吸","体力流失"] }, '0001BCBC':{ 'value':10, 'name':["加林根"], 'effect_list':["减损生命","减损魔力","减损体力","减缓魔力恢复"] }, '0003AD63':{ 'value':25, 'name':["灵质","灵皮"], 'effect_list':["回复魔力","增强毁灭魔法","提高魔力上限","减损生命"] }, '0401CD6E':{ 'value':20, 'name':["烈焰树精木片","烧焦的树精木"], 'effect_list':["降低火焰抗性","增强变化魔法","减缓魔力恢复","降低速度"] }, '00077E1C':{ 'value':2, 'name':["蓝山花"], 'effect_list':["回复生命","增强召唤魔法","提高生命上限","减缓魔力恢复"] }, '000E4F0C':{ 'value':1, 'name':["蓝色蜻蜓"], 'effect_list':["提高闪电抗性","提高扒窃能力","回复生命","恐惧"] }, '000727DE':{ 'value':2, 'name':["蓝蝶翅膀"], 'effect_list':["减损体力","增强召唤魔法","减缓魔力恢复","提高附魔效果"] }, '0006F950':{ 'value':4, 'name':["鳞片伞菌","鳞片菇"], 'effect_list':["降低魔法抗性","增强幻术魔法","加快体力恢复","提高负重"] }, '000889A2':{ 'value':5, 'name':["龙舌兰"], 'effect_list':["提高火焰抗性","提高议价能力","增强幻术魔法","提高双手伤害"] }, '000A9195':{ 'value':3, 'name':["蜜蜂"], 'effect_list':["回复体力","降低体力上限","加快体力恢复","降低闪电抗性"] }, '0003AD5B':{ 'value':250, 'name':["魔族心脏","魔族之心"], 'effect_list':["回复生命","减缓体力恢复","减损魔力","恐惧"] }, '00059B86':{ 'value':10, 'name':["奈恩根"], 'effect_list':["减损生命","减损体力","隐形","提高魔法抗性"] }, '0004DA24':{ 'value':1, 'name':["娜米拉腐菌","娜米拉的腐败物"], 'effect_list':["减损魔力","提高开锁能力","恐惧","加快生命恢复"] }, '0006BC00':{ 'value':2, 'name':["泥沼蟹壳"], 'effect_list':["回复体力","治愈疾病","提高毒素抗性","提高火焰抗性"] }, '0007EDF5':{ 'value':5, 'name':["诺德藤壶"], 'effect_list':["减损魔力","水下呼吸","加快生命恢复","提高扒窃能力"] }, '0401CD72':{ 'value':20, 'name':["气母胶质","水母果冻"], 'effect_list':["麻痹","提高负重","回复体力","恐惧"] }, '0004DA25':{ 'value':10, 'name':["气泡草"], 'effect_list':["减损体力","狂乱","回复生命","提高锻造效果"] }, '0006ABCB':{ 'value':5, 'name':["犬根","犬型根"], 'effect_list':["减损体力","提高单手伤害","提高弓箭伤害","麻痹"] }, '000B18CD':{ 'value':1, 'name':["人类心脏"], 'effect_list':["减损生命","减损魔力","减缓魔力恢复","狂乱"] }, '001016B3':{ 'value':1, 'name':["人肉"], 'effect_list':["减损生命","麻痹","回复魔力","提高潜行能力"] }, '000516C8':{ 'value':4, 'name':["丧钟花","死亡丧钟"], 'effect_list':["减损生命","降低体力上限","降低速度","降低毒素抗性"] }, '00023D6F':{ 'value':2, 'name':["松木画眉蛋","松鹅卵"], 'effect_list':["回复体力","提高开锁能力","降低毒素抗性","提高闪电抗性"] }, '000EC870':{ 'value':4, 'name':["树伞菌","天鹅菇"], 'effect_list':["回复魔力","生命流失","加快体力恢复","增强幻术魔法"] }, '00063B5F':{ 'value':15, 'name':["树精的树液"], 'effect_list':["减缓魔力恢复","提高附魔效果","提高锻造效果","增强变化魔法"] }, '00106E19':{ 'value':15, 'name':["赛瑞迪尔斗鱼","西罗帝尔斗鱼"], 'effect_list':["减损体力","增强恢复魔法","恐惧","降低生命上限"] }, '0003AD5F':{ 'value':100, 'name':["霜盐"], 'effect_list':["降低火焰抗性","提高寒霜抗性","回复魔力","增强召唤魔法"] }, '0007E8C5':{ 'value':3, 'name':["食人鱼卵"], 'effect_list':["提高毒素抗性","提高扒窃能力","生命流失","提高体力上限"] }, '0003AD70':{ 'value':3, 'name':["食人鱼鳞"], 'effect_list':["提高寒霜抗性","生命流失","提高重甲技能","提高格挡效果"] }, '0007E8C8':{ 'value':2, 'name':["岩莺的蛋","石溪刺莺卵"], 'effect_list':["回复生命","提高单手伤害","减损体力","降低魔法抗性"] }, '000B701A':{ 'value':10, 'name':["深红奈恩根","猩红奈恩根"], 'effect_list':["减损生命","减损体力","隐形","提高魔法抗性"] }, '0200B087':{ 'value':5, 'name':["幽光萌花","闪光花"], 'effect_list':["提高魔法抗性","恐惧","加快生命恢复","麻痹"] }, '04017008':{ 'value':1, 'name':["特拉玛根","真菌的根"], 'effect_list':["降低闪电抗性","提高负重","减损魔力","降低速度"] }, '0003F7F8':{ 'value':1, 'name':["苔原棉花"], 'effect_list':["提高魔法抗性","提高魔力上限","提高格挡效果","提高议价能力"] }, '000B2183':{ 'value':1, 'name':["藤蔓丛"], 'effect_list':["回复魔力","减缓体力恢复","提高负重","降低魔法抗性"] }, '04017E97':{ 'value':1, 'name':["苦痛草","痛苦草"], 'effect_list':["降低生命上限","降低体力上限","降低魔力上限","生命流失"] }, '0006B689':{ 'value':20, 'name':["乌鸦鬼婆之爪"], 'effect_list':["提高魔法抗性","魔力流失","提高附魔效果","提高议价能力"] }, '0003AD66':{ 'value':20, 'name':["乌鸦鬼婆之羽"], 'effect_list':["减损魔力","增强召唤魔法","狂乱","降低闪电抗性"] }, '0007EE01':{ 'value':5, 'name':["微光伞菌","荧光菇"], 'effect_list':["提高闪电抗性","增强毁灭魔法","提高锻造效果","提高生命上限"] }, '0003AD76':{ 'value':25, 'name':["吸血鬼灰烬"], 'effect_list':["隐形","回复魔力","加快生命恢复","治愈疾病"] }, '0004DA23':{ 'value':1, 'name':["小恶魔菌","小恶魔粪"], 'effect_list':["减损生命","生命流失","麻痹","回复生命"] }, '00085500':{ 'value':2, 'name':["小珍珠"], 'effect_list':["回复体力","提高单手伤害","增强恢复魔法","提高寒霜抗性"] }, '0004B0BA':{ 'value':5, 'name':["小麦"], 'effect_list':["回复生命","提高生命上限","减缓体力恢复","魔力流失"] }, '00106E18':{ 'value':6, 'name':["希思特鲤鱼"], 'effect_list':["回复体力","提高魔力上限","减缓体力恢复","水下呼吸"] }, '0006BC02':{ 'value':2, 'name':["熊爪"], 'effect_list':["回复体力","提高生命上限","提高单手伤害","减缓魔力恢复"] }, '00045C28':{ 'value':1, 'name':["薰衣草"], 'effect_list':["提高魔法抗性","提高体力上限","降低魔力上限","增强召唤魔法"] }, '0003AD60':{ 'value':125, 'name':["虚无盐"], 'effect_list':["降低闪电抗性","提高魔法抗性","减损生命","提高魔力上限"] }, '0001B3BD':{ 'value':4, 'name':["雪果","雪浆果"], 'effect_list':["提高火焰抗性","提高附魔效果","提高寒霜抗性","提高闪电抗性"] }, '0004DA20':{ 'value':10, 'name':["鲜血王冠"], 'effect_list':["降低火焰抗性","提高格挡效果","降低毒素抗性","提高魔法抗性"] }, '020059BA':{ 'value':2, 'name':["先祖飞蛾翅膀","先祖蛾翅膀"], 'effect_list':["减损体力","增强召唤魔法","减缓魔力恢复","提高附魔效果"] }, '0006BC0E':{ 'value':2, 'name':["幽魂外皮"], 'effect_list':["回复体力","增强毁灭魔法","提高负重","提高魔法抗性"] }, '000D8E3F':{ 'value':50, 'name':["月亮糖"], 'effect_list':["降低火焰抗性","提高寒霜抗性","回复魔力","加快魔力恢复"] }, '000727DF':{ 'value':5, 'name':["月蛾翅膀"], 'effect_list':["减损魔力","提高轻甲技能","加快生命恢复","隐形"] }, '0002F44C':{ 'value':8, 'name':["龙葵","夜茄"], 'effect_list':["减损生命","减缓魔力恢复","体力流失","增强毁灭魔法"] }, '00034CDF':{ 'value':2, 'name':["盐堆"], 'effect_list':["降低魔法抗性","增强恢复魔法","降低速度","加快魔力恢复"] }, '0004DA73':{ 'value':1, 'name':["萤火虫的胸壳"], 'effect_list':["回复体力","魔力流失","降低魔法抗性","提高体力上限"] }, '0401CD6F':{ 'value':20, 'name':["野猪牙"], 'effect_list':["提高体力上限","提高生命上限","提高格挡效果","狂乱"] }, '00106E1C':{ 'value':15, 'name':["银岸鲈鱼"], 'effect_list':["回复体力","减缓体力恢复","降低生命上限","提高寒霜抗性"] }, '000E7EBC':{ 'value':15, 'name':["鹰喙","鹰的喙"], 'effect_list':["回复体力","提高寒霜抗性","提高负重","提高闪电抗性"] }, '0300F1CC':{ 'value':5, 'name':["老鹰蛋","鹰的蛋","鹰卵"], 'effect_list':["提高魔法抗性","减缓魔力恢复","水下呼吸","体力流失"] }, '000E7ED0':{ 'value':15, 'name':["鹰羽毛"], 'effect_list':["治愈疾病","提高轻甲技能","提高单手伤害","提高潜行能力"] }, '0007E8B7':{ 'value':5, 'name':["沼泽真菌荚"], 'effect_list':["提高闪电抗性","魔力流失","麻痹","回复生命"] }, '000854FE':{ 'value':2, 'name':["珍珠"], 'effect_list':["回复体力","提高格挡效果","回复魔力","提高闪电抗性"] }, '0003AD71':{ 'value':15, 'name':["直立根"], 'effect_list':["降低魔法抗性","增强幻术魔法","加快魔力恢复","回复魔力"] }, '00077E1E':{ 'value':2, 'name':["紫山花"], 'effect_list':["回复体力","提高潜行能力","魔力流失","提高寒霜抗性"] }, '0009151B':{ 'value':5, 'name':["蜘蛛卵"], 'effect_list':["减损体力","减缓魔力恢复","提高开锁能力","提高弓箭伤害"] } # 'FExxx821':{ # 'value':9, # 'name':["哨卫眼"], # 'effect_list':["夜视","强化法力","增强幻术魔法","法术吸收"] # } } effect_dict={ '降低毒素抗性':{ 'value':37, 'materials':['阿贝希恩长鳍鱼','巢螋卵','短鹿角','剑齿虎牙齿','松木画眉蛋','丧钟花','鲜血王冠','巨型青苔'], 'magnitude_type':'percent', 'magnitude':9, 'duration':30 }, '提高毒素抗性':{ 'value':86, 'materials':['草籽','大蒜','伐莫耳','蜂箱外壳','黄山花','蓟花','食人鱼卵','巨魔脂肪','焦黑的恶鼠皮','泥沼蟹壳'], 'magnitude_type':'percent', 'magnitude':18, 'duration':60 }, '魔力流失':{ 'value':45, 'materials':['小麦','紫山花','萤火虫的胸壳','乌鸦鬼婆之爪','沼泽真菌荚'], 'magnitude_type':'point', 'magnitude':4, 'duration':10 }, '回复生命':{ 'value':14, 'materials':['帝王蝴蝶翅膀','灰烬跳虫胶质','剑齿虎眼','魔族心脏','小麦','气泡草','法萨德燕鸥羽毛','小恶魔菌','焦黑的恶鼠皮','蓝山花','沼泽真菌荚','岩莺的蛋','蓝色蜻蜓'], 'magnitude_type':'point', 'magnitude':22, 'duration':None }, '降低寒霜抗性':{ 'value':28, 'materials':['阿贝希恩长鳍鱼','冰怨灵的牙','白帽伞菌','火盐','灰烬跳虫胶质','精灵耳'], 'magnitude_type':'percent', 'magnitude':13, 'duration':30 }, '回复体力':{ 'value':17, 'materials':['橙色蜻蜓','长毛象牙粉末','长鹿角','蜂巢','剑齿虎牙齿','剑齿虎眼','松木画眉蛋','熊爪','紫山花','小珍珠','鹰喙','银岸鲈鱼','气母胶质','萤火虫的胸壳','焦黑的恶鼠皮','蜜蜂','泥沼蟹壳','幽魂外皮','珍珠','希思特鲤鱼','鲑鱼卵'], 'magnitude_type':'point', 'magnitude':22, 'duration':None }, '回复魔力':{ 'value':17, 'materials':['矮人油','白帽伞菌','草籽','火盐','红山花','精灵耳','霜盐','灵质','直立根','吸血鬼灰烬','藤蔓丛','月亮糖','人肉','荆棘之心','巨型青苔','珍珠','树伞菌'], 'magnitude_type':'point', 'magnitude':22, 'duration':None }, '降低火焰抗性':{ 'value':33, 'materials':['冰怨灵的牙','刺柏浆果','长毛象牙粉末','霜盐','烈焰树精木片','月亮糖','鲜血王冠'], 'magnitude_type':'percent', 'magnitude':13, 'duration':30 }, '提高寒霜抗性':{ 'value':60, 'materials':['寒霜甘草','蓟花','霜盐','紫山花','小珍珠','鹰喙','银岸鲈鱼','雪果','月亮糖','食人鱼鳞'], 'magnitude_type':'percent', 'magnitude':13, 'duration':60 }, '提高火焰抗性':{ 'value':60, 'materials':['毒蝇伞','骨粉','火盐','灰烬草种荚','灰烬藤蔓丛','灰烬魔尘','精灵耳','雪果','龙舌兰','泥沼蟹壳','贝瑞特的骨灰'], 'bonus_material':['灰烬草种荚'], 'bonus_value':86, 'magnitude_type':'percent', 'magnitude':13, 'bonus_magnitude':18, 'duration':60 }, '加快体力恢复':{ 'value':126, 'materials':['毒蝇伞','鳞片伞菌','蜜蜂','树伞菌'], 'magnitude_type':'percent', 'magnitude':22, 'duration':300 }, '加快魔力恢复':{ 'value':126, 'materials':['矮人油','大蒜','火盐','直立根','架子湾葡萄','盐堆','月亮糖','鲑鱼卵'], 'bonus_value':0, 'magnitude_type':'percent', 'magnitude':22, 'duration':300 }, '加快生命恢复':{ 'value':126, 'materials':['刺柏浆果','大蒜','帝王伞苔','吸血鬼灰烬','月蛾翅膀','幽光萌花','娜米拉腐菌','诺德藤壶'], 'magnitude_type':'percent', 'magnitude':22, 'duration':300 }, '减损生命':{ 'value':2, 'materials':['帝王伞苔','毒茂花','短鹿角','恶鼠尾巴','伐莫耳','河布丁','红山花','灵质','丧钟花','奈恩根','人类心脏','虚无盐','巨魔脂肪','小恶魔菌','人肉','加林根','龙葵','深红奈恩根'], 'magnitude_type':'point', 'magnitude':13, 'duration':None }, '减损体力':{ 'value':30, 'materials':['骨粉','灰烬藤蔓丛','巨人脚趾','气泡草','奈恩根','蓝蝶翅膀','西罗帝尔斗鱼','先祖蛾翅膀','巢蚁猎人触角','岩莺的蛋','加林根','犬根','贝瑞特的骨灰','蜘蛛卵','深红奈恩根'], 'magnitude_type':'point', 'magnitude':13, 'duration':None }, '减损魔力':{ 'value':36, 'materials':['巢螋卵','吊苔','帝王蝴蝶翅膀','光尘','剑齿虎眼','魔族心脏','人类心脏','特拉玛根','月蛾翅膀','加林根','乌鸦鬼婆之羽','娜米拉腐菌','诺德藤壶'], 'magnitude_type':'point', 'magnitude':13, 'duration':None }, '减缓体力恢复':{ 'value':113, 'materials':['刺柏浆果','长鹿角','恶鼠尾巴','寒霜甘草','黄山花','巨人脚趾','魔族心脏','小麦','银岸鲈鱼','藤蔓丛','希思特鲤鱼'], 'magnitude_type':'percent', 'magnitude':100, 'duration':22 }, '降低速度':{ 'value':176, 'materials':['长鹿角','毒茂花','河布丁','丧钟花','盐堆','特拉玛根','烈焰树精木片'], 'magnitude_type':'percent', 'magnitude':50, 'duration':22 }, '减缓魔力恢复':{ 'value':188, 'materials':['巢蚁猎人触角','吊苔','光尘','熊爪','蓝蝶翅膀','人类心脏','先祖蛾翅膀','烈焰树精木片','鸡蛋','树精的树液','蓝山花','加林根','龙葵','蜘蛛卵','鹰的蛋'], 'magnitude_type':'percent', 'magnitude':100, 'duration':22 }, '狂乱':{ 'value':68, 'materials':['毒蝇伞','伐莫耳','气泡草','人类心脏','巨魔脂肪','野猪牙','乌鸦鬼婆之羽'], 'magnitude_type':'point', 'magnitude':4, 'duration':10 }, '恐惧':{ 'value':76, 'materials':['长毛象牙粉末','毒茂花','魔族心脏','西罗帝尔斗鱼','气母胶质','幽光萌花','娜米拉腐菌','蓝色蜻蜓'], 'magnitude_type':'point', 'magnitude':4, 'duration':30 }, '降低魔法抗性':{ 'value':37, 'materials':['矮人油','直立根','架子湾葡萄','盐堆','萤火虫的胸壳','鳞片伞菌','岩莺的蛋','藤蔓丛'], 'magnitude_type':'percent', 'magnitude':9, 'duration':30 }, '提高魔法抗性':{ 'value':32, 'materials':['奈恩根','法萨德燕鸥羽毛','鸡蛋','虚无盐','苔原棉花','乌鸦鬼婆之爪','幽光萌花','薰衣草','鲜血王冠','幽魂外皮','深红奈恩根','鹰的蛋'], 'magnitude_type':'percent', 'magnitude':4, 'duration':60 }, '麻痹':{ 'value':182, 'materials':['气母胶质','小恶魔菌','沼泽真菌荚','人肉','幽光萌花','荆棘之心','犬根'], 'magnitude_type':None, 'magnitude':None, 'duration':4 }, '提高附魔效果':{ 'value':9, 'materials':['巢蚁猎人触角','灰烬魔尘','蓝蝶翅膀','先祖蛾翅膀','雪果','树精的树液','乌鸦鬼婆之爪'], 'magnitude_type':'percent', 'magnitude':4, 'duration':30 }, '提高开锁能力':{ 'value':18, 'materials':['伐莫耳','灰烬草种荚','松木画眉蛋','娜米拉腐菌','蜘蛛卵'], 'magnitude_type':'percent', 'magnitude':9, 'duration':30 }, '增强变化魔法':{ 'value':34, 'materials':['草籽','河布丁','烈焰树精木片','树精的树液'], 'magnitude_type':'percent', 'magnitude':18, 'duration':60 }, '提高议价能力':{ 'value':30, 'materials':['帝王蝴蝶翅膀','苔原棉花','乌鸦鬼婆之爪','龙舌兰'], 'magnitude_type':'percent', 'magnitude':4, 'duration':30 }, '提高轻甲技能':{ 'value':40, 'materials':['恶鼠尾巴','蜂巢','蜂箱外壳','灰烬跳虫胶质','法萨德燕鸥羽毛','月蛾翅膀','鹰羽毛'], 'magnitude_type':'percent', 'magnitude':9, 'duration':60 }, '提高重甲技能':{ 'value':40, 'materials':['冰怨灵的牙','白帽伞菌','剑齿虎牙齿','蓟花','食人鱼鳞'], 'magnitude_type':'point', 'magnitude':9, 'duration':60 }, '提高魔力上限':{ 'value':51, 'materials':['白帽伞菌','帝王伞苔','红山花','灵质','架子湾葡萄','虚无盐','苔原棉花','荆棘之心','希思特鲤鱼','鲑鱼卵'], 'magnitude_type':'point', 'magnitude':18, 'duration':60 }, '提高体力上限':{ 'value':51, 'materials':['巢螋卵','长鹿角','大蒜','食人鱼卵','萤火虫的胸壳','野猪牙','薰衣草'], 'bonus_material':['野猪牙'], 'bonus_value':378, 'magnitude_type':'point', 'magnitude':18, 'bonus_magnitude':22, 'duration':60, 'bonus_duration':300 }, '增强召唤魔法':{ 'value':53, 'materials':['巢蚁猎人触角','骨粉','霜盐','蓝蝶翅膀','先祖蛾翅膀','蓝山花','乌鸦鬼婆之羽','薰衣草','贝瑞特的骨灰'], 'magnitude_type':'percent', 'magnitude':22, 'duration':60 }, '提高锻造效果':{ 'value':60, 'materials':['剑齿虎牙齿','气泡草','微光伞菌','树精的树液'], 'magnitude_type':'point', 'magnitude':18, 'duration':30 }, '提高生命上限':{ 'value':60, 'materials':['吊苔','黄山花','巨人脚趾','小麦','熊爪','微光伞菌','蓝山花','野猪牙'], 'bonus_material':['巨人脚趾','野猪牙'], 'bonus_value':354, 'magnitude_type':'point', 'magnitude':18, 'duration':60, 'bonus_duration':300 }, '增强幻术魔法':{ 'value':68, 'materials':['矮人油','直立根','鳞片伞菌','龙舌兰','树伞菌'], 'magnitude_type':'percent', 'magnitude':18, 'duration':60 }, '提高弓箭伤害':{ 'value':86, 'materials':['刺柏浆果','精灵耳','犬根','蜘蛛卵'], 'magnitude_type':'percent', 'magnitude':18, 'duration':60 }, '提高潜行能力':{ 'value':86, 'materials':['阿贝希恩长鳍鱼','长毛象牙粉末','蜂箱外壳','寒霜甘草','灰烬草种荚','紫山花','鹰羽毛','人肉'], 'magnitude_type':'percent', 'magnitude':18, 'duration':60 }, '增强恢复魔法':{ 'value':86, 'materials':['阿贝希恩长鳍鱼','短鹿角','黄山花','盐堆','小珍珠','西罗帝尔斗鱼'], 'magnitude_type':'percent', 'magnitude':18, 'duration':60 }, '提高扒窃能力':{ 'value':86, 'materials':['橙色蜻蜓','食人鱼卵','诺德藤壶','蓝色蜻蜓'], 'magnitude_type':'percent', 'magnitude':18, 'duration':60 }, '提高格挡效果':{ 'value':86, 'materials':['蜂巢','苔原棉花','野猪牙','荆棘之心','食人鱼鳞','鲜血王冠','珍珠'], 'magnitude_type':'percent', 'magnitude':18, 'duration':60 }, '提高单手伤害':{ 'value':86, 'materials':['吊苔','熊爪','小珍珠','岩莺的蛋','鹰羽毛','犬根'], 'magnitude_type':'percent', 'magnitude':18, 'duration':60 }, '提高双手伤害':{ 'value':86, 'materials':['帝王伞苔','毒蝇伞','巨魔脂肪','龙舌兰'], 'magnitude_type':'percent', 'magnitude':18, 'duration':60 }, '增强毁灭魔法':{ 'value':107, 'materials':['蜂箱外壳','光尘','灰烬藤蔓丛','灵质','微光伞菌','龙葵','幽魂外皮'], 'magnitude_type':'percent', 'magnitude':22, 'duration':60 }, '提高负重':{ 'value':151, 'materials':['毒茂花','河布丁','巨人脚趾','鹰喙','特拉玛根','气母胶质','鳞片伞菌','藤蔓丛','幽魂外皮'], 'magnitude_type':'point', 'magnitude':18, 'duration':300 }, '降低生命上限':{ 'value':4, 'materials':['剑齿虎眼','架子湾葡萄','西罗帝尔斗鱼','银岸鲈鱼','恶鼠尾巴','巨型青苔'], 'magnitude_type':'point', 'magnitude':9, 'duration':10 }, '降低魔力上限':{ 'value':11, 'materials':['草籽','寒霜甘草','灰烬魔尘','红山花','橙色蜻蜓','痛苦草','薰衣草'], 'magnitude_type':'point', 'magnitude':9, 'duration':10 }, '降低体力上限':{ 'value':17, 'materials':['蜂巢','骨粉','灰烬魔尘','蓟花','丧钟花','蜜蜂','痛苦草','贝瑞特的骨灰'], 'bonus_material':['丧钟花'], 'bonus_value':38, 'magnitude_type':'point', 'magnitude':9, 'duration':10, 'bonus_duration':20 }, '降低闪电抗性':{ 'value':39, 'materials':['灰烬草种荚','特拉玛根','虚无盐','蜜蜂','乌鸦鬼婆之羽','巨型青苔'], 'magnitude_type':'percent', 'magnitude':13, 'duration':30 }, '生命流失':{ 'value':55, 'materials':['橙色蜻蜓','食人鱼卵','小恶魔菌','痛苦草','食人鱼鳞','树伞菌'], 'magnitude_type':'point', 'magnitude':4, 'duration':10 }, '提高闪电抗性':{ 'value':60, 'materials':['光尘','灰烬跳虫胶质','松木画眉蛋','微光伞菌','鹰喙','雪果','沼泽真菌荚','珍珠','蓝色蜻蜓'], 'magnitude_type':'percent', 'magnitude':13, 'duration':60 }, '水下呼吸':{ 'value':71, 'materials':['鸡蛋','诺德藤壶','希思特鲤鱼','鲑鱼卵','鹰的蛋', ], 'magnitude_type':None, 'magnitude':None, 'duration':22 #, #'duration_boost':True }, '体力流失':{ 'value':8, 'materials':['帝王蝴蝶翅膀','短鹿角','鸡蛋','龙葵','鹰的蛋'], 'magnitude_type':'point', 'magnitude':4, 'duration':10 }, '隐形':{ 'value':190, 'materials':['冰怨灵的牙','巢螋卵','灰烬藤蔓丛','吸血鬼灰烬','奈恩根','月蛾翅膀','深红奈恩根'], 'magnitude_type':None, 'magnitude':None, 'duration':18 }, '治愈疾病':{ 'value':14, 'materials':['吸血鬼灰烬','法萨德燕鸥羽毛','焦黑的恶鼠皮','鹰羽毛','泥沼蟹壳'], 'magnitude_type':None, 'magnitude':None, 'duration':None } } material_name_to_id_dict={} material_exclude_id_list=[] recipe_dict={} def recipe_add(_material_id_list, _effect_list): # print(_material_id_list,_effect_list) # 按照材料的价值排序 _material_list = [] for _material_id in _material_id_list: _name = material_dict[_material_id]['name'][0] _value = material_dict[_material_id]['value'] _material_list.append({ 'name':_name, 'value':_value }) _material_list.sort(key=operator.itemgetter('value','name')) # 构建临时材料名字列表 _material_names=[] for _material in _material_list: _material_names.append(_material['name']) # 转换为元组,用来做索引 _material_names=tuple(_material_names) if _material_names not in recipe_dict.keys(): recipe_dict[_material_names]={ 'effect_list':[], 'value':0 #稍后计算 } # 更新配方字典 for _effect in _effect_list: if _effect not in recipe_dict[_material_names]['effect_list']: recipe_dict[_material_names]['effect_list'].append(_effect) return def calc_recipe(): global recipe_dict global material_name_to_id_dict material_name_to_id_dict={} for material_id in material_dict.keys(): for name in material_dict[material_id]['name']: material_name_to_id_dict[name] = material_id recipe_dict={} #print(material_name_to_id_dict) for _material_1_id in material_dict.keys(): #第一种材料的id for _effect_1 in material_dict[_material_1_id]['effect_list']: #遍历第一种材料的效果 for _material_2_name in effect_dict[_effect_1]['materials']: #遍历当前效果的材料 _material_2_id = material_name_to_id_dict[_material_2_name] #当前第二种材料的id if(_material_2_id != _material_1_id): recipe_add([_material_1_id, _material_2_id], [_effect_1]) for _effect_2 in material_dict[_material_2_id]['effect_list']: #遍历第二种材料的效果 for _material_3_name in effect_dict[_effect_2]['materials']: #遍历当前效果的材料 _material_3_id = material_name_to_id_dict[_material_3_name] #当前第三种材料的id if(_material_2_id != _material_3_id and _material_1_id != _material_3_id): recipe_add([_material_1_id, _material_2_id, _material_3_id], [_effect_1, _effect_2]) #print(recipe_dict) print("len(recipe_dict)=%s"%(len(recipe_dict))) def get_recipe_effect_property(_effect_name, _recipe_material_id_list): _base_value = effect_dict[_effect_name]['value'] _magnitude_type = effect_dict[_effect_name]['magnitude_type'] _base_magnitude = effect_dict[_effect_name]['magnitude'] _base_duration = effect_dict[_effect_name]['duration'] if 'bonus_value' in effect_dict[_effect_name].keys() and 'bonus_material' in effect_dict[_effect_name].keys(): _bonus_material_id_list = [] for _bonus_material_name in effect_dict[_effect_name]['bonus_material']: _bonus_material_id_list.append(material_name_to_id_dict[_bonus_material_name]) for _bonus_material_id in _bonus_material_id_list: if _bonus_material_id in _recipe_material_id_list: # print(_material_name_tuple) # print(_effect_name) _base_value = effect_dict[_effect_name]['bonus_value'] if 'bonus_magnitude' in effect_dict[_effect_name].keys(): _base_magnitude = effect_dict[_effect_name]['bonus_magnitude'] if 'bonus_duration' in effect_dict[_effect_name].keys(): _base_duration = effect_dict[_effect_name]['bonus_duration'] break return { 'base_value':_base_value, 'magnitude_type':_magnitude_type, 'base_magnitude':_base_magnitude, 'base_duration':_base_duration } recipe_list=[] def filter_recipe_list(): global recipe_list global material_exclude_id_list #写入列表(list),用来排序 recipe_list =[] for _material_name_tuple in recipe_dict.keys(): # 效果过滤 if(len(config['effect_include']) > 0): _count = 0 for _effect in config['effect_include']: if _effect in recipe_dict[_material_name_tuple]['effect_list']: _count=_count+1 if(_count != len(config['effect_include'])): continue _recipe_material_id_list=[] for _material_name in _material_name_tuple: _recipe_material_id_list.append(material_name_to_id_dict[_material_name]) #material_ban_list _exclude_material_found = False for _material_id in _recipe_material_id_list: if(_material_id in material_exclude_id_list): _exclude_material_found = True break if _exclude_material_found: continue # 材料过滤 if(len(config['material_include']) > 0): _count = 0 for _material_name in config['material_include']: if _material_name not in material_name_to_id_dict.keys(): break _material_id = material_name_to_id_dict[_material_name] if _material_id in _recipe_material_id_list: _count= _count + 1 if(_count != len(config['material_include'])): continue #按照炼金效果的价值对配方的效果排序 #并计算药水的价格 _effect_list = [] _potion_base_value = 0 _value_mutilpy = config['value_mutilpy'] for _effect_name in recipe_dict[_material_name_tuple]['effect_list']: ''' _base_value = effect_dict[_effect_name]['value'] _magnitude_type = effect_dict[_effect_name]['magnitude_type'] _base_magnitude = effect_dict[_effect_name]['magnitude'] _base_duration = effect_dict[_effect_name]['duration'] if 'bonus_value' in effect_dict[_effect_name].keys() and 'bonus_material' in effect_dict[_effect_name].keys(): _bonus_material_id_list = [] for _bonus_material_name in effect_dict[_effect_name]['bonus_material']: _bonus_material_id_list.append(material_name_to_id_dict[_bonus_material_name]) for _bonus_material_id in _bonus_material_id_list: if _bonus_material_id in _recipe_material_id_list: # print(_material_name_tuple) # print(_effect_name) _base_value = effect_dict[_effect_name]['bonus_value'] if 'bonus_magnitude' in effect_dict[_effect_name].keys(): _base_magnitude = effect_dict[_effect_name]['bonus_magnitude'] if 'bonus_duration' in effect_dict[_effect_name].keys(): _base_duration = effect_dict[_effect_name]['bonus_duration'] break ''' _property = get_recipe_effect_property(_effect_name, _recipe_material_id_list) _base_value = _property['base_value'] _magnitude_type = _property['magnitude_type'] _base_magnitude = _property['base_magnitude'] _base_duration = _property['base_duration'] _magnitude = _base_magnitude _duration = _base_duration if _magnitude_type == None and _duration != None: _duration = int(_duration * _value_mutilpy ) if _magnitude_type == 'percent': if _base_magnitude in [100,50] and _duration != None: _duration = int(_duration * _value_mutilpy ) else: if _base_magnitude != None: _magnitude = int(_base_magnitude * _value_mutilpy) if _magnitude_type == 'point': _magnitude = int(_base_magnitude * _value_mutilpy) _effect_list.append({ 'name':_effect_name, 'value':_base_value, 'magnitude_type':_magnitude_type, 'base_magnitude':_base_magnitude, 'base_duration':_base_duration, 'magnitude':_magnitude, 'duration':_duration }) _potion_base_value = _potion_base_value + _base_value # 计算利润 _effect_list.sort(key=operator.itemgetter('value'), reverse=True) _total_material_value = 0 for _material in _material_name_tuple: _material_id = material_name_to_id_dict[_material] _total_material_value = _total_material_value + material_dict[_material_id]['value'] _effective_in_recipe = 0 for _material in _material_name_tuple: _material_id = material_name_to_id_dict[_material] _material_total_effect_value = 0 _material_total_uneffect_value = 0 for _effect_name in material_dict[_material_id]['effect_list']: _value = get_recipe_effect_property(_effect_name, _recipe_material_id_list)['base_value'] if _effect_name in recipe_dict[_material_name_tuple]['effect_list']: _material_total_effect_value = _material_total_effect_value + _value else: _material_total_uneffect_value = _material_total_uneffect_value + _value _effective_in_recipe = _effective_in_recipe + _material_total_effect_value / (_material_total_effect_value + _material_total_uneffect_value) _effective_in_recipe = _effective_in_recipe / len(_recipe_material_id_list) _potion_value = _potion_base_value * _value_mutilpy _potion_price = _potion_value * config['sell_mutilpy'] _total_cost = _total_material_value * config['buy_mutilpy'] recipe_list.append({ 'material': _material_name_tuple, 'effect_list': _effect_list, 'base_value': _potion_base_value, 'value': _potion_value, 'price': _potion_price, 'cost' : _total_cost, 'profit': _potion_price - _total_cost, 'effective': _effective_in_recipe }) #print(recipe_list) print("len(recipe_list)=%s"%(len(recipe_list))) return def sort_by_price(): recipe_list.sort(key=operator.itemgetter('price'), reverse=True) return def sort_by_profit(): recipe_list.sort(key=operator.itemgetter('profit'), reverse=True) return def sort_by_cost(): recipe_list.sort(key=operator.itemgetter('cost'), reverse=False) return def sort_by_effective(): recipe_list.sort(key=operator.itemgetter('effective'), reverse=True) return def output(_file): count = 0 with open(_file, mode='w',encoding='utf-8') as f: for _recipe in recipe_list: _str_out="" _str_count="["+str(count)+"]" # if(len(_str_count)<=16): # _str_count=_str_count+"\t" if(len(_str_count)<=8): _str_count=_str_count+"\t" _str_out=_str_count # 材料 for _material in _recipe['material']: _material_id = material_name_to_id_dict[_material] _material_value = material_dict[_material_id]['value'] _str_price = str(_material_value) _str_material = _material + "["+ _str_price +"]" # 一个汉字占两个字母的位置 if((len(_material)*2 + len(_str_price)+2)<=8): _str_material=_str_material+"\t" _str_out=_str_out+_str_material+"\t" if(len(_recipe['material']) == 2): _str_out=_str_out+"\t\t" # 价格 # 人物1级时药水的价值 _base_value = int(_recipe['base_value']) _str_out=_str_out+str(_base_value)+"\t" #当前药水的价值 _current_value = int(_recipe['value']) _str_out=_str_out+str(_current_value)+"\t" # 售价 _price = int(_recipe['price']) _str_out=_str_out+str(_price)+"\t" # 购买原料的成本 _cost = int(_recipe['cost']) _str_out=_str_out+str(_cost)+"\t" # 利润 _profit = int(_recipe['profit']) _str_out=_str_out+str(_profit)+"\t" # 效果 for _effect in _recipe['effect_list']: _effect_price = _effect['value'] _str_price = str(_effect_price) _effect = _effect['name'] _str_effect=_effect+"["+_str_price+"]" # if((len(_effect)*2 + len(_str_price)+2)<=24): # _str_effect=_str_effect+"\t" if((len(_effect)*2 + len(_str_price)+2)<=17): _str_effect=_str_effect+"\t" if((len(_effect)*2 + len(_str_price)+2)<=8): _str_effect=_str_effect+"\t" _str_out=_str_out+_str_effect+"\t" _str_out=_str_out+"\n" f.write(_str_out) count=count +1 print(_file+"\t" + str(count)) #output('output_by_price.txt') #recipe_list.sort(key=operator.itemgetter('profit'), reverse=True) #output('output_by_profit.txt') ####################################################################### import pygame import win32api import win32con import win32gui import time screen = None clock = None def ui_setup(): global screen global clock Width = 0 Height = 0 screen = pygame.display.set_mode((Width, Height),pygame.NOFRAME) clock = pygame.time.Clock() # Set window transparency color hwnd = pygame.display.get_wm_info()["window"] # ~ win32gui.SetWindowLong(hwnd, win32con.GWL_EXSTYLE, # ~ win32gui.GetWindowLong(hwnd, win32con.GWL_EXSTYLE) | win32con.WS_EX_LAYERED) win32gui.SetWindowLong(hwnd, win32con.GWL_EXSTYLE, win32con.WS_EX_TRANSPARENT | win32con.WS_EX_LAYERED) win32gui.SetLayeredWindowAttributes(hwnd, 0, 0, win32con.LWA_COLORKEY) win32gui.SetForegroundWindow (hwnd) # // 去掉标题栏及边框 # LONG_PTR Style = GetWindowLongPtr(hwnd, GWL_STYLE); # Style = Style & ~WS_CAPTION & ~WS_SYSMENU & ~WS_SIZEBOX; # SetWindowLongPtr(hwnd, GWL_STYLE, Style); left, top, right, bottom = win32gui.GetWindowRect(hwnd) Width, Height = right - left, bottom - top # print("Window Width = %d, Height=%d" % (Width,Height)) win32gui.SetWindowPos(hwnd, win32con.HWND_TOPMOST, left,top,Width,Height, \ win32con.SWP_NOMOVE | win32con.SWP_NOACTIVATE| \ win32con.SWP_NOOWNERZORDER| win32con.SWP_SHOWWINDOW) return def draw_text(text="text",color=(0,0,255),position=(10,70)): global screen textFont = pygame.font.SysFont('simhei', 24) #color = (0,0,255) text_fmt = textFont.render(text,1, color) screen.blit(text_fmt,position) return def draw_recipe(show_type,_show_sort, _index): if show_type < 1: return _top_left = 880 _top_up = 80 _offset_y = _top_up _column_width = 210 _line_height = 32 _str_num = str(_index)+ "/" + str(len(recipe_list)) draw_text(text=_str_num, position=(_top_left,_top_up - 32)) _show_sort = {'effective':'按利用率降序','cost':'按成本升序','price':'按售价降序','profit':'按利润降序'}[_show_sort] draw_text(text=_show_sort, position=(_top_left + 100,_top_up - 32)) draw_text('基础', position=(_top_left + _column_width * 3, _top_up - 32)) draw_text('价值', position=(_top_left + _column_width * 3 + 64, _top_up - 32)) draw_text('售价', position=(_top_left + _column_width * 3 + 64*2, _top_up - 32)) draw_text('成本', position=(_top_left + _column_width * 3 + 64*3, _top_up - 32)) draw_text('利润', position=(_top_left + _column_width * 3 + 64*4, _top_up - 32)) draw_text('利用率', position=(_top_left + _column_width * 3 + 64*5, _top_up - 32)) _index = _index - 1 while _offset_y < 500 and _index + 1 < len(recipe_list): _index = _index + 1 _recipe = recipe_list[_index] # for _recipe in recipe_list: # if _offset_y > 500: # break #材料名字 _offset_x = _top_left for _material in _recipe['material']: _material_id = material_name_to_id_dict[_material] _material_value = material_dict[_material_id]['value'] _str_value = str(_material_value) _str_material = _material + "["+ _str_value +"]" draw_text(text=_str_material,position=(_offset_x,_offset_y)) _offset_x = _offset_x + _column_width #价值和利润 _offset_x = _top_left + _column_width * 3 draw_text(text=str(int(_recipe['base_value'])),position=(_offset_x,_offset_y)) _offset_x = _offset_x + 64 draw_text(text=str(int(_recipe['value'])),position=(_offset_x,_offset_y)) _offset_x = _offset_x + 64 draw_text(text=str(int(_recipe['price'])),position=(_offset_x,_offset_y)) _offset_x = _offset_x + 64 draw_text(text=str(int(_recipe['cost'])),position=(_offset_x,_offset_y)) _offset_x = _offset_x + 64 draw_text(text=str(int(_recipe['profit'])),position=(_offset_x,_offset_y)) _offset_x = _offset_x + 64 draw_text(text=str(int(_recipe['effective']*100))+'%',position=(_offset_x,_offset_y)) _offset_x = _offset_x + 64 _offset_y = _offset_y + _line_height if show_type < 2: continue #效果 _recipe_effect_list = _recipe['effect_list'] # print(_recipe_effect_list) for _effect in _recipe_effect_list: _offset_x = _top_left for _material_name in _recipe['material']: _material_id = material_name_to_id_dict[_material_name] _material_effect_list = material_dict[_material_id]['effect_list'] if _effect['name'] in _material_effect_list: _str_effect = _effect['name'] +"[" + str(_effect['value']) + "]" draw_text(text=_str_effect,color=(255,255,0),position=(_offset_x,_offset_y)) _offset_x = _offset_x + _column_width # _offset_x = _top_left + _column_width * 3 if 'magnitude_type' in _effect.keys() and 'magnitude' in _effect.keys() and 'base_magnitude' in _effect.keys(): if _effect['magnitude_type'] in ['point','percent']: _str_magnitude = str(_effect['base_magnitude']) if _effect['magnitude_type'] == 'percent': _str_magnitude = _str_magnitude + "%" draw_text(text=_str_magnitude,color=(255,255,0),position=(_offset_x,_offset_y)) _str_magnitude = str(_effect['magnitude']) if _effect['magnitude_type'] == 'percent': _str_magnitude = _str_magnitude + "%" draw_text(text=_str_magnitude,color=(255,255,0),position=(_offset_x + 64 * 2,_offset_y)) if 'base_duration' in _effect.keys() and _effect['base_duration'] != None: _str_duration = str(_effect['base_duration']) + 's' draw_text(text=_str_duration,color=(255,255,0),position=(_offset_x + 64 * 1,_offset_y)) if 'duration' in _effect.keys() and _effect['duration'] != None: _str_duration = str(_effect['duration']) + 's' draw_text(text=_str_duration,color=(255,255,0),position=(_offset_x + 64 * 3,_offset_y)) _offset_y = _offset_y + _line_height if show_type < 3: continue #把所有材料的效果都显示出来 _offset_x = _top_left _effect_name_list = [] for _effect in _recipe['effect_list']: _effect_name_list.append(_effect['name']) for _material_name in _recipe['material']: _material_id = material_name_to_id_dict[_material_name] _material_effect_list = material_dict[_material_id]['effect_list'] for _effect_name in _material_effect_list: if _effect_name not in _effect_name_list: _effect_value = effect_dict[_effect_name]['value'] if 'bonus_material' in effect_dict[_effect_name].keys(): for _bonus_material_name in effect_dict[_effect_name]['bonus_material']: if material_name_to_id_dict[_material_name] == material_name_to_id_dict[_bonus_material_name]: _effect_value = effect_dict[_effect_name]['bonus_value'] _str_effect = _effect_name + "[" + str(_effect_value) + "]" draw_text(text=_str_effect,color=(0,233,233),position=(_offset_x,_offset_y)) _offset_y = _offset_y + _line_height _offset_x = _offset_x + _column_width return # _offset_y = _offset_y + _line_height def sort_and_output(_show_sort): if _show_sort == 'profit': sort_by_effective() output('sort_by_effective.txt') sort_by_price() output('sort_by_price.txt') sort_by_cost() output('sort_by_cost.txt') sort_by_profit() output('sort_by_profit.txt') if _show_sort == 'price': sort_by_effective() output('sort_by_effective.txt') sort_by_cost() output('sort_by_cost.txt') sort_by_profit() output('sort_by_profit.txt') sort_by_price() output('sort_by_price.txt') if _show_sort == 'sort': sort_by_effective() output('sort_by_effective.txt') sort_by_profit() output('sort_by_profit.txt') sort_by_price() output('sort_by_price.txt') sort_by_cost() output('sort_by_cost.txt') if _show_sort == 'effective': sort_by_profit() output('sort_by_profit.txt') sort_by_price() output('sort_by_price.txt') sort_by_cost() output('sort_by_cost.txt') sort_by_effective() output('sort_by_effective.txt') return def exclude_material(_recipe_index,_material_index): global material_exclude_id_list if len(recipe_list) == 0: return if _recipe_index < 0 or _recipe_index >= len(recipe_list): return _recipe = recipe_list[_recipe_index] _material_name_tuple = _recipe['material'] if _material_index > len(_material_name_tuple): return _material_name = _material_name_tuple[_material_index - 1] _material_id = material_name_to_id_dict[_material_name] material_exclude_id_list.append(_material_id) print(_material_name + " temp exclude ") # print(material_exclude_id_list) filter_recipe_list() # sort_and_output() return def remove_recipe(_index): global recipe_list if _index < len(recipe_list): print(recipe_list[_index - 1]['material']) del recipe_list[_index - 1] return def ui_loop(): global show_profit_on_overlay _show_type = 0 running = True _show_sort = 'profit' _recipe_index = 0 pygame.init() ui_setup() while running: for event in pygame.event.get(): if event.type == pygame.QUIT: running = False #需要把pygame窗口切换到前台,此时按键操作被pygame截留,游戏不会接收到任何操作 #点击鼠标,pygame窗口将失去焦点 if event.type == pygame.KEYUP and event.key == pygame.key.key_code("escape"): running = False if event.type == pygame.KEYUP and event.key == pygame.key.key_code("F1"): exclude_material(_recipe_index, 1) sort_and_output(_show_sort) if event.type == pygame.KEYUP and event.key == pygame.key.key_code("F2"): exclude_material(_recipe_index, 2) sort_and_output(_show_sort) if event.type == pygame.KEYUP and event.key == pygame.key.key_code("F3"): exclude_material(_recipe_index, 3) sort_and_output(_show_sort) if event.type == pygame.KEYUP and event.key == pygame.key.key_code("F4"): _show_type = 1 _recipe_index = 0 calc_recipe() read_config() filter_recipe_list() sort_and_output(_show_sort) if event.type == pygame.KEYUP and event.key == pygame.key.key_code("F8"): _recipe_index = 0 if _show_sort == 'effective': _show_sort = 'price' sort_by_price() print("sort_by_price") elif _show_sort == 'price': sort_by_cost() _show_sort = 'cost' print("sort_by_cost") elif _show_sort == 'cost': sort_by_profit() _show_sort = 'profit' print("sort_by_profit") else:#elif _show_sort == 'profit': sort_by_effective() _show_sort = 'effective' print("sort_by_effective") # print(_show_sort) if event.type == pygame.KEYUP and event.key == pygame.key.key_code("delete"): remove_recipe(_recipe_index) sort_and_output(_show_sort) if event.type == pygame.KEYUP and event.key == pygame.key.key_code("F12"): _show_type = _show_type + 1 if _show_type > 3: _show_type = 0 print("_show_type=%s"%(_show_type)) if event.type == pygame.KEYUP and event.key == pygame.key.key_code("up"): _recipe_index = _recipe_index - 1 if _recipe_index < 0: _recipe_index = 0 if event.type == pygame.KEYUP and event.key == pygame.key.key_code("down"): _recipe_index = _recipe_index + 1 if _recipe_index > len(recipe_list) - 1: _recipe_index = len(recipe_list) - 1 #################################################### screen.fill(0) if _show_type > 0: draw_recipe(_show_type, _show_sort, _recipe_index) pygame.display.flip() clock.tick(60) pygame.quit() return ui_loop()

[option] #可以写简单的计算式 #药水的基础价值618 #有炼金装备等,药水价值699 #有口才等,商人收购价为246 #键不存在,或者值为空则按照默认值 value_mutilpy=;892/618 #默认为1 sell_mutilpy=;246/699 #默认为1/3 buy_mutilpy=;65/20 #默认为3 #空白、单引号和双引号会被去掉 #多余的逗号会被忽略 #第二个=等同注释 material_exclude="人类心脏","人肉", ;" 灰烬草种荚", "灰烬魔尘 ", "黄色山花"''''', ''"""" 荆棘之心 ","魔族心脏","气母胶质","深红奈恩根","幽光萌花","巢蚁猎人触角","先祖飞蛾翅膀",,"野猪牙","毒茂花","巨人的脚趾",特拉玛根,,,,,,,;吊苔,熊爪,藤蔓丛,树伞菌,鳞片伞菌,长鹿角,丧钟花,诺德藤壶,蓝色蜻蜓,犬根,岩莺的蛋,蓝蝶翅膀,老鹰蛋,鸡蛋,,巢螋卵,帝王伞苔,寒霜甘草,微光伞菌,橙色蜻蜓,食人鱼卵,奈恩根,刺柏浆果,娜米拉腐菌,架子湾葡萄,小珍珠,,,,,, effect_include= =提高格挡效果 material_include=#蓟花,紫山花
在透明窗口上显示前几个结果的详细信息。需要在游戏启动器里设置窗口、无边框。
打开商人界面或者炼金界面,切换窗口到pygame的透明窗口,不要点击鼠标,否则透明窗口会失去焦点。 F4读取配置文件,计算并显示,F1、F2、F3临时将最上边的材料之一加入黑名单,并重新计算。
用esc退出。
显示效果的幅度和持续时间。
不想要命令行,可以把.py后缀改成.pyw。
使用上下按键翻动,delete按键暂时删除最上面的配方,
F12改变显示方式,不显示,只显示一行,显示生效的效果,显示未生效的效果
F8切换透明窗口上显示的配方排序
左上角显示当前配方的位置和数量
################################################
版本日志,
V9,最初发布
V10,增加了effect_filter
V11,增加material_filter
V12,修改价格和收益计算
V13,修正,材料过滤没有使用材料ID。读取配置文件 alchemy_combine_calc__config.ini
V13.5,提高对配置文件的容错
alchemy_combine_calc_overlay_v0.1.py
使用透明窗口,显示材料间的关联。
alchemy_combine_calc_overlay_v0.2.py
用esc退出
alchemy_combine_calc_overlay_v0.3.py
显示效果的幅度和持续时间
alchemy_combine_calc_overlay_v0.4.py
重新把配方按照利润排序写入文件 output_by_profit.txt
alchemy_combine_calc_overlay_v0.5.py
F5 F6 F7临时屏蔽第二个配方中的材料
F9 F10 F11临时屏蔽第三个配方中的材料
F8切换透明窗口上显示的配方排序
output_by_profit.txt 和 output_by_price.txt都会输出
alchemy_combine_calc_overlay_v0.6.3.py
1 2 3 4临时删除透明窗口上相应的配方,
F8只重新排序,不再重新过滤
v0.2到v0.3时,失误删除了'提高生命上限'的'bonus_material'
alchemy_combine_calc_overlay_v0.7.py
更改配置文件键值 增加对配置文件的容错
alchemy_combine_calc_overlay_v0.8.py
F12改变显示方式,不显示,只显示一行,显示生效的效果,显示未生效的效果
1-9都可以临时删除配方
alchemy_combine_calc_overlay_v0.9.py
使用上下按键翻动,delete按键暂时删除最上面的配方,
1-9注释掉了,F5 -F7 F8-F11也注释掉了
左上角显示当前配方的位置和数量
alchemy_combine_calc_overlay_v0.10.py
增加按成本升序
alchemy_combine_calc_overlay_v0.11.py
增加按材料利用率降序