From ed938585df7e40487bf2f6ac67ae7132a1d3f7b6 Mon Sep 17 00:00:00 2001 From: Willem Cazander Date: Tue, 1 Feb 2022 12:12:06 +0100 Subject: [PATCH] Added base10 and base11 --- .../demo4d/screen/BasePartRenderer.java | 5 +- .../numberxd/base2t/BasePartFactory.java | 6 +- .../numberxd/base2t/T10PartDecimal.java | 64 ++++++++++++++++++ .../numberxd/base2t/T11PartUndecimal.java | 65 +++++++++++++++++++ .../numberxd/base2t/facet/BasePart.java | 2 + .../numberxd/base2t/BasePartFactoryTest.java | 3 - .../numberxd/base2t/T10PartDecimalTest.java | 38 +++++++++++ .../numberxd/base2t/T11PartUndecimalTest.java | 38 +++++++++++ 8 files changed, 214 insertions(+), 7 deletions(-) create mode 100644 numberxd/src/main/love/distributedrebirth/numberxd/base2t/T10PartDecimal.java create mode 100644 numberxd/src/main/love/distributedrebirth/numberxd/base2t/T11PartUndecimal.java create mode 100644 numberxd/src/test/love/distributedrebirth/numberxd/base2t/T10PartDecimalTest.java create mode 100644 numberxd/src/test/love/distributedrebirth/numberxd/base2t/T11PartUndecimalTest.java diff --git a/core/src/love/distributedrebirth/demo4d/screen/BasePartRenderer.java b/core/src/love/distributedrebirth/demo4d/screen/BasePartRenderer.java index f3026188..6ca9e8d3 100644 --- a/core/src/love/distributedrebirth/demo4d/screen/BasePartRenderer.java +++ b/core/src/love/distributedrebirth/demo4d/screen/BasePartRenderer.java @@ -51,7 +51,8 @@ public class BasePartRenderer extends ImGuiRendererMain { BasePart[] baseParts = BasePartFactory.buildBasePartsByBase(baseNumber); int flags = ImGuiTableFlags.ScrollX | ImGuiTableFlags.RowBg | ImGuiTableFlags.BordersOuter | ImGuiTableFlags.BordersV; - ImGui.beginTable("base-part", 9, flags); + ImGui.beginTable("base-part", 10, flags); + ImGui.tableSetupColumn("Name"); ImGui.tableSetupColumn("Ordinal"); ImGui.tableSetupColumn("Tone"); ImGui.tableSetupColumn("Letter"); @@ -66,6 +67,8 @@ public class BasePartRenderer extends ImGuiRendererMain { for (BasePart part:baseParts) { ImGui.tableNextRow(); ImGui.tableNextColumn(); + ImGui.text(part.name()); + ImGui.tableNextColumn(); ImGui.text(Integer.toString(part.ordinal())); ImGui.tableNextColumn(); ImGui.text(part.getIdentifierTone()); diff --git a/numberxd/src/main/love/distributedrebirth/numberxd/base2t/BasePartFactory.java b/numberxd/src/main/love/distributedrebirth/numberxd/base2t/BasePartFactory.java index eb4a952b..7f9a6ce0 100644 --- a/numberxd/src/main/love/distributedrebirth/numberxd/base2t/BasePartFactory.java +++ b/numberxd/src/main/love/distributedrebirth/numberxd/base2t/BasePartFactory.java @@ -4,7 +4,7 @@ import love.distributedrebirth.numberxd.base2t.facet.BasePart; public final class BasePartFactory { - private static final int[] SUPPORTED_BASES = {2,3,4,5,6,7,8,12,16,20,60}; + private static final int[] SUPPORTED_BASES = {2,3,4,5,6,7,8,10,11,12,16,20,60}; public static int[] getSupportedBases() { return SUPPORTED_BASES; @@ -29,9 +29,9 @@ public final class BasePartFactory { case 9: throw new IllegalArgumentException("Unsupported base: "+base); case 10: - throw new IllegalArgumentException("Unsupported base: "+base); + return T10PartDecimal.values(); case 11: - throw new IllegalArgumentException("Unsupported base: "+base); + return T11PartUndecimal.values(); case 12: return T12PartUncial.values(); case 16: diff --git a/numberxd/src/main/love/distributedrebirth/numberxd/base2t/T10PartDecimal.java b/numberxd/src/main/love/distributedrebirth/numberxd/base2t/T10PartDecimal.java new file mode 100644 index 00000000..6ae2e7ba --- /dev/null +++ b/numberxd/src/main/love/distributedrebirth/numberxd/base2t/T10PartDecimal.java @@ -0,0 +1,64 @@ +package love.distributedrebirth.numberxd.base2t; + +import java.util.Arrays; +import java.util.Collections; +import java.util.Map; +import java.util.function.Consumer; +import java.util.stream.Collectors; + +import love.distributedrebirth.numberxd.base2t.facet.BasePart; +import love.distributedrebirth.numberxd.base2t.facet.BaseFacetKey; +import love.distributedrebirth.numberxd.base2t.facet.BaseFacetMap; + +/** + * The distribution by 10. + * + * @author willemtsade ©Δ∞ 仙上主天 + */ +public enum T10PartDecimal implements BasePart { + + PART_1 ("˥","0","零","zero"), + PART_2 ("˦","1","壹","one"), + PART_3 ("˧","2","貳","two"), + PART_4 ("˨","3","參","three"), + PART_5 ("˩","4","肆","four"), + PART_6 ("꜒","5","伍","five"), + PART_7 ("꜓","6","陸","six"), + PART_8 ("꜔","7","柒","seven"), + PART_9 ("꜕","8","捌","eight"), + PART_10("꜖","9","玖","nine"), + ; + + public static int LENGTH() { return values().length; }; + private final BaseFacetMap bfm = BaseFacetMap.newInstance(); + private static final Map TONE_MAP = Collections.unmodifiableMap( + Arrays.asList(values()).stream().collect(Collectors.toMap(v -> v.getIdentifierTone(), v -> v))); + private static final Map CHINA_MAP = Collections.unmodifiableMap( + Arrays.asList(values()).stream().collect(Collectors.toMap(v -> v.getChinaKey(), v -> v))); + + private T10PartDecimal(String idTone, String idLetter, String chinaKey, String chinaValue) { + this.getBFM().putInit(BaseFacetKey.ID_TONE, idTone); + this.getBFM().putInit(BaseFacetKey.ID_LETTER, idLetter); + this.getBFM().putInit(BaseFacetKey.CHINA_KEY, chinaKey); + this.getBFM().putInit(BaseFacetKey.CHINA_VALUE, chinaValue); + } + + @Override + public BaseFacetMap getBFM() { + return bfm; + } + + public static void forEach(Consumer consumer) { + for (T10PartDecimal value:values()) { + consumer.accept(value); + } + } + + public static T10PartDecimal valueOfTone(String identifierTone) { + return TONE_MAP.get(identifierTone); + } + + public static T10PartDecimal valueOfChina(String chinaKey) { + return CHINA_MAP.get(chinaKey); + } +} diff --git a/numberxd/src/main/love/distributedrebirth/numberxd/base2t/T11PartUndecimal.java b/numberxd/src/main/love/distributedrebirth/numberxd/base2t/T11PartUndecimal.java new file mode 100644 index 00000000..d7bf3fe2 --- /dev/null +++ b/numberxd/src/main/love/distributedrebirth/numberxd/base2t/T11PartUndecimal.java @@ -0,0 +1,65 @@ +package love.distributedrebirth.numberxd.base2t; + +import java.util.Arrays; +import java.util.Collections; +import java.util.Map; +import java.util.function.Consumer; +import java.util.stream.Collectors; + +import love.distributedrebirth.numberxd.base2t.facet.BasePart; +import love.distributedrebirth.numberxd.base2t.facet.BaseFacetKey; +import love.distributedrebirth.numberxd.base2t.facet.BaseFacetMap; + +/** + * The distribution by 11. + * + * @author willemtsade ©Δ∞ 仙上主天 + */ +public enum T11PartUndecimal implements BasePart { + + PART_1 ("˥","0","走","walk"), + PART_2 ("꜈","1","跑","run"), + PART_3 ("꜉","2","坐","sit"), + PART_4 ("꜋","3","掛","hang"), + PART_5 ("꜌","4","鋪","lay"), + PART_6 ("꜔","5","跳","jump"), + PART_7 ("꜍","6","落","drop"), + PART_8 ("꜎","7","寂","lonely"), + PART_9 ("꜏","8","談","talk"), + PART_10("꜐","9","春","life"), + PART_11("˩","=","耦","mate"), + ; + + public static int LENGTH() { return values().length; }; + private final BaseFacetMap bfm = BaseFacetMap.newInstance(); + private static final Map TONE_MAP = Collections.unmodifiableMap( + Arrays.asList(values()).stream().collect(Collectors.toMap(v -> v.getIdentifierTone(), v -> v))); + private static final Map CHINA_MAP = Collections.unmodifiableMap( + Arrays.asList(values()).stream().collect(Collectors.toMap(v -> v.getChinaKey(), v -> v))); + + private T11PartUndecimal(String idTone, String idLetter, String chinaKey, String chinaValue) { + this.getBFM().putInit(BaseFacetKey.ID_TONE, idTone); + this.getBFM().putInit(BaseFacetKey.ID_LETTER, idLetter); + this.getBFM().putInit(BaseFacetKey.CHINA_KEY, chinaKey); + this.getBFM().putInit(BaseFacetKey.CHINA_VALUE, chinaValue); + } + + @Override + public BaseFacetMap getBFM() { + return bfm; + } + + public static void forEach(Consumer consumer) { + for (T11PartUndecimal value:values()) { + consumer.accept(value); + } + } + + public static T11PartUndecimal valueOfTone(String identifierTone) { + return TONE_MAP.get(identifierTone); + } + + public static T11PartUndecimal valueOfChina(String chinaKey) { + return CHINA_MAP.get(chinaKey); + } +} diff --git a/numberxd/src/main/love/distributedrebirth/numberxd/base2t/facet/BasePart.java b/numberxd/src/main/love/distributedrebirth/numberxd/base2t/facet/BasePart.java index b0de6124..962ce1d0 100644 --- a/numberxd/src/main/love/distributedrebirth/numberxd/base2t/facet/BasePart.java +++ b/numberxd/src/main/love/distributedrebirth/numberxd/base2t/facet/BasePart.java @@ -7,6 +7,8 @@ package love.distributedrebirth.numberxd.base2t.facet; */ public interface BasePart extends BaseFacetStore { + String name(); + int ordinal(); default String getIdentifierTone() { diff --git a/numberxd/src/test/love/distributedrebirth/numberxd/base2t/BasePartFactoryTest.java b/numberxd/src/test/love/distributedrebirth/numberxd/base2t/BasePartFactoryTest.java index c6525ebf..dc8b89c8 100644 --- a/numberxd/src/test/love/distributedrebirth/numberxd/base2t/BasePartFactoryTest.java +++ b/numberxd/src/test/love/distributedrebirth/numberxd/base2t/BasePartFactoryTest.java @@ -21,9 +21,6 @@ public class BasePartFactoryTest { Assertions.assertNotNull(bases); Assertions.assertTrue(bases.length > 1); Assertions.assertTrue(bases.length < 100); - for (int base:bases) { - Assertions.assertNotNull(base); - } } @Test diff --git a/numberxd/src/test/love/distributedrebirth/numberxd/base2t/T10PartDecimalTest.java b/numberxd/src/test/love/distributedrebirth/numberxd/base2t/T10PartDecimalTest.java new file mode 100644 index 00000000..122bcbeb --- /dev/null +++ b/numberxd/src/test/love/distributedrebirth/numberxd/base2t/T10PartDecimalTest.java @@ -0,0 +1,38 @@ +package love.distributedrebirth.numberxd.base2t; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +/** + * + * + * @author willemtsade ©Δ∞ 仙上主天 + */ +public class T10PartDecimalTest { + + @Test + public void testBasePart() { + for (T10PartDecimal value:T10PartDecimal.values()) { + Assertions.assertNotNull(value.getIdentifierTone()); + Assertions.assertNotNull(value.getIdentifierLetter()); + Assertions.assertNotNull(value.getChinaKey()); + Assertions.assertNotNull(value.getChinaValue()); + } + } + + @Test + public void testToneMap() { + Assertions.assertEquals(T10PartDecimal.PART_1, T10PartDecimal.valueOfTone("˥")); + Assertions.assertEquals(T10PartDecimal.PART_2, T10PartDecimal.valueOfTone("˦")); + Assertions.assertEquals(T10PartDecimal.PART_9, T10PartDecimal.valueOfTone("꜕")); + Assertions.assertEquals(T10PartDecimal.PART_10, T10PartDecimal.valueOfTone("꜖")); + } + + @Test + public void testChinaMap() { + Assertions.assertEquals(T10PartDecimal.PART_1, T10PartDecimal.valueOfChina("零")); + Assertions.assertEquals(T10PartDecimal.PART_2, T10PartDecimal.valueOfChina("壹")); + Assertions.assertEquals(T10PartDecimal.PART_9, T10PartDecimal.valueOfChina("捌")); + Assertions.assertEquals(T10PartDecimal.PART_10, T10PartDecimal.valueOfChina("玖")); + } +} diff --git a/numberxd/src/test/love/distributedrebirth/numberxd/base2t/T11PartUndecimalTest.java b/numberxd/src/test/love/distributedrebirth/numberxd/base2t/T11PartUndecimalTest.java new file mode 100644 index 00000000..936290d3 --- /dev/null +++ b/numberxd/src/test/love/distributedrebirth/numberxd/base2t/T11PartUndecimalTest.java @@ -0,0 +1,38 @@ +package love.distributedrebirth.numberxd.base2t; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +/** + * + * + * @author willemtsade ©Δ∞ 仙上主天 + */ +public class T11PartUndecimalTest { + + @Test + public void testBasePart() { + for (T11PartUndecimal value:T11PartUndecimal.values()) { + Assertions.assertNotNull(value.getIdentifierTone()); + Assertions.assertNotNull(value.getIdentifierLetter()); + Assertions.assertNotNull(value.getChinaKey()); + Assertions.assertNotNull(value.getChinaValue()); + } + } + + @Test + public void testToneMap() { + Assertions.assertEquals(T11PartUndecimal.PART_1, T11PartUndecimal.valueOfTone("˥")); + Assertions.assertEquals(T11PartUndecimal.PART_2, T11PartUndecimal.valueOfTone("꜈")); + Assertions.assertEquals(T11PartUndecimal.PART_10, T11PartUndecimal.valueOfTone("꜐")); + Assertions.assertEquals(T11PartUndecimal.PART_11, T11PartUndecimal.valueOfTone("˩")); + } + + @Test + public void testChinaMap() { + Assertions.assertEquals(T11PartUndecimal.PART_1, T11PartUndecimal.valueOfChina("走")); + Assertions.assertEquals(T11PartUndecimal.PART_2, T11PartUndecimal.valueOfChina("跑")); + Assertions.assertEquals(T11PartUndecimal.PART_10, T11PartUndecimal.valueOfChina("春")); + Assertions.assertEquals(T11PartUndecimal.PART_11, T11PartUndecimal.valueOfChina("耦")); + } +}