装备最高10,不同等级的失败有等级不变和等级掉落的概率
<value1 : 升级成功
<value2:升级失败,等级不变
>=value2: 升级失败,等级掉落
import java.util.Scanner;
public class Intensify {
static int level;
public static void main(String[] args){
int value1;
double value2;
System.out.print("请输入当前装备等级:");
Scanner sc = new Scanner(System.in);
level= sc.nextInt();
for(int i=1;;i++){
float n=(float)(Math.random()*100);
if(level==10){
System.out.println("已强化到最高级");
return;
}
switch (level){
case 4: value1=70;value2=100;
check(value1,value2,n,i);
break;
case 5: value1=50;value2=100-50*0.05;
check(value1,value2,n,i);
break;
case 6: value1=35;value2=100-65*0.1;
check(value1,value2,n,i);
break;
case 7: value1=25;value2=100-75*0.2;
check(value1,value2,n,i);
break;
case 8: value1=10;value2=100-90*0.3;
check(value1,value2,n,i);
break;
case 9: value1=5;value2=100-95*0.5;
check(value1,value2,n,i);
break;
}
}
}
public static void check(int value1,double value2,float n,int i){
System.out.println(n);//概率可注释
if(n<value1){
level++;
System.out.println("强化成功!你装备当前的等级为:"+level);
System.out.println("已强化"+i+"次");
}else if(n>=value2){
level--;
System.out.println("强化失败!你装备当前的等级为:"+level);
System.out.println("已强化"+i+"次");
}else {
System.out.println("强化失败!你装备当前的等级为:"+level);
System.out.println("已强化"+i+"次");
}
}
}