diff --git a/lib-numberxd/src/main/love/distributedrebirth/numberxd/base2t/part/warp/TOSWarpCore.java b/lib-numberxd/src/main/love/distributedrebirth/numberxd/base2t/part/warp/TOSWarpCore.java index d18e560f..6bb25bfc 100644 --- a/lib-numberxd/src/main/love/distributedrebirth/numberxd/base2t/part/warp/TOSWarpCore.java +++ b/lib-numberxd/src/main/love/distributedrebirth/numberxd/base2t/part/warp/TOSWarpCore.java @@ -27,6 +27,7 @@ public enum TOSWarpCore implements DefaultEnumInstanceᴶᴹˣ BBC = BãßBȍőnCoffinOpenʸᴰ.newInstance(); @@ -37,6 +38,7 @@ public enum TOSWarpCore implements DefaultEnumInstanceᴶᴹˣ chinaKey = new HashMap<>(); + Map chinaValue = new HashMap<>(); + for (WaterCipherHeart heart:warpBucket.theWater().getCipherHearts()) { + BãßBȍőnPartʸᴰ[] bases = BasePartFactory.INSTANCE.BãßBuildPartsByBase(heart.getBass()); + Map> baseParts = new HashMap<>(); + for (BãßBȍőnPartʸᴰ base:bases) { + baseParts.put(base.BȍőnNaam(), base); + } + for (WaterCipherHeartTone tone:heart.getHeartTones()) { + if(chinaKey.containsKey(tone.getChinaKey())) { + throw new IllegalArgumentException("Duplicate chinaKey: "+tone.getChinaKey()); + } + if(chinaValue.containsKey(tone.getChinaValue())) { + throw new IllegalArgumentException("Duplicate chinaValue: "+tone.getChinaValue()); + } + chinaKey.put(tone.getChinaKey(), tone.getDialTone()); + chinaValue.put(tone.getChinaValue(), tone.getDialTone()); + } + } + } + public void BãßArmWarpCore(WaterBucket warpBucket) { + BãßValidateWarpCore(warpBucket); warpCoreWrites.increment(); armedWarpWaterName.setValueString(warpBucket.theWater().getName()); armedWarpWaterDesc.setValueString(warpBucket.theWater().getDescription()); diff --git a/lib-numberxd/src/test/love/distributedrebirth/numberxd/base2t/part/warp/TOSWarpCoreTest.java b/lib-numberxd/src/test/love/distributedrebirth/numberxd/base2t/part/warp/TOSWarpCoreTest.java new file mode 100644 index 00000000..240f1b90 --- /dev/null +++ b/lib-numberxd/src/test/love/distributedrebirth/numberxd/base2t/part/warp/TOSWarpCoreTest.java @@ -0,0 +1,41 @@ +package love.distributedrebirth.numberxd.base2t.part.warp; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +import love.distributedrebirth.bassboonyd.BãßBȍőnAuthorInfoʸᴰ; + +@BãßBȍőnAuthorInfoʸᴰ(name = "willemtsade", copyright = "©Δ∞ 仙上主天") +public class TOSWarpCoreTest { + + @Test + public void testCurrentWarpCore() { + WaterBucket warpCore = TOSWarpCore.INSTANCE.BãßCurrentWarpCore(); + Assertions.assertNotNull(warpCore); + Assertions.assertNotNull(warpCore.theWater()); + Assertions.assertNotNull(warpCore.theWater().getName()); + Assertions.assertNotNull(warpCore.theWater().getDescription()); + Assertions.assertNotNull(warpCore.theWater().getCipherHearts()); + Assertions.assertTrue(warpCore.theWater().getCipherHearts().size() > 1); + Assertions.assertTrue(warpCore.theWater().getCipherHearts().size() < 100); + } + + @Test + public void testValidateWarpCore() { + WaterBucket warpCore = TOSWarpCore.INSTANCE.BãßCurrentWarpCore(); + + warpCore.theWater().getCipherHearts().get(5).getHeartTones().get(0).setChinaKey("零"); + warpCore.theWater().getCipherHearts().get(5).getHeartTones().get(1).setChinaKey("零"); + IllegalArgumentException thrownKey = Assertions.assertThrows(IllegalArgumentException.class, () -> { + TOSWarpCore.INSTANCE.BãßValidateWarpCore(warpCore); + }); + Assertions.assertEquals("Duplicate chinaKey: 零", thrownKey.getMessage()); + + warpCore.theWater().getCipherHearts().get(4).getHeartTones().get(0).setChinaValue("pink"); + warpCore.theWater().getCipherHearts().get(4).getHeartTones().get(1).setChinaValue("pink"); + IllegalArgumentException thrownValue = Assertions.assertThrows(IllegalArgumentException.class, () -> { + TOSWarpCore.INSTANCE.BãßValidateWarpCore(warpCore); + }); + Assertions.assertEquals("Duplicate chinaValue: pink", thrownValue.getMessage()); + } +}