1111import bwapi .values .*;
1212
1313import java .util .*;
14+ import java .util .stream .Collectors ;
15+ import java .util .stream .IntStream ;
1416
1517public class Game {
1618 final GameData gameData ;
@@ -52,7 +54,12 @@ public Collection<Player> getPlayers() {
5254
5355
5456 public Collection <Unit > getAllUnits () {
55- return units .values ();
57+ Set <Unit > units = new HashSet <>();
58+ for (int id =0 ; id < gameData .getInitialUnitCount (); id ++) {
59+ units .add (new Unit (gameData .unit (id ), this ));
60+ }
61+ return units ;
62+ //return units.values();
5663 }
5764
5865 /*
@@ -78,9 +85,13 @@ public Collection<Bullet> getBullets() {
7885 return bullets ;
7986 }
8087
81- /*
82- public List<Position> getNukeDots();
83- */
88+
89+ public Set <Position > getNukeDots () {
90+ return IntStream .range (0 , gameData .nukeDotCount ())
91+ .mapToObj (id -> new Position (gameData .getNukeDotX (id ), gameData .getNukeDotY ((id ))))
92+ .collect (Collectors .toSet ());
93+ }
94+
8495
8596 public Force getForce (final int forceID ) {
8697 return forces .get (forceID );
@@ -93,22 +104,26 @@ public Player getPlayer(final int playerID) {
93104 public Unit getUnit (final int unitID ) {
94105 return units .get (unitID );
95106 }
96- /*
97107
98- public Unit indexToUnit(int unitIndex);
108+ //TODO
109+ //public Unit indexToUnit(int unitIndex);
99110
100- */
101111 public Region getRegion (final int regionID ) {
102112 return regions .get (regionID );
103113 }
104114
105- /*
106- public GameType getGameType() ;
107-
108- public int getLatency();
115+ public GameType getGameType () {
116+ return GameType .gameTypes .get (gameData .gameType ());
117+ }
109118
110- public int getFrameCount();
119+ public int getLatency () {
120+ return gameData .latency ();
121+ }
111122
123+ public int getFrameCount () {
124+ return gameData .frameCount ();
125+ }
126+ /*
112127 public int getReplayFrameCount();
113128
114129 public int getFPS();
@@ -141,7 +156,6 @@ public Region getRegion(final int regionID) {
141156
142157 public List<Unit> getUnitsInRectangle(int left, int top, int right, int bottom);
143158
144- public List<Unit> getUnitsInRectangle(Position topLeft, Position bottomRight);
145159
146160 public List<Unit> getUnitsInRadius(int x, int y, int radius);
147161
@@ -472,8 +486,12 @@ public Player neutral() {
472486
473487 public void setFrameSkip(int frameSkip);
474488
475- public boolean hasPath(Position source, Position destination);
476-
489+ */
490+ //TODO
491+ public boolean hasPath (Position source , Position destination ) {
492+ return false ;
493+ }
494+ /*
477495 public boolean setAlliance(Player player, boolean allied);
478496
479497 public boolean setAlliance(Player player);
@@ -495,11 +513,17 @@ public Collection<Region> getAllRegions() {
495513 return regions .values ();
496514 }
497515
498- /*
499- public Region getRegionAt(int x, int y);
516+ //TODO
517+ public Region getRegionAt (final int x , final int y ) {
518+ return null ;
519+ }
500520
501- public Region getRegionAt(Position position);
521+ //TODO
522+ public Region getRegionAt (final Position position ) {
523+ return null ;
524+ }
502525
526+ /*
503527 public int getLastEventTime();
504528
505529 public boolean setRevealAll();
0 commit comments