spec counter: combine item variations into one weapon

This is to keep specs from multiple variants of a weapon within one counter, like when in a party with multiple players.
This commit is contained in:
Matt Dennis
2021-04-09 21:58:51 -04:00
committed by GitHub
parent a14e864e35
commit 2eb5a8ce32
3 changed files with 16 additions and 14 deletions

View File

@@ -26,6 +26,7 @@ package net.runelite.client.plugins.specialcounter;
import com.google.common.collect.ImmutableSet;
import com.google.inject.Provides;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
@@ -314,7 +315,7 @@ public class SpecialCounterPlugin extends Plugin
for (SpecialWeapon specialWeapon : SpecialWeapon.values())
{
if (specialWeapon.getItemID() == weapon.getId())
if (Arrays.stream(specialWeapon.getItemID()).anyMatch(id -> id == weapon.getId()))
{
return specialWeapon;
}
@@ -328,7 +329,7 @@ public class SpecialCounterPlugin extends Plugin
if (counter == null)
{
counter = new SpecialCounter(itemManager.getImage(specialWeapon.getItemID()), this, config,
counter = new SpecialCounter(itemManager.getImage(specialWeapon.getItemID()[0]), this, config,
hit, specialWeapon);
infoBoxManager.addInfoBox(counter);
specialCounter[specialWeapon.ordinal()] = counter;

View File

@@ -33,20 +33,16 @@ import net.runelite.api.ItemID;
@Getter
enum SpecialWeapon
{
DRAGON_WARHAMMER("Dragon Warhammer", ItemID.DRAGON_WARHAMMER, false, SpecialCounterConfig::dragonWarhammerThreshold),
ARCLIGHT("Arclight", ItemID.ARCLIGHT, false, SpecialCounterConfig::arclightThreshold),
DARKLIGHT("Darklight", ItemID.DARKLIGHT, false, SpecialCounterConfig::darklightThreshold),
BANDOS_GODSWORD("Bandos Godsword", ItemID.BANDOS_GODSWORD, true, SpecialCounterConfig::bandosGodswordThreshold),
BANDOS_GODSWORD_OR("Bandos Godsword", ItemID.BANDOS_GODSWORD_OR, true, SpecialCounterConfig::bandosGodswordThreshold),
BARRELCHEST_ANCHOR("Barrelchest Anchor", ItemID.BARRELCHEST_ANCHOR, true, (c) -> 0),
BONE_DAGGER("Bone Dagger", ItemID.BONE_DAGGER, true, (c) -> 0),
BONE_DAGGER_P("Bone Dagger (p)", ItemID.BONE_DAGGER_P, true, (c) -> 0),
BONE_DAGGER_P8876("Bone Dagger (p+)", ItemID.BONE_DAGGER_P_8876, true, (c) -> 0),
BONE_DAGGER_P8878("Bone Dagger (p++)", ItemID.BONE_DAGGER_P_8878, true, (c) -> 0),
DORGESHUUN_CROSSBOW("Dorgeshuun Crossbow", ItemID.DORGESHUUN_CROSSBOW, true, (c) -> 0);
DRAGON_WARHAMMER("Dragon Warhammer", new int[]{ItemID.DRAGON_WARHAMMER}, false, SpecialCounterConfig::dragonWarhammerThreshold),
ARCLIGHT("Arclight", new int[]{ItemID.ARCLIGHT}, false, SpecialCounterConfig::arclightThreshold),
DARKLIGHT("Darklight", new int[]{ItemID.DARKLIGHT}, false, SpecialCounterConfig::darklightThreshold),
BANDOS_GODSWORD("Bandos Godsword", new int[]{ItemID.BANDOS_GODSWORD, ItemID.BANDOS_GODSWORD_OR}, true, SpecialCounterConfig::bandosGodswordThreshold),
BARRELCHEST_ANCHOR("Barrelchest Anchor", new int[]{ItemID.BARRELCHEST_ANCHOR}, true, (c) -> 0),
BONE_DAGGER("Bone Dagger", new int[]{ItemID.BONE_DAGGER, ItemID.BONE_DAGGER_P, ItemID.BONE_DAGGER_P_8876, ItemID.BONE_DAGGER_P_8878}, true, (c) -> 0),
DORGESHUUN_CROSSBOW("Dorgeshuun Crossbow", new int[]{ItemID.DORGESHUUN_CROSSBOW}, true, (c) -> 0);
private final String name;
private final int itemID;
private final int[] itemID;
private final boolean damage;
private final Function<SpecialCounterConfig, Integer> threshold;
}

View File

@@ -258,6 +258,11 @@ public class SpecialCounterPluginTest
specialCounterPlugin.onVarbitChanged(new VarbitChanged());
specialCounterPlugin.onHitsplatApplied(hitsplat(target, Hitsplat.HitsplatType.DAMAGE_ME));
// Set up spec weapon as BGS(OR)
ItemContainer equipment = mock(ItemContainer.class);
when(equipment.getItem(EquipmentInventorySlot.WEAPON.getSlotIdx())).thenReturn(new Item(ItemID.BANDOS_GODSWORD_OR, 1));
when(client.getItemContainer(InventoryID.EQUIPMENT)).thenReturn(equipment);
// Second special attack
when(client.getVar(VarPlayer.SPECIAL_ATTACK_PERCENT)).thenReturn(0);
specialCounterPlugin.onVarbitChanged(new VarbitChanged());