- 提示1:
- DNF装备强化在+1~+3 不会失败;
- +4~+7,失败后物品原有强化等级降低1级;
- +8~+10,失败后掉3级;
- 10上11或以上就爆了。
提示2:
- DNF装备强化1~3级,成功率100%
- DNF装备强化3~4级,成功率95%
- DNF装备强化4~5级,成功率90%
- DNF装备强化5~6级,成功率80%
- DNF装备强化6~7级,成功率75%
- DNF装备强化7~8级,成功率62.1%
- DNF装备强化8~9级,成功率53.7%
- DNF装备强化9~10级,成功率41.4%
- DNF装备强化10~11级,成功率33.9%
- DNF装备强化11~12级,成功率28%
- DNF装备强化12~13级,成功率20.7%
- DNF装备强化13~14级,成功率17.3%
- DNF装备强化14~15级,成功率13.6%
- DNF装备强化15~16级,成功率10.1% ``
实现流程:
要求输入装备的原始等级,输入1执行强化,根据原始等级以及强化的成功率,显示装备的强化结果
package com.softeem.lesson06.oop.method;
public class DNF {
public void qianghua(int initLevel,int targetLevel) {
int count = 0;
do {
count++;
switch(initLevel) {
case 0:
case 1:
case 2:
//强化1-3级
initLevel = q1_3(initLevel);
break;
case 3:
case 4:
case 5:
case 6:
//强化4~7
initLevel = q4_7(initLevel);
break;
case 7:
case 8:
case 9:
//强化8~10
initLevel = q8_10(initLevel);
break;
default:
//强化10以上
initLevel = q10(initLevel);
break;
}
}while(initLevel < targetLevel && initLevel != -1);
System.out.println("强化结束,总强化次数:"+count);
}
/**
* 强化1-3级
* @param level
* @return
*/
public int q1_3(int level) {
level++;
System.out.println("强化成功,当前等级:"+level);
return level;
}
/**
* 随机浮点数表示成功率
* @return
*/
public double d() {
return Math.random();
}
/**
* 强化4-7级
* @param level
* @return
*/
public int q4_7(int level) {
int i = level;
switch(level) {
case 3:
i = d() < 0.95 ? level + 1 : level - 1;
break;
case 4:
i = d() < 0.9 ? level + 1 : level - 1;
break;
case 5:
i = d() < 0.8 ? level + 1 : level - 1;
break;
case 6:
i = d() < 0.75 ? level + 1 : level - 1;
break;
}
if(i > level) {
System.out.println("强化成功,当前等级:" + i);
}else {
System.out.println("强化失败,当前等级:" + i);
}
return i;
}
/**
* 强化8-10级
* @param level
* @return
*/
public int q8_10(int level) {
int i = level;
switch(level) {
case 7:
i = d() < 0.621 ? level + 1 : level - 3;
break;
case 8:
i = d() < 0.537 ? level + 1 : level - 3;
break;
case 9:
i = d() < 0.414 ? level + 1 : level - 3;
break;
}
if(i > level) {
System.out.println("强化成功,当前等级:" + i);
}else {
System.out.println("强化失败,当前等级:" + i);
}
return i;
}
/**
* 强化10级以上
* @param level
* @return
*/
public int q10(int level) {
int i = level;
switch(level) {
case 10:
i = d() < 0.339 ? level + 1 : -1;
break;
case 11:
i = d() < 0.28 ? level + 1 : -1;
break;
case 12:
i = d() < 0.207 ? level + 1 : -1;
break;
case 13:
i = d() < 0.173 ? level + 1 : -1;
break;
case 14:
i = d() < 0.136 ? level + 1 : -1;
break;
case 15:
i = d() < 0.101 ? level + 1 : -1;
break;
}
if(i > level) {
System.out.println("强化成功,当前等级:" + i);
}else {
System.out.println("强化失败,装备已损坏!");
}
return i;
}
public static void main(String[] args) {
DNF d = new DNF();
d.qianghua(0, 15);
}
}