clues: highlight the last clue's STASH until items are deposited back

This commit is contained in:
Hydrox6
2021-04-26 13:49:36 +01:00
committed by Adam
parent 94685b6ef4
commit aa44339769
4 changed files with 93 additions and 3 deletions

View File

@@ -33,10 +33,12 @@ import com.google.inject.testing.fieldbinder.BoundFieldModule;
import net.runelite.api.ChatMessageType;
import net.runelite.api.Client;
import net.runelite.api.NPC;
import net.runelite.api.NullObjectID;
import net.runelite.api.Player;
import net.runelite.api.coords.WorldPoint;
import net.runelite.api.events.ChatMessage;
import net.runelite.api.events.GameTick;
import net.runelite.api.events.MenuOptionClicked;
import net.runelite.api.widgets.Widget;
import net.runelite.api.widgets.WidgetInfo;
import net.runelite.client.game.ItemManager;
@@ -45,6 +47,8 @@ import net.runelite.client.plugins.cluescrolls.clues.hotcold.HotColdLocation;
import net.runelite.client.ui.overlay.OverlayManager;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -168,4 +172,47 @@ public class ClueScrollPluginTest
verify(client, times(++clueSetupHintArrowClears)).clearHintArrow();
verify(client, times(1)).setHintArrow(any(WorldPoint.class));
}
@Test
public void testSTASHMarkerPersistence()
{
when(client.getCachedNPCs()).thenReturn(new NPC[] {});
// Set up emote clue
final Widget clueWidget = mock(Widget.class);
when(clueWidget.getText()).thenReturn("Spin in the Varrock Castle courtyard. Equip a black axe, a coif and a ruby ring.");
when(client.getWidget(WidgetInfo.CLUE_SCROLL_TEXT)).thenReturn(clueWidget);
plugin.onGameTick(new GameTick());
// Simulate clicking on the STASH
MenuOptionClicked menuOptionClicked = new MenuOptionClicked();
menuOptionClicked.setMenuOption("Search");
menuOptionClicked.setMenuTarget("<col=ffff>STASH unit (easy)");
menuOptionClicked.setId(NullObjectID.NULL_28983);
plugin.onMenuOptionClicked(menuOptionClicked);
// Check that the STASH is stored after withdrawing
ChatMessage withdrawMessage = new ChatMessage();
withdrawMessage.setType(ChatMessageType.GAMEMESSAGE);
withdrawMessage.setMessage("You withdraw your items from the STASH unit.");
plugin.onChatMessage(withdrawMessage);
assertNotNull(plugin.getActiveSTASHClue());
// Complete the step and get a new step, check that the clue is stored for rendering
when(clueWidget.getText()).thenReturn("Talk to the bartender of the Rusty Anchor in Port Sarim.");
plugin.onGameTick(new GameTick());
assertNotNull(plugin.getActiveSTASHClue());
// Simulate depositing the emote items, make sure it's cleared the stored clue
ChatMessage depositMessage = new ChatMessage();
depositMessage.setType(ChatMessageType.GAMEMESSAGE);
depositMessage.setMessage("You deposit your items into the STASH unit.");
plugin.onChatMessage(depositMessage);
assertNull(plugin.getActiveSTASHClue());
// Make sure that the STASH won't get re-marked if it's not part of the active clue.
plugin.onMenuOptionClicked(menuOptionClicked);
plugin.onChatMessage(withdrawMessage);
assertNull(plugin.getActiveSTASHClue());
}
}