Merge pull request #4687 from Nightfirecat/three-step-cryptic-clue

Add solutions for 3 step cryptic master clues (continued from #3352)
This commit is contained in:
Abex
2018-10-04 06:36:32 -06:00
committed by GitHub
10 changed files with 296 additions and 61 deletions

View File

@@ -32,7 +32,6 @@ import java.awt.image.BufferedImage;
import java.time.Duration;
import java.time.Instant;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Stream;
import javax.inject.Inject;
import lombok.Getter;
@@ -80,11 +79,13 @@ import net.runelite.client.plugins.cluescrolls.clues.MapClue;
import net.runelite.client.plugins.cluescrolls.clues.NpcClueScroll;
import net.runelite.client.plugins.cluescrolls.clues.ObjectClueScroll;
import net.runelite.client.plugins.cluescrolls.clues.TextClueScroll;
import net.runelite.client.plugins.cluescrolls.clues.ThreeStepCrypticClue;
import net.runelite.client.ui.overlay.OverlayManager;
import net.runelite.client.ui.overlay.worldmap.WorldMapPointManager;
import net.runelite.client.util.ImageUtil;
import net.runelite.client.util.QueryRunner;
import net.runelite.client.util.Text;
import org.apache.commons.lang3.ArrayUtils;
@PluginDescriptor(
name = "Clue Scroll",
@@ -179,9 +180,9 @@ public class ClueScrollPlugin extends Plugin
return;
}
if (clue instanceof LocationsClueScroll)
if (clue instanceof HotColdClue)
{
if (((LocationsClueScroll)clue).update(event.getMessage(), this))
if (((HotColdClue) clue).update(event.getMessage(), this))
{
worldMapPointsSet = false;
}
@@ -225,6 +226,12 @@ public class ClueScrollPlugin extends Plugin
resetClue();
}
}
// if three step clue check for clue scroll pieces
if (clue instanceof ThreeStepCrypticClue)
{
((ThreeStepCrypticClue) clue).checkForParts(client, event, itemManager);
}
}
@Subscribe
@@ -255,11 +262,41 @@ public class ClueScrollPlugin extends Plugin
if (clue instanceof LocationsClueScroll)
{
final List<WorldPoint> locations = ((LocationsClueScroll) clue).getLocations();
final WorldPoint[] locations = ((LocationsClueScroll) clue).getLocations();
if (!locations.isEmpty())
if (locations.length > 0)
{
addMapPoints(locations.toArray(new WorldPoint[locations.size()]));
addMapPoints(locations);
}
if (clue instanceof ObjectClueScroll)
{
int[] objectIds = ((ObjectClueScroll) clue).getObjectIds();
if (objectIds.length > 0)
{
for (WorldPoint location : locations)
{
final LocalPoint localLocation = LocalPoint.fromWorld(client, location);
if (localLocation != null)
{
final Scene scene = client.getScene();
final Tile[][][] tiles = scene.getTiles();
final Tile tile = tiles[client.getPlane()][localLocation.getSceneX()][localLocation.getSceneY()];
objectsToMark = Arrays.stream(tile.getGameObjects())
.filter(object -> object != null && ArrayUtils.contains(objectIds, object.getId()))
.toArray(GameObject[]::new);
// Set hint arrow to first object found as there can only be 1 hint arrow
if (config.displayHintArrows() && objectsToMark.length >= 1)
{
client.setHintArrow(objectsToMark[0].getWorldLocation());
}
}
}
}
}
}
@@ -282,11 +319,11 @@ public class ClueScrollPlugin extends Plugin
if (clue instanceof NpcClueScroll)
{
String npc = ((NpcClueScroll) clue).getNpc();
String[] npcs = ((NpcClueScroll) clue).getNpcs();
if (npc != null)
if (npcs.length > 0)
{
Query query = new NPCQuery().nameEquals(npc);
Query query = new NPCQuery().nameEquals(npcs);
npcsToMark = queryRunner.runQuery(query);
// Set hint arrow to first NPC found as there can only be 1 hint arrow
@@ -302,40 +339,6 @@ public class ClueScrollPlugin extends Plugin
}
}
if (clue instanceof ObjectClueScroll)
{
final ObjectClueScroll objectClueScroll = (ObjectClueScroll) clue;
int objectId = objectClueScroll.getObjectId();
if (objectId != -1)
{
// Match object with location every time
final WorldPoint location = objectClueScroll.getLocation();
if (location != null)
{
final LocalPoint localLocation = LocalPoint.fromWorld(client, location);
if (localLocation != null)
{
final Scene scene = client.getScene();
final Tile[][][] tiles = scene.getTiles();
final Tile tile = tiles[client.getPlane()][localLocation.getSceneX()][localLocation.getSceneY()];
objectsToMark = Arrays.stream(tile.getGameObjects())
.filter(object -> object != null && object.getId() == objectId)
.toArray(GameObject[]::new);
// Set hint arrow to first object found as there can only be 1 hint arrow
if (config.displayHintArrows() && objectsToMark.length >= 1)
{
client.setHintArrow(objectsToMark[0].getWorldLocation());
}
}
}
}
}
if (clue instanceof EmoteClue)
{
ItemContainer equipment = client.getItemContainer(InventoryID.EQUIPMENT);
@@ -510,6 +513,14 @@ public class ClueScrollPlugin extends Plugin
return hotColdClue;
}
// three step cryptic clues need unedited text to check which steps are already done
final ThreeStepCrypticClue threeStepCrypticClue = ThreeStepCrypticClue.forText(text, clueScrollText.getText());
if (threeStepCrypticClue != null)
{
return threeStepCrypticClue;
}
// We have unknown clue, reset
resetClue();
return null;

