dnf手游 70 版本 装备搭配测试脚本

坨之歌 / 2023-08-04 / 原文

# 武器数据库, 懒得写了
WEAPON_DB = {}
# 装备数据库
"""
    安魂 
        25-45技能 +3(每集算作0.8整体提升), 
        1.5cd左右 50重置, 即放两次技能必然可以放得出第三次技能, 两个单位时间内可以放出三倍伤害. 即一单位时间内1.5倍伤害, 
            考虑还有觉醒和 7065技能的存在, 25-45的伤害占比大概在70, 再 * 0.7
            考虑实战不可能完全理想按的出所有技能 * 0.8
    
    坠落
        v10技能 +4(每级算作0.0125整体提升), 
        lv25技能 +2(每级算作0.02整体提升)
    
    深海 
        lv45技能 +1(每级算作0.025整体提升), 

"""
EQUIP_DB = {
    "纯粹": {"属强": 110, "攻击": 50, "力智系数": 0.02, "属白": 0.1, "减防": 1.074, "暴击值": 80},
    "鬼面": {"黄字": 0.32, "攻击系数": 0.62, "技伤": 1.15 * 1.13, "白字": 0.12},
    "冥火": {"属强": 100, "技伤": 1.12 * 1.09, "属白": 0.3, "白字": 0.1, "攻击系数": 0.12},
    "黑暗": {"属强": 115, "黄字": 0.35, "技伤": 1.1 * 1.09, "攻击": 100, "属白": 0.05},
    "坚定": {"属强": 35, "白字": 0.50, "技伤": 1.26, "攻击系数": 0.17, "属白": 0.05, "黄字": 0.07, "力智系数": 0.1, "爆伤": 0.1, "暴击值": 100},
    "幽魂": {"属强": 120, "黄字": 0.05, "爆伤": 0.2, "技伤": 1.1 * 1.05, "属白": 0.2, "暴击值": 70, "力智": 50, "攻击": 50},
    "恶魔": {"力智系数": 0.34, "攻击系数": 0.24, "技伤": 1.15 * 1.13, "白字": 0.4},
    "虚空": {"属强": 50, "攻击系数": 0.1, "力智系数": 0.1, "技伤": 1.1 * 1.27, "黄字": 0.3, "暴击值": 80, "爆伤": 0.15},
    "坠落": {"属强": 50, "黄字": 0.18, "技伤": 1.12 * 1.14, "属白": 0.1, "暴击值": 200, "白字": 0.1, "其他暂定": 1.06 * 1.04},
    "天狼": {"爆伤": 0.12, "力智": 132, "白字": 0.25, "技伤": 1.28, "减防": 1.248, "攻击系数": 0.06, "力智系数": 0.06, "黄字": 0.06},
    "沉默": {"力智系数": 0.30, "攻击系数": 0.10, "白字": 0.26, "技伤": 1.19, "黄字": 0.25, "暴击值": 300, "减防": 1.048},
    "深海": {"属强": 65, "技伤": 1.15 * 1.07, "属白": 0.1, "攻击系数": 0.4, "暴击值": 100, "力智系数": 0.08, "其他暂定": 1.02},
    "黑洞": {"白字": 0.58, "技伤": 1.22 * 1.13, "暴击值": 100, "力智系数": 0.07, "黄字": 0.13, "攻击系数": 0.2},
    "安魂": {"属强": 75, "攻击系数": 0.15, "cd": 10, "白字": 0.15, "技伤": 1.27, "其他暂定": 1.24 * 1.5 * 0.7 * 0.8}
}
# 首饰数据库
JEWELRY_DB = {
    "暗杀": {"技伤": 1.32, "黄字": 0.125, "暴击值": 130, "力智系数": 0.03, "爆伤": 0.125},
    "火套": {"属强": 39, "技伤": 1.11, "属白": 0.15, "爆伤": 0.14, "黄字": 0.09},
    "明星": {"属强": 36, "技伤": 1.11, "属白": 0.24, },
    "精炼": {"技伤": 1.07 * 1.05 * 1.05, "黄字": 0.10, "暴击值": 130, "力智系数": 0.06, "白字": 0.23, "属强": 26}
}


