File tree Expand file tree Collapse file tree 5 files changed +33
-5
lines changed
Expand file tree Collapse file tree 5 files changed +33
-5
lines changed Original file line number Diff line number Diff line change 44
55import java .util .Objects ;
66
7- public class Bullet {
7+ public class Bullet implements Comparable < Bullet > {
88 private final BulletData bulletData ;
99 private final int id ;
1010 private final Game game ;
@@ -83,4 +83,9 @@ public boolean equals(Object o) {
8383 public int hashCode () {
8484 return Objects .hash (id );
8585 }
86+
87+ @ Override
88+ public int compareTo (final Bullet other ) {
89+ return id - other .id ;
90+ }
8691}
Original file line number Diff line number Diff line change 66import java .util .Objects ;
77import java .util .stream .Collectors ;
88
9- public class Force {
9+ public class Force implements Comparable < Force > {
1010 private final Game game ;
1111
1212 private final int id ;
@@ -44,4 +44,9 @@ public boolean equals(Object o) {
4444 public int hashCode () {
4545 return Objects .hash (id );
4646 }
47+
48+ @ Override
49+ public int compareTo (final Force other ) {
50+ return id - other .id ;
51+ }
4752}
Original file line number Diff line number Diff line change 1010import static bwapi .UpgradeType .*;
1111import static bwapi .WeaponType .*;
1212
13- public class Player {
13+ public class Player implements Comparable < Player > {
1414 private final PlayerData playerData ;
1515 private final Game game ;
1616 private final int id ;
@@ -409,4 +409,9 @@ public boolean equals(Object o) {
409409 public int hashCode () {
410410 return Objects .hash (id );
411411 }
412+
413+ @ Override
414+ public int compareTo (final Player other ) {
415+ return id - other .id ;
416+ }
412417}
Original file line number Diff line number Diff line change 11package bwapi ;
22
3- class Point {
3+ class Point implements Comparable < Point > {
44 static final int TILE_WALK_FACTOR = 4 ; // 32 / 8
55
66 public final int x ;
@@ -79,4 +79,12 @@ public boolean isValid(final Game game) {
7979 public int hashCode () {
8080 return (x << 16 ) ^ y ;
8181 }
82+
83+ @ Override
84+ public int compareTo (Point o ) {
85+ if (scalar == o .scalar ) {
86+ return hashCode () - o .hashCode ();
87+ }
88+ return scalar - o .scalar ;
89+ }
8290}
Original file line number Diff line number Diff line change 44import bwapi .ClientData .RegionData ;
55import java .util .*;
66
7- public class Region {
7+ public class Region implements Comparable < Region > {
88 private final RegionData regionData ;
99 private final Game game ;
1010
@@ -133,4 +133,9 @@ public boolean equals(Object o) {
133133 public int hashCode () {
134134 return Objects .hash (id );
135135 }
136+
137+ @ Override
138+ public int compareTo (final Region other ) {
139+ return id - other .id ;
140+ }
136141}
You can’t perform that action at this time.
0 commit comments