public int[] daguai(int arr[]) {
System.out.println("Do You Want To Play Now(1.yes-2.no)");
int a = new Scanner(System.in).nextInt();
int pblood = arr[0];
int pattack = arr[1];
int pdefase = arr[2];
int mblood = arr[3];
int mattack = arr[4];
int mdefase = arr[5];
if (a == 1) {
System.out.println("玩家的生命值" + pblood + "玩家的攻击力" + pattack
+ "玩家的防御力" + pdefase);
System.out.println("怪物的生命值" + mblood + "怪物的攻击力" + mattack
+ "怪物的防御力" + mdefase);
System.out.println("Monster Is Right|attacking nums?(times)");
while (mblood > 0 || pblood > 0) {
System.out.println("请输入攻击次数");
int b = new Scanner(System.in).nextInt();
int rand = new Random().nextInt();
for (int i = 0; i < 2 * b; i++) {
// 这是玩家打怪物
if (i % 2 != 1) {
// 随机出来玩家的伤害
System.out.println("*************");
try {
Thread.sleep(40);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
int randp = new Random().nextInt(2) + 5;
// System.out.println(randp+"随机数");
pblood = pblood - randp * (1 - pdefase / 100);
System.out.println("--玩家在流血" + pblood);
if (pblood < 0) {
System.out.println("--玩家死了" + pblood);
break;
}
} else if (i % 2 == 1) {// 这是玩家被怪物打
try {
Thread.sleep(40);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
int randm = new Random().nextInt(2) + 5;
mblood = mblood - randm * (1 - mdefase / 100);
// System.out.println(randm+"随机数");
System.out.println("怪物正在流血" + mblood);
if (mblood < 0) {
System.out.println("--怪物死了" + mblood);
break;
}
}
}
int resb[] = { pblood, pattack, pdefase, mblood, mattack,
mdefase };
for (int i = 0; i < resb.length; i++) {
System.out.print("%" + resb[i]);
}
// System.out.println("()"+pblood+"**"+pattack+"**"+pdefase);
// System.out.println(mblood+"**"+mattack+"**"+mdefase);
return resb;
}
}
return null;
}
java佩恩沃星球打怪掉血实现
最新推荐文章于 2021-12-16 22:41:55 发布