-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLane.java
More file actions
68 lines (54 loc) · 1.73 KB
/
Lane.java
File metadata and controls
68 lines (54 loc) · 1.73 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
import java.util.ArrayList;
public class Lane {
private ArrayList<Heros> herosInLane = new ArrayList<>();
private ArrayList<Monsters> monstersInLane;
private int laneIndex;
private Map map;
private ArrayList<Heros> heroList;
public Lane(Map map, int laneIndex, ArrayList<Heros> heroList){
this.heroList = heroList;
this.map = map;
this.laneIndex = laneIndex;
update();
}
public void update(){
herosInLane = new ArrayList<>();
for (int col = 3 * laneIndex; col <= 3 * laneIndex + 1;col++){
for (int row = 0; row < 8; row++){
String cellInfo = map.getStatus()[col][row].getCurrentInfo();
if (cellInfo.contains("H")){
int heroIndex = cellInfo.charAt(1) - '0' - 1;
herosInLane.add(heroList.get(heroIndex));
}
}
}
}
public int getLaneIndex() {
return laneIndex;
}
public void setLaneIndex(int laneIndex) {
this.laneIndex = laneIndex;
}
public int getHighestHeroRow() {
if (herosInLane.isEmpty()) {
return -1;
}
int highestRow = -1;
for (Heros i : herosInLane) {
highestRow = Math.max(highestRow, i.getHeroRow());
}
return highestRow;
}
public ArrayList<Heros> getHerosInLane() {
return herosInLane;
}
public ArrayList<Monsters> getMonstersInLane() {
return monstersInLane;
}
public void setHerosInLane(ArrayList<Heros> herosInLane) {
this.herosInLane = herosInLane;
}
public void setMonstersInLane(ArrayList<Monsters> monstersInLane) {
this.monstersInLane = monstersInLane;
}
}