View File

@@ -219,4 +219,9 @@ public class AnagramClue extends ClueScroll implements TextClueScroll, NpcClueSc
return null;
}
public String[] getNpcs()
{
return new String[] {npc};
}
}

View File

@@ -128,4 +128,9 @@ public class CipherClue extends ClueScroll implements TextClueScroll, NpcClueScr
return null;
}
public String[] getNpcs()
{
return new String[] {npc};
}
}

View File

@@ -50,7 +50,7 @@ import net.runelite.client.ui.overlay.components.TitleComponent;
@Getter
public class CrypticClue extends ClueScroll implements TextClueScroll, NpcClueScroll, ObjectClueScroll
{
private static final Set<CrypticClue> CLUES = ImmutableSet.of(
public static final Set<CrypticClue> CLUES = ImmutableSet.of(
new CrypticClue("Show this to Sherlock.", "Sherlock", new WorldPoint(2733, 3415, 0), "Sherlock is located to the east of the Sorcerer's tower in Seers' Village."),
new CrypticClue("Talk to the bartender of the Rusty Anchor in Port Sarim.", "Bartender", new WorldPoint(3045, 3256, 0), "The Rusty Anchor is located in the north of Port Sarim."),
new CrypticClue("The keeper of Melzars... Spare? Skeleton? Anar?", "Oziach", new WorldPoint(3068, 3516, 0), "Speak to Oziach in Edgeville"),
@@ -198,7 +198,7 @@ public class CrypticClue extends ClueScroll implements TextClueScroll, NpcClueSc
new CrypticClue("Fiendish cooks probably wont dig the dirty dishes.", new WorldPoint(3043, 4974, 1), "Dig by the fire in the Rogues' Den."),
new CrypticClue("My life was spared but these voices remain, now guarding these iron gates is my bane.", "Key Master", new WorldPoint(1310, 1251, 0), "Speak to the Key Master in Cerberus' Lair."),
new CrypticClue("Search the boxes in one of the tents in Al Kharid.", BOXES_361, new WorldPoint(3308, 3206, 0), "Search the boxes in the tent east of the Silk trader."),
new CrypticClue("One of several rhyming brothers, in business attire with an obsession for paper work.", "Piles", new WorldPoint(3186, 3936, 0), "Speak to Piles in the Resource Area."),
new CrypticClue("One of several rhyming brothers, in business attire with an obsession for paper work.", "Piles", new WorldPoint(3186, 3936, 0), "Speak to Piles in the Wilderness Resource Area. An entry fee of 7,500 coins is required, or less if Wilderness Diaries have been completed."),
new CrypticClue("Search the drawers on the first floor of a building overlooking Ardougne's Market.", DRAWERS_352, new WorldPoint(2657, 3322, 1), "Climb the ladder in the house north of the market."),
new CrypticClue("'A bag belt only?', he asked his balding brothers.", "Abbot Langley", new WorldPoint(3058, 3487, 0), "Talk-to Abbot Langley in Monastery west of Edgeville"),
new CrypticClue("Search the drawers upstairs in Falador's shield shop.", DRAWERS, new WorldPoint(2971, 3386, 1), "Cassie's Shield Shop at the northern Falador entrance."),
@@ -216,10 +216,10 @@ public class CrypticClue extends ClueScroll implements TextClueScroll, NpcClueSc
new CrypticClue("Search the drawers in the house next to the Port Sarim mage shop.", DRAWERS, new WorldPoint(3024, 3259, 0), "House east of Betty's. Contains a cooking sink."),
new CrypticClue("With a name like that, you'd expect a little more than just a few scimitars.", "Daga", new WorldPoint(2759, 2775, 0), "Speak to Daga on Ape Atoll."),
new CrypticClue("Strength potions with red spiders' eggs? He is quite a herbalist.", "Apothecary", new WorldPoint(3194, 3403, 0), "Talk to Apothecary in the South-western Varrock. (the) apothecary is just north-west of the Varrock Swordshop."),
new CrypticClue("Robin wishes to see your finest range equipment.", "Robin", new WorldPoint(3673, 3492, 0), "Robin at the inn in Port Phasmatys. Speak to him with +182 in ranged attack bonus."),
new CrypticClue("Robin wishes to see your finest ranged equipment.", "Robin", new WorldPoint(3673, 3492, 0), "Robin at the inn in Port Phasmatys. Speak to him with +182 in ranged attack bonus."),
new CrypticClue("You will need to under-cook to solve this one.", CRATE_357, new WorldPoint(3219, 9617, 0), "Search the crate in the Lumbridge basement."),
new CrypticClue("Search through some drawers found in Taverley's houses.", DRAWERS_350, new WorldPoint(2894, 3418, 0), "The south-eastern most house, south of Jatix's Herblore Shop."),
new CrypticClue("Anger Abbot Langley.", "Abbot Langley", new WorldPoint(3058, 3487, 0), "Speak to Abbot Langley while you have a negative prayer bonus"),
new CrypticClue("Anger Abbot Langley.", "Abbot Langley", new WorldPoint(3058, 3487, 0), "Speak to Abbot Langley in the Edgeville Monastery while you have a negative prayer bonus (currently only possible with an Ancient staff)."),
new CrypticClue("Dig where only the skilled, the wealthy, or the brave can choose not to visit again.", new WorldPoint(3221, 3219, 0), "Dig at Lumbridge spawn"),
new CrypticClue("Scattered coins and gems fill the floor. The chest you seek is in the north east.", "King Black Dragon", CLOSED_CHEST_375, new WorldPoint(2288, 4702, 0), "Kill the King Black Dragon for a key (elite), and then open the closed chest in the NE corner of the lair."),
new CrypticClue("A ring of water surrounds 4 powerful rings, dig above the ladder located there.", new WorldPoint(1910, 4367, 0), "Dig by the ladder leading to the Dagannoth Kings room in the Waterbirth Island Dungeon."),
@@ -229,7 +229,7 @@ public class CrypticClue extends ClueScroll implements TextClueScroll, NpcClueSc
new CrypticClue("Dig under Razorlor's toad batta.", new WorldPoint(3139, 4554, 0), "Dig on the toad batta spawn in Tarn's Lair."),
new CrypticClue("Talk to Cassie in Falador.", "Cassie", new WorldPoint(2975, 3383, 0), "Cassie is found just south-east of the northern Falador gate."),
new CrypticClue("Faint sounds of 'Arr', fire giants found deep, the eastern tip of a lake, are the rewards you could reap.", new WorldPoint(3055, 10338, 0), "Dig south of the pillar at the end of the Deep Wilderness Dungeon."),
new CrypticClue("If you're feeling brave, dig beneath the dragon's eye.", new WorldPoint(2410, 4714, 0), "Dig below the mossy rock under the Viyeldi caves."),
new CrypticClue("If you're feeling brave, dig beneath the dragon's eye.", new WorldPoint(2410, 4714, 0), "Dig below the mossy rock under the Viyeldi caves (Legend's Quest). Items needed: Pickaxe, unpowered orb, lockpick, spade, and any charge orb spell."),
new CrypticClue("Search the tents in the Imperial Guard camp in Burthorpe for some boxes.", BOXES_3686, new WorldPoint(2885, 3540, 0), "Search in the tents in northwest corner of the camp."),
new CrypticClue("A dwarf, approaching death, but very much in the light.", "Thorgel", new WorldPoint(1863, 4639, 0), "Thorgel at the entrance to the Death altar"),
new CrypticClue("You must be 100 to play with me.", "Squire (Veteran)", new WorldPoint(2638, 2656, 0), "Speak to the Veteran boat squire at Pest Control"),
@@ -273,7 +273,7 @@ public class CrypticClue extends ClueScroll implements TextClueScroll, NpcClueSc
new CrypticClue("Belladonna, my dear. If only I had gloves, then I could hold you at last.", "Tool Leprechaun", new WorldPoint(3088, 3357, 0), "Talk to Tool Leprechaun at Draynor Manor"),
new CrypticClue("Impossible to make angry", "Abbot Langley", new WorldPoint(3059, 3486, 0), "Speak to Abbot Langley at the Edgeville Monastery."),
new CrypticClue("Search the crates in Horvik's armoury.", CRATE_5106, new WorldPoint(3228, 3433, 0), "Horvik's in Varrock"),
new CrypticClue("Ghommal wishes to be impressed by how strong your equipment is.", "Ghommal", new WorldPoint(2878, 3546, 0), "Talk to Ghommal at the Warriors' Guild while wearing sufficiently strong equipment"),
new CrypticClue("Ghommal wishes to be impressed by how strong your equipment is.", "Ghommal", new WorldPoint(2878, 3546, 0), "Speak to Ghommal at the Warriors' Guild with a total Melee Strength bonus of over 100."),
new CrypticClue("Shhhh!", "Logosia", new WorldPoint(1633, 3808, 0), "Speak to Logosia in the Arceuus House Library's ground floor."),
new CrypticClue("Salty peter.", "Konoo", new WorldPoint(1703, 3524, 0), "Talk to Konoo who is digging saltpeter in the Hosidius district in Zeah."),
new CrypticClue("Talk to Zeke in Al Kharid.", "Zeke", new WorldPoint(3287, 3190, 0), "Zeke is the owner of the scimitar shop in Al Kharid."),
@@ -288,11 +288,11 @@ public class CrypticClue extends ClueScroll implements TextClueScroll, NpcClueSc
new CrypticClue("Speak to Ellis in Al Kharid.", "Ellis", new WorldPoint(3276, 3191, 0), "Ellis is tanner just north of Al Kharid bank."),
new CrypticClue("Search the chests in the Dwarven Mine.", CLOSED_CHEST_375, new WorldPoint(3000, 9798, 0), "The chest is on the western wall, where Hura's Crossbow Shop is, in the Dwarven Mine."),
new CrypticClue("In a while...", null, "Kill a crocodile."),
new CrypticClue("A chisel and hammer reside in his home, strange for one of magic. Impress him with your magical equipment.", "Wizard Cromperty", new WorldPoint(2682, 3325, 0), "Wizard Cromperty NE, East Ardougne. +100 magic attack bonus needed"),
new CrypticClue("A chisel and hammer reside in his home, strange for one of magic. Impress him with your magical equipment.", "Wizard Cromperty", new WorldPoint(2682, 3325, 0), "Wizard Cromperty, NE corner of East Ardougne. +100 magic attack bonus needed"),
new CrypticClue("You have all of the elements available to solve this clue. Fortunately you do not have to go as far as to stand in a draft.", CRATE_18506, new WorldPoint(2723, 9891, 0), "Search the crate, west of the Air Elementals, inside the Elemental Workshop."),
new CrypticClue("A demon's best friend holds the next step of this clue.", null, "Kill a hellhound."),
new CrypticClue("Dig in the centre of a great city of 5 districts.", new WorldPoint(1639, 3673, 0), "Dig in front of the large statue in the centre of Great Kourend."),
new CrypticClue("Hopefully this set of armor will help you to keep surviving.", "Sir Vyvin", new WorldPoint(2982, 3336, 2), "Speak to Sir Vyvin while wearing a white full helm, platebody, and platelegs."),
new CrypticClue("Hopefully this set of armour will help you to keep surviving.", "Sir Vyvin", new WorldPoint(2982, 3336, 2), "Speak to Sir Vyvin while wearing a white full helm, platebody, and platelegs."),
new CrypticClue("The beasts retreat, for their Queen is gone; the song of this town still plays on. Dig near the birthplace of a blade, be careful not to melt your spade.", new WorldPoint(2342, 3677, 0), "Dig in front of the small furnace in the Piscatoris Fishing Colony."),
new CrypticClue("Darkness wanders around me, but fills my mind with knowledge.", "Biblia", new WorldPoint(1633, 3825, 2), "Speak to Biblia on the Arceuus House Library's top floor."),
new CrypticClue("I would make a chemistry joke, but I'm afraid I wouldn't get a reaction.", "Chemist", new WorldPoint(2932, 3212, 0), "Talk to the Chemist in Rimmington"),
@@ -432,4 +432,14 @@ public class CrypticClue extends ClueScroll implements TextClueScroll, NpcClueSc
return null;
}
public int[] getObjectIds()
{
return new int[] {objectId};
}
public String[] getNpcs()
{
return new String[] {npc};
}
}

View File

@@ -84,9 +84,9 @@ public class HotColdClue extends ClueScroll implements LocationClueScroll, Locat
}
@Override
public List<WorldPoint> getLocations()
public WorldPoint[] getLocations()
{
return Lists.transform(digLocations, HotColdLocation::getWorldPoint);
return Lists.transform(digLocations, HotColdLocation::getWorldPoint).toArray(new WorldPoint[0]);
}
@Override
@@ -232,7 +232,6 @@ public class HotColdClue extends ClueScroll implements LocationClueScroll, Locat
}
}
@Override
public boolean update(final String message, final ClueScrollPlugin plugin)
{
if (!message.startsWith("The device is"))
@@ -407,4 +406,9 @@ public class HotColdClue extends ClueScroll implements LocationClueScroll, Locat
this.location = wp;
reset();
}
public String[] getNpcs()
{
return new String[] {npc};
}
}

