aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/ProcessorFactory.java1
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorBoxSolver.java70
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorTrivia.java133
3 files changed, 173 insertions, 31 deletions
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/ProcessorFactory.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/ProcessorFactory.java
index df8f6cbc..33196531 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/ProcessorFactory.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/ProcessorFactory.java
@@ -36,5 +36,6 @@ public class ProcessorFactory {
registerRoomProcessor("puzzle_silverfish", new RoomProcessorIcePath.Generator()); // done
registerRoomProcessor("puzzle_icefill", new RoomProcessorIcePath2.Generator());
registerRoomProcessor("puzzle_box", new RoomProcessorBoxSolver.Generator());
+ registerRoomProcessor("puzzle_trivia", new RoomProcessorTrivia.Generator());
}
}
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorBoxSolver.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorBoxSolver.java
index 7287c8b2..7206352b 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorBoxSolver.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorBoxSolver.java
@@ -123,57 +123,65 @@ public class RoomProcessorBoxSolver extends GeneralRoomProcessor {
return true;
}
+ private int lastPlayerY = 0;
+ private Point lastPlayer = null;
+
@Override
public void tick() {
super.tick();
if (bugged) return;
-// boolean calculate = lastboard == null;
byte[][] currboard = buildCurrentState();
-// if (!calculate) {
-// label:
-// for (int y = 0; y < 6; y ++) {
-// for (int x = 0; x < 7; x++)
-// if (currboard[y][x] != lastboard[y][x]) {
-// calculate = true;
-// break label;
-// }
-// }
-// }
-//
- if (Minecraft.getMinecraft().thePlayer.getPosition().getY() < 68) {
- Point playerPos = getPlayerPos();
- try {
- solution = solve(currboard, playerPos.x, playerPos.y);
- if (solution != null)
- solution.addFirst(new Move(playerPos.x, playerPos.y));
- } catch (Error e) {
- e.printStackTrace();
+ Point playerPos = getPlayerPos(currboard);
+ boolean calculate = lastboard == null || lastPlayerY != Minecraft.getMinecraft().thePlayer.getPosition().getY() || (Minecraft.getMinecraft().thePlayer.getPosition().getY() < 68 && !playerPos.equals(lastPlayer));
+ if (!calculate) {
+ label:
+ for (int y = 0; y < 6; y ++) {
+ for (int x = 0; x < 7; x++)
+ if (currboard[y][x] != lastboard[y][x]) {
+ calculate = true;
+ break label;
+ }
}
- } else {
- for (int i = 0; i < 7; i++) {
- if (currboard[5][i] == 0) {
- try {
- solution = solve(currboard, i, 5);
- if (solution != null) {
- solution.addFirst(new Move(i, 5));
- break;
+ }
+ if (calculate) {
+ if (Minecraft.getMinecraft().thePlayer.getPosition().getY() < 68) {
+ try {
+ solution = solve(currboard, playerPos.x, playerPos.y);
+ if (solution != null)
+ solution.addFirst(new Move(playerPos.x, playerPos.y));
+ } catch (Error e) {
+ e.printStackTrace();
+ }
+ } else {
+ for (int i = 0; i < 7; i++) {
+ if (currboard[5][i] == 0) {
+ try {
+ solution = solve(currboard, i, 5);
+ if (solution != null) {
+ solution.addFirst(new Move(i, 5));
+ break;
+ }
+ } catch (Error e) {
+ e.printStackTrace();
}
- } catch (Error e) {
- e.printStackTrace();
}
}
}
}
+ lastPlayerY = Minecraft.getMinecraft().thePlayer.getPosition().getY();
+ lastPlayer = playerPos;
+ lastboard = currboard;
}
private LinkedList<Action> solution;
- public Point getPlayerPos() {
+ public Point getPlayerPos(byte[][] map) {
BlockPos playerPos = Minecraft.getMinecraft().thePlayer.getPosition();
int minDir = Integer.MAX_VALUE;
Point pt = null;
for (int y = 0; y < poses.length; y++) {
for (int x = 0; x < poses[0].length; x++) {
+ if (map[y][x] == 1) continue;
int dir = (int) poses[y][x].distanceSq(playerPos);
if (dir < minDir) {
minDir = dir;
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorTrivia.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorTrivia.java
new file mode 100644
index 00000000..cc269bd4
--- /dev/null
+++ b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorTrivia.java
@@ -0,0 +1,133 @@
+package kr.syeyoung.dungeonsguide.roomprocessor;
+
+import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint;
+import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom;
+import kr.syeyoung.dungeonsguide.utils.RenderUtils;
+import kr.syeyoung.dungeonsguide.utils.TextUtils;
+import net.minecraft.client.Minecraft;
+import net.minecraft.util.ChatComponentText;
+import net.minecraft.util.IChatComponent;
+
+import java.awt.*;
+import java.util.*;
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+public class RoomProcessorTrivia extends GeneralRoomProcessor {
+
+ public RoomProcessorTrivia(DungeonRoom dungeonRoom) {
+ super(dungeonRoom);
+ }
+
+
+ private 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);
+ String ch2 = chat.getUnformattedText();
+ System.out.println(ch2 + " / "+chat.getFormattedText());
+ if (chat.getFormattedText().contains("§r§6§lQuestion ")) {
+ questionDialogStart = true;
+ }
+
+ if (questionDialogStart && (chat.getFormattedText().startsWith("§r ") || chat.getFormattedText().trim().startsWith("§r§6 "))) {
+ questionDialog.add(chat.getFormattedText());
+ }
+
+ if (chat.getFormattedText().contains("§r§6 ⓒ")) {
+ questionDialogStart = false;
+ parseDialog();
+ }
+ }
+ public static final Pattern anwerPattern = Pattern.compile("§r§6 . §a(.+)§r");
+ private void parseDialog() {
+ String question = TextUtils.stripColor(questionDialog.get(1)).trim();
+ String answerA = getAnswer(questionDialog.get(2));
+ String answerB = getAnswer(questionDialog.get(2));
+ String answerC = getAnswer(questionDialog.get(2));
+ String theRealAnswer = match(question, answerA, answerB, answerC);
+
+ if (theRealAnswer == null)
+ Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("§eDungeons Guide :::: §cCouldn't determine the answer!"));
+ else
+ Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("§eDungeons Guide :::: §6"+theRealAnswer+"§f is the correct answer!"));
+ correctAnswer = theRealAnswer;
+ }
+ String correctAnswer;
+
+ private String getAnswer(String answerString) {
+ Matcher matcher = anwerPattern.matcher(answerString.trim());
+ if (!matcher.matches()) return "";
+ return matcher.group(1);
+ }
+ private String match(String question, String a, String b, String c) {
+ String[] answers = RoomProcessorTrivia.answers.get(question.toLowerCase().trim());
+ if (match(answers, a)) return "A";
+ if (match(answers, b)) return "B";
+ if (match(answers, c)) return "C";
+ return "Unknown";
+ }
+ private boolean match(String[] match, String match2) {
+ for (String s : match) {
+ if (s.equalsIgnoreCase(match2)) return true;
+ }
+ return false;
+ }
+
+ @Override
+ public void drawWorld(float partialTicks) {
+ super.drawWorld(partialTicks);
+ if (correctAnswer == null) return;
+
+ OffsetPoint op = (OffsetPoint) getDungeonRoom().getDungeonRoomInfo().getProperties().get(correctAnswer);
+ if (op != null) {
+ RenderUtils.highlightBlock(op.getBlockPos(getDungeonRoom()), new Color(0,255,0,50), partialTicks);
+ }
+ }
+
+ public static class Generator implements RoomProcessorGenerator<RoomProcessorTrivia> {
+ @Override
+ public RoomProcessorTrivia createNew(DungeonRoom dungeonRoom) {
+ RoomProcessorTrivia defaultRoomProcessor = new RoomProcessorTrivia(dungeonRoom);
+ return defaultRoomProcessor;
+ }
+ }
+}