Skip to content

Commit 4217ebd

Browse files
authored
Merge pull request #49 from dgant/no-base-assert
Allow quieting assertions via BWTA interface
2 parents 3e6b7ed + 156869b commit 4217ebd

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

src/main/java/bwta/BWTA.java

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@
44
import bwapi.Player;
55
import bwapi.Position;
66
import bwapi.TilePosition;
7+
import bwem.Area;
78
import bwem.BWEM;
89
import bwem.Base;
910
import bwem.ChokePoint;
1011

11-
import bwem.Area;
12+
import java.io.OutputStream;
1213
import java.util.*;
1314
import java.util.stream.Collectors;
1415

@@ -21,6 +22,26 @@ public class BWTA {
2122
private static List<Chokepoint> chokepoints;
2223
private static List<BaseLocation> baseLocations;
2324

25+
/**
26+
* Extension to traditional BWTA interface for JBWAPI
27+
* Exposes BWEM's setFailOnError(boolean) method for aggressively asserting errors.
28+
*
29+
* @param value Whether BWEM should throw an exception on assertion failure.
30+
*/
31+
public static void setFailOnError(final boolean value) {
32+
bwem.setFailOnError(value);
33+
}
34+
35+
/**
36+
* Extension to traditional BWTA interface for JBWAPI
37+
* Exposes BWEM's setFailOnErrorStream(OutputStream) method for specifying error log destination.
38+
*
39+
* @param stream Where to log BWEM errors.
40+
*/
41+
public static void setFailOnErrorStream(OutputStream stream) {
42+
bwem.setFailOutputStream(stream);
43+
}
44+
2445
public static void readMap(final Game game) {
2546
System.err.println("WARNING: this BWTA is fake and only translates BWTA calls to their respective BWEM calls. Please use BWEM directly if possible.");
2647
bwem = new BWEM(game);

0 commit comments

Comments
 (0)