All checks were successful
Run test asserts / Test-Asserts (push) Successful in 49s
169 lines
6.6 KiB
Java
169 lines
6.6 KiB
Java
/*
|
|
* Copyright ©Δ∞ 仙上主天
|
|
* All rights reserved.
|
|
*
|
|
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
|
* that the following conditions are met:
|
|
*
|
|
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
|
* following disclaimer.
|
|
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
|
|
* the following disclaimer in the documentation and/or other materials provided with the distribution.
|
|
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
|
|
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
|
|
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
|
|
* even on air gaped systems, all information in the universe is owned by the pi creator.
|
|
*
|
|
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE CONTRIBUTORS "AS IS" AND ANY
|
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
|
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
|
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
|
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
*/
|
|
|
|
package ᒢᣘᐧᐧ.ᣕᓫᐪᑋᓫᣗ.ᐪᐤᣕᓫ;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
|
|
/// Nether tone slug view record.
|
|
///
|
|
/// @author للَّٰهِilLצسُو
|
|
/// @version ©Δ∞ 仙上主天
|
|
public record NetherToneSlugView(
|
|
int ag1,
|
|
int ag2,
|
|
int ag3,
|
|
int bl0w,
|
|
int cr1,
|
|
int cr2,
|
|
int cr3,
|
|
int db1,
|
|
int db2,
|
|
int db3,
|
|
int er0w
|
|
) {
|
|
|
|
public NetherToneSlugView {
|
|
if (ag1 < 0 || ag1 > 63) { throw new IllegalArgumentException("ag1: " + ag1); }
|
|
if (ag2 < 0 || ag2 > 63) { throw new IllegalArgumentException("ag2: " + ag2); }
|
|
if (ag3 < 0 || ag3 > 63) { throw new IllegalArgumentException("ag3: " + ag3); }
|
|
if (bl0w < 0 || bl0w > 511) { throw new IllegalArgumentException("bl0w: " + bl0w); }
|
|
if (cr1 < 0 || cr1 > 63) { throw new IllegalArgumentException("cr1: " + cr1); }
|
|
if (cr2 < 0 || cr2 > 63) { throw new IllegalArgumentException("cr2: " + cr2); }
|
|
if (cr3 < 0 || cr3 > 63) { throw new IllegalArgumentException("cr3: " + cr3); }
|
|
if (db1 < 0 || db1 > 63) { throw new IllegalArgumentException("db1: " + db1); }
|
|
if (db2 < 0 || db2 > 63) { throw new IllegalArgumentException("db2: " + db2); }
|
|
if (db3 < 0 || db3 > 63) { throw new IllegalArgumentException("db3: " + db3); }
|
|
if (er0w < 0 || er0w > 511) { throw new IllegalArgumentException("er0w: " + er0w); }
|
|
}
|
|
|
|
private final static String VALUES_3 = "\u05D3\u05D5\u05D6\u05D9\u05E8\u05F0\u05F1\u05F2";
|
|
private final static String VALUES_6 = "\u05B0\u05B2\u05B3\u05B5\u05B6\u05B7\u05BB\u05BD";
|
|
private final static String VALUES_9 = "\u0594\u0595\u0598\u059D\u059E\u059F\u05A0\u05A9";
|
|
private void printNúmero2Lingua6(StringBuilder buf, int value) {
|
|
buf.appendCodePoint(VALUES_3.codePoints().skip((value >> 3) & 7).findFirst().getAsInt());
|
|
buf.appendCodePoint(VALUES_6.codePoints().skip((value >> 0) & 7).findFirst().getAsInt());
|
|
}
|
|
private void printNúmero2Lingua9(StringBuilder buf, int value) {
|
|
buf.appendCodePoint(VALUES_3.codePoints().skip((value >> 6) & 7).findFirst().getAsInt());
|
|
buf.appendCodePoint(VALUES_6.codePoints().skip((value >> 3) & 7).findFirst().getAsInt());
|
|
buf.appendCodePoint(VALUES_9.codePoints().skip((value >> 0) & 7).findFirst().getAsInt());
|
|
}
|
|
|
|
public String toNúmero2Lingua() {
|
|
StringBuilder buf = new StringBuilder();
|
|
printNúmero2Lingua6(buf, ag1);
|
|
printNúmero2Lingua6(buf, ag2);
|
|
printNúmero2Lingua6(buf, ag3);
|
|
printNúmero2Lingua9(buf, bl0w);
|
|
printNúmero2Lingua6(buf, cr1);
|
|
printNúmero2Lingua6(buf, cr2);
|
|
printNúmero2Lingua6(buf, cr3);
|
|
printNúmero2Lingua6(buf, db1);
|
|
printNúmero2Lingua6(buf, db2);
|
|
printNúmero2Lingua6(buf, db3);
|
|
printNúmero2Lingua9(buf, er0w);
|
|
return buf.toString();
|
|
}
|
|
|
|
public List<Class<?>> toNetherTones(int idx) {
|
|
Class<?> qClass = qClass(idx);
|
|
List<Class<?>> result = new ArrayList<>(11);
|
|
for (int i = 0; i < 11; i++) {
|
|
Class<?> subClass = qClass.getPermittedSubclasses()[i];
|
|
Class<?>[] valueClasses = subClass.getPermittedSubclasses();
|
|
result.add(switch (i) {
|
|
case 0: yield valueClasses[ag1];
|
|
case 1: yield valueClasses[ag2];
|
|
case 2: yield valueClasses[ag3];
|
|
case 3: yield valueClasses[bl0w];
|
|
case 4: yield valueClasses[cr1];
|
|
case 5: yield valueClasses[cr2];
|
|
case 6: yield valueClasses[cr3];
|
|
case 7: yield valueClasses[db1];
|
|
case 8: yield valueClasses[db2];
|
|
case 9: yield valueClasses[db3];
|
|
case 10: yield valueClasses[er0w];
|
|
default:
|
|
throw new IllegalArgumentException("Unexpected value: " + i);
|
|
});
|
|
}
|
|
return result;
|
|
}
|
|
|
|
// TODO: idx = 0 = Q1 = maybe enum
|
|
static private Class<?> qClass(int idx) {
|
|
if (idx < 0) {
|
|
throw new IllegalArgumentException("Negative Q index: " + idx);
|
|
}
|
|
if (idx >= 8) {
|
|
throw new IllegalArgumentException("Outside octal Q space boundry: " + idx);
|
|
}
|
|
return NetherTone.class.getPermittedSubclasses()[idx];
|
|
}
|
|
|
|
static NetherToneSlugView ofQSluq(int idx, Class<? extends NetherTone> q) {
|
|
Class<?> qClass = qClass(idx);
|
|
int[] d = new int[11];
|
|
int dataIdx = 0;
|
|
for (Class<?> subClass : qClass.getPermittedSubclasses()) {
|
|
boolean hasValue = false;
|
|
Class<?>[] valueClasses = subClass.getPermittedSubclasses();
|
|
for (int i = 0; i < valueClasses.length; i++) {
|
|
Class<?> valueClass = valueClasses[i];
|
|
if (valueClass.isAssignableFrom(q)) {
|
|
hasValue = true;
|
|
d[dataIdx] = i;
|
|
dataIdx++;
|
|
break;
|
|
}
|
|
}
|
|
if (!hasValue) {
|
|
throw new IllegalArgumentException("missing Q value in nether space of: " + subClass);
|
|
}
|
|
}
|
|
return new NetherToneSlugView(d[0], d[1], d[2], d[3], d[4], d[5], d[6], d[7], d[8], d[9], d[10]);
|
|
}
|
|
|
|
static boolean slugPresent(int idx, Class<? extends NetherTone> q) {
|
|
Class<?> qClass = qClass(idx);
|
|
for (Class<?> subClass : qClass.getPermittedSubclasses()) {
|
|
boolean hasValue = false;
|
|
for (Class<?> valueClass : subClass.getPermittedSubclasses()) {
|
|
if (valueClass.isAssignableFrom(q)) {
|
|
hasValue = true;
|
|
break;
|
|
}
|
|
}
|
|
if (!hasValue) {
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
}
|