class wourd {
//创建敌人对象,之后都用初始化方法改变敌人属性
private foe foe = new foe();
private player player = new player();
private money money = new money();
private map map = new map();
private event event = new event();
private static stage[] playerW = new stage[4];
private static Scanner sc = new Scanner(System.in);
private static Random R = new Random();
private static boolean lightningRod = false;
class stage {
String[] namearr = {"♈龙鳞甲", "♐物理学圣剑", "♐搅屎棍", "♉通天镜", "♐格斗家的拳套",
"♈破旧的皮甲", "♎破皮鞋", "♎香港脚穿过的鞋子", "♉避雷针", "♈灼热斗篷", "♉逢考必过"};
int[] typearr = {0, 1, 1, 3, 1, 0, 2, 1, 3, 0, 3};
int type;
int ID;
String name;
String bewrite = "普通";
int virtueHP = 0;
int virtueattack = 0;
int virtuedefence = 0;
int gup = 0;
int bup = 0;
void the0() {
int p;
int b;
p = R.nextInt(9);
b = R.nextInt(3) * 10;
virtueHP = b + p;
b = R.nextInt(5);
virtuedefence = b + 3;
p = R.nextInt(21);
if (p < 5) {
gup = 1;
bewrite = "[稀有]";
} else if (p > 17) {
gup = 2;
bewrite = "[史诗]";
} else if (p == 20) {
gup = 3;
bewrite = "[传说]";
}
}
void the1() {
int p;
int b;
b = R.nextInt(5);
virtueattack = b + 3;
p = R.nextInt(21);
if (p < 5) {
bup = 1;
bewrite = "稀有";
} else if (p > 17) {
bup = 2;
bewrite = "史诗";
} else if (p == 20) {
bup = 3;
bewrite = "传说";
}
}
void the2() {
int p;
int b;
b = R.nextInt(3);
virtuedefence = b + 1;
p = R.nextInt(21);
if (p < 5) {
bup = 1;
bewrite = "[稀有]";
} else if (p > 17) {
bup = 2;
bewrite = "[史诗]";
} else if (p == 20) {
bup = 3;
bewrite = "[传说]";
}
}
void initial() {
int i = R.nextInt(11);
name = namearr[i];
type = typearr[i];
ID = i;
switch (type) {
case 0:
the0();
break;
case 1:
the1();
break;
case 2:
the2();
break;
case 3:
the3();
break;
default:
break;
}
if (ID == 7) {
type = 2;
}
}
//商店类
class money {
int money;
String stone[] = {"+5HP ", "+2攻击 ", "+1防御 ", "+10经验 ", "赌博 ", "道具 "};
int price[] = {10, 10, 10, 10, 20, 30};
int L = stone.length;
Random R = new Random();
int p[] = new int[3];
void initial() {
for (int i = 0; i < 3; i++) {
p[i] = R.nextInt(5);
}
}
void show() {
initial();
System.out.println("欢迎来到本小店,您需要买点什么?");
System.out.println("你的金币:" + money);
System.out.println("1:" + stone[p[0]] + "2:" + stone[p[1]] + "3:" + stone[p[2]]);
int c = event.keyinM() - 1;
int e = p[c];
switch (e) {
case 0:
if (money >= price[e]) {
money -= price[e];
player.hpChange(-5);
event.thedo(event.keyin());
} else {
System.out.println("你的钱不够滚吧");
event.thedo(event.keyin());
}
break;
case 1:
if (money >= price[e]) {
money -= price[e];
player.attack(2);
event.thedo(event.keyin());
} else {
System.out.println("你的钱不够滚吧");
event.thedo(event.keyin());
}
break;
case 2:
if (money >= price[e]) {
money -= price[e];
player.defence(1);
event.thedo(event.keyin());
} else {
System.out.println("你的钱不够滚吧");
event.thedo(event.keyin());
}
break;
case 3:
if (money >= price[e]) {
money -= price[e];
player.experience(10);
event.thedo(event.keyin());
} else {
System.out.println("你的钱不够滚吧");
event.thedo(event.keyin());
}
break;
case 4:
System.out.println("请输入你要赌多少钱,赌赢押金翻倍,赌输血本无归:");
if (sc.hasNextInt()) {
c = sc.nextInt();
} else {
sc.next();
System.out.println("白痴,你再乱输个试试?");
}
if (money >= c) {
money -= c;
int j = R.nextInt(10);
for (int i1 = 0; i1 < playerW.length; i1++) {
if (playerW[i1] != null) {
if (playerW[i1].ID == 3) {
j = 0;
}
}
}
if (j == 0) {
money += c * 2;
System.out.println("恭喜你赌赢了!");
} else {
System.out.println("啊,您赌输了,要再接再厉哦!");
}
event.thedo(event.keyin());
} else {
System.out.println("你的钱不够滚吧");
event.thedo(event.keyin());
}
break;
case 5:
break;
}
}
}
//玩家类
class player {
String name;
int attack;
int experience;
int defence;
int maxHP;
int HP;
int experienceUP = 2;
int rank;
void getstge() {
stage z = new stage();
z.initial();
boolean ok = true;
int B = 0;
for (int i1 = 0; i1 < playerW.length; i1++) {
stage s = playerW[i1];
if (s != null) {
if (z.type == s.type) {
ok = false;
B = i1;
break;
}
} else {
B = i1;
break;
}
}
if (ok) {
playerW[B] = z;
System.out.println("你获得了:");
z.show();
} else {
System.out.println("你已经有同类型的装备了:");
System.out.println("装备中:");
playerW[B].show();
System.out.println("***********************");
System.out.println("新获得:");
z.show();
System.out.println("是否更换装备?\n 1:是 2:否");
int c;
if (sc.hasNextInt()) {
c = sc.nextInt();
} else {
sc.next();
System.out.println("白痴,你再乱输个试试?");
c = 2;
}
if (c == 1) {
playerW[B] = z;
}
}
}
int stgeA() {
int i = 0;
for (int i1 = 0; i1 < playerW.length; i1++) {
stage s = playerW[i1];
if (s != null) {
i += playerW[i1].virtueattack;
}
}
return i;
}
int stgeD() {
int i = 0;
for (int i1 = 0; i1 < playerW.length; i1++) {
stage s = playerW[i1];
if (s != null) {
i += playerW[i1].virtuedefence;
}
}
return i;
}
int stgeH() {
int i = 0;
for (int i1 = 0; i1 < playerW.length; i1++) {
stage s = playerW[i1];
if (s != null) {
i += playerW[i1].virtueHP;
}
}
return i;
}
int stgeG() {
int i = 0;
for (int i1 = 0; i1 < playerW.length; i1++) {
stage s = playerW[i1];
if (s != null) {
i += playerW[i1].gup;
}
}
return i;
}
int stgeB() {
int i = 0;
for (int i1 = 0; i1 < playerW.length; i1++) {
stage s = playerW[i1];
if (s != null) {
i += playerW[i1].bup;
}
}
return i;
}
//玩家血量变动及死亡判定
boolean hpChange(int i) {
HP -= i;
if (i >= 0) {
if (HP <= 0) {
//事件实现
boolean mapeve(int i) {
int c;
//输出事件名称
System.out.println(map[i]);
//判断事件类型
switch (i) {
case 0:
//直接进入下次输入
event.thedo(event.keyin());
break;
case 1:
//返回真,创建敌人,进入战斗
return true;
case 2:
lightningRod = false;
for (int i1 = 0; i1 < playerW.length; i1++) {
if (playerW[i1] != null) {
if (playerW[i1].ID == 8) {
lightningRod = true;
}
}
}
if (lightningRod) {
System.out.println("避雷针生效了!");
player.hpChange(-1);
} else {
if (player.hpChange(3)) {
return false;
}
}
event.thedo(event.keyin());
break;
case 3:
System.out.println("蛋白质是牛肉的6倍");
player.hpChange(-2);
event.thedo(event.keyin());
break;
//失足少女
case 4:
System.out.println("对方想上你,是否从了对方ps:干了将-3HP+2攻击;\n0:否 | 1:是");
if (sc.hasNextInt()) {
c = sc.nextInt();
} else {
sc.next();
player.hpChange(2);
System.out.println("白痴,你再乱输个试试?");
event.thedo(event.keyin());
break;
}
if (c == 1) {
if (player.hpChange(2)) {
return false;
}
player.attack += 2;
event.thedo(event.keyin());
} else {
System.out.println("你居然放弃了啪啪啪的机会这是人干的事吗");
event.thedo(event.keyin());
break;
}
break;
case 5:
return true;
case 6:
money.show();
break;
default:
break;
}
return false;
}
}
//敌人类
class foe {
//敌人名称数组
String name[] = {"应杰", "柴匡", "野生的皮卡丘", "比利王", "贝爷", "五五开", "大贤者"};
//敌人攻击力
int attack;
//敌人防御力
int defence;
//敌人最大血量
int maxHP;
//玩家最大血量
int HP;
//敌人名称
String foeN;
int BOSSI = 0;
//敌人创建
/**
* @param i
*/
void initial(int i) {
//敌人随机属性值
int a = R.nextInt(5) - 2;
//初始化名字
foeN = "☠" + name[R.nextInt(7)];
attack = i * 2 + a;
defence = i + a;
maxHP = i * 10 + a;
HP = maxHP;
switch (BOSSI) {
case 5:
foeN = "♜BOOS1";
attack = player.attack;
defence = 2;
maxHP = 30;
HP = maxHP;
break;
case 10:
foeN = "♜BOOS2";
attack = player.attack;
defence = 10;
maxHP = 50;
HP = maxHP;
break;
case 15:
foeN = "♜BOOS3";
attack = player.defence + 8;
defence = player.attack;
maxHP = 60;
HP = maxHP;
break;
case 20:
foeN = "♜BOOS4";
attack = player.attack;
defence = player.defence;
maxHP = 60;
HP = maxHP;
break;
case 30:
foeN = "♛最终BOSS,暗黑" + player.name;
attack = player.attack + 10;
defence = player.defence + 10;
maxHP = 100;
HP = maxHP;
break;
default:
break;
}
}
//敌人攻击
boolean foeA() {
int A = attack - player.defence;
int o = R.nextInt(10 - player.stgeD());
if (o == 0) {
A = 0;
System.out.println(player.name + "格挡了" + foeN + "的攻击");
}
if (o == 1) {
A *= 2;
System.out.println(foeN + "打出了暴击");
}
if (A < 0) {
A = 0;
}
System.out.println(foeN + "攻击了" + player.name + "造成了" + A + "点伤害");
if (player.hpChange(A)) {
return true;
}
return false;
//玩家输入,随机事件
int keyin() {
System.out.println();
Scanner sc = new Scanner(System.in);
int i;
if (sc.hasNextInt()) {
i = sc.nextInt();
} else {
sc.next();
System.out.println("白痴,你再乱输个试试?");
i = 0;
}
return i;
}
int keyinM() {
int i;
String j;
j = sc.next();
i = j.codePointAt(0) - 48;
while (i != 1 && i != 2 && i != 3) {
System.out.println("请正确输入:");
j = sc.next();
i = j.codePointAt(0) - 48;
}
return i;
}
void thedo(int i) {
if (i == 5) {
show();
} else {
//随机情景
i = R.nextInt(7);
//敌人创建
if (map.mapeve(i)) {
foe.initial(player.rank);
System.out.println(foe.foeN + "跳出来了,进入战斗");
fight();
}
}
}
//玩家战斗行为判断
void fight() {
int a = event.doin();
switch (a) {
//战斗
case 0:
int o = R.nextInt(8);
int PINA = player.attack + player.stgeA() - foe.defence;
if (o == 0) {
PINA = 0;
System.out.println(foe.foeN + "格挡了你的攻击");
}
int c = R.nextInt(10 - player.stgeB());
if (c == 0) {
PINA *= 2;
System.out.println("你打出了暴击");
}
if (PINA <= 0) {
PINA = 0;
}
System.out.println(player.name + "攻击了" + foe.foeN + "造成了" + PINA + "点伤害");
if (foe.hpChange(PINA)) {
int E = (R.nextInt(player.rank) + 1) * 3;
money.money += 10 + E;
player.getstge();
player.experience(E);
if (foe.BOSSI == 30) {
System.out.println("恭喜你通关了");
return;
}
event.thedo(event.keyin());
} else {
if (foe.foeA()) {
return;
}
fight();
}
break;
//逃跑
case 1:
int B = R.nextInt(2);
for (int i1 = 0; i1 < playerW.length; i1++) {
if (playerW[i1] != null) {
if (playerW[i1].ID == 10) {
B = 1;
}
}
}
if (B == 1) {
System.out.println("你成功跑掉了");
event.thedo(event.keyin());
} else {
System.out.println("逃跑失败");
if (foe.foeA()) {
return;
}
fight();
}
break;
//求饶
case 2:
System.out.println(player.name + "向" + foe.foeN + "献上了一朵嫩菊,使其兽性大发,大干一场" + player.name + "乘机跑掉了");
event.thedo(event.keyin());
break;
}
}
int doin() {
System.out.println("1:战斗,2:逃跑,3:跪地求饶");
Scanner sc = new Scanner(System.in);
int i;
String j;
j = sc.next();
i = j.codePointAt(0) - 48;
while (i != 1 && i != 2 && i != 3) {
System.out.println("请正确输入:");
j = sc.next();
i = j.codePointAt(0) - 48;
}