Refactor BA

This commit is contained in:
Scott Burns
2019-05-16 01:32:44 +02:00
parent ade46371fe
commit ce1a34c4da
7 changed files with 486 additions and 465 deletions

View File

@@ -38,85 +38,115 @@ public interface BarbarianAssaultConfig extends Config
description = "Show time to next call change",
position = 0
)
default boolean showTimer() { return true; }
default boolean showTimer()
{
return true;
}
@ConfigItem(
keyName = "waveTimes",
name = "Show wave and game duration",
description = "Displays wave and game duration",
position = 1
)
default boolean waveTimes() { return true; }
@ConfigItem(
keyName = "showEggCountMessage",
name = "Show count of eggs collected as collector.",
description = "Display egg count as collector after each wave",
position = 2
)
default boolean showEggCount() { return false; }
@ConfigItem(
keyName = "showEggCountOverlay",
name = "Overlay of eggs counted",
description = "Display current egg count as collector",
position = 3
)
default boolean showEggCountOverlay() { return false; }
@ConfigItem(
keyName = "showHpCountMessage",
name = "Show count of Hp healed as healer.",
description = "Display healed count as healer after each wave",
position = 4
)
default boolean showHpCount() { return false; }
@ConfigItem(
keyName = "showHpCountOverlay",
name = "Overlay of Hp counted",
description = "Display current healed count as healer",
position = 5
position = 1
)
default boolean showHpCountOverlay() { return false; }
default boolean waveTimes()
{
return true;
}
@ConfigItem(
keyName = "highlightCollectorEggs",
name = "Highlight collector eggs",
description = "Highlight called egg colors",
position = 6
keyName = "showEggCountMessage",
name = "Show count of eggs collected as collector.",
description = "Display egg count as collector after each wave",
position = 2
)
default boolean highlightCollectorEggs() { return false; }
default boolean showEggCount()
{
return false;
}
@ConfigItem(
keyName = "showTotalRewards",
name = "Summarize total reward points",
description = "Displays total eggs/healed hp and missed attacks/lost runners",
position = 7
keyName = "showEggCountOverlay",
name = "Overlay of eggs counted",
description = "Display current egg count as collector",
position = 3
)
default boolean showTotalRewards(){ return false; };
default boolean showEggCountOverlay()
{
return false;
}
@ConfigItem(
keyName = "showSummaryOfPoints",
name = "Display summary of advanced points",
description = "Gives summary of advanced points breakdown in chat log",
position = 8
)
default boolean showSummaryOfPoints() { return false; };
@ConfigItem(
keyName = "wrongPoisonFoodTextColor",
name = "Change healer wrong poison pack color",
description = "Change healer wrong poison pack color",
position = 9
keyName = "showHpCountMessage",
name = "Show count of Hp healed as healer.",
description = "Display healed count as healer after each wave",
position = 4
)
default Color wrongPoisonFoodTextColor() { return Color.BLACK;}
default boolean showHpCount()
{
return false;
}
@ConfigItem(
keyName = "highlightItems",
name = "Highlight called poison/bait",
description = "Highlights the poison or bait that was called by your teammate",
position = 10
@ConfigItem(
keyName = "showHpCountOverlay",
name = "Overlay of Hp counted",
description = "Display current healed count as healer",
position = 5
)
default boolean showHpCountOverlay()
{
return false;
}
@ConfigItem(
keyName = "highlightCollectorEggs",
name = "Highlight collector eggs",
description = "Highlight called egg colors",
position = 6
)
default boolean highlightCollectorEggs()
{
return false;
}
@ConfigItem(
keyName = "showTotalRewards",
name = "Summarize total reward points",
description = "Displays total eggs/healed hp and missed attacks/lost runners",
position = 7
)
default boolean showTotalRewards()
{
return false;
}
@ConfigItem(
keyName = "showSummaryOfPoints",
name = "Display summary of advanced points",
description = "Gives summary of advanced points breakdown in chat log",
position = 8
)
default boolean showSummaryOfPoints()
{
return false;
}
@ConfigItem(
keyName = "wrongPoisonFoodTextColor",
name = "Change healer wrong poison pack color",
description = "Change healer wrong poison pack color",
position = 9
)
default Color wrongPoisonFoodTextColor()
{
return Color.BLACK;
}
@ConfigItem(
keyName = "highlightItems",
name = "Highlight called poison/bait",
description = "Highlights the poison or bait that was called by your teammate",
position = 10
)
default boolean highlightItems()
{
@@ -124,10 +154,10 @@ public interface BarbarianAssaultConfig extends Config
}
@ConfigItem(
keyName = "highlightColor",
name = "Highlight color",
description = "Configures the color to highlight the called poison/bait",
position = 11
keyName = "highlightColor",
name = "Highlight color",
description = "Configures the color to highlight the called poison/bait",
position = 11
)
default Color highlightColor()
{

View File

@@ -31,8 +31,8 @@ import java.awt.Graphics2D;
import java.awt.Polygon;
import java.awt.Rectangle;
import java.awt.Stroke;
import java.util.Map;
import java.awt.image.BufferedImage;
import java.util.Map;
import javax.inject.Inject;
import lombok.Getter;
import lombok.Setter;
@@ -60,9 +60,9 @@ import net.runelite.client.util.ImageUtil;
class BarbarianAssaultOverlay extends Overlay
{
private static final int MAX_EGG_DISTANCE = 2500;
private final int HEALTH_BAR_HEIGHT = 20;
private final Color HEALTH_BAR_COLOR = new Color(225, 35, 0, 125);
private static final Color BACKGROUND = new Color(0, 0, 0, 150);
private final int HEALTH_BAR_HEIGHT = 20;
private final Color HEALTH_BAR_COLOR = new Color(225, 35, 0, 125);
private static final Color BACKGROUND = new Color(0, 0, 0, 150);
private static final int OFFSET_Z = 20;
private final Client client;
@@ -124,13 +124,15 @@ class BarbarianAssaultOverlay extends Overlay
graphics.drawImage(plugin.getClockImage(), spriteBounds.x, spriteBounds.y, null);
}
if (role == Role.COLLECTOR && config.highlightCollectorEggs()) {
if (role == Role.COLLECTOR && config.highlightCollectorEggs())
{
String heardCall = plugin.getCollectorHeardCall();
Color highlightColor = BarbarianAssaultPlugin.getEggColor(heardCall);
Map<WorldPoint, Integer> calledEggMap = plugin.getCalledEggMap();
Map<WorldPoint, Integer> yellowEggMap = plugin.getYellowEggs();
if (calledEggMap != null) {
if (calledEggMap != null)
{
renderEggLocations(graphics, calledEggMap, highlightColor);
}
@@ -139,10 +141,12 @@ class BarbarianAssaultOverlay extends Overlay
}
Widget inventory = client.getWidget(WidgetInfo.INVENTORY);
if (config.highlightItems() && inventory != null && !inventory.isHidden() && ((role == Role.DEFENDER || role == Role.HEALER))) {
if (config.highlightItems() && inventory != null && !inventory.isHidden() && ((role == Role.DEFENDER || role == Role.HEALER)))
{
int listenItemId = plugin.getListenItemId(role.getListen());
if (listenItemId != -1) {
if (listenItemId != -1)
{
Color color = config.highlightColor();
BufferedImage highlight = ImageUtil.fillImage(itemManager.getImage(listenItemId), new Color(color.getRed(), color.getGreen(), color.getBlue(), 150));
@@ -156,47 +160,47 @@ class BarbarianAssaultOverlay extends Overlay
}
}
if (role == Role.HEALER)
{
for (HealerTeam teammate : HealerTeam.values())
{
Widget widget = client.getWidget(teammate.getTeammate());
if (widget == null)
{
continue;
}
if (role == Role.HEALER)
{
for (HealerTeam teammate : HealerTeam.values())
{
Widget widget = client.getWidget(teammate.getTeammate());
if (widget == null)
{
continue;
}
String[] teammateHealth = widget.getText().split(" / ");
final int curHealth = Integer.parseInt(teammateHealth[0]);
final int maxHealth = Integer.parseInt(teammateHealth[1]);
String[] teammateHealth = widget.getText().split(" / ");
final int curHealth = Integer.parseInt(teammateHealth[0]);
final int maxHealth = Integer.parseInt(teammateHealth[1]);
int width = teammate.getWidth();
final int filledWidth = getBarWidth(maxHealth, curHealth, width);
int width = teammate.getWidth();
final int filledWidth = getBarWidth(maxHealth, curHealth, width);
int offsetX = teammate.getOffset().getX();
int offsetY = teammate.getOffset().getY();
int x = widget.getCanvasLocation().getX() - offsetX;
int y = widget.getCanvasLocation().getY() - offsetY;
int offsetX = teammate.getOffset().getX();
int offsetY = teammate.getOffset().getY();
int x = widget.getCanvasLocation().getX() - offsetX;
int y = widget.getCanvasLocation().getY() - offsetY;
graphics.setColor(HEALTH_BAR_COLOR);
graphics.fillRect(x, y, filledWidth, HEALTH_BAR_HEIGHT);
}
}
graphics.setColor(HEALTH_BAR_COLOR);
graphics.fillRect(x, y, filledWidth, HEALTH_BAR_HEIGHT);
}
}
return null;
}
private static int getBarWidth(int base, int current, int size)
{
final double ratio = (double) current / base;
private static int getBarWidth(int base, int current, int size)
{
final double ratio = (double) current / base;
if (ratio >= 1)
{
return size;
}
if (ratio >= 1)
{
return size;
}
return (int) Math.round(ratio * size);
}
return (int) Math.round(ratio * size);
}
private void renderEggLocations(Graphics2D graphics, Map<WorldPoint, Integer> eggMap, Color color)
{

View File

@@ -29,27 +29,35 @@ import com.google.inject.Provides;
import java.awt.Color;
import java.awt.Font;
import java.awt.Image;
import java.util.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import javax.inject.Inject;
import lombok.AccessLevel;
import lombok.Getter;
import net.runelite.api.*;
import net.runelite.api.coords.WorldPoint;
import net.runelite.api.events.*;
import net.runelite.api.kit.KitType;
import lombok.extern.slf4j.Slf4j;
import net.runelite.api.ChatMessageType;
import net.runelite.api.Client;
import net.runelite.api.EquipmentInventorySlot;
import net.runelite.api.GameState;
import net.runelite.api.InventoryID;
import net.runelite.api.Item;
import net.runelite.api.GameState;
import net.runelite.api.ItemID;
import net.runelite.api.MenuEntry;
import net.runelite.api.MessageNode;
import net.runelite.api.Player;
import net.runelite.api.Tile;
import net.runelite.api.Varbits;
import net.runelite.api.coords.WorldPoint;
import net.runelite.api.events.ChatMessage;
import net.runelite.api.events.GameStateChanged;
import net.runelite.api.events.ItemContainerChanged;
import net.runelite.api.events.ItemDespawned;
import net.runelite.api.events.ItemSpawned;
import net.runelite.api.events.MenuEntryAdded;
import net.runelite.api.events.VarbitChanged;
import net.runelite.api.events.WidgetLoaded;
import net.runelite.api.events.GameStateChanged;
import net.runelite.api.kit.KitType;
import net.runelite.api.widgets.Widget;
import net.runelite.api.widgets.WidgetID;
import net.runelite.api.widgets.WidgetInfo;
@@ -67,16 +75,15 @@ import net.runelite.client.ui.overlay.OverlayManager;
import net.runelite.client.util.ColorUtil;
import net.runelite.client.util.ImageUtil;
import net.runelite.client.util.Text;
import lombok.extern.slf4j.Slf4j;
@Slf4j
@PluginDescriptor(
name = "Barbarian Assault+",
description = "Custom barbarian assault plugin, use along with BA Tools",
tags = {"minigame", "overlay", "timer"},
type = PluginType.PVM // don't remove this, added this because our barbarian assault plugin is big time modified
name = "Barbarian Assault+",
description = "Custom barbarian assault plugin, use along with BA Tools",
tags = {"minigame", "overlay", "timer"},
type = PluginType.PVM // don't remove this, added this because our barbarian assault plugin is big time modified
)
public class BarbarianAssaultPlugin extends Plugin
{
@@ -86,19 +93,24 @@ public class BarbarianAssaultPlugin extends Plugin
@Getter
private int collectedEggCount = 0;
@Getter
private int positiveEggCount = 0;
@Getter
private int wrongEggs = 0;
@Getter
private int HpHealed = 0;
@Getter
private int totalCollectedEggCount = 0;
@Getter
private int totalHpHealed = 0;
private boolean hasAnnounced;
private Font font;
private Font font;
private final Image clockImage = ImageUtil.getResourceStreamFromClass(getClass(), "clock.png");
private int inGameBit = 0;
private String currentWave = START_WAVE;
@@ -116,7 +128,6 @@ public class BarbarianAssaultPlugin extends Plugin
@Getter(AccessLevel.PACKAGE)
private final HashMap<WorldPoint, Integer> yellowEggs = new HashMap<>();
@Inject
@Getter
private Client client;
@@ -133,45 +144,20 @@ public class BarbarianAssaultPlugin extends Plugin
@Inject
private BarbarianAssaultOverlay overlay;
private final ImmutableList<WidgetInfo> WIDGETS = ImmutableList.of(
WidgetInfo.BA_FAILED_ATTACKER_ATTACKS,
WidgetInfo.BA_RUNNERS_PASSED,
WidgetInfo.BA_EGGS_COLLECTED,
WidgetInfo.BA_HITPOINTS_REPLENISHED,
WidgetInfo.BA_WRONG_POISON_PACKS,
WidgetInfo.BA_HONOUR_POINTS_REWARD
);
private final ImmutableList<WidgetInfo> POINTSWIDGETS = ImmutableList.of(
//base
WidgetInfo.BA_BASE_POINTS,
//att
WidgetInfo.BA_FAILED_ATTACKER_ATTACKS_POINTS,
WidgetInfo.BA_RANGERS_KILLED,
WidgetInfo.BA_FIGHTERS_KILLED,
//def
WidgetInfo.BA_RUNNERS_PASSED_POINTS,
WidgetInfo.BA_RUNNERS_KILLED,
//coll
WidgetInfo.BA_EGGS_COLLECTED_POINTS,
//heal
WidgetInfo.BA_HEALERS_KILLED,
WidgetInfo.BA_HITPOINTS_REPLENISHED_POINTS,
WidgetInfo.BA_WRONG_POISON_PACKS_POINTS
);
@Provides
@Provides
BarbarianAssaultConfig provideConfig(ConfigManager configManager)
{
return configManager.getConfig(BarbarianAssaultConfig.class);
}
private Game game;
private Wave wave;
@Override
protected void startUp() throws Exception
{
overlayManager.add(overlay);
font = FontManager.getRunescapeFont()
.deriveFont(Font.BOLD, 24);
.deriveFont(Font.BOLD, 24);
}
@Override
@@ -202,12 +188,14 @@ public class BarbarianAssaultPlugin extends Plugin
{
if (event.getGroupId() == WidgetID.BA_REWARD_GROUP_ID)
{
wave = new Wave(client);
Wave wave = new Wave(client);
Widget rewardWidget = client.getWidget(WidgetInfo.BA_REWARD_TEXT);
if (rewardWidget != null && rewardWidget.getText().contains(ENDGAME_REWARD_NEEDLE_TEXT) && gameTime != null)
{
if (config.waveTimes())
{
announceTime("Game finished, duration: ", gameTime.getTime(false));
}
if (config.showTotalRewards())
{
announceSomething(game.getGameSummary());
@@ -215,7 +203,7 @@ public class BarbarianAssaultPlugin extends Plugin
}
Widget pointsWidget = client.getWidget(WidgetInfo.BA_RUNNERS_PASSED);
if (!rewardWidget.getText().contains(ENDGAME_REWARD_NEEDLE_TEXT) && pointsWidget != null
&& config.showSummaryOfPoints() && !hasAnnounced && client.getVar(Varbits.IN_GAME_BA) == 0)
&& config.showSummaryOfPoints() && !hasAnnounced && client.getVar(Varbits.IN_GAME_BA) == 0)
{
wave.setWaveAmounts();
wave.setWavePoints();
@@ -249,13 +237,15 @@ public class BarbarianAssaultPlugin extends Plugin
{
hasAnnounced = true;
}
if (!chatMessage.getType().equals(ChatMessageType.GAMEMESSAGE))
{
return;
}
if (!chatMessage.getType().equals(ChatMessageType.GAMEMESSAGE))
{
return;
}
int inGame = client.getVar(Varbits.IN_GAME_BA);
if (inGameBit != inGame)
{
return;
}
final String message = chatMessage.getMessage().toLowerCase();
final MessageNode messageNode = chatMessage.getMessageNode();
final String nodeValue = Text.removeTags(messageNode.getValue());
@@ -368,13 +358,14 @@ public class BarbarianAssaultPlugin extends Plugin
inGameBit = inGame;
}
@Subscribe
public void onItemSpawned(ItemSpawned itemSpawned)
{
int itemId = itemSpawned.getItem().getId();
WorldPoint worldPoint = itemSpawned.getTile().getWorldLocation();
HashMap<WorldPoint, Integer> eggMap = getEggMap(itemId);
if (eggMap != null)
if (eggMap != null)
{
Integer existingQuantity = eggMap.putIfAbsent(worldPoint, 1);
if (existingQuantity != null)
@@ -470,9 +461,9 @@ public class BarbarianAssaultPlugin extends Plugin
private void announceSomething(final ChatMessageBuilder chatMessage)
{
chatMessageManager.queue(QueuedMessage.builder()
.type(ChatMessageType.CONSOLE)
.runeLiteFormattedMessage(chatMessage.build())
.build());
.type(ChatMessageType.CONSOLE)
.runeLiteFormattedMessage(chatMessage.build())
.build());
}
String getCollectorHeardCall()
@@ -570,26 +561,22 @@ public class BarbarianAssaultPlugin extends Plugin
private void announceTime(String preText, String time)
{
final String chatMessage = new ChatMessageBuilder()
.append(ChatColorType.NORMAL)
.append(preText)
.append(ChatColorType.HIGHLIGHT)
.append(time)
.build();
.append(ChatColorType.NORMAL)
.append(preText)
.append(ChatColorType.HIGHLIGHT)
.append(time)
.build();
chatMessageManager.queue(QueuedMessage.builder()
.type(ChatMessageType.CONSOLE)
.runeLiteFormattedMessage(chatMessage)
.build());
.type(ChatMessageType.CONSOLE)
.runeLiteFormattedMessage(chatMessage)
.build());
}
private boolean isEgg(int itemID)
{
if (itemID == ItemID.RED_EGG || itemID == ItemID.GREEN_EGG
|| itemID == ItemID.BLUE_EGG || itemID == ItemID.YELLOW_EGG)
{
return true;
}
return false;
return itemID == ItemID.RED_EGG || itemID == ItemID.GREEN_EGG
|| itemID == ItemID.BLUE_EGG || itemID == ItemID.YELLOW_EGG;
}
private boolean isUnderPlayer(Tile tile)
@@ -616,12 +603,12 @@ public class BarbarianAssaultPlugin extends Plugin
return font;
}
public Image getClockImage()
Image getClockImage()
{
return clockImage;
}
public int getListenItemId(WidgetInfo listenInfo)
int getListenItemId(WidgetInfo listenInfo)
{
Widget listenWidget = client.getWidget(listenInfo);

View File

@@ -24,120 +24,124 @@
*/
package net.runelite.client.plugins.barbarianassault;
import java.awt.Color;
import java.util.ArrayList;
import lombok.Getter;
import net.runelite.api.Client;
import net.runelite.api.events.ChatMessage;
import net.runelite.client.chat.ChatColorType;
import net.runelite.client.chat.ChatMessageBuilder;
import net.runelite.client.eventbus.Subscribe;
import java.awt.*;
import java.util.ArrayList;
@Getter
public class Game
{
private Client client;
private String currentWave;
private ArrayList<Wave> waves = new ArrayList<>();
private String[] totalDescriptions = {
"A: ",
"; D: ",
"; C: ",
"; Vial: ",
"; H packs: ",
"; Total: "};
private String[] otherPointsDescriptions = {
" A: ",
"; D: ",
"; C: ",
"; H: "
};
private int[] totalPoints = new int[6];
private int[] totalAmounts = new int[6];
private int[] otherRolesPoints = new int[4];
private Client client;
private String currentWave;
private ArrayList<Wave> waves = new ArrayList<>();
private String[] totalDescriptions = {
"A: ",
"; D: ",
"; C: ",
"; Vial: ",
"; H packs: ",
"; Total: "};
private String[] otherPointsDescriptions = {
" A: ",
"; D: ",
"; C: ",
"; H: "
};
private int[] totalPoints = new int[6];
private int[] totalAmounts = new int[6];
private int[] otherRolesPoints = new int[4];
Game(Client client)
{
this.client = client;
}
Game(Client client, ArrayList<Wave> waves)
{
this.client = client;
this.waves = waves;
}
@Subscribe
public void onChatMessage(ChatMessage chatMessage)
{
if (chatMessage.getMessage().startsWith("---- Wave:"))
{
String[] tempMessage = chatMessage.getMessage().split(" ");
currentWave = tempMessage[2];
String[] temp = currentWave.split(" ");
}
if (currentWave.equals("1"))
{
waves = null;
totalPoints = new int[6];
totalAmounts = new int[6];
}
}
ChatMessageBuilder getGameSummary()
{
int[] amountsList;
int[] pointsList;
int[] otherRolesPointsList;
ChatMessageBuilder message = new ChatMessageBuilder();
message.append("Round points: ");
for (Wave w : waves)
{
amountsList = w.getWaveAmounts();
pointsList = w.getWavePoints();
otherRolesPointsList = w.getOtherRolesPointsList();
for (int j = 0; j < totalAmounts.length; j++) {
totalAmounts[j] += amountsList[j];
}
for (int k = 0; k < totalPoints.length; k++) {
totalPoints[k] += pointsList[k];
}
for (int z = 0; z < otherRolesPoints.length; z++) {
otherRolesPoints[z] += otherRolesPointsList[z];
}
}
for (int i = 0; i < otherRolesPoints.length; i++)
{
otherRolesPoints[i] += 80;
}
totalAmounts[5] += 80;
for (int i = 0; i < totalDescriptions.length; i++)
{
if (i != 4)
{
message.append(totalDescriptions[i]);
message.append(String.valueOf(totalAmounts[i]));
message.append("(");
if (totalPoints[i] < 0)
{
message.append(Color.RED, String.valueOf(totalPoints[i]));
}
else if (totalPoints[i] > 0)
{
message.append(Color.BLUE, String.valueOf(totalPoints[i]));
}
else
{
message.append(String.valueOf(totalPoints[i]));
}
message.append(")");
}
}
message.append(System.getProperty("line.separator"));
message.append("All roles points this game: ");
for(int i = 0; i < otherPointsDescriptions.length; i++)
{
message.append(otherPointsDescriptions[i]);
message.append(String.valueOf(otherRolesPoints[i]));
}
return message;
}
Game(Client client)
{
this.client = client;
}
Game(Client client, ArrayList<Wave> waves)
{
this.client = client;
this.waves = waves;
}
@Subscribe
public void onChatMessage(ChatMessage chatMessage)
{
if (chatMessage.getMessage().startsWith("---- Wave:"))
{
String[] tempMessage = chatMessage.getMessage().split(" ");
currentWave = tempMessage[2];
String[] temp = currentWave.split(" ");
}
if (currentWave.equals("1"))
{
waves = null;
totalPoints = new int[6];
totalAmounts = new int[6];
}
}
ChatMessageBuilder getGameSummary()
{
int[] amountsList;
int[] pointsList;
int[] otherRolesPointsList;
ChatMessageBuilder message = new ChatMessageBuilder();
message.append("Round points: ");
for (Wave w : waves)
{
amountsList = w.getWaveAmounts();
pointsList = w.getWavePoints();
otherRolesPointsList = w.getOtherRolesPointsList();
for (int j = 0; j < totalAmounts.length; j++)
{
totalAmounts[j] += amountsList[j];
}
for (int k = 0; k < totalPoints.length; k++)
{
totalPoints[k] += pointsList[k];
}
for (int z = 0; z < otherRolesPoints.length; z++)
{
otherRolesPoints[z] += otherRolesPointsList[z];
}
}
for (int i = 0; i < otherRolesPoints.length; i++)
{
otherRolesPoints[i] += 80;
}
totalAmounts[5] += 80;
for (int i = 0; i < totalDescriptions.length; i++)
{
if (i != 4)
{
message.append(totalDescriptions[i]);
message.append(String.valueOf(totalAmounts[i]));
message.append("(");
if (totalPoints[i] < 0)
{
message.append(Color.RED, String.valueOf(totalPoints[i]));
}
else if (totalPoints[i] > 0)
{
message.append(Color.BLUE, String.valueOf(totalPoints[i]));
}
else
{
message.append(String.valueOf(totalPoints[i]));
}
message.append(")");
}
}
message.append(System.getProperty("line.separator"));
message.append("All roles points this game: ");
for (int i = 0; i < otherPointsDescriptions.length; i++)
{
message.append(otherPointsDescriptions[i]);
message.append(String.valueOf(otherRolesPoints[i]));
}
return message;
}
}

View File

@@ -36,10 +36,13 @@ enum Role
@Getter
private final WidgetInfo listen;
@Getter
private final WidgetInfo call;
@Getter
private final WidgetInfo roleText;
@Getter
private final WidgetInfo roleSprite;

View File

@@ -34,17 +34,22 @@ import net.runelite.api.Constants;
class Round
{
private final Instant roundStartTime;
@Getter
private final Role roundRole;
@Getter
@Setter
private boolean runnersKilled;
@Getter
@Setter
private boolean rangersKilled;
@Getter
@Setter
private boolean healersKilled;
@Getter
@Setter
private boolean fightersKilled;
@@ -56,12 +61,7 @@ class Round
this.roundStartTime = Instant.now().plusMillis(2 * Constants.GAME_TICK_LENGTH);
}
public long getRoundTime()
{
return Duration.between(roundStartTime, Instant.now()).getSeconds();
}
public long getTimeToChange()
long getTimeToChange()
{
return 30 + (Duration.between(Instant.now(), roundStartTime).getSeconds() % 30);
}

View File

@@ -25,193 +25,186 @@
package net.runelite.client.plugins.barbarianassault;
import com.google.common.collect.ImmutableList;
import java.awt.Color;
import lombok.Getter;
import net.runelite.api.Client;
import net.runelite.api.widgets.Widget;
import net.runelite.api.widgets.WidgetInfo;
import net.runelite.client.chat.ChatMessageBuilder;
import net.runelite.client.chat.ChatMessageManager;
import javax.inject.Inject;
import java.awt.*;
@Getter
class Wave
{
private Client client;
private final ImmutableList<WidgetInfo> WIDGETS = ImmutableList.of(
WidgetInfo.BA_FAILED_ATTACKER_ATTACKS,
WidgetInfo.BA_RUNNERS_PASSED,
WidgetInfo.BA_EGGS_COLLECTED,
WidgetInfo.BA_HITPOINTS_REPLENISHED,
WidgetInfo.BA_WRONG_POISON_PACKS,
WidgetInfo.BA_HONOUR_POINTS_REWARD
);
private final ImmutableList<WidgetInfo> POINTSWIDGETS = ImmutableList.of(
//base
WidgetInfo.BA_BASE_POINTS,
//att
WidgetInfo.BA_FAILED_ATTACKER_ATTACKS_POINTS,
WidgetInfo.BA_RANGERS_KILLED,
WidgetInfo.BA_FIGHTERS_KILLED,
//def
WidgetInfo.BA_RUNNERS_PASSED_POINTS,
WidgetInfo.BA_RUNNERS_KILLED,
//coll
WidgetInfo.BA_EGGS_COLLECTED_POINTS,
//heal
WidgetInfo.BA_HEALERS_KILLED,
WidgetInfo.BA_HITPOINTS_REPLENISHED_POINTS,
WidgetInfo.BA_WRONG_POISON_PACKS_POINTS
);
private int[] waveAmounts = new int[6];
private int[] allPointsList = new int[10];
private int[] wavePoints = new int[6];
private int[] otherRolesPointsList = new int[4];
private String[] descriptions = {
" A: ",
"; D: ",
"; C: ",
"; Vial: ",
"; H packs: ",
"; Total: "};
private Client client;
private final ImmutableList<WidgetInfo> WIDGETS = ImmutableList.of(
WidgetInfo.BA_FAILED_ATTACKER_ATTACKS,
WidgetInfo.BA_RUNNERS_PASSED,
WidgetInfo.BA_EGGS_COLLECTED,
WidgetInfo.BA_HITPOINTS_REPLENISHED,
WidgetInfo.BA_WRONG_POISON_PACKS,
WidgetInfo.BA_HONOUR_POINTS_REWARD
);
private final ImmutableList<WidgetInfo> POINTSWIDGETS = ImmutableList.of(
//base
WidgetInfo.BA_BASE_POINTS,
//att
WidgetInfo.BA_FAILED_ATTACKER_ATTACKS_POINTS,
WidgetInfo.BA_RANGERS_KILLED,
WidgetInfo.BA_FIGHTERS_KILLED,
//def
WidgetInfo.BA_RUNNERS_PASSED_POINTS,
WidgetInfo.BA_RUNNERS_KILLED,
//coll
WidgetInfo.BA_EGGS_COLLECTED_POINTS,
//heal
WidgetInfo.BA_HEALERS_KILLED,
WidgetInfo.BA_HITPOINTS_REPLENISHED_POINTS,
WidgetInfo.BA_WRONG_POISON_PACKS_POINTS
);
private int[] waveAmounts = new int[6];
private int[] allPointsList = new int[10];
private int[] wavePoints = new int[6];
private int[] otherRolesPointsList = new int[4];
private String[] descriptions = {
" A: ",
"; D: ",
"; C: ",
"; Vial: ",
"; H packs: ",
"; Total: "};
private String[] otherPointsDescriptions = {
" A: ",
" D: ",
" C: ",
" H: "
};
Wave(Client client)
{
this.client = client;
}
void setWaveAmounts(int[] amounts)
{
for (int i = 0; i < amounts.length; i++)
{
waveAmounts[i] = amounts[i];
}
}
private String[] otherPointsDescriptions = {
" A: ",
" D: ",
" C: ",
" H: "
};
void setWavePoints(int[] points, int[] otherRolesPoints)
{
for (int i = 0; i < points.length; i++)
{
wavePoints[i] = points[i];
}
for (int i = 0; i < otherRolesPoints.length; i++)
{
otherRolesPointsList[i] = otherRolesPoints[i];
}
}
void setWaveAmounts()
{
for (int i = 0; i < WIDGETS.size(); i++)
{
Widget w = client.getWidget(WIDGETS.get(i));
if (w != null)
{
waveAmounts[i] = Integer.parseInt(w.getText());
}
}
}
void setWavePoints()
{
for (int i = 0; i < POINTSWIDGETS.size(); i++)
{
Widget w = client.getWidget(POINTSWIDGETS.get(i));
allPointsList[i] = Integer.parseInt(w.getText());
switch (i)
{
case 1:
wavePoints[0] += allPointsList[i];
break;
case 4:
wavePoints[1] += allPointsList[i];
break;
case 6:
wavePoints[2] += allPointsList[i];
break;
case 8:
case 9:
wavePoints[3] += allPointsList[i];
break;
default:
break;
}
}
wavePoints[5] = 0;
for (int i = 0; i < wavePoints.length-1; i++)
{
wavePoints[5] += wavePoints[i];
}
for (int i = 0; i < POINTSWIDGETS.size(); i++)
{
Widget w = client.getWidget(POINTSWIDGETS.get(i));
switch (i)
{
case 0:
otherRolesPointsList[0] += Integer.parseInt(w.getText());
otherRolesPointsList[1] += Integer.parseInt(w.getText());
otherRolesPointsList[2] += Integer.parseInt(w.getText());
otherRolesPointsList[3] += Integer.parseInt(w.getText());
break;
case 1:
case 2:
case 3:
otherRolesPointsList[0] += Integer.parseInt(w.getText());
break;
case 4:
case 5:
otherRolesPointsList[1] += Integer.parseInt(w.getText());
break;
case 6:
otherRolesPointsList[2] += Integer.parseInt(w.getText());
break;
case 7:
case 8:
case 9:
otherRolesPointsList[3] += Integer.parseInt(w.getText());
break;
default:
break;
}
}
}
ChatMessageBuilder getWaveSummary()
{
ChatMessageBuilder message = new ChatMessageBuilder();
message.append("Wave points:");
for(int i = 0; i < descriptions.length; i++)
{
if (i != 4)
{
message.append(descriptions[i]);
message.append(String.valueOf(waveAmounts[i]));
message.append("(");
if (wavePoints[i] < 0)
{
message.append(Color.RED, String.valueOf(wavePoints[i]));
}
else if (wavePoints[i] > 0)
{
message.append(Color.BLUE, String.valueOf(wavePoints[i]));
}
else
{
message.append(String.valueOf(wavePoints[i]));
}
message.append(")");
}
}
message.append(System.getProperty("line.separator"));
message.append("All roles points this wave: ");
for(int i = 0; i < otherPointsDescriptions.length; i++)
{
message.append(otherPointsDescriptions[i]);
message.append(String.valueOf(otherRolesPointsList[i]));
}
return message;
}
Wave(Client client)
{
this.client = client;
}
void setWaveAmounts(int[] amounts)
{
System.arraycopy(amounts, 0, waveAmounts, 0, amounts.length);
}
void setWavePoints(int[] points, int[] otherRolesPoints)
{
System.arraycopy(points, 0, wavePoints, 0, points.length);
System.arraycopy(otherRolesPoints, 0, otherRolesPointsList, 0, otherRolesPoints.length);
}
void setWaveAmounts()
{
for (int i = 0; i < WIDGETS.size(); i++)
{
Widget w = client.getWidget(WIDGETS.get(i));
if (w != null)
{
waveAmounts[i] = Integer.parseInt(w.getText());
}
}
}
void setWavePoints()
{
for (int i = 0; i < POINTSWIDGETS.size(); i++)
{
Widget w = client.getWidget(POINTSWIDGETS.get(i));
allPointsList[i] = Integer.parseInt(w.getText());
switch (i)
{
case 1:
wavePoints[0] += allPointsList[i];
break;
case 4:
wavePoints[1] += allPointsList[i];
break;
case 6:
wavePoints[2] += allPointsList[i];
break;
case 8:
case 9:
wavePoints[3] += allPointsList[i];
break;
default:
break;
}
}
wavePoints[5] = 0;
for (int i = 0; i < wavePoints.length - 1; i++)
{
wavePoints[5] += wavePoints[i];
}
for (int i = 0; i < POINTSWIDGETS.size(); i++)
{
Widget w = client.getWidget(POINTSWIDGETS.get(i));
switch (i)
{
case 0:
otherRolesPointsList[0] += Integer.parseInt(w.getText());
otherRolesPointsList[1] += Integer.parseInt(w.getText());
otherRolesPointsList[2] += Integer.parseInt(w.getText());
otherRolesPointsList[3] += Integer.parseInt(w.getText());
break;
case 1:
case 2:
case 3:
otherRolesPointsList[0] += Integer.parseInt(w.getText());
break;
case 4:
case 5:
otherRolesPointsList[1] += Integer.parseInt(w.getText());
break;
case 6:
otherRolesPointsList[2] += Integer.parseInt(w.getText());
break;
case 7:
case 8:
case 9:
otherRolesPointsList[3] += Integer.parseInt(w.getText());
break;
default:
break;
}
}
}
ChatMessageBuilder getWaveSummary()
{
ChatMessageBuilder message = new ChatMessageBuilder();
message.append("Wave points:");
for (int i = 0; i < descriptions.length; i++)
{
if (i != 4)
{
message.append(descriptions[i]);
message.append(String.valueOf(waveAmounts[i]));
message.append("(");
if (wavePoints[i] < 0)
{
message.append(Color.RED, String.valueOf(wavePoints[i]));
}
else if (wavePoints[i] > 0)
{
message.append(Color.BLUE, String.valueOf(wavePoints[i]));
}
else
{
message.append(String.valueOf(wavePoints[i]));
}
message.append(")");
}
}
message.append(System.getProperty("line.separator"));
message.append("All roles points this wave: ");
for (int i = 0; i < otherPointsDescriptions.length; i++)
{
message.append(otherPointsDescriptions[i]);
message.append(String.valueOf(otherRolesPointsList[i]));
}
return message;
}
}