Skip to content

Commit f4404ff

Browse files
committed
fill arrays with missing 0's
1 parent 60193aa commit f4404ff

File tree

2 files changed

+36
-4
lines changed

2 files changed

+36
-4
lines changed

src/main/java/bwapi/TechType.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,15 @@ public enum TechType {
5050

5151
/// IMPLEMENTATION
5252
private static final int[] defaultOreCost = // Same as default gas cost
53-
{100, 200, 200, 100, 0, 150, 0, 200, 100, 150, 100, 100, 0, 100, 0, 200, 100, 100, 0, 200, 150, 150, 150, 0, 100, 200, 0, 200, 0, 100, 100, 100, 200};
53+
{100, 200, 200, 100, 0, 150, 0, 200, 100, 150, 100, 100, 0, 100, 0, 200, 100, 100, 0, 200, 150, 150, 150, 0,
54+
100, 200, 0, 200, 0, 100, 100, 100, 200, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
5455
private static final int[] defaultTimeCost =
55-
{1200, 1500, 1800, 1200, 0, 1200, 0, 1200, 1800, 1500, 1200, 1200, 0, 1200, 0, 1500, 1500, 1200, 0, 1800, 1200, 1800, 1500, 0, 1200, 1200, 0, 1800, 0, 1800, 1800, 1500, 1800};
56+
{1200, 1500, 1800, 1200, 0, 1200, 0, 1200, 1800, 1500, 1200, 1200, 0, 1200, 0, 1500, 1500, 1200, 0, 1800,
57+
1200, 1800, 1500, 0, 1200, 1200, 0, 1800, 0, 1800, 1800, 1500, 1800, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
58+
0, 0, 0, 0};
5659
private static final int[] defaultEnergyCost =
57-
{0, 100, 100, 0, 50, 0, 100, 75, 150, 25, 25, 0, 0, 150, 100, 150, 0, 75, 75, 75, 100, 150, 100, 0, 50, 125, 0, 150, 0, 50, 75, 100, 0, 0, 1};
60+
{0, 100, 100, 0, 50, 0, 100, 75, 150, 25, 25, 0, 0, 150, 100, 150, 0, 75, 75, 75, 100, 150, 100, 0, 50, 125,
61+
0, 150, 0, 50, 75, 100, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
5862
private static final UnitType[] whatResearches = {
5963
UnitType.Terran_Academy, UnitType.Terran_Covert_Ops, UnitType.Terran_Science_Facility, UnitType.Terran_Machine_Shop,
6064
UnitType.None, UnitType.Terran_Machine_Shop, UnitType.None, UnitType.Terran_Science_Facility, UnitType.Terran_Physics_Lab,
@@ -87,7 +91,7 @@ public enum TechType {
8791
0, TARG_UNIT, TARG_BOTH, TARG_POS, TARG_BOTH, 0, TARG_UNIT, TARG_UNIT, TARG_UNIT, 0, 0, 0,
8892
TARG_UNIT, TARG_UNIT, TARG_BOTH, TARG_BOTH, TARG_UNIT, TARG_BOTH, TARG_UNIT, TARG_BOTH, TARG_UNIT,
8993
TARG_BOTH, TARG_BOTH, TARG_UNIT, TARG_UNIT, TARG_BOTH, 0, TARG_UNIT, TARG_UNIT, TARG_UNIT, TARG_UNIT,
90-
TARG_BOTH, 0, 0, TARG_BOTH, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, TARG_BOTH
94+
TARG_BOTH, 0, 0, TARG_BOTH, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, TARG_BOTH, 0
9195
};
9296
private static final Order[] techOrders = {
9397
Order.None, CastLockdown, CastEMPShockwave, PlaceMine, CastScannerSweep, Order.None, CastDefensiveMatrix,
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package bwapi;
2+
3+
import org.junit.Test;
4+
import java.lang.reflect.*;
5+
import java.util.*;
6+
7+
import static org.junit.Assert.assertEquals;
8+
9+
10+
/**
11+
* Reads all arrays
12+
*/
13+
public class TechTypeTest {
14+
15+
@Test
16+
public void testArraySizes() throws IllegalAccessException {
17+
18+
int expectedSize = 1 + Arrays.stream(TechType.values()).max(Comparator.comparingInt(a -> a.id)).get().id;
19+
20+
for (Field f : TechType.class.getDeclaredFields()) {
21+
if (f.getType().isArray() && !f.getName().startsWith("$") && !f.getName().startsWith("_")) {
22+
f.setAccessible(true);
23+
int size = Array.getLength(f.get(0));
24+
assertEquals(expectedSize, size);
25+
}
26+
}
27+
}
28+
}

0 commit comments

Comments
 (0)