Skip to content

Commit d76fef9

Browse files
committed
small cleanup
1 parent a07a56f commit d76fef9

File tree

6 files changed

+59
-122
lines changed

6 files changed

+59
-122
lines changed

src/main/java/bwapi/Game.java

Lines changed: 36 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,6 @@ public Position getScreenPosition() {
235235
return new Position(gameData.screenX(), gameData.screenY());
236236
}
237237

238-
//TODO
239238
public void setScreenPosition(final int x, final int y) {
240239
addCommand(SetScreenPosition.value, x, y);
241240
}
@@ -261,23 +260,31 @@ public void enableFlag(final Flag flag) {
261260
}
262261

263262
//TODO
264-
// public List<Unit> getUnitsOnTile(int tileX, int tileY);
265-
//
266-
// public List<Unit> getUnitsOnTile(TilePosition tile);
267-
//
263+
public Set<Unit> getUnitsOnTile(final int tileX, final int tileY) {
264+
return new HashSet<>();
265+
}
266+
267+
public Set<Unit> getUnitsOnTile(final TilePosition tile) {
268+
return getUnitsOnTile(tile.x, tile.y);
269+
}
270+
268271
//TODO
269-
public Set<Unit> getUnitsInRectangle(int left, int top, int right, int bottom, final UnitFilter filter) {
272+
public Set<Unit> getUnitsInRectangle(final int left, final int top, final int right, final int bottom, final UnitFilter filter) {
270273
return new HashSet<>();
271274
}
272275

273276
public Set<Unit> getUnitsInRectangle(final Position leftTop, final Position rightBottom, final UnitFilter filter) {
274277
return getUnitsInRectangle(leftTop.x, leftTop.y, rightBottom.x, rightBottom.y, filter);
275278
}
276-
//
277-
//
278-
// public List<Unit> getUnitsInRadius(int x, int y, int radius);
279-
//
280-
// public List<Unit> getUnitsInRadius(Position center, int radius);
279+
280+
//TODO
281+
public Set<Unit> getUnitsInRadius(final int x, final int y, final int radius) {
282+
return new HashSet<>();
283+
}
284+
285+
public Set<Unit> getUnitsInRadius(final Position center, final int radius) {
286+
return getUnitsInRadius(center.x, center.y, radius);
287+
}
281288

282289
public int mapWidth() {
283290
return gameData.mapWidth();
@@ -1057,7 +1064,7 @@ public boolean hasPath(final Position source, final Position destination) {
10571064
// public void setGUI(bool enabled);
10581065
// public int getLastEventTime();
10591066
// public boolean setMap(final String cstr_mapFileName);
1060-
// public boolean setRevealAll();return true;
1067+
// public boolean setRevealAll();
10611068
// public boolean setRevealAll(boolean reveal);
10621069

10631070
public void setTextSize() {
@@ -1093,25 +1100,24 @@ public Region getRegionAt(final Position position) {
10931100
return getRegionAt(position.x, position.y);
10941101
}
10951102

1096-
/*
1097-
public TilePosition getBuildLocation(UnitType type, TilePosition desiredPosition, int maxRange);
1098-
1099-
public TilePosition getBuildLocation(UnitType type, TilePosition desiredPosition);
1100-
1101-
public TilePosition getBuildLocation(UnitType type, TilePosition desiredPosition, int maxRange, boolean creep);
1102-
1103-
public int getDamageFrom(UnitType fromType, UnitType toType, Player fromPlayer);
1104-
1105-
public int getDamageFrom(UnitType fromType, UnitType toType);
1106-
1107-
public int getDamageFrom(UnitType fromType, UnitType toType, Player fromPlayer, Player toPlayer);
1108-
1109-
public int getDamageTo(UnitType toType, UnitType fromType, Player toPlayer);
1110-
1111-
public int getDamageTo(UnitType toType, UnitType fromType);
11121103

1113-
public int getDamageTo(UnitType toType, UnitType fromType, Player toPlayer, Player fromPlayer);
1114-
*/
1104+
// public TilePosition getBuildLocation(UnitType type, TilePosition desiredPosition, int maxRange);
1105+
//
1106+
// public TilePosition getBuildLocation(UnitType type, TilePosition desiredPosition)
1107+
//
1108+
// public TilePosition getBuildLocation(UnitType type, TilePosition desiredPosition, int maxRange, boolean creep);
1109+
//
1110+
// public int getDamageFrom(UnitType fromType, UnitType toType, Player fromPlayer);
1111+
//
1112+
// public int getDamageFrom(UnitType fromType, UnitType toType);
1113+
//
1114+
// public int getDamageFrom(UnitType fromType, UnitType toType, Player fromPlayer, Player toPlayer);
1115+
//
1116+
// public int getDamageTo(UnitType toType, UnitType fromType, Player toPlayer);
1117+
//
1118+
// public int getDamageTo(UnitType toType, UnitType fromType);
1119+
//
1120+
// public int getDamageTo(UnitType toType, UnitType fromType, Player toPlayer, Player fromPlayer);
11151121

11161122
//Since 4.2.0
11171123
public int getRandomSeed() {

src/main/java/bwapi/Player.java

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import bwapi.values.Color;
66

77
import JavaBWAPIBackend.Client.GameData.PlayerData;
8+
import bwapi.values.TextColor;
89

910
import java.util.Set;
1011
import java.util.stream.Collectors;
@@ -50,7 +51,7 @@ public Force getForce() {
5051
}
5152

5253
public boolean isAlly(final Player player) {
53-
return getForce() == player.getForce();
54+
return getForce().equals(player.getForce());
5455
}
5556

5657
public boolean isEnemy(final Player player) {
@@ -201,35 +202,34 @@ public Color getColor() {
201202
return new Color(playerData.color());
202203
}
203204

204-
//TODO
205-
public char getTextColor() {
205+
public TextColor getTextColor() {
206206
switch (playerData.color()) {
207207
case 111: // red
208-
return BrightRed.value;
208+
return BrightRed;
209209
case 165: // blue
210-
return Blue.value;
210+
return Blue;
211211
case 159: // teal
212-
return Teal.value;
212+
return Teal;
213213
case 164: // purp
214-
return Purple.value;
214+
return Purple;
215215
case 179: // oj
216-
return Orange.value;
216+
return Orange;
217217
case 19: // brown
218-
return Brown.value;
218+
return Brown;
219219
case 84: // white
220-
return PlayerWhite.value;
220+
return PlayerWhite;
221221
case 135: // yellow
222-
return PlayerYellow.value;
222+
return PlayerYellow;
223223
case 185: // green p9
224-
return DarkGreen.value;
224+
return DarkGreen;
225225
case 136: // p10
226-
return LightYellow.value;
226+
return LightYellow;
227227
case 134: // p11
228-
return Tan.value;
228+
return Tan;
229229
case 51: // p12
230-
return GreyBlue.value;
230+
return GreyBlue;
231231
default:
232-
return Default.value;
232+
return Default;
233233
}
234234
}
235235

src/main/java/bwapi/Unit.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2105,8 +2105,6 @@ else if ( isConstructing() || !isCompleted() || (getType().isBuilding() && !isId
21052105
return uType != Zerg_Larva && uType != Zerg_Egg && uType != Zerg_Cocoon;
21062106
}
21072107

2108-
//TODO
2109-
// https://github.com/bwapi/bwapi/blob/456ad612abc84da4103162ba0bf8ec4f053a4b1d/bwapi/Shared/Templates.h#L1033
21102108
public boolean canResearch() {
21112109
return canResearch(true);
21122110
}

src/main/java/bwapi/types/EventType.java

Lines changed: 0 additions & 37 deletions
This file was deleted.

src/main/java/bwapi/utils/TextUtils.java

Lines changed: 5 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,16 @@
11
package bwapi.utils;
22

3-
public class TextUtils {
4-
public static final byte Previous = 0x01;
5-
public static final byte Cyan = 0x02;
6-
public static final byte Yellow = 0x03;
7-
public static final byte White = 0x04;
8-
public static final byte Grey = 0x05;
9-
public static final byte Red = 0x06;
10-
public static final byte Green = 0x07;
11-
public static final byte Red_P1 = 0x08;
12-
public static final byte Tab = 0x09;
13-
public static final byte Newline = 0x0A;
14-
public static final byte Invisible_no_override = 0x0B;
15-
public static final byte Remove_beyond = 0x0C;
16-
public static final byte Clear_formatting = 0x0D;
17-
public static final byte Blue = 0x0E;
18-
public static final byte Teal = 0x0F;
19-
public static final byte Purple = 0x10;
20-
public static final byte Orange = 0x11;
21-
public static final byte Right_Align = 0x12;
22-
public static final byte Center_Align = 0x13;
23-
public static final byte Invisible = 0x14;
24-
public static final byte Brown = 0x15;
25-
public static final byte White_p7 = 0x16;
26-
public static final byte Yellow_p8 = 0x17;
27-
public static final byte Green_p9 = 0x18;
28-
public static final byte Brighter_Yellow = 0x19;
29-
public static final byte Cyan_default = 0x1A;
30-
public static final byte Pinkish = 0x1B;
31-
public static final byte Dark_Cyan = 0x1C;
32-
public static final byte Greygreen = 0x1D;
33-
public static final byte Bluegrey = 0x1E;
34-
public static final byte Turquoise = 0x1F;
3+
import bwapi.values.TextColor;
354

5+
public class TextUtils {
366
/**
37-
* Format text with a color to display on broodwar
7+
* Format text with a textcolor to display on broodwar
388
*/
39-
public static String formatText(final String text, final byte format){
9+
public static String formatText(final String text, final TextColor format){
4010
byte[] data = text.getBytes();
4111
int len = text.length();
4212
byte[] formatted = new byte[len + 1];
43-
formatted[0] = format;
13+
formatted[0] = format.value;
4414
System.arraycopy(data, 0, formatted, 1, len);
4515
return new String(formatted);
4616
}

src/main/java/bwapi/values/TextColor.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ public enum TextColor {
2929
GreyCyan(30),
3030
Turquoise(31);
3131

32-
public final char value;
32+
public final byte value;
3333

3434
TextColor(final int value){
35-
this.value = (char)value;
35+
this.value = (byte)value;
3636
}
3737

3838
//SINCE 4.2

0 commit comments

Comments
 (0)