算一下胡桃伤害

算一下胡桃伤害

直接把代码扔这了

import java.math.*;
import java.util.Random;

public class dps {


    public static void main(String[] args) {
        //胡桃基础面板
        double hpBase = 15552;          //基础三明治
        double atkBase = 106;           //基础攻击力
        double criDmgBase = 0.384;      //基础爆伤
        double fireBase = 0.33;         //基础火伤
        double criRateBase = 0.05;      //基础暴击率

        boolean bianli = false;         //是否启用遍历寻找最佳武器
        boolean pingjun = true;         //是否使用计算武器平均伤害计算

        //new出各种武器
        Weapon[] weapons = new Weapon[10];
        weapons[0] = new Weapon("xiali", 454, 0, 0, 0, 0, 0.2, 221);
        weapons[1] = new Weapon("shizuo", 510, 0, 0, 0, 0, 0.08, 0);
        weapons[2] = new Weapon("heiyan", 510, 0, 0.551, 0, 0, 0, 0);
        weapons[3] = new Weapon("juedou", 454, 0, 0, 0.368, 0.2, 0, 0);
        weapons[4] = new Weapon("zongshi", 565, 0, 0, 0.1, 0, 0, 0);
        weapons[5] = new Weapon("humo", 608, 0.2, 0.662, 0, 0, 0, 0);
        weapons[6] = new Weapon("tiankong", 674, 0, 0, 0.08, 0, 0.15, 0);
        weapons[7] = new Weapon("guanhong", 608, 0, 0, 0, 0.496 + 0.2 + 0.2, 0, 0);
        weapons[8] = new Weapon("hepu", 674, 0, 0, 0.221, 7 * 0.032, 0.12, 0);
        weapons[9] = new Weapon("baiying", 401, 0, 0, 0.221, 0, 0.48, 0);

        //5件圣遗物
//        SYW flower = new SYW();
//        SYW feather = new SYW();
//        SYW clock = new SYW();
//        SYW cup = new SYW();
//        SYW hat = new SYW();
        //圣遗物定义函数,此处为了减少计算量,规定使用生命表,主词条仅头和杯不定主词条
        //另外这个程序用于计算同等歪度属性下的伤害高地之比,所以有效副词条(生命,攻击,暴击)的强度和条数相同,只是种类不同
        //精通由于配队,以及触发的不确定性,只做大致估计,不精确计算

        //关于圣遗物副词条,为了简化运算,每个圣遗物选择一个词条满成长,并且选择一个词条无成长,选择范围从
        //生命值,生命值%,攻击力,攻击力%,暴击率,暴击伤害,元素精通 中选择

        //设置主词条
        int[] ctType = new int[12];
        for (int i = 0; i < 12; i++) {
            ctType[i] = 0;
        }
        ctType[0] = 1;
        ctType[1] = 4;
//        flower.hp += 4780;
//        clock.hpP += 0.466;
//        feather.atk += 311;
//        hat.setZCT(ctType[0]);
//        cup.setZCT(ctType[1]);


//        int[] fctRand = new int[10];
        Random r = new Random();
        //产生随机数,保证所有武器用同一套副词条
//        for (int i = 0; i < 10; i++) {
//            fctRand[i] = r.nextInt(7);
//        }

        int max = 0;
        int z = (int) Math.pow(7, 10) * 3;
        max = r.nextInt(z);
        int[] randNum = new int[100];
        for (int i = 0; i < 100; i++){
            randNum[i] = r.nextInt(z);
        }
        //a为武器种类
        for (int a = 0; a < 10; a++) {
//        int a = 5;
            //设置副词条
            //count作为圣遗物词条种类
            //max记录最高伤害量的圣遗物编号
            //z是一共有多少种圣遗物
            //maxDmg记录最大伤害量
            //jj是头的类型
            int jj = 0;
            int syw1 = 0;
            //System.out.println(z);
            double maxDmg = 0;
            SYW all;
            int[] pow7 = new int[12];
            for (int i = 0; i < 11; i++) {
                pow7[i] = (int) Math.pow(7, i);
//                System.out.println(pow7[i]);
            }
            //这个if下面用于遍历最极限伤害情况
            if (bianli) {
                max = 0;
                for (int count = 0; count < z / 4; count++) {
                    for (int j = 0; j < 4; j++) {
                        ctType[0] = j;
                        ctType[1] = (count) % 3 + 2;
                        ctType[2] = (count / 3) % 7;
                        ctType[3] = (count / 3 % (pow7[2])) / 7;
                        ctType[4] = (count / 3 % (pow7[3])) / pow7[2];
                        ctType[5] = (count / 3 % (pow7[4])) / pow7[3];
                        ctType[6] = (count / 3 % (pow7[5])) / pow7[4];
                        ctType[7] = (count / 3 % (pow7[6])) / pow7[5];
                        ctType[8] = (count / 3 % (pow7[7])) / pow7[6];
                        ctType[9] = (count / 3 % (pow7[8])) / pow7[7];
                        ctType[10] = (count / 3 % (pow7[9])) / pow7[8];
                        ctType[11] = (count / 3 % (pow7[10])) / pow7[9];
                        //初始化all
                        SYW sywDefault = new SYW();
                        sywDefault.hp += 4780;
                        sywDefault.hpP += 0.466;
                        sywDefault.atk += 311;
                        all = sywDefault;
                        //设置主词条
                        all.setZCT(ctType[0]);
                        all.setZCT(ctType[1]);
                        //设置副词条
                        for (int i = 2; i < 12; i++) {
                            all.setFCT(ctType[i], (i % 2) * 3 + 1);
                        }
                        double dmgNow;
                        //计算伤害量
                        dmgNow = dmgCulculate(a, hpBase, atkBase, criDmgBase, fireBase, criRateBase, weapons, all, false);
                        if (maxDmg < dmgNow && ctType[0] != ctType[2] && ctType[0] != ctType[3] && ctType[2] != ctType[3] &&
                                ctType[4] != ctType[5] &&
                                ctType[6] != ctType[7] &&
                                ctType[8] != ctType[9] &&
                                ctType[10] != ctType[11]) {
                            max = count;
                            maxDmg = dmgNow;
                            jj = j;
                            //System.out.println("updated" + Double.toString(maxDmg));
//                            for(int i = 2; i < 12; i++) {
//                                System.out.print(Integer.toString(ctType[i]) + " ");
//
//                            }System.out.println(" ");

                        }

                    }
//                    if (count % 10000000 == 0) {
//                        System.out.println(count);
//                    }
                }
            }

            //这个if下面用于观察圣遗物比较歪的情况下各个武器的表现
            if (pingjun) {
                if(a == 8 || a == 3) {
                    jj = 0;
                } else {
                    jj = 1;
                }
                ctType[1] = 4;
                double tempDMG = 0;
                for (int i = 0; i<100;i++){
                    tempDMG += culDmg(hpBase, atkBase, criDmgBase, fireBase, criRateBase, weapons, ctType, a, jj, randNum[i], pow7, false);
                }
                double arvDmg = tempDMG / 100;
                System.out.printf("%7.2f", arvDmg);
                System.out.println('\t' + weapons[a].name);
            }

            //计算伤害量,并打印
            //culDmg(hpBase, atkBase, criDmgBase, fireBase, criRateBase, weapons, ctType, a, jj, max, pow7, true);
            //打印词条
            //printAns(ctType);
        }

    }