View File

@@ -24,15 +24,11 @@
*/
package net.runelite.client.plugins.cluescrolls.clues;
import java.util.List;
import net.runelite.api.coords.WorldPoint;
import net.runelite.client.plugins.cluescrolls.ClueScrollPlugin;
public interface LocationsClueScroll
{
boolean update(String message, ClueScrollPlugin plugin);
void reset();
List<WorldPoint> getLocations();
WorldPoint[] getLocations();
}

View File

@@ -213,4 +213,9 @@ public class MapClue extends ClueScroll implements ObjectClueScroll
return null;
}
public int[] getObjectIds()
{
return new int[] {objectId};
}
}

View File

@@ -26,5 +26,5 @@ package net.runelite.client.plugins.cluescrolls.clues;
public interface NpcClueScroll
{
String getNpc();
String[] getNpcs();
}

View File

@@ -26,5 +26,5 @@ package net.runelite.client.plugins.cluescrolls.clues;
public interface ObjectClueScroll extends LocationClueScroll
{
int getObjectId();
int[] getObjectIds();
}

View File

@@ -0,0 +1,199 @@
/*
* Copyright (c) 2018, Eadgars Ruse <https://github.com/Eadgars-Ruse>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.client.plugins.cluescrolls.clues;
import java.awt.Dimension;
import java.awt.Graphics2D;
import java.util.AbstractMap;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.stream.Stream;
import lombok.Getter;
import net.runelite.api.Client;
import net.runelite.api.InventoryID;
import net.runelite.api.Item;
import static net.runelite.api.ItemID.TORN_CLUE_SCROLL_PART_1;
import static net.runelite.api.ItemID.TORN_CLUE_SCROLL_PART_2;
import static net.runelite.api.ItemID.TORN_CLUE_SCROLL_PART_3;
import net.runelite.api.coords.WorldPoint;
import net.runelite.api.events.ItemContainerChanged;
import net.runelite.client.game.ItemManager;
import static net.runelite.client.plugins.cluescrolls.ClueScrollOverlay.TITLED_CONTENT_COLOR;
import net.runelite.client.plugins.cluescrolls.ClueScrollPlugin;
import net.runelite.client.ui.overlay.components.LineComponent;
import net.runelite.client.ui.overlay.components.PanelComponent;
import net.runelite.client.ui.overlay.components.TitleComponent;
@Getter
public class ThreeStepCrypticClue extends ClueScroll implements TextClueScroll, ObjectClueScroll, NpcClueScroll, LocationsClueScroll
{
private static final int CLUE_STEPS = 3;
private List<Map.Entry<CrypticClue, Boolean>> clueSteps;
private int[] objectIds;
private WorldPoint[] locations;
private String[] npcs;
private String text;
private ThreeStepCrypticClue(List<Map.Entry<CrypticClue, Boolean>> steps, String text)
{
final int numClueSteps = steps.size();
this.clueSteps = steps;
this.text = text;
this.locations = new WorldPoint[numClueSteps];
this.npcs = new String[numClueSteps];
this.objectIds = new int[numClueSteps];
for (int i = 0; i < numClueSteps; i++)
{
CrypticClue c = clueSteps.get(i).getKey();
locations[i] = c.getLocation();
npcs[i] = c.getNpc();
objectIds[i] = c.getObjectId();
}
}
@Override
public void makeOverlayHint(PanelComponent panelComponent, ClueScrollPlugin plugin)
{
panelComponent.setPreferredSize(new Dimension(200, 0));
for (int i = 0; i < CLUE_STEPS; i++)
{
Map.Entry<CrypticClue, Boolean> e = clueSteps.get(i);
if (!e.getValue())
{
CrypticClue c = e.getKey();
panelComponent.getChildren().add(TitleComponent.builder().text("Cryptic Clue #" + (i + 1)).build());
panelComponent.getChildren().add(LineComponent.builder().left("Solution:").build());
panelComponent.getChildren().add(LineComponent.builder()
.left(c.getSolution())
.leftColor(TITLED_CONTENT_COLOR)
.build());
}
}
}
@Override
public void makeWorldOverlayHint(Graphics2D graphics, ClueScrollPlugin plugin)
{
for (Map.Entry<CrypticClue, Boolean> e : clueSteps)
{
if (!e.getValue())
{
e.getKey().makeWorldOverlayHint(graphics, plugin);
}
}
}
public void checkForParts(Client client, final ItemContainerChanged event, ItemManager itemManager)
{
if (event.getItemContainer() == client.getItemContainer(InventoryID.INVENTORY))
{
checkForPart(event, itemManager, TORN_CLUE_SCROLL_PART_1, 0);
checkForPart(event, itemManager, TORN_CLUE_SCROLL_PART_2, 1);
checkForPart(event, itemManager, TORN_CLUE_SCROLL_PART_3, 2);
}
}
private void checkForPart(final ItemContainerChanged event, ItemManager itemManager, int clueScrollPart, int index)
{
final Stream<Item> items = Arrays.stream(event.getItemContainer().getItems());
// If we have the part then that step is done
if (items.anyMatch(item -> itemManager.getItemComposition(item.getId()).getId() == clueScrollPart))
{
clueSteps.get(index).setValue(true);
}
}
@Override
public void reset()
{
this.locations = new WorldPoint[] {};
}
public static ThreeStepCrypticClue forText(String plainText, String text)
{
List<Map.Entry<CrypticClue, Boolean>> steps = new ArrayList<>(CLUE_STEPS);
StringBuilder threeStepText = new StringBuilder(text.replaceAll("<br><br>", " ").toLowerCase());
boolean stepDone;
for (int i = 0; i < CLUE_STEPS; i++)
{
// if text has <str> - strikethrough - tag then it is already done
stepDone = threeStepText.toString().startsWith("<str>");
if (stepDone)
{
// chop off <str> tag
threeStepText.delete(0, 5);
}
for (CrypticClue clue : CrypticClue.CLUES)
{
if (threeStepText.toString().startsWith(clue.getText().toLowerCase()))
{
if (stepDone)
{
steps.add(new AbstractMap.SimpleEntry<>(clue, true));
// chop off </str> tag
threeStepText.delete(0, 6);
}
else
{
steps.add(new AbstractMap.SimpleEntry<>(clue, false));
}
if (i < CLUE_STEPS - 1)
{
// chop off the length of the clue text plus a space
threeStepText.delete(0, clue.getText().length() + 1);
}
break;
}
}
}
if (steps.isEmpty())
{
return null;
}
return new ThreeStepCrypticClue(steps, plainText);
}
@Override
public WorldPoint getLocation()
{
return null;
}
}