This repository was archived by the owner on Mar 9, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathGame.java
More file actions
55 lines (44 loc) · 1.42 KB
/
Game.java
File metadata and controls
55 lines (44 loc) · 1.42 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
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
public class Game {
private final Map<Integer, Integer> _playerSetTargets;
private final Map<Integer, Position> _spawnPositions;
private final Set<Position> _alreadySpawnedPositions;
private final StringBuilder _logr;
public Game() {
_playerSetTargets = new HashMap<>();
_spawnPositions = new HashMap<>();
_alreadySpawnedPositions = new HashSet<>();
_logr = new StringBuilder();
}
public void spawnAttacker(int id, Position pos) {
_spawnPositions.put(id, pos);
_alreadySpawnedPositions.add(pos);
}
public Map<Integer, Position> getSpawnPositions() {
return _spawnPositions;
}
public Map<Integer, Integer> getPlayerSetTargets() {
return _playerSetTargets;
}
public boolean alreadySpawnedAtPosition(Position pos) {
return _alreadySpawnedPositions.contains(pos);
}
public void setTarget(int attacker_id, int defender_id) {
_playerSetTargets.put(attacker_id, defender_id);
}
public void setTarget(Attacker attacker, Defender defender) {
setTarget(attacker.get_id(), defender.get_id());
}
public void log(String s) {
_logr.append(s + "\n");
}
public String getLog() {
return _logr.toString();
}
public void clearLog() {
_logr.setLength(0);
}
}