Skip to content

Commit 36a4387

Browse files
committed
more invasion logging for testing
1 parent c8500fa commit 36a4387

File tree

2 files changed

+29
-5
lines changed

2 files changed

+29
-5
lines changed

src/main/java/lol/hyper/customlauncher/invasiontracker/Invasion.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,14 @@ public class Invasion implements Comparable<Invasion> {
2727
public ZonedDateTime endTime;
2828
private int cogsDefeated;
2929
public final boolean megaInvasion;
30+
private final long cacheStartTime;
3031

3132
public Invasion(String district, String cogType, int cogsTotal, boolean megaInvasion) {
3233
this.cogType = cogType;
3334
this.district = district;
3435
this.cogsTotal = cogsTotal;
3536
this.megaInvasion = megaInvasion;
37+
this.cacheStartTime = System.nanoTime();
3638
}
3739

3840
/**
@@ -98,4 +100,8 @@ public boolean equals(Object o) {
98100

99101
return invasion.getDistrict().equals(this.getDistrict());
100102
}
103+
104+
public long getCacheStartTime() {
105+
return cacheStartTime;
106+
}
101107
}

src/main/java/lol/hyper/customlauncher/invasiontracker/InvasionTask.java

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ public void actionPerformed(ActionEvent e) {
6161
// if we do not have that invasion stored, create a new invasion object
6262
// and add it to the list
6363
if (!invasionTracker.invasions.containsKey(district)) {
64-
logger.info("New invasion: " + district);
6564
JSONObject temp = invasionsJSON.getJSONObject(key);
6665
String cogType = temp.getString("Type");
6766
int cogsDefeated = temp.getInt("CurrentProgress");
@@ -74,6 +73,15 @@ public void actionPerformed(ActionEvent e) {
7473
.atZone(ZoneId.systemDefault());
7574
invasionTracker.invasions.put(district, newInvasion);
7675
invasionTracker.showNotification(newInvasion, true);
76+
logger.info(
77+
"Tracking new invasion for "
78+
+ district
79+
+ ". Cogs: "
80+
+ cogsDefeated
81+
+ "/"
82+
+ cogsTotal
83+
+ ". ETA: "
84+
+ newInvasion.endTime);
7785
} else {
7886
if (!invasionTracker.invasions.containsKey(district)) {
7987
return; // JUST IN CASE
@@ -82,10 +90,18 @@ public void actionPerformed(ActionEvent e) {
8290
// we want to update the total cogs defeated and the end time
8391
Invasion tempInv = invasionTracker.invasions.get(district);
8492
JSONObject temp = invasionsJSON.getJSONObject(key);
85-
logger.info("Updating invasion: " + district);
8693
// ignore mega invasion cog count
8794
if (!temp.getBoolean("MegaInvasion")) {
8895
int cogsDefeated = temp.getInt("CurrentProgress");
96+
logger.info(
97+
"Updating invasion details for "
98+
+ district
99+
+ ". Cogs: "
100+
+ tempInv.getCogsDefeated()
101+
+ " -> "
102+
+ cogsDefeated
103+
+ ". ETA: "
104+
+ tempInv.endTime);
89105
tempInv.updateCogsDefeated(cogsDefeated);
90106
tempInv.endTime =
91107
Instant.parse(temp.getString("EstimatedCompletion"))
@@ -99,13 +115,15 @@ public void actionPerformed(ActionEvent e) {
99115
Iterator<Map.Entry<String, Invasion>> it = invasionTracker.invasions.entrySet().iterator();
100116
while (it.hasNext()) {
101117
Map.Entry<String, Invasion> pair = it.next();
102-
// this is the district
118+
String cogType = pair.getValue().getCogType();
119+
String district = pair.getKey();
103120
// <district>/<cog name>
104-
String key = pair.getKey() + "/" + pair.getValue().getCogType();
121+
String key = district + "/" + cogType;
105122
if (!invasionsJSON.has(key)) {
106123
invasionTracker.showNotification(pair.getValue(), false);
124+
String savedDuration = (System.nanoTime() - pair.getValue().getCacheStartTime())/ 1000000000 + " seconds.";
107125
it.remove();
108-
logger.info("Remove invasion: " + key);
126+
logger.info("Removing saved invasion for " + district + ". Tracked for " + savedDuration);
109127
}
110128
}
111129
invasionTracker.runs++;

0 commit comments

Comments
 (0)