    public static double culDmg(double hpBase, double atkBase, double criDmgBase, double fireBase, double criRateBase,
                                Weapon[] weapons, int[] ctType, int a, int jj, int max, int[] pow7, boolean ifPrint) {
        SYW all;
        //max = 568432159;
        ctType[0] = jj;
        ctType[1] = max % 3 + 2;
        ctType[2] = (max / 3) % 7;
        ctType[3] = (max / 3 % (pow7[2])) / 7;
        ctType[4] = (max / 3 % (pow7[3])) / pow7[2];
        ctType[5] = (max / 3 % (pow7[4])) / pow7[3];
        ctType[6] = (max / 3 % (pow7[5])) / pow7[4];
        ctType[7] = (max / 3 % (pow7[6])) / pow7[5];
        ctType[8] = (max / 3 % (pow7[7])) / pow7[6];
        ctType[9] = (max / 3 % (pow7[8])) / pow7[7];
        ctType[10] = (max / 3 % (pow7[9])) / pow7[8];
        ctType[11] = (max / 3 % (pow7[10])) / pow7[9];
        //初始化
        SYW sywDefault = new SYW();
        sywDefault.hp += 4780;
        sywDefault.hpP += 0.466;
        sywDefault.atk += 311;
        all = sywDefault;
        //设置主词条
        all.setZCT(ctType[0]);
        all.setZCT(ctType[1]);
        //设置副词条
        for (int i = 2; i < 12; i++) {
            all.setFCT(ctType[i], (i % 2) * 3 + 1);
        }
        double dmgNow;
        //计算伤害量
        dmgNow = dmgCulculate(a, hpBase, atkBase, criDmgBase, fireBase, criRateBase, weapons, all, ifPrint);
        return dmgNow;
    }

