aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor
diff options
context:
space:
mode:
authorsyeyoung <cyong06@naver.com>2021-07-18 18:02:44 +0900
committersyeyoung <cyong06@naver.com>2021-07-18 18:02:44 +0900
commita9e35133d52e271b70a06d77747cfbe867e065e3 (patch)
tree9543c11362a3da9e35274a79e1120c24e966176f /src/main/java/kr/syeyoung/dungeonsguide/roomprocessor
parentbceb0858a8215dad1f70342035e26ac45b9d970d (diff)
downloadSkyblock-Dungeons-Guide-a9e35133d52e271b70a06d77747cfbe867e065e3.tar.gz
Skyblock-Dungeons-Guide-a9e35133d52e271b70a06d77747cfbe867e065e3.tar.bz2
Skyblock-Dungeons-Guide-a9e35133d52e271b70a06d77747cfbe867e065e3.zip
Move trivia answers to DG Backend StaticResource API (TM)
Also Move Dungeon Bonus Score to that
Diffstat (limited to 'src/main/java/kr/syeyoung/dungeonsguide/roomprocessor')
-rwxr-xr-xsrc/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorTrivia.java87
1 files changed, 27 insertions, 60 deletions
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorTrivia.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorTrivia.java
index 47c7e4ac..148dfbb9 100755
--- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorTrivia.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorTrivia.java
@@ -25,10 +25,12 @@ import kr.syeyoung.dungeonsguide.features.FeatureRegistry;
import kr.syeyoung.dungeonsguide.utils.RenderUtils;
import kr.syeyoung.dungeonsguide.utils.SkyblockUtils;
import kr.syeyoung.dungeonsguide.utils.TextUtils;
+import kr.syeyoung.dungeonsguide.wsresource.StaticResourceCache;
import net.minecraft.client.Minecraft;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.IChatComponent;
import org.apache.commons.lang3.math.NumberUtils;
+import org.json.JSONObject;
import java.awt.*;
import java.io.IOException;
@@ -41,54 +43,12 @@ public class RoomProcessorTrivia extends GeneralRoomProcessor {
public RoomProcessorTrivia(DungeonRoom dungeonRoom) {
super(dungeonRoom);
-// for (Map.Entry<String, String[]> answer : answers.entrySet()) {
-// StringBuilder sb = new StringBuilder();
-// for (String s : answer.getValue()) {
-// sb.append(s).append(',');
-// }
-// dungeonRoom.getDungeonRoomInfo().getProperties().put(answer.getKey(), sb.toString());
-// }
}
private final List<String> questionDialog = new ArrayList<String>();
private boolean questionDialogStart = false;
-// private static final Map<String, String[]> answers = new HashMap<String,String[]>() {{
-// put("what is the status of the watcher?", new String[]{"stalker"});
-// put("what is the status of bonzo?", new String[]{"new necromancer"});
-// put("what is the status of scarf?", new String[]{"apprentice necromancer"});
-// put("what is the status of the professor?", new String[]{"professor"});
-// put("what is the status of thorn?", new String[]{"shaman necromancer"});
-// put("what is the status of livid?", new String[]{"master necromancer"});
-// put("what is the status of sadan?", new String[]{"necromancer lord"});
-// put("what is the status of maxor?", new String[]{"young wither"});
-// put("what is the status of goldor?", new String[]{"wither soldier"});
-// put("what is the status of storm?", new String[]{"elementalist"});
-// put("what is the status of necron?", new String[]{"wither lord"});
-// put("how many total fairy souls are there?", new String[]{"209 fairy souls"});
-// put("how many fairy souls are there in spider's den?", new String[]{"17"});
-// put("how many fairy souls are there in the end?", new String[]{"12"});
-// put("how many fairy souls are there in the barn?", new String[]{"7"});
-// put("how many fairy souls are there in mushroom desert?", new String[]{"8"});
-// put("how many fairy souls are there in blazing fortress?", new String[]{"19"});
-// put("how many fairy souls are there in the park?", new String[]{"11"});
-// put("how many fairy souls are there in jerry's workshop?", new String[]{"5"});
-// put("how many fairy souls are there in the hub?", new String[]{"79"});
-// put("how many fairy souls are there in deep caverns?", new String[]{"21"});
-// put("how many fairy souls are there in gold mine?", new String[]{"12"});
-// put("how many fairy souls are there in dungeon hub?", new String[]{"7"});
-// put("which brother is on the spider's den?", new String[]{"rick"});
-// put("what is the name of rick's brother?", new String[]{"pat"});
-// put("what is the name of the painter in the hub?", new String[]{"marco"});
-// put("what is the name of the person that upgrades pets?", new String[]{"kat"});
-// put("what is the name of the lady of the nether?", new String[]{"elle"});
-// put("which villager in the village gives you a rogue sword?", new String[]{"jamie"});
-// put("how many unique minions are there?", new String[]{"52"});
-// put("which of these enemies does not spawn in the spider's den?", new String[]{"zombie spider","cave spider","broodfather"});
-// put("which of these monsters only spawns at night?", new String[]{"zombie villager","ghast"});
-// put("which of these is not a dragon in the end?", new String[]{"zoomer dragon","weak dragon","stonk dragon","holy dragon","boomer dragon","stable dragon"});
-// }};
@Override
public void chatReceived(IChatComponent chat) {
super.chatReceived(chat);
@@ -113,15 +73,8 @@ public class RoomProcessorTrivia extends GeneralRoomProcessor {
String answerA = getAnswer(questionDialog.get(2));
String answerB = getAnswer(questionDialog.get(3));
String answerC = getAnswer(questionDialog.get(4));
- String theRealAnswer = match(question, answerA, answerB, answerC);
-
- if (theRealAnswer == null)
- Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("§eDungeons Guide §7:: §eTrivia §7:: §cCouldn't determine the answer! (no question found)"));
- else if (theRealAnswer.length() >1)
- Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("§eDungeons Guide §7:: §eTrivia §7:: §cCouldn't determine the answer! ("+theRealAnswer+")"));
- else
- Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("§eDungeons Guide §7:: §eTrivia §7:: "+theRealAnswer+"§f is the correct answer!"));
- correctAnswer = theRealAnswer;
+ match(question, answerA, answerB, answerC);
+
}
String correctAnswer;
@@ -131,15 +84,29 @@ public class RoomProcessorTrivia extends GeneralRoomProcessor {
if (!matcher.matches()) return "";
return matcher.group(1);
}
- private String match(String question, String a, String b, String c) {
- String semi_answers = (String) getDungeonRoom().getDungeonRoomInfo().getProperties().get(question.toLowerCase().trim());
- if (semi_answers == null) return null;
- semi_answers = takeCareOfPlaceHolders(semi_answers);
- String[] answers = semi_answers.split(",");
- if (match(answers, a)) return "A";
- if (match(answers, b)) return "B";
- if (match(answers, c)) return "C";
- return semi_answers;
+ private void match(String question, String a, String b, String c) {
+ StaticResourceCache.INSTANCE.getResource(StaticResourceCache.TRIVIA_ANSWERS).thenAccept(value -> {
+ JSONObject answersJSON = new JSONObject(value.getValue());
+
+ String semi_answers = answersJSON.getString(question.toLowerCase().trim());
+ String theRealAnswer;
+ if (semi_answers == null) theRealAnswer = null;
+ else {
+ semi_answers = takeCareOfPlaceHolders(semi_answers);
+ String[] answers = semi_answers.split(",");
+ if (match(answers, a)) theRealAnswer = "A";
+ else if (match(answers, b)) theRealAnswer = "B";
+ else if (match(answers, c)) theRealAnswer = "C";
+ else theRealAnswer = semi_answers;
+ }
+ if (theRealAnswer == null)
+ Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("§eDungeons Guide §7:: §eTrivia §7:: §cCouldn't determine the answer! (no question found)"));
+ else if (theRealAnswer.length() >1)
+ Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("§eDungeons Guide §7:: §eTrivia §7:: §cCouldn't determine the answer! ("+theRealAnswer+")"));
+ else
+ Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("§eDungeons Guide §7:: §eTrivia §7:: "+theRealAnswer+"§f is the correct answer!"));
+ correctAnswer = theRealAnswer;
+ });
}
private String takeCareOfPlaceHolders(String input) {