1
0
mirror of https://github.com/Eyre-S/sekai-scores.git synced 2024-11-22 11:14:56 +08:00

add "id" field to Song and Difficulty

- add "id" field to Song, means the song id in game and wiki.
- add "id" field to Difficulty, it is a String of EASY/EXPERT etc.
- changes the parseJSONString implementation
- add song 夜に駆ける, complete the group SekaiSpecial
This commit is contained in:
A.C.Sukazyo Eyre 2022-11-21 17:04:20 +08:00
parent 3032af55e5
commit 079da346b0
Signed by: Eyre_S
GPG Key ID: C17CE40291207874
11 changed files with 100 additions and 67 deletions

View File

@ -1,7 +1,7 @@
## Project Configurations ## Project Configurations
# Proj Metadata # Proj Metadata
projVersion = 0.3 projVersion = 0.4
# Dependencies # Dependencies

View File

@ -1,4 +1,4 @@
## Project Configurations ## Project Configurations
# Proj Metadata # Proj Metadata
moduleVersion = 0.1 moduleVersion = 0.2

View File

@ -5,36 +5,41 @@ import cc.sukazyo.sekai_scores.DifficultiesSekai;
import cc.sukazyo.sekai_scores.Song; import cc.sukazyo.sekai_scores.Song;
import cc.sukazyo.sekai_scores.SongUnit; import cc.sukazyo.sekai_scores.SongUnit;
import static cc.sukazyo.sekai_scores.DifficultiesSekai.*;
public class Nightcord25ji { public class Nightcord25ji {
/** <a href="https://www.sekaipedia.org/wiki/Keitai_Renwa">...</a> */
public static final Song Keitai_Renwa = new Song( public static final Song Keitai_Renwa = new Song(
"携帯恋話", SongUnit.NIGHTCORD_25JI, 61, "携帯恋話", SongUnit.NIGHTCORD_25JI,
new DifficultiesSekai( new DifficultiesSekai(
new Difficulty( 8, 204), new Difficulty( EASY_NAME, 8, 204),
new Difficulty(12, 361), new Difficulty(NORMAL_NAME, 12, 361),
new Difficulty(18, 651), new Difficulty( HARD_NAME, 18, 651),
new Difficulty(25, 981), new Difficulty(EXPERT_NAME, 25, 981),
new Difficulty(29, 1131) new Difficulty(MASTER_NAME, 29, 1131)
) )
); );
/** <a href="https://www.sekaipedia.org/wiki/Kuyamu_to_Kaite_Mirai">...</a> */
public static final Song Kuyamu_to_Kaite_Mirai = new Song( public static final Song Kuyamu_to_Kaite_Mirai = new Song(
"悔やむと書いてミライ", SongUnit.NIGHTCORD_25JI, 60, "悔やむと書いてミライ", SongUnit.NIGHTCORD_25JI,
new DifficultiesSekai( new DifficultiesSekai(
new Difficulty( 8, 190), new Difficulty( EASY_NAME, 8, 190),
new Difficulty(13, 440), new Difficulty(NORMAL_NAME,13, 440),
new Difficulty(17, 541), new Difficulty( HARD_NAME,17, 541),
new Difficulty(26, 815), new Difficulty(EXPERT_NAME,26, 815),
new Difficulty(30, 973) new Difficulty(MASTER_NAME,30, 973)
) )
); );
/** <a href="https://www.sekaipedia.org/wiki/ID_Smile">...</a> */
public static final Song ID_SMILE = new Song( public static final Song ID_SMILE = new Song(
"アイディスマイル", SongUnit.NIGHTCORD_25JI, 116, "アイディスマイル", SongUnit.NIGHTCORD_25JI,
new DifficultiesSekai( new DifficultiesSekai(
new Difficulty( 7, 263), new Difficulty( EASY_NAME, 7, 263),
new Difficulty(12, 439), new Difficulty(NORMAL_NAME,12, 439),
new Difficulty(17, 703), new Difficulty( HARD_NAME,17, 703),
new Difficulty(25, 985), new Difficulty(EXPERT_NAME,25, 985),
new Difficulty(28, 1247) new Difficulty(MASTER_NAME,28, 1247)
) )
); );

View File

@ -5,26 +5,31 @@ import cc.sukazyo.sekai_scores.DifficultiesSekai;
import cc.sukazyo.sekai_scores.Song; import cc.sukazyo.sekai_scores.Song;
import cc.sukazyo.sekai_scores.SongUnit; import cc.sukazyo.sekai_scores.SongUnit;
import static cc.sukazyo.sekai_scores.DifficultiesSekai.*;
public class Other { public class Other {
/** <a href="https://www.sekaipedia.org/wiki/Don%27t_Fight_The_Music">...</a> */
public static final Song Dont_Fight_the_Music = new Song( public static final Song Dont_Fight_the_Music = new Song(
"Don't Fight The Music", SongUnit.OTHER, 164, "Don't Fight The Music", SongUnit.OTHER,
new DifficultiesSekai( new DifficultiesSekai(
new Difficulty( 9, 520), new Difficulty( EASY_NAME, 9, 520),
new Difficulty(15, 701), new Difficulty(NORMAL_NAME,15, 701),
new Difficulty(23, 1175), new Difficulty( HARD_NAME,23, 1175),
new Difficulty(30, 1545), new Difficulty(EXPERT_NAME,30, 1545),
new Difficulty(36, 1888) new Difficulty(MASTER_NAME,36, 1888)
) )
); );
/** <a href="https://www.sekaipedia.org/wiki/Tokugawa_Cup_Noodle_Kinshirei">...</a> */
public static final Song Tokugawa_Kappu_Nuudoru_Kinshirei = new Song( public static final Song Tokugawa_Kappu_Nuudoru_Kinshirei = new Song(
"徳川カップヌードル禁止令", SongUnit.OTHER, 234, "徳川カップヌードル禁止令", SongUnit.OTHER,
new DifficultiesSekai( new DifficultiesSekai(
new Difficulty( 8, 264), new Difficulty( EASY_NAME, 8, 264),
new Difficulty(13, 498), new Difficulty(NORMAL_NAME,13, 498),
new Difficulty(19, 758), new Difficulty( HARD_NAME,19, 758),
new Difficulty(27, 1065), new Difficulty(EXPERT_NAME,27, 1065),
new Difficulty(31, 1241) new Difficulty(MASTER_NAME,31, 1241)
) )
); );

View File

@ -5,26 +5,41 @@ import cc.sukazyo.sekai_scores.DifficultiesSekai;
import cc.sukazyo.sekai_scores.Song; import cc.sukazyo.sekai_scores.Song;
import cc.sukazyo.sekai_scores.SongUnit; import cc.sukazyo.sekai_scores.SongUnit;
import static cc.sukazyo.sekai_scores.DifficultiesSekai.*;
public class SekaiSpecial { public class SekaiSpecial {
public static final Song Gunjou_Sanka = new Song( /** <a href="https://www.sekaipedia.org/wiki/Yoru_ni_Kakeru">...</a> */
"群青讃歌", SongUnit.SP, public static final Song Yoru_ni_Kakeru = new Song(
139, "夜に駆ける", SongUnit.SP,
new DifficultiesSekai( new DifficultiesSekai(
new Difficulty( 7, 199), new Difficulty( EASY_NAME, 6, 182),
new Difficulty(13, 344), new Difficulty(NORMAL_NAME,11, 357),
new Difficulty(17, 475), new Difficulty( HARD_NAME,18, 594),
new Difficulty(24, 711), new Difficulty(EXPERT_NAME,25, 932),
new Difficulty(27, 833) new Difficulty(MASTER_NAME,29, 1140)
) )
); );
public static final Song Journey = new Song( /** <a href="https://www.sekaipedia.org/wiki/Gunjou_Sanka">...</a> */
"Journey", SongUnit.SP, public static final Song Gunjou_Sanka = new Song(
141, "群青讃歌", SongUnit.SP,
new DifficultiesSekai( new DifficultiesSekai(
new Difficulty( 6, 199), new Difficulty( EASY_NAME, 7, 199),
new Difficulty(12, 512), new Difficulty(NORMAL_NAME,13, 344),
new Difficulty(18, 922), new Difficulty( HARD_NAME,17, 475),
new Difficulty(25, 1285), new Difficulty(EXPERT_NAME,24, 711),
new Difficulty(28, 1322) new Difficulty(MASTER_NAME,27, 833)
)
);
/** <a href="https://www.sekaipedia.org/wiki/Journey">...</a> */
public static final Song Journey = new Song(
235, "Journey", SongUnit.SP,
new DifficultiesSekai(
new Difficulty( EASY_NAME, 6, 199),
new Difficulty(NORMAL_NAME,12, 512),
new Difficulty( HARD_NAME,18, 922),
new Difficulty(EXPERT_NAME,25, 1285),
new Difficulty(MASTER_NAME,28, 1322)
) )
); );

View File

@ -1,10 +1,10 @@
package cc.sukazyo.sekai_scores; package cc.sukazyo.sekai_scores;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import java.util.function.BiConsumer; import java.util.function.Consumer;
public interface Difficulties { public interface Difficulties {
void forEach(@Nonnull BiConsumer<String, Difficulty> action); void forEach(@Nonnull Consumer<Difficulty> action);
} }

View File

@ -1,7 +1,7 @@
package cc.sukazyo.sekai_scores; package cc.sukazyo.sekai_scores;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import java.util.function.BiConsumer; import java.util.function.Consumer;
public record DifficultiesSekai( public record DifficultiesSekai(
@Nonnull Difficulty easy, @Nonnull Difficulty easy,
@ -18,24 +18,20 @@ public record DifficultiesSekai(
public static final String MASTER_NAME = "MASTER"; public static final String MASTER_NAME = "MASTER";
@Override @Override
public void forEach (@Nonnull BiConsumer<String, Difficulty> action) { public void forEach (@Nonnull Consumer<Difficulty> action) {
action.accept(EASY_NAME, easy); action.accept(easy);
action.accept(NORMAL_NAME, normal); action.accept(normal);
action.accept(HARD_NAME, hard); action.accept(hard);
action.accept(EXPERT_NAME, expert); action.accept(expert);
action.accept(MASTER_NAME, master); action.accept(master);
} }
@Override @Override
@Nonnull @Nonnull
public String toString() { public String toString() {
return String.format( return String.format(
"[{\"id\":\"%s\",%s},{\"id\":\"%s\",%s},{\"id\":\"%s\",%s},{\"id\":\"%s\",%s},{\"id\":\"%s\",%s}]", "[%s,%s,%s,%s,%s]",
EASY_NAME, easy.toStringSimple(), easy,normal,hard,expert,master
NORMAL_NAME, normal.toStringSimple(),
HARD_NAME, hard.toStringSimple(),
EXPERT_NAME, expert.toStringSimple(),
MASTER_NAME, master.toStringSimple()
); );
} }

View File

@ -1,13 +1,21 @@
package cc.sukazyo.sekai_scores; package cc.sukazyo.sekai_scores;
import cc.sukazyo.sekai_scores.util.Converter;
import javax.annotation.Nonnegative; import javax.annotation.Nonnegative;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
public record Difficulty( public record Difficulty(
@Nonnegative String id,
@Nonnegative int level, @Nonnegative int level,
@Nonnegative int noteCount @Nonnegative int noteCount
) { ) {
/**
* @since 0.4
*/
@Nonnull public String id () { return id; }
/** /**
* The difficulty number of this difficulty map. * The difficulty number of this difficulty map.
* <p> * <p>
@ -37,8 +45,8 @@ public record Difficulty(
@Nonnull @Nonnull
public String toStringSimple () { public String toStringSimple () {
return String.format( return String.format(
"\"difficulty\":%d,\"notes\":%d", "\"id\":%s,\"difficulty\":%d,\"notes\":%d",
level, noteCount Converter.parseJSONString(id), level, noteCount
); );
} }

View File

@ -5,6 +5,7 @@ import cc.sukazyo.sekai_scores.util.Converter;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
public record Song( public record Song(
int id,
@Nonnull String name, @Nonnull String name,
@Nonnull SongUnit unit, @Nonnull SongUnit unit,
@Nonnull Difficulties difficulties @Nonnull Difficulties difficulties
@ -14,7 +15,8 @@ public record Song(
@Nonnull @Nonnull
public String toString () { public String toString () {
return String.format( return String.format(
"{\"name\":\"%s\",\"unit\":%s,\"difficulties\":%s}", "{\"id\":%d,\"name\":%s,\"unit\":%s,\"difficulties\":%s}",
id,
Converter.parseJSONString(name), Converter.parseJSONString(name),
unit, unit,
difficulties difficulties

View File

@ -55,7 +55,7 @@ public enum SongUnit {
@Nonnull @Nonnull
public String toString() { public String toString() {
return String.format( return String.format(
"{\"id\":%d,\"fullname\":\"%s\"}", "{\"id\":%d,\"fullname\":%s}",
id, id,
Converter.parseJSONString(name) Converter.parseJSONString(name)
); );

View File

@ -1,12 +1,14 @@
package cc.sukazyo.sekai_scores.util; package cc.sukazyo.sekai_scores.util;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public class Converter { public class Converter {
@Nonnull @Nonnull
public static String parseJSONString (@Nonnull String input) { public static String parseJSONString (@Nullable String input) {
return input.replaceAll("'", "\\'").replaceAll("\"", "\\\""); if (input == null) return "null";
return "\"" + input.replaceAll("\\\\", "\\\\\\\\").replaceAll("\"", "\\\\\"") + "\"";
} }
} }