    public static void printAns(int[] ctType) {
        switch (ctType[0]) {
            case 0 -> System.out.print("暴伤 " + '\t');
            case 1 -> System.out.print("爆率 " + '\t');
            case 2 -> System.out.print("攻击%" + '\t');
            case 3 -> System.out.print("生命%" + '\t');
        }
        switch (ctType[1]) {
            case 2 -> System.out.print("攻击%" + '\t');
            case 3 -> System.out.print("生命%" + '\t');
            case 4 -> System.out.print("火伤%" + '\t');
        }
        System.out.println("攻击 " + '\t' + "生命 " + '\t' + "生命%" + '\t');
        for (int i = 1; i < 6; i++) {
            switch (ctType[i * 2 + 1]) {
                case 0 -> System.out.print("暴伤 " + '\t');
                case 1 -> System.out.print("爆率 " + '\t');
                case 2 -> System.out.print("攻击%" + '\t');
                case 3 -> System.out.print("生命%" + '\t');
                case 4 -> System.out.print("生命 " + '\t');
                case 5 -> System.out.print("攻击 " + '\t');
                case 6 -> System.out.print("精通 " + '\t');
            }
        }
        System.out.println("");
        for (int i = 1; i < 6; i++) {
            switch (ctType[i * 2]) {
                case 0 -> System.out.print("暴伤 " + '\t');
                case 1 -> System.out.print("爆率 " + '\t');
                case 2 -> System.out.print("攻击%" + '\t');
                case 3 -> System.out.print("生命%" + '\t');
                case 4 -> System.out.print("生命 " + '\t');
                case 5 -> System.out.print("攻击 " + '\t');
                case 6 -> System.out.print("精通 " + '\t');
            }

        }
        System.out.println("\n=======================================");
    }
    //伤害计算
    public static double dmgCulculate(int a, double hpBase, double atkBase, double criDmgBase,
                                      double fireBase, double criRB, Weapon[] weapons, SYW all, boolean ifPrint) {
        //这个伤害计算只做同练度的横向比较,故不计算技能倍率,怪物抗性等数值
        double dmg, hp, atk, criticalRate, criticalDmg, master, dmgAddition;
        hp = hpBase * (weapons[a].hpWeapon + all.hpP) + all.hp;
        atk = weapons[a].atkBaseWeapon + atkBase + hp * 0.06;               //e技能增加攻击力和基础攻击力
        if(atk > (atkBase + weapons[a].atkBaseWeapon) * 5){
            atk = (atkBase + weapons[a].atkBaseWeapon) * 5;
//            System.out.printf("%4.2f", hp);
//            System.out.print('\t');
//            System.out.printf("%4.2f", atk);
//            System.out.println("溢出");
        }                                                                   //防止400%溢出
        atk += all.atk;                                                     //圣遗物固定攻击力
        atk += (weapons[a].atkBaseWeapon + atkBase) * (weapons[a].atkAddWeapon + all.atkP);             //武器和圣遗物百分比攻击力
        if (a == 5) atk += hp * 0.018;                                      //护摩的额外攻击力
        criticalRate = weapons[a].criProbabilityWeapon + all.criP + criRB;  //总暴击率
        criticalDmg = weapons[a].criDmgWeapon + all.criD + criDmgBase;      //总暴击伤害
        master = weapons[a].masterWeapon + all.master;      //元素精通值
        double masterDmg = 0.004527 * master / 2.4;         //这里只是近似值,没有找到很确切的公式
        dmgAddition = weapons[a].dmgAddWeapon + all.fire + fireBase;        //总伤害加成
        //伤害计算公式
        dmg = atk * ((criticalRate * criticalDmg) + (1 - criticalRate)) * dmgAddition * (1 + masterDmg * 0.4);
        //打印结果
        if (ifPrint) {
            System.out.printf("%7.2f", hp);
            System.out.print('\t');
            System.out.printf("%7.2f", atk);
            System.out.print('\t');
            System.out.printf("%7.2f", criticalRate);
            System.out.print('\t');
            System.out.printf("%7.2f", criticalDmg);
            System.out.print('\t');
            System.out.printf("%7.2f", dmgAddition);
            System.out.print('\t');
            System.out.printf("%7.2f", masterDmg);
            System.out.print('\t');
            System.out.printf("%7.2f", dmg);
            System.out.print('\t');
            System.out.print(weapons[a].name);
            System.out.print('\n');
        }
        return dmg;
    }


}