class CalDnf(object):

    def __init__(self, power=None, attack=None, attribute_strengthen=None,
                 yellow=None, white=None, reduce_defense=None, skill_damage=None,
                 critical=None, critical_value=None, critical_damage=None, has_pearl=True):
        # 基础力智
        self.base_power = power or 3800
        # 基础攻击
        self.base_attack = attack or 2200
        # 基础属强 基础29 + 工会16 + 三张16 + 宠物22+ 武器10 + 5级徽章*2
        self.base_attribute_strengthen = attribute_strengthen or 153
        # 基础黄字
        self.base_yellow = yellow or 0.21  # 称号(15) + 武器宝珠(6)
        # 基础白字
        self.base_white = white or 0.24  # 赛利亚(21) + 雷龙(3)
        # 基础减防
        self.base_reduce_defense = reduce_defense or 0
        # 基础技伤
        self.base_skill_damage = skill_damage or 0.2
        # 基础暴击率
        self.base_critical = critical or 0.15
        # 基础暴击值
        self.base_critical_value = critical_value or 1000
        # 基础暴伤
        self.base_critical_damage = critical_damage or 1.5
        # 有宝珠的情况下多加黄字 0.05
        if has_pearl:
            self.base_white += 0.05

        # 最终测算结果
        self.result = []

    def cal_compose(self):
        for equip, equip_info in EQUIP_DB.items():
            for jewelry, jewelry_info in JEWELRY_DB.items():
                # 火套不会跟光以及暗的套装搭配. 直接忽略
                if jewelry == "火套":
                    if equip in ["幽魂", "纯粹"]:
                        continue

                power = 0
                attack = 0
                power_rate = 0
                attack_rate = 0
                yellow = 0
                white = 0
                attribute_strengthen = 0
                attribute_strengthen_yellow_rate = 0
                attribute_strengthen_white_rate = 0
                reduce_defense = 0
                skill_damage = 0
                critical = 0
                critical_value = 0
                critical_damage = 0
                other = 0

                for each in [equip_info, jewelry_info]:
                    power += each.get("力智", 0)
                    attack += each.get("攻击", 0)
                    power_rate += each.get("力智系数", 0)
                    attack_rate += each.get("攻击系数", 0)
                    yellow += each.get("黄字", 0)
                    white += each.get("白字", 0)
                    attribute_strengthen += each.get("属强", 0)
                    attribute_strengthen_white_rate += each.get("属白", 0)
                    attribute_strengthen_yellow_rate += each.get("属黄", 0)
                    reduce_defense += each.get("减防", 0)
                    skill_damage += each.get("技伤", 0)
                    critical += each.get("暴击率", 0)
                    critical_value += each.get("暴击值", 0)
                    critical_damage += each.get("爆伤", 0)
                    other += each.get("其他暂定", 0)

                self.result.append(self.cal_main(power, attack, power_rate, attack_rate,
                                                 attribute_strengthen, yellow,
                                                 attribute_strengthen_yellow_rate, white,
                                                 attribute_strengthen_white_rate,
                                                 reduce_defense, skill_damage, critical,
                                                 critical_value, critical_damage,
                                                 other, f"{equip} + {jewelry}"))


    @staticmethod
    def show_num(num, length=5):
        show_v = "%.2f" % float(num)
        while len(show_v) < length:
            show_v += " "
        return show_v

    def cal_main(self, power, attack, power_rate, attack_rate, attribute_strengthen, yellow,
                 attribute_strengthen_yellow_rate, white, attribute_strengthen_white_rate, reduce_defense,
                 skill_damage, critical, critical_value, critical_damage, other, show_name):
        # ----------------- 面板信息 -----------------
        panel_power = self.base_power + power  # 力智
        panel_attack = (self.base_attack + attack) * (1 + attack_rate) * (1 + panel_power / 250)  # 攻击
        panel_critical_value = self.base_critical_value + critical_value  # 暴击值
        panel_critical = self.base_critical + critical + panel_critical_value / 25.3 / 100  # 暴击率
        panel_critical_damage = self.base_critical_damage + critical_damage  # 暴击伤害
        panel_attribute_strengthen = self.base_attribute_strengthen + attribute_strengthen  # 属强
        # ----------------- 加成系数 -----------------
        power_rate = power_rate  # 力智百分比增加
        attack_rate = attack_rate  # 攻击百分比增加
        yellow_rate = self.base_yellow + yellow  # 黄字百分比增加
        white_rate = self.base_white + white  # 白字百分比增加
        attribute_strengthen_yellow_rate = attribute_strengthen_yellow_rate  # 属黄百分比增加
        attribute_strengthen_white_rate = attribute_strengthen_white_rate  # 属白百分比增加
        skill_damage_rate = self.base_skill_damage + skill_damage  # 技工增加 (装备间乘算后, 于技能加算)
        reduce_defense_rate = self.base_reduce_defense + reduce_defense  # 减防转换为最终伤害系数
        other = other  # 其他暂定的调整系数
        #  ----------------- 暂存常数系数 -----------------
        critical_desire = panel_critical * panel_critical_damage + (1 - panel_critical)
        yellow = attribute_strengthen_yellow_rate * (1 + panel_attribute_strengthen / 220) + yellow_rate + 1
        white = attribute_strengthen_white_rate * (1 + panel_attribute_strengthen / 220) + white_rate + 1

        return {
            "组合": show_name,
            "力智": panel_power,
            "攻击": self.show_num(panel_attack, 3),
            "属强": self.show_num(panel_attribute_strengthen, 3),
            "暴击": self.show_num(panel_critical, 3),
            "暴伤": self.show_num(panel_critical_damage, 3),
            "暴击期望": self.show_num(critical_desire, 3),
            "其他加成": self.show_num(other, 3),

            "力智系数": self.show_num(power_rate, 3),
            "攻击系数": self.show_num(0.05 + attack_rate, 3),
            "黄字": self.show_num(yellow, 3),
            "白字": self.show_num(white, 3),
            "技伤": self.show_num(skill_damage_rate, 3),
            "减防": self.show_num(reduce_defense_rate, 3),
            "强度": self.show_num(panel_attack * yellow * white * critical_desire * (
                    1 + panel_attribute_strengthen / 220) * skill_damage_rate * 1 or other, 11),

        }

    def run(self):
        self.cal_compose()
        print(" ---------------------------  基础信息 --------------------------- ")
        print(f"属强:{self.base_attribute_strengthen} "
              f"| 黄字:{self.base_yellow} "
              f"| 白字:{self.base_white} "
              f"| 力智:{self.base_power} "
              f"| 攻击:{self.base_attack} "
              f"| 暴击率:{self.base_critical} "
              f"| 暴击值:{self.base_critical_value} "
              f"| 暴伤:{self.base_critical_damage} "
              f"| 技伤:{self.base_skill_damage} "
              f"| 减防:{self.base_reduce_defense} ")

        print(" ---------------------------  排名信息 --------------------------- ")
        c = 1

        for i in sorted(self.result, key=lambda x: float(x["强度"]), reverse=True):
            print(f"{str(c) if len(str(c)) ==2 else '0'+str(c)} {i['组合']} --  强度:{i['强度']} "
                  f"| 属强:{i['属强']} "
                  f"| 黄字:{i['黄字']} "
                  f"| 白字:{i['白字']} "
                  f"| 力智:{i['力智']} "
                  f"| 力智系数:{i['力智系数']} "
                  f"| 攻击:{i['攻击']} "
                  f"| 攻击系数:{i['攻击系数']} "
                  f"| 暴击:{i['暴击']} "
                  f"| 暴伤:{i['暴伤']} "
                  f"| 暴击期望:{i['暴击期望']} "
                  f"| 技伤:{i['技伤']} "
                  f"| 减防:{i['减防']} "
                  f"| 其他加成:{i['其他加成']}")
            c += 1


if __name__ == '__main__':
    cal = CalDnf()
    cal.run()