-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathReBorn.java
More file actions
97 lines (93 loc) · 3.96 KB
/
ReBorn.java
File metadata and controls
97 lines (93 loc) · 3.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
import java.util.ArrayList;
import java.util.Random;
public class ReBorn {
private HeroList heroList = new HeroList();
private MonsterList monsterList = new MonsterList();
private int index;
private ArrayList<Heros> realHero;
private static ArrayList<Monsters> realMonster;
private static Board board;
public ReBorn(ArrayList<Heros> realHero, ArrayList<Monsters> realMonster, int index, Board board){
this.realHero = realHero;
this.realMonster = realMonster;
this.index = index;
this.board = board;
if (realMonster.size() == 2){
rebornMonster();
}
if (realHero.size() == 2){
rebornHero();
}
}
public void rebornMonster(){
Random random = new Random();
int a = random.nextInt(monsterList.getMonsterList().size());
realMonster.add(index,monsterList.getMonsterList().get(a));
if(index == 0){
int hpo = random.nextInt(0,2);
if(!board.getStatus()[0][7].getCurrentInfo().contains("M") &&
!board.getStatus()[1][7].getCurrentInfo().contains("M")){
board.getStatus()[hpo][7].setCurrentInfo(" M1");
realMonster.get(index).setMonsterCol(hpo);
realMonster.get(index).setMonsterRow(7);
realMonster.get(index).setIndex(0);
}
} else if (index == 1) {
if (!board.getStatus()[3][7].getCurrentInfo().contains("M") &&
!board.getStatus()[4][7].getCurrentInfo().contains("M")){
int hpo = random.nextInt(3,5);
board.getStatus()[hpo][7].setCurrentInfo(" M2");
realMonster.get(index).setMonsterCol(hpo);
realMonster.get(index).setMonsterRow(7);
realMonster.get(index).setIndex(1);
}
}
else {
if (!board.getStatus()[6][7].getCurrentInfo().contains("M") &&
!board.getStatus()[7][7].getCurrentInfo().contains("M")){
int hpo = random.nextInt(6,8);
board.getStatus()[hpo][7].setCurrentInfo(" M3");
realMonster.get(index).setMonsterCol(hpo);
realMonster.get(index).setMonsterRow(7);
realMonster.get(index).setIndex(2);
}
}
}
public void rebornHero(){
Random random = new Random();
int a = random.nextInt(monsterList.getMonsterList().size());
realHero.add(index, heroList.getHeroList().get(a));
if(index == 0){
int hpo = random.nextInt(0,2);
if(!board.getStatus()[0][7].getCurrentInfo().contains("H") &&
!board.getStatus()[1][7].getCurrentInfo().contains("H")) {
board.getStatus()[hpo][7].setCurrentInfo("H1 ");
realHero.get(index).setHeroCol(hpo);
realHero.get(index).setHeroRow(0);
}
} else if (index == 1) {
if (!board.getStatus()[3][7].getCurrentInfo().contains("H") &&
!board.getStatus()[4][7].getCurrentInfo().contains("H")){
int hpo = random.nextInt(3,5);
board.getStatus()[hpo][7].setCurrentInfo("H2 ");
realHero.get(index).setHeroCol(hpo);
realHero.get(index).setHeroRow(0);
}
}
else {
if (!board.getStatus()[6][7].getCurrentInfo().contains("H") &&
!board.getStatus()[7][7].getCurrentInfo().contains("H")){
int hpo = random.nextInt(6,8);
board.getStatus()[hpo][7].setCurrentInfo("H3 ");
realHero.get(index).setHeroCol(hpo);
realHero.get(index).setHeroRow(0);
}
}
}
public ArrayList<Monsters> getRealMonster(){
return realMonster;
}
public ArrayList<Heros> getRealHero(){
return realHero;
}
}