Skip to content

Commit

Permalink
Adds nextTier to CombatTaskNotifier
Browse files Browse the repository at this point in the history
Also updates changeLog, tests, and json-examples
  • Loading branch information
jdanthdavis committed Nov 9, 2024
1 parent a264b7f commit fb429d9
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 7 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
## Unreleased

- Minor: Remove boss image embed from kill count notifications with screenshots disabled. (#578)
- Dev: Add current tier and total possible points to combat task metadata. (#586)
- Dev: Add current tier, total possible points, and next tier to combat task metadata. (#586)

## 1.10.12

Expand Down
4 changes: 3 additions & 1 deletion docs/json-examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,8 @@ JSON for Combat Achievement Notifications:
"tierProgress": 517,
"tierTotalPoints": 645,
"totalPossiblePoints": 14814,
"currentTier": "MASTER"
"currentTier": "MASTER",
"nextTier": "GRANDMASTER"
},
"type": "COMBAT_ACHIEVEMENT"
}
Expand All @@ -370,6 +371,7 @@ JSON for Combat Achievement Tier Completion Notifications:
"tierProgress": 0,
"tierTotalPoints": 540,
"totalPossiblePoints": 14814,
"nextTier": "GRANDMASTER",
"justCompletedTier": "MASTER"
},
"type": "COMBAT_ACHIEVEMENT"
Expand Down
6 changes: 4 additions & 2 deletions src/main/java/dinkplugin/notifiers/CombatTaskNotifier.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ private void handle(CombatAchievementTier tier, String task) {
int totalPoints = client.getVarbitValue(TOTAL_POINTS_ID);
int totalPossiblePoints = client.getVarbitValue(GRANDMASTER_TOTAL_POINTS_ID);

Integer nextUnlockPointsThreshold = cumulativeUnlockPoints.ceilingKey(totalPoints + 1);
var nextThreshold = cumulativeUnlockPoints.ceilingEntry(totalPoints + 1);
Integer nextUnlockPointsThreshold = nextThreshold != null ? nextThreshold.getKey() : null;
Map.Entry<Integer, CombatAchievementTier> prev = cumulativeUnlockPoints.floorEntry(totalPoints);
int prevThreshold = prev != null ? prev.getKey() : 0;

Expand All @@ -102,6 +103,7 @@ private void handle(CombatAchievementTier tier, String task) {
CombatAchievementTier completedTier = crossedThreshold ? prev.getValue() : null;
String completedTierName = completedTier != null ? completedTier.getDisplayName() : "N/A";
CombatAchievementTier currentTier = crossedThreshold || prev == null ? null : prev.getValue();
CombatAchievementTier nextTier = nextThreshold != null ? nextThreshold.getValue() : null;

String player = Utils.getPlayerName(client);
Template message = Template.builder()
Expand All @@ -119,7 +121,7 @@ private void handle(CombatAchievementTier tier, String task) {
.type(NotificationType.COMBAT_ACHIEVEMENT)
.text(message)
.playerName(player)
.extra(new CombatAchievementData(tier, task, taskPoints, totalPoints, tierProgress, tierTotalPoints, totalPossiblePoints, currentTier, completedTier))
.extra(new CombatAchievementData(tier, task, taskPoints, totalPoints, tierProgress, tierTotalPoints, totalPossiblePoints, currentTier, nextTier, completedTier))
.build());
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,12 @@ public class CombatAchievementData extends NotificationData {
@Nullable
CombatAchievementTier currentTier;

/**
* The next tier to be unlocked
*/
@Nullable
CombatAchievementTier nextTier;

/**
* The tier whose rewards were just unlocked,
* <i>if</i> the player just completed the tier.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ void testNotify() {
.replacement("{{task}}", Replacements.ofWiki("Whack-a-Mole"))
.build()
)
.extra(new CombatAchievementData(CombatAchievementTier.HARD, "Whack-a-Mole", 3, 200, 85, 189, 2005, CombatAchievementTier.MEDIUM, null))
.extra(new CombatAchievementData(CombatAchievementTier.HARD, "Whack-a-Mole", 3, 200, 85, 189, 2005, CombatAchievementTier.MEDIUM, CombatAchievementTier.HARD, null))
.playerName(PLAYER_NAME)
.type(NotificationType.COMBAT_ACHIEVEMENT)
.build()
Expand All @@ -100,7 +100,7 @@ void testNotifyUnlock() {
false,
NotificationBody.builder()
.text(buildUnlockTemplate("Master", "No Pressure"))
.extra(new CombatAchievementData(CombatAchievementTier.GRANDMASTER, "No Pressure", 6, 1466, 1466 - 1465, 2005 - 1465, 2005, null, CombatAchievementTier.MASTER))
.extra(new CombatAchievementData(CombatAchievementTier.GRANDMASTER, "No Pressure", 6, 1466, 1466 - 1465, 2005 - 1465, 2005, null, CombatAchievementTier.GRANDMASTER, CombatAchievementTier.MASTER))
.playerName(PLAYER_NAME)
.type(NotificationType.COMBAT_ACHIEVEMENT)
.build()
Expand All @@ -127,7 +127,7 @@ void testNotifyUnlockGrand() {
false,
NotificationBody.builder()
.text(buildUnlockTemplate("Grandmaster", "No Pressure"))
.extra(new CombatAchievementData(CombatAchievementTier.GRANDMASTER, "No Pressure", 6, 2005, null, null, 2005, null, CombatAchievementTier.GRANDMASTER))
.extra(new CombatAchievementData(CombatAchievementTier.GRANDMASTER, "No Pressure", 6, 2005, null, null, 2005, null, null, CombatAchievementTier.GRANDMASTER))
.playerName(PLAYER_NAME)
.type(NotificationType.COMBAT_ACHIEVEMENT)
.build()
Expand Down

0 comments on commit fb429d9

Please sign in to comment.