spec counter: add spec threshold notifications

This allows configuring spec thresholds which a notification will be sent for
when reached. Additionally it colors the infobox text red or green based on if
the threshold has been reached.

Co-authored-by: Dylan <dylanhe@gmail.com>
Co-authored-by: jgozon <47003557+jgozon@users.noreply.github.com>
This commit is contained in:
Adam
2021-01-08 14:24:37 -05:00
committed by Adam
parent cb22bdd026
commit 4a214f9807
5 changed files with 208 additions and 8 deletions

View File

@@ -42,6 +42,7 @@ import net.runelite.api.VarPlayer;
import net.runelite.api.events.HitsplatApplied;
import net.runelite.api.events.InteractingChanged;
import net.runelite.api.events.VarbitChanged;
import net.runelite.client.Notifier;
import net.runelite.client.game.ItemManager;
import net.runelite.client.ui.overlay.infobox.InfoBoxManager;
import net.runelite.client.ws.PartyService;
@@ -76,6 +77,14 @@ public class SpecialCounterPluginTest
@Bind
private ItemManager itemManager;
@Mock
@Bind
private Notifier notifier;
@Mock
@Bind
private SpecialCounterConfig specialCounterConfig;
@Inject
private SpecialCounterPlugin specialCounterPlugin;
@@ -227,4 +236,62 @@ public class SpecialCounterPluginTest
verify(infoBoxManager).removeInfoBox(any(SpecialCounter.class));
}
}
@Test
public void testNotification()
{
// Create an enemy
NPC target = mock(NPC.class);
// Create player
Player player = mock(Player.class);
when(client.getLocalPlayer()).thenReturn(player);
when(specialCounterConfig.bandosGodswordThreshold()).thenReturn(2);
when(specialCounterConfig.thresholdNotification()).thenReturn(true);
// Attack enemy
when(player.getInteracting()).thenReturn(target);
specialCounterPlugin.onInteractingChanged(new InteractingChanged(player, target));
// First special attack
when(client.getVar(VarPlayer.SPECIAL_ATTACK_PERCENT)).thenReturn(50);
specialCounterPlugin.onVarbitChanged(new VarbitChanged());
specialCounterPlugin.onHitsplatApplied(hitsplat(target, Hitsplat.HitsplatType.DAMAGE_ME));
// Second special attack
when(client.getVar(VarPlayer.SPECIAL_ATTACK_PERCENT)).thenReturn(0);
specialCounterPlugin.onVarbitChanged(new VarbitChanged());
specialCounterPlugin.onHitsplatApplied(hitsplat(target, Hitsplat.HitsplatType.DAMAGE_ME));
verify(notifier).notify("Bandos Godsword special attack threshold reached!");
}
@Test
public void testNotificationNotThreshold()
{
// Create an enemy
NPC target = mock(NPC.class);
// Create player
Player player = mock(Player.class);
when(client.getLocalPlayer()).thenReturn(player);
when(specialCounterConfig.bandosGodswordThreshold()).thenReturn(3);
lenient().when(specialCounterConfig.thresholdNotification()).thenReturn(true);
// Attack enemy
when(player.getInteracting()).thenReturn(target);
specialCounterPlugin.onInteractingChanged(new InteractingChanged(player, target));
// First special attack
when(client.getVar(VarPlayer.SPECIAL_ATTACK_PERCENT)).thenReturn(50);
specialCounterPlugin.onVarbitChanged(new VarbitChanged());
specialCounterPlugin.onHitsplatApplied(hitsplat(target, Hitsplat.HitsplatType.DAMAGE_ME));
// Second special attack
when(client.getVar(VarPlayer.SPECIAL_ATTACK_PERCENT)).thenReturn(0);
specialCounterPlugin.onVarbitChanged(new VarbitChanged());
specialCounterPlugin.onHitsplatApplied(hitsplat(target, Hitsplat.HitsplatType.DAMAGE_ME));
verify(notifier, never()).notify(any());
}
}