diff --git a/build.gradle b/build.gradle index 4cf75c6..b45dabf 100644 --- a/build.gradle +++ b/build.gradle @@ -19,6 +19,8 @@ dependencies { testImplementation "org.junit.jupiter:junit-jupiter-api:${lib_junit_v}" testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:${lib_junit_v}" + testImplementation project(":sekai-scores-db") + } final JavaVersion proj_java = JavaVersion.VERSION_17 diff --git a/gradle.properties b/gradle.properties index 1d6ef47..904eac9 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,7 +1,7 @@ ## Project Configurations # Proj Metadata -projVersion = 0.2 +projVersion = 0.3 # Dependencies diff --git a/sekai-scores-db/build.gradle b/sekai-scores-db/build.gradle index f969a42..76b5f9c 100644 --- a/sekai-scores-db/build.gradle +++ b/sekai-scores-db/build.gradle @@ -1,11 +1,11 @@ +import java.nio.charset.Charset +import java.nio.charset.StandardCharsets + plugins { id 'java' id 'java-library' } -group 'cc.sukazyo' -version moduleVersion - repositories { mavenCentral() } @@ -19,6 +19,31 @@ dependencies { } +final JavaVersion proj_java = JavaVersion.VERSION_17 +final Charset proj_source_encoding = StandardCharsets.UTF_8 + +group 'cc.sukazyo' +version moduleVersion + test { useJUnitPlatform() -} \ No newline at end of file +} + +java { + + sourceCompatibility proj_java + targetCompatibility proj_java + + withSourcesJar() + +} + +tasks.withType(JavaCompile) { + options.encoding = proj_source_encoding.name() +} + +tasks.withType(Javadoc) { + options.encoding = proj_source_encoding.name() + options.docEncoding = proj_source_encoding.name() + options.charSet = proj_source_encoding.name() +} diff --git a/src/main/java/cc/sukazyo/sekai_scores/DifficultiesSekai.java b/src/main/java/cc/sukazyo/sekai_scores/DifficultiesSekai.java index df6eed6..946fe81 100644 --- a/src/main/java/cc/sukazyo/sekai_scores/DifficultiesSekai.java +++ b/src/main/java/cc/sukazyo/sekai_scores/DifficultiesSekai.java @@ -26,4 +26,17 @@ public record DifficultiesSekai( action.accept(MASTER_NAME, master); } + @Override + @Nonnull + public String toString() { + return String.format( + "[{\"id\":\"%s\",%s},{\"id\":\"%s\",%s},{\"id\":\"%s\",%s},{\"id\":\"%s\",%s},{\"id\":\"%s\",%s}]", + EASY_NAME, easy.toStringSimple(), + NORMAL_NAME, normal.toStringSimple(), + HARD_NAME, hard.toStringSimple(), + EXPERT_NAME, expert.toStringSimple(), + MASTER_NAME, master.toStringSimple() + ); + } + } diff --git a/src/main/java/cc/sukazyo/sekai_scores/Difficulty.java b/src/main/java/cc/sukazyo/sekai_scores/Difficulty.java index 661b283..4cab80c 100644 --- a/src/main/java/cc/sukazyo/sekai_scores/Difficulty.java +++ b/src/main/java/cc/sukazyo/sekai_scores/Difficulty.java @@ -1,8 +1,45 @@ package cc.sukazyo.sekai_scores; import javax.annotation.Nonnegative; +import javax.annotation.Nonnull; public record Difficulty( @Nonnegative int level, @Nonnegative int noteCount -) {} +) { + + /** + * The difficulty number of this difficulty map. + *
+ * it is a number in range 1-36 in official prsk game. + * @since 0.2 + */ + @Nonnegative public int level () { return level; } + /** + * an alias of {@link #level} field. + * @since 0.3 + * @see #level() + */ + @Nonnegative public int difficulty () { return level(); } + + /** + * The total note count in this difficulty map. + * @since 0.2 + */ + @Nonnegative public int noteCount () { return noteCount; } + + @Override + @Nonnull + public String toString() { + return String.format("{%s}", toStringSimple()); + } + + @Nonnull + public String toStringSimple () { + return String.format( + "\"difficulty\":%d,\"notes\":%d", + level, noteCount + ); + } + +} diff --git a/src/main/java/cc/sukazyo/sekai_scores/ScoreBaseData.java b/src/main/java/cc/sukazyo/sekai_scores/ScoreBaseData.java index 9577c29..392ccf5 100644 --- a/src/main/java/cc/sukazyo/sekai_scores/ScoreBaseData.java +++ b/src/main/java/cc/sukazyo/sekai_scores/ScoreBaseData.java @@ -2,6 +2,7 @@ package cc.sukazyo.sekai_scores; import javax.annotation.CheckForSigned; import javax.annotation.Nonnegative; +import javax.annotation.Nonnull; /** * @see ScoreBase @@ -182,4 +183,17 @@ public class ScoreBaseData { return combo; } + @Override + @Nonnull + public String toString() { + return String.format( + "{\"perfect\":%d,\"great\":%d,\"good\":%d,\"bad\":%d,\"miss\":%d,\"judge\":{\"fast\":%s,\"slow\":%s,\"flick\":%s},\"combo\":%s}", + notePerfect, noteGreat, noteGood, noteBad, noteMiss, + judgeFast==NULL ? "null" : judgeFast, + judgeSlow==NULL ? "null" : judgeFast, + judgeFlick==NULL ? "null" : judgeFast, + combo==NULL ? "null" : combo + ); + } + } diff --git a/src/main/java/cc/sukazyo/sekai_scores/Song.java b/src/main/java/cc/sukazyo/sekai_scores/Song.java index e9c733d..744051f 100644 --- a/src/main/java/cc/sukazyo/sekai_scores/Song.java +++ b/src/main/java/cc/sukazyo/sekai_scores/Song.java @@ -1,9 +1,24 @@ package cc.sukazyo.sekai_scores; +import cc.sukazyo.sekai_scores.util.Converter; + import javax.annotation.Nonnull; public record Song( @Nonnull String name, @Nonnull SongUnit unit, @Nonnull Difficulties difficulties -) {} +) { + + @Override + @Nonnull + public String toString () { + return String.format( + "{\"name\":\"%s\",\"unit\":%s,\"difficulties\":%s}", + Converter.parseJSONString(name), + unit, + difficulties + ); + } + +} diff --git a/src/main/java/cc/sukazyo/sekai_scores/SongUnit.java b/src/main/java/cc/sukazyo/sekai_scores/SongUnit.java index 4928626..756d9f0 100644 --- a/src/main/java/cc/sukazyo/sekai_scores/SongUnit.java +++ b/src/main/java/cc/sukazyo/sekai_scores/SongUnit.java @@ -1,23 +1,64 @@ package cc.sukazyo.sekai_scores; +import cc.sukazyo.sekai_scores.util.Converter; + import javax.annotation.Nonnull; public enum SongUnit { - VSINGER("VIRTUAL SINGER"), - LEO_NEED("Leo/need"), - MORE_MORE_JUMP("MORE MORE JUMP!"), - VIVID_BAD_SQUAD("Vivid BAD SQUAD"), - WONDERLANDS_SHOWTIME("ワンダーランズ×ショウタイム"), - NIGHTCORD_25JI("25時、ナイトコードで。"), - OTHER("other"), - SP("セカイ") + VSINGER(0, "VIRTUAL SINGER"), + LEO_NEED(1, "Leo/need"), + MORE_MORE_JUMP(2, "MORE MORE JUMP!"), + VIVID_BAD_SQUAD(3, "Vivid BAD SQUAD"), + WONDERLANDS_SHOWTIME(4, "ワンダーランズ×ショウタイム"), + NIGHTCORD_25JI(5, "25時、ナイトコードで。"), + /** + * Just the "other" unit in game. + * @since 0.2 + */ + OTHER(-1, "other"), + /** + * It collects that songs belongs to multiple units. + *
+ * Like "Journey", "群青讃歌", it belongs to all of those units exists in game, + * and hard to assign those songs to those units exists. So this group was created, + * means the song belongs to "the whole セカイ". + *
+ * This unit/group doesn't exist in the game. + * @since 0.2 + */ + SP(-2, "セカイ") ; + /** + * An id of this group/unit. + *
+ * The value start at 0 for {@link #VSINGER} + * and increment according to the order of the groups/units in the game. + *
+ * for some special group/unit, it has a special id: + *