dnf強化系統實測 java代碼

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * dnf強化系統實測
 */
public class Qianghua {
    public static void main(String[] args) throws IOException {
        //手動強化
        //manualQianghua();
        //自動強化
        autoQianghua(0,16);
    }

    public static void manualQianghua() throws IOException{
        BufferedReader in   =
                new   BufferedReader(new InputStreamReader(System.in));
        int current = 0;
        while (true){
            System.out.println("當前強化: +" + current + ",是否繼續強化?" );
            String str = in.readLine();
            if("q".equals(str)) break;
            current = qianghua(current);
        }
    }

    public static void autoQianghua(int current,int target){
        final int init = current;
        long sum = 0;
        long zengfubaohu = 0;
        while (true){
            System.out.println("當前強化: +" + current + ",是否繼續強化?" );
            current = qianghua(current);
            System.out.println("==================>");
            sum++;
            if(current == 0) zengfubaohu++;
            if(current == target) break;
        }
        System.out.println("初始強化等級:" + init);
        System.out.println("目標強化等級:" + target);
        System.out.println("強化次數:" + sum);
        System.out.println("強化保護劵次數:" + zengfubaohu);
    }

    public static int qianghua(int current){
        if (success(current)){
            int temp = current + 1;
            System.out.println("強化 +" + temp + "成功");
            return temp;
        }else{
            return current - wrong(current);
        }
    }

    public static int wrong(int current){
        System.out.println("強化失敗");
        if(current <= 3){
            return 0;
        }else if(current <= 7){
            return 1;
        }else if(current < 10){
            double d = Math.random();
            if(d < 0.5){
                //50%失敗不掉
                return 0;
            }else if(d < 0.8){
                //30%失敗掉1
                return 1;
            }else{
                //20%失敗掉2
                return 2;
            }
        }else {
            return current;
        }
    }

    public static boolean success(int current){
        double d = Math.random();
        if(current <= 3){
            return true;
        }else if(current <= 4){
            return d <= 0.95;
        }else if(current <= 5){
            return d <= 0.90;
        }else if(current <= 6){
            return d <= 0.80;
        }else if(current <= 7){
            return d <= 0.75;
        }else if(current <= 8){
            return d <= 0.621;
        }else if(current <= 9){
            return d <= 0.537;
        }else if(current <= 10){
            return d <= 0.414;
        }else if(current <= 11){
            return d <= 0.339;
        }else if(current <= 12){
            return d <= 0.28;
        }else if(current <= 13){
            return d <= 0.207;
        }else if(current <= 14){
            return d <= 0.173;
        }else if(current <= 15){
            return d <= 0.136;
        }else{
            return d <= 0.101;
        }
    }
}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章