aboutsummaryrefslogtreecommitdiff
path: root/src/test/java
diff options
context:
space:
mode:
authorSpaceMonkeyy86 <jackreynolds9128@gmail.com>2025-06-14 14:17:57 +0000
committerGitHub <noreply@github.com>2025-06-14 22:17:57 +0800
commit2d63e6088aa588556b588070e826ce6c0ec1492d (patch)
tree633424000f41029eae67981d4ff607c870deff66 /src/test/java
parentcd29a1475253ff3ca8098765875a45fdbefd75e7 (diff)
downloadSkyblocker-2d63e6088aa588556b588070e826ce6c0ec1492d.tar.gz
Skyblocker-2d63e6088aa588556b588070e826ce6c0ec1492d.tar.bz2
Skyblocker-2d63e6088aa588556b588070e826ce6c0ec1492d.zip
One flow waterboard solver (#1283)
* Port Desco19's waterboard solver to Skyblocker * Many waterboard tweaks * Update watertimes.json to newer version and fix leftover water check * Visualize water paths on board * General improvements * Preview lever effects * Fix preview hitboxes being too small in rooms with an entrance from below * Refactor into multiple files and add config options * Benchmark all solutions and improve two of them * Show indicator line from next lever to the lever after that * Optimize many of the slower solutions * Add marks support for easier solution iteration * Tweak comments * Clean up one flow waterboard solver * Add suggested comments * Add lever type argument type and debug command * Verify json file * Make commands debug only and make feedback translatable * Update VerifyJsonTest * Make color codes less scuffed --------- Co-authored-by: Kevinthegreat <92656833+kevinthegreat1@users.noreply.github.com>
Diffstat (limited to 'src/test/java')
-rw-r--r--src/test/java/de/hysky/skyblocker/VerifyJsonTest.java56
1 files changed, 56 insertions, 0 deletions
diff --git a/src/test/java/de/hysky/skyblocker/VerifyJsonTest.java b/src/test/java/de/hysky/skyblocker/VerifyJsonTest.java
index 81045238..3a047366 100644
--- a/src/test/java/de/hysky/skyblocker/VerifyJsonTest.java
+++ b/src/test/java/de/hysky/skyblocker/VerifyJsonTest.java
@@ -1,7 +1,11 @@
package de.hysky.skyblocker;
import com.google.gson.*;
+import de.hysky.skyblocker.skyblock.dungeon.puzzle.waterboard.Waterboard;
+import net.minecraft.Bootstrap;
+import net.minecraft.SharedConstants;
import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import java.io.InputStreamReader;
@@ -9,6 +13,12 @@ import java.io.InputStreamReader;
public class VerifyJsonTest {
private static final Gson GSON = new GsonBuilder().setPrettyPrinting().create();
+ @BeforeAll
+ public static void setup() {
+ SharedConstants.createGameVersion();
+ Bootstrap.initialize();
+ }
+
@Test
void verifyKuudraPearlWaypoints() {
@SuppressWarnings("DataFlowIssue")
@@ -138,4 +148,50 @@ public class VerifyJsonTest {
Assertions.assertTrue(pos.get(1).getAsJsonPrimitive().isNumber());
Assertions.assertTrue(pos.get(2).getAsJsonPrimitive().isNumber());
}
+
+ @Test
+ void verifyWaterTimes() {
+ @SuppressWarnings("DataFlowIssue")
+ JsonObject waterTimes = GSON.fromJson(new InputStreamReader(Waterboard.class.getResourceAsStream("/assets/skyblocker/dungeons/watertimes.json")), JsonObject.class);
+
+ Assertions.assertFalse(waterTimes.isEmpty());
+ waterTimes.asMap().forEach(this::verifyVariant);
+ }
+
+ private void verifyVariant(String variant, JsonElement waterTimesElement) {
+ Assertions.assertTrue(Integer.parseInt(variant) > 0);
+
+ Assertions.assertTrue(waterTimesElement.isJsonObject());
+ JsonObject waterTimes = waterTimesElement.getAsJsonObject();
+ Assertions.assertFalse(waterTimes.isEmpty());
+ waterTimes.asMap().forEach(this::verifySolution);
+ }
+
+ private void verifySolution(String doorCombination, JsonElement solutionElement) {
+ // Verify that door is a valid combination
+ Assertions.assertEquals(3, doorCombination.length());
+ Assertions.assertTrue(Integer.parseInt(doorCombination) > 0);
+ // Verify that door contains increasing digits
+ Assertions.assertTrue(doorCombination.charAt(0) < doorCombination.charAt(1) && doorCombination.charAt(1) < doorCombination.charAt(2));
+
+ Assertions.assertTrue(solutionElement.isJsonObject());
+ JsonObject solution = solutionElement.getAsJsonObject();
+ Assertions.assertFalse(solution.isEmpty());
+ solution.asMap().forEach(this::verifyDoor);
+ }
+
+ private void verifyDoor(String door, JsonElement timesElement) {
+ Assertions.assertNotNull(Waterboard.LeverType.fromName(door));
+
+ Assertions.assertTrue(timesElement.isJsonArray());
+ JsonArray times = timesElement.getAsJsonArray();
+ Assertions.assertFalse(times.isEmpty());
+
+ for (JsonElement time : times) {
+ Assertions.assertTrue(time.isJsonPrimitive());
+ Assertions.assertTrue(time.getAsJsonPrimitive().isNumber());
+ double timeValue = time.getAsDouble();
+ Assertions.assertTrue(timeValue >= 0);
+ }
+ }
}