Skip to content

Commit

Permalink
Exposed more enumerated type IDs. Added JavaDoc for new training queu…
Browse files Browse the repository at this point in the history
…e accessors.
  • Loading branch information
dgant committed Apr 15, 2022
1 parent 04bef2c commit 226b179
Show file tree
Hide file tree
Showing 10 changed files with 16 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/main/java/bwapi/BulletType.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public enum BulletType {
Arrays.stream(BulletType.values()).forEach(v -> idToEnum[v.id] = v);
}

final int id;
public final int id;

BulletType(final int id) {
this.id = id;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/bwapi/CommandType.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public enum CommandType {
Arrays.stream(CommandType.values()).forEach(v -> idToEnum[v.id] = v);
}

final int id;
public final int id;

CommandType(final int id) {
this.id = id;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/bwapi/EventType.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public enum EventType {
Arrays.stream(EventType.values()).forEach(v -> idToEnum[v.id] = v);
}

final int id;
public final int id;

EventType(int id) {
this.id = id;
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/bwapi/GameType.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ public enum GameType {
Arrays.stream(GameType.values()).forEach(v -> idToEnum[v.id] = v);
}


final int id;
public final int id;

GameType(final int id) {
this.id = id;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/bwapi/Latency.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public enum Latency {
Arrays.stream(Latency.values()).forEach(v -> idToEnum[v.id] = v);
}

final int id;
public final int id;

Latency(final int id) {
this.id = id;
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/bwapi/Order.java
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,7 @@ public enum Order {
Arrays.stream(Order.values()).forEach(v -> idToEnum[v.id] = v);
}


final int id;
public final int id;

Order(final int id) {
this.id = id;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/bwapi/PlayerType.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public enum PlayerType {
Arrays.stream(PlayerType.values()).forEach(v -> idToEnum[v.id] = v);
}

final int id;
public final int id;

PlayerType(final int id) {
this.id = id;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/bwapi/Race.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public enum Race {
Arrays.stream(Race.values()).forEach(v -> idToEnum[v.id] = v);
}

final int id;
public final int id;

Race(final int id) {
this.id = id;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/bwapi/ShapeType.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ enum ShapeType {
Arrays.stream(ShapeType.values()).forEach(v -> idToEnum[v.id] = v);
}

final int id;
public final int id;

ShapeType(final int id) {
this.id = id;
Expand Down
8 changes: 7 additions & 1 deletion src/main/java/bwapi/Unit.java
Original file line number Diff line number Diff line change
Expand Up @@ -826,7 +826,7 @@ public UnitType getBuildType() {
}

/**
* Retrieves the list of units queued up to be trained.
* Retrieves the list of unit types queued up to be trained.
*
* @return a List<UnitType> containing all the types that are in this factory's training
* queue, from oldest to most recent.
Expand All @@ -838,13 +838,19 @@ public List<UnitType> getTrainingQueue() {
return IntStream.range(0, getTrainingQueueCount()).mapToObj(this::getTrainingQueueAt).collect(Collectors.toList());
}

/**
* Retrieves a unit type from a specific index in the queue of units this unit is training.
*/
public UnitType getTrainingQueueAt(int i) {
if (game.isLatComEnabled() && self().trainingQueue[i].valid(game.getFrameCount())) {
return self().trainingQueue[i].get();
}
return UnitType.idToEnum[unitData.getTrainingQueue(i)];
}

/**
* Retrieves the number of units in this unit's training queue.
*/
public int getTrainingQueueCount() {
int count = unitData.getTrainingQueueCount();
if (game.isLatComEnabled() && self().trainingQueueCount.valid(game.getFrameCount())) {
Expand Down

0 comments on commit 226b179

Please sign in to comment.