Skip to content

Commit

Permalink
Add Minigame storage - Giants' Foundry
Browse files Browse the repository at this point in the history
  • Loading branch information
Thource committed Apr 2, 2023
1 parent 8f06bc6 commit 8873725
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 115 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,6 @@ nbproject/
.idea/modules/**/*.iml
.idea/libraries/**/*.xml
.idea/sonarlint
.idea/compiler.xml
.idea/jarRepositories.xml
.idea/misc.xml
15 changes: 0 additions & 15 deletions .idea/compiler.xml

This file was deleted.

30 changes: 0 additions & 30 deletions .idea/jarRepositories.xml

This file was deleted.

69 changes: 0 additions & 69 deletions .idea/misc.xml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package dev.thource.runelite.dudewheresmystuff.minigames;

import dev.thource.runelite.dudewheresmystuff.DudeWheresMyStuffPlugin;
import dev.thource.runelite.dudewheresmystuff.ItemStack;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import lombok.Getter;
import net.runelite.api.ItemID;
import net.runelite.api.widgets.Widget;
import org.apache.commons.lang3.math.NumberUtils;

/** GiantsFoundry is responsible for tracking the player's Giants' Foundry points. */
@Getter
public class GiantsFoundry extends MinigamesStorage {

private static final Pattern HAND_IN_PATTERN = Pattern.compile("at quality: (\\d+)");

private final ItemStack points =
new ItemStack(ItemID.COLOSSAL_BLADE, "Points", 0, 0, 0, true);
private boolean didJustHandIn = false;

GiantsFoundry(DudeWheresMyStuffPlugin plugin) {
super(MinigamesStorageType.GIANTS_FOUNDRY, plugin);

items.add(points);
}

@Override
public boolean onGameTick() {
Widget shopWidget = plugin.getClient().getWidget(753, 13);
if (shopWidget != null) {
points.setQuantity(Integer.parseInt(shopWidget.getText()));
lastUpdated = System.currentTimeMillis();
return true;
}

Widget chatWidget = plugin.getClient().getWidget(229, 1);
if (chatWidget != null) {
if (!didJustHandIn) {
Matcher matcher = HAND_IN_PATTERN.matcher(chatWidget.getText());
if (matcher.find()) {
points.setQuantity(points.getQuantity() + NumberUtils.toInt(matcher.group(1)));
lastUpdated = System.currentTimeMillis();
didJustHandIn = true;
return true;
}
}
} else {
didJustHandIn = false;
}

return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ private MinigamesStorageManager(DudeWheresMyStuffPlugin plugin) {
storages.add(new MahoganyHomes(plugin));
storages.add(new Slayer(plugin));
storages.add(new PestControl(plugin));
storages.add(new GiantsFoundry(plugin));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ public enum MinigamesStorageType implements StorageType {
TEMPOROSS("Tempoross", true, "tempoross"),
SLAYER("Slayer", true, "slayer"),
SOUL_WARS("Soul Wars", true, "soulwars"),
MAHOGANY_HOMES("Mahogany Homes", false, "mahoganyhomes");
MAHOGANY_HOMES("Mahogany Homes", false, "mahoganyhomes"),
GIANTS_FOUNDRY("Giants' Foundry", false, "giantsfoundry");

private final String name;
private final int itemContainerId = -1;
Expand Down

0 comments on commit 8873725

Please sign in to comment.