Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ test {
}

group = 'randomeventhelper'
version = '2.5.6'
version = '2.5.7'

tasks.withType(JavaCompile).configureEach {
options.encoding = 'UTF-8'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,13 @@ private Map<RelationshipType, Set<RandomEventItem>> initializeRelationships()
RandomEventItem.KITESHIELD, RandomEventItem.WOODEN_SHIELD
));

map.put(RelationshipType.MELEE_GEAR, Set.of(
RandomEventItem.BATTLE_AXE, RandomEventItem.LONGSWORD, RandomEventItem.MACE,
RandomEventItem.SCIMITAR, RandomEventItem.FULL_HELM, RandomEventItem.MED_HELM, RandomEventItem.PLATEBODY,
RandomEventItem.PLATELEGS, RandomEventItem.SQUARE_SHIELD_1, RandomEventItem.SQUARE_SHIELD_2,
RandomEventItem.KITESHIELD, RandomEventItem.WOODEN_SHIELD
));

map.put(RelationshipType.JEWELRY_ACCESSORIES, Set.of(
RandomEventItem.NECKLACE, RandomEventItem.RING, RandomEventItem.HOLY_SYMBOL,
RandomEventItem.CAPE_OF_LEGENDS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ public enum RandomEventItem
WATERMELON_SLICE(41156),
WATER_RUNE(41231),
BONES(2674),

KEY(29232);

private final int modelID;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,20 @@ public enum RelationshipType
CONTAINER_STORAGE("container, storage, bottle, jug, pot, holding"),

// Thematic groups
PIRATE_THEME("pirate, sea, nautical, hook, eyepatch, boots, hat, yarr, crime"),
ENTERTAINMENT_THEME("entertainment, performance, jester, mime, mask, fun, clown, fool, mask, face"),
PIRATE_THEME("pirate, sea, nautical, hook, eyepatch, boots, hat, yarr, crime, strange"),
ENTERTAINMENT_THEME("entertainment, performance, jester, mime, mask, fun, clown, fool, mask, face, strange"),
PROFESSIONAL_THEME("profession, work, chef, trade, job, occupation"),

// Equipment categories
MELEE_WEAPONS("melee, sword, axe, mace, scimitar, close, combat, sharp"),
RANGED_WEAPONS("ranged, bow, crossbow, arrows, ammunition, distance, sharp"),
MAGIC_RUNES("runes, elemental, air, earth, fire, water, magic, abracadabra, hocus pocus"),
HEAD_ARMOR("head, helmet, hat, protection, headwear, skull, mask"),
HEAD_ARMOR("head, helmet, hat, protection, headwear, skull, mask, headgear"),
BODY_ARMOR("body, chest, torso, platebody, apron, protection"),
LEG_ARMOR("legs, platelegs, protection, lower, body"),
FOOT_ARMOR("feet, boots, footwear, walking, protection"),
SHIELDS("shield, defense, blocking, protection, guard"),
MELEE_GEAR("melee, sword, scimitar, axe, mace, combat, sharp, helmet, platebody, platelegs, shield"),
JEWELRY_ACCESSORIES("jewelry, accessories, necklace, ring, cape, status"),
FACE_ACCESSORIES("face, mask, eyepatch, hook, covering, facial"),

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ public class SurpriseExamHelper
@Inject
private SurpriseExamOverlay overlay;

private String patternCardHint;

@Getter
private ImmutableSet<RandomEventItem> patternCardAnswers;

Expand Down Expand Up @@ -113,6 +115,7 @@ public void startUp()
{
this.eventBus.register(this);
this.overlayManager.add(overlay);
this.patternCardHint = null;
this.patternCardAnswers = null;
this.patternCardAnswerWidgets = null;
this.patternNextAnswer = null;
Expand All @@ -124,6 +127,7 @@ public void shutDown()
{
this.eventBus.unregister(this);
this.overlayManager.remove(overlay);
this.patternCardHint = null;
this.patternCardAnswers = null;
this.patternCardAnswerWidgets = null;
this.patternNextAnswer = null;
Expand All @@ -140,13 +144,13 @@ public void onWidgetLoaded(WidgetLoaded widgetLoaded)
Widget examHintWidget = this.client.getWidget(InterfaceID.PatternCards.HINT);
if (examHintWidget != null)
{
String examHint = examHintWidget.getText();
log.debug("Exam hint widget loaded with text: {}", examHint);
if (examHint != null && !examHint.isEmpty())
this.patternCardHint = examHintWidget.getText();
log.debug("Exam hint widget loaded with text: {}", this.patternCardHint);
if (this.patternCardHint != null && !this.patternCardHint.isEmpty())
{
log.debug("Exam available pattern card items: {}", this.getPatternCardMap().values().asList());
List<RandomEventItem> answerItems = this.relationshipSystem.findItemsByHint(examHint, this.getPatternCardMap().values().asList(), 3);
log.debug("Found answer items for exam hint '{}': {}", examHint, answerItems);
List<RandomEventItem> answerItems = this.relationshipSystem.findItemsByHint(this.patternCardHint, this.getPatternCardMap().values().asList(), 3);
log.debug("Found answer items for exam hint '{}': {}", this.patternCardHint, answerItems);
if (answerItems.size() >= 3)
{
this.patternCardAnswers = ImmutableSet.copyOf(answerItems);
Expand All @@ -167,14 +171,15 @@ public void onWidgetLoaded(WidgetLoaded widgetLoaded)
}
else
{
log.warn("Found {} items for exam hint '{}', expected 3.", answerItems.size(), examHint);
log.warn("Found {} items for exam hint '{}', expected 3.", answerItems.size(), this.patternCardHint);
this.patternCardAnswers = null;
this.patternCardAnswerWidgets = null;
}
}
else
{
log.warn("Exam hint widget text is empty or null.");
this.patternCardHint = null;
this.patternCardAnswers = null;
this.patternCardAnswerWidgets = null;
}
Expand Down Expand Up @@ -228,6 +233,7 @@ public void onWidgetClosed(WidgetClosed widgetClosed)
if (widgetClosed.getGroupId() == InterfaceID.PATTERN_CARDS)
{
log.debug("Pattern cards widget closed, resetting pattern card answers.");
this.patternCardHint = null;
this.patternCardAnswers = null;
this.patternCardAnswerWidgets = null;
}
Expand All @@ -246,6 +252,7 @@ public void onNpcDespawned(NpcDespawned npcDespawned)
if (npcDespawned.getNpc().getId() == NpcID.PATTERN_TEACHER)
{
log.debug("Mr. Mordaut NPC despawned, resetting all answers.");
this.patternCardHint = null;
this.patternCardAnswers = null;
this.patternCardAnswerWidgets = null;
this.patternNextAnswer = null;
Expand All @@ -259,6 +266,9 @@ public void onCommandExecuted(CommandExecuted executedCommand)
if (executedCommand.getCommand().equalsIgnoreCase("exportexampuzzle"))
{
StringBuilder sb = new StringBuilder();
sb.append("Pattern Card Matching Hint: ");
sb.append(this.patternCardHint != null ? this.patternCardHint : "NULL");
sb.append("\n");
sb.append("Pattern Card Matching Available Items: ");
sb.append(this.getPatternCardMap() != null ? this.getPatternCardMap().values().asList().toString() : "NULL");
sb.append("\n");
Expand Down
16 changes: 16 additions & 0 deletions src/test/java/randomeventhelper/RelationshipSystemTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@ public void testPatternMatching()
);
List<RandomEventItem> puzzle1ActualItems = relationshipSystem.findItemsByHint(puzzle1.getHint(), puzzle1.getGivenItems(), 3).subList(0, 3);
Assertions.assertThat(puzzle1ActualItems).containsExactlyInAnyOrderElementsOf(puzzle1.getExpectedMatchingItems());

RelationshipSystemTestMatchingData puzzle2 = new RelationshipSystemTestMatchingData(
"Some professions use such strange headgear.",
"[CAKE (41202), TROUT_COD_PIKE_SALMON_4 (41217), SHARK (41166), ARROWS (41177), TINDERBOX (41154), HERRING_OR_MACKEREL (41193), PLATELEGS (41179), ORE (41170), LEDERHOSEN_HAT (41164), LONGSWORD (41150), BONES (2674), POT (41223), PIRATE_HAT (41187), JESTER_HAT (41196), AXE (41184)]",
List.of(RandomEventItem.LEDERHOSEN_HAT, RandomEventItem.PIRATE_HAT, RandomEventItem.JESTER_HAT)
);
List<RandomEventItem> puzzle2ActualItems = relationshipSystem.findItemsByHint(puzzle2.getHint(), puzzle2.getGivenItems(), 3).subList(0, 3);
Assertions.assertThat(puzzle2ActualItems).containsExactlyInAnyOrderElementsOf(puzzle2.getExpectedMatchingItems());
}

@Test
Expand All @@ -35,6 +43,14 @@ public void testNextMissingItem()
);
RandomEventItem puzzle1ActualNextMissingItem = relationshipSystem.findMissingItem(puzzle1.getInitialSequenceItems(), puzzle1.getItemChoices());
Assertions.assertThat(puzzle1ActualNextMissingItem).isEqualTo(puzzle1.getExpectedNextMissingItem());

RelationshipSystemTestNextMissingItemData puzzle2 = new RelationshipSystemTestNextMissingItemData(
"[LONGSWORD (41150), FULL_HELM (41178), KITESHIELD (41200)]",
"[EARTH_RUNE (41157), BAR (41153), PLATEBODY (27094), CAKE (41202)]",
RandomEventItem.PLATEBODY
);
RandomEventItem puzzle2ActualNextMissingItem = relationshipSystem.findMissingItem(puzzle2.getInitialSequenceItems(), puzzle2.getItemChoices());
Assertions.assertThat(puzzle2ActualNextMissingItem).isEqualTo(puzzle2.getExpectedNextMissingItem());
}

@Data
Expand Down