-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGame.java
73 lines (59 loc) · 2.05 KB
/
Game.java
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
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
public class Game {
private final Map<Integer, Integer> _playerSetTargets;
private final List<SpawnDetail> _spawnPositions;
private final Set<Position> _alreadySpawnedPositions;
private final StringBuilder _logr;
private final List<Integer> _ability_activations;
public static Set<Integer> already_activated_attacker_ids = new HashSet<>();
public Game() {
_playerSetTargets = new HashMap<>();
_spawnPositions = new ArrayList<>();
_alreadySpawnedPositions = new HashSet<>();
_logr = new StringBuilder();
_ability_activations = new ArrayList<>();
}
public void spawnAttacker(int id, Position pos) {
_spawnPositions.add(new SpawnDetail(id, pos));
_alreadySpawnedPositions.add(pos);
}
public void activateAbility(int attacker_id) {
already_activated_attacker_ids.add(attacker_id);
_ability_activations.add(attacker_id);
}
public List<SpawnDetail> getSpawnPositions() {
return _spawnPositions;
}
public Map<Integer, Integer> getPlayerSetTargets() {
return _playerSetTargets;
}
public List<Integer> getAbilityActivations() {
return _ability_activations;
}
public boolean alreadySpawnedAtPosition(Position pos) {
return _alreadySpawnedPositions.contains(pos);
}
public void setTarget(int attackerId, int defenderId) {
_playerSetTargets.put(attackerId, defenderId);
}
public void setTarget(Attacker attacker, Defender defender) {
setTarget(attacker.getId(), defender.getId());
}
public void setTarget(Attacker attacker, Attacker opponent_attacker) {
setTarget(attacker.getId(), opponent_attacker.getId());
}
public void log(String s) {
_logr.append(s + "\n");
}
public String getLog() {
return _logr.toString();
}
public void clearLog() {
_logr.setLength(0);
}
}