java模拟魔兽世界武器掉落

public class moshowplus {
    public static void main(String[] args) {
        /*☆☆☆假设这个可怜的男爵的物品掉落率数组是这样的:
        【瑞文戴尔男爵的骷髅马(1%),瑞文戴尔家族徽记、男爵的佩刀、斯坦索姆的哀嚎、
        大墓地的意志四者必定掉落其中之一,堕落天灾军团的徽记85%,纳克萨玛斯的钥匙10%】,
        请每次运行程序的时候在控制台上将掉落信息打印出来。
        * */
        String[] horse = new String[]{"瑞文戴尔男爵的骷髅马",""};
        String[] quarter = new String[]{"瑞文戴尔家族徽记","男爵的佩刀","斯坦索姆的哀嚎","大墓地的意志"};
        String[] disaster = new String[]{"堕落天灾军团的徽记",""};
        String[] key = new String[]{"纳克萨玛斯的钥匙",""};
        Random random = new Random();
        int j = 50;
        while (j > 0){

            for (int i = 0;i < 4;i++){
                int which_drop = i;
                if (which_drop == 0){
                    int pro = random.nextInt(101);
                    if (pro == 1){
                        System.out.print(horse[0] + ",");
                    }
                }else if (which_drop == 1){
                    int pro = random.nextInt(101);
                    if (pro > 0 && pro <= 25){
                        System.out.print(quarter[0] + ",");
                    }else if (pro > 25 && pro <= 50){
                        System.out.print(quarter[1] + ",");
                    }else if (pro > 50 && pro <= 75){
                        System.out.print(quarter[2] + ",");
                    }else if (pro > 70 && pro <=100){
                        System.out.print(quarter[3] + ",");
                    }
                }else if (which_drop == 2){
                    int pro = random.nextInt(101);
                    if (pro > 0 && pro <= 85){
                        System.out.print(disaster[0] + ",");
                    }
                }else{
                    int pro = random.nextInt(101);
                    if (pro > 0 && pro <= 10){
                        System.out.println(key[0]);
                    }else {
                        System.out.println();
                    }
                }
            }
            j--;
        }

    }
}
经验分享 程序员 微信小程序 职场和发展