-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWeapons.java
More file actions
68 lines (58 loc) · 1.74 KB
/
Copy pathWeapons.java
File metadata and controls
68 lines (58 loc) · 1.74 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.Iterator;
import java.util.ArrayList;
/**
* A weapons class which initializes all the possible types of weapons. It also allows for weapons to be iterable and searched
* through their names.
*
* @Team MAGA
* @Author Gajun Young - 16440714
* @Author Royal Thomas - 16326926
* @Author Richard Otroshchenko - 16353416
*/
public class Weapons implements Iterable<Weapon>, Iterator<Weapon>{
private final ArrayList<Weapon> weapons = new ArrayList<>();
private Iterator<Weapon> iterator;
private TileGrid grid = new TileGrid();
public Weapons() {
}
//Creates a bunch of weapons for the game
public void createWeapons() {
weapons.add(new Weapon("Candle Stick", grid.map[12][1]));
weapons.add(new Weapon("Dagger", grid.map[2][11]));
weapons.add(new Weapon("Lead Pipe", grid.map[2][1]));
weapons.add(new Weapon("Revolver", grid.map[23][1]));
weapons.add(new Weapon("Rope", grid.map[16][19]));
weapons.add(new Weapon("Spanner", grid.map[10][19]));
}
//Iterates to get a specific weapon
public Weapon get(String name) {
for (Weapon weapon : weapons) {
if (weapon.hasName(name)) {
return weapon;
}
}
return null;
}
//Iterates to check if two tokens are on the same tile
public boolean getSameTile(Tile tile) {
for(Weapon weapon: weapons) {
if(weapon.hasTile(tile)) {
return true;
}
}
return false;
}
@Override
public Iterator<Weapon> iterator() {
iterator = weapons.iterator();
return iterator;
}
@Override
public boolean hasNext() {
return iterator.hasNext();
}
@Override
public Weapon next() {
return iterator.next();
}
}