class Weapon {
    //各种加成,基础攻击力,百分百生命,爆伤,爆率,百分比攻击,百分比增伤,精通
    public double atkBaseWeapon, hpWeapon, criDmgWeapon, criProbabilityWeapon, atkAddWeapon,
            dmgAddWeapon, masterWeapon;
    public String name;

    //按顺序写,有的写数字,没有的写0
    Weapon(String _name, double atk, double hp, double criD, double criP,
           double atkA, double dmgA, double master) {
        name = _name;
        atkBaseWeapon = atk;
        hpWeapon = 1 + hp;
        criDmgWeapon = 1.5 + criD;
        criProbabilityWeapon = criP;
        atkAddWeapon = 1 + atkA;
        dmgAddWeapon = 1 + dmgA;
        masterWeapon = master;
    }

}

//圣遗物类包含7种属性
class SYW {
    public double hp;
    public double hpP;
    public double atk;
    public double atkP;
    public double criD;
    public double criP;
    public double master;
    public double fire;

    //圣遗物属性,生命,生命%,攻击,攻击%,爆伤,爆率,火伤,精通,除此之外不计算其他内容
    public SYW(double hp, double hpP, double atk, double atkP, double criD, double criP, double master, double fire) {
        this.hp = hp;
        this.hpP = hpP;
        this.atk = atk;
        this.atkP = atkP;
        this.criD = criD;
        this.criP = criP;
        this.master = master;
        this.fire = fire;
    }
    //空构造函数
    SYW() {
        hp = 0;
        hpP = 0;
        atk = 0;
        atkP = 0;
        criD = 0;
        criP = 0;
        master = 0;
        fire = 0;
    }
    //根据参数给圣遗物添加等级不同的副词条
    public void setFCT(int type, int level) {
        switch (type) {
            case 0 -> criD += level * 0.07;
            case 1 -> criP += level * 0.035;
            case 2 -> atkP += level * 0.053;
            case 3 -> hpP += level * 0.053;
            case 4 -> hp += level * 269;
            case 5 -> atk += level * 18;
            case 6 -> master += level * 21;
        }
    }
    //根据参数给圣遗物添加属性
    public void setZCT(int type) {
        switch (type) {
            case 0 -> criD += 0.622;
            case 1 -> criP += 0.311;
            case 2 -> atkP += 0.466;
            case 3 -> hpP += 0.466;
            case 4 -> fire += 0.466;
        }
    }
    //两个圣遗物属性叠加
    public SYW sum(SYW syw) {
        double _atk = atk + syw.atk;
        double _hp = hp + syw.hp;
        double _atkP = atkP + syw.atkP;
        double _hpP = hpP + syw.hpP;
        double _criD = criD + syw.criD;
        double _criP = criP + syw.criP;
        double _master = master + syw.master;
        double _fire = fire + syw.fire;
        return new SYW(_hp, _hpP, _atk, _atkP, _criD, _criP, _master, _fire);
    }
}

就一个文件,有点乱

  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值