模拟地下城与勇士(DNF)的装备强化过程
DNF装备强化在+1~+3 不会失败;
- +4~+7,失败后物品原有强化等级降低1级;
- +8~+10,失败后掉3级;
- 10上11或以上就爆了。
*要求输入装备的原始等级,输入1执行强化,根据原始等级以及强化的成功率,显示装备的强化结果
Math.random()
public class Text {
public static void main(String[] args) {
Scanner sc =new Scanner(System.in);
//输入等级
System.out.println("请输入您装备的等级:");
int grade = sc.nextInt();
//执行
System.out.println("输入1开始强化");
int a = sc.nextInt();
//概率
double p = Math.random();
switch(grade){
case 1 :
System.out.println("强化成功,当前装备等级:"+ "+1");
break;
case 2 :
System.out.println("强化成功,当前装备等级:"+ "+2");
break;
case 3 :
System.out.println("强化成功,当前装备等级:"+ "+3");
break;
case 4 :
if(p < 0.95){
System.out.println("强化成功,当前装备等级:"+ "+4");
}else {
grade = grade - 1;
System.out.println("强化失败,装备降低一级:"+ "当前等级为:" + grade );
}
break;
case 5 :
if(p < 0.9){
System.out.println("强化成功,当前装备等级:"+ "+5");
}else {
grade = grade - 1;
System.out.println("强化失败,装备降低一级:"+ "当前等级为:" + grade );
}
break;
case 6 :
if(p < 0.8){
System.out.println("强化成功,当前装备等级:"+ "+6");
}else {
grade = grade - 1;
System.out.println("强化失败,装备降低一级:"+ "当前等级为:" + grade );
}
break;
case 7 :
if(p < 0.75){
System.out.println("强化成功,当前装备等级:"+ "+7");
}else {
grade = grade - 1;
System.out.println("强化失败,装备降低一级:"+ "当前等级为:" + grade );
}
break;
case 8 :
if(p < 0.621){
System.out.println("强化成功,当前装备等级:"+ "+8");
}else {
grade = grade - 3;
System.out.println("强化失败,装备降低三级:"+ "当前等级为:" + grade );
}
break;
case 9 :
if(p < 0.537){
System.out.println("强化成功,当前装备等级:"+ "+9");
}else {
grade = grade - 3;
System.out.println("强化失败,装备降低三级:"+ "当前等级为:" + grade );
}
break;
case 10 :
if(p < 0.414){
System.out.println("强化成功,当前装备等级:"+ "+10");
}else {
grade = grade - 3;
System.out.println("强化失败,装备降低三级:"+ "当前等级为:" + grade);
}
break;
case 11 :
if(p < 0.339){
System.out.println("强化成功,当前装备等级:"+ "+11");
}else {
System.out.println("强化失败,您的装备以报废!");
}
break;
case 12 :
if(p < 0.28){
System.out.println("强化成功,当前装备等级:"+ "+12");
}else {
System.out.println("强化失败,您的装备以报废!");
}
break;
case 13 :
if(p < 0.207){
System.out.println("强化成功,当前装备等级:"+ "+13");
}else {
System.out.println("强化失败,您的装备以报废!");
}
break;
case 14 :
if(p < 0.173){
System.out.println("强化成功,当前装备等级:"+ "+14");
}else {
System.out.println("强化失败,您的装备以报废!");
}
break;
case 15 :
if(p < 0.136){
System.out.println("强化成功,当前装备等级:"+ "+15");
}else {
System.out.println("强化失败,您的装备以报废!");
}
break;
default:
System.out.println("请输入正确的等级!");
}
}
}