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

change data/meta definition.

- change the id and seq and name def of SongUnit
- change and added fields to Song
- change and added fields to Difficulty
- add subproj sekai-database for db connection and action(empty currently)
- add sekai-cli command database to execute database manager action(no implementation currently)
This commit is contained in:
A.C.Sukazyo Eyre 2022-12-05 22:16:06 +08:00
parent 2fd49d2bdb
commit 21dbb194fd
Signed by: Eyre_S
GPG Key ID: C17CE40291207874
16 changed files with 182 additions and 39 deletions

View File

@ -1,7 +1,7 @@
## Project Configurations ## Project Configurations
# Proj Metadata # Proj Metadata
projVersion = 0.5 projVersion = 0.6
# Dependencies # Dependencies

View File

@ -1,7 +1,7 @@
## Project Configurations ## Project Configurations
# Proj Metadata # Proj Metadata
moduleVersion = 0.5.1 moduleVersion = 0.5.2
# dependencies # dependencies
lib_postgres_driver = 42.5.1 lib_postgres_driver = 42.5.1

View File

@ -2,6 +2,7 @@ package cc.sukazyo.sekai_cli;
import cc.sukazyo.sekai_cli.client.AddScore; import cc.sukazyo.sekai_cli.client.AddScore;
import cc.sukazyo.sekai_cli.client.Configs; import cc.sukazyo.sekai_cli.client.Configs;
import cc.sukazyo.sekai_cli.client.Database;
import java.util.List; import java.util.List;
@ -28,12 +29,19 @@ public class ClientMain {
if ($args.size() > 0) { if ($args.size() > 0) {
final String i0 = $args.remove(0); final String i0 = $args.remove(0);
if (i0.equals("add")) { switch (i0) {
AddScore.main($args.toArray(String[]::new)); case "add" -> {
$done(); AddScore.main($args.toArray(String[]::new));
} else if (i0.equals("config")) { $done();
Configs.main($args.toArray(String[]::new)); }
$done(); case "config" -> {
Configs.main($args.toArray(String[]::new));
$done();
}
case "database" -> {
Database.main($args.toArray(String[]::new));
$done();
}
} }
} }

View File

@ -1,5 +1,7 @@
package cc.sukazyo.sekai_cli; package cc.sukazyo.sekai_cli;
import cc.sukazyo.sekai_cli.db.PostgresConfig;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import java.io.File; import java.io.File;
@ -25,6 +27,12 @@ public class Config {
@Nonnull public final String db_auth_pwd; @Nonnull public final String db_auth_pwd;
@Nullable public final String db_schema; @Nullable public final String db_schema;
private PostgresConfig db = null;
public PostgresConfig db () {
if (db == null) db = new PostgresConfig(this);
return db;
}
private Config (Properties props) { private Config (Properties props) {
// user config field // user config field
this.sekai_id = Long.parseLong(props.getProperty("user.sekai-id")); this.sekai_id = Long.parseLong(props.getProperty("user.sekai-id"));

View File

@ -0,0 +1,46 @@
package cc.sukazyo.sekai_cli.client;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.List;
import static cc.sukazyo.sekai_cli.Log._debug;
import static cc.sukazyo.sekai_cli.Log._user;
public class Database {
public static void main (String[] args) {
final List<String> $args = Arrays.asList(args);
final String subcommand = $args.remove(0);
if (subcommand.equals("import")) {
if ($args.isEmpty()) {
System.out.println("""
database import: <type> <file-path>
currently available types:
song
song-difficulty
""");
} else {
final Path file;
try { file = Paths.get($args.remove(1)); }
catch (IndexOutOfBoundsException e) {
_user("database import: need a file path.");
_debug(e);
}
switch ($args.remove(0)) {
case "song" ->
_user("type song: WIP");
case "song-difficulty" ->
_user("type song-difficulty: WIP");
default ->
_user("unavailable type.\ncurrently available types:\n song\n song-difficulty");
}
}
}
}
}

View File

@ -37,7 +37,11 @@ public class PostgresConfig {
} }
public String struct() { public String struct() {
return struct == null ? "default" : struct; return struct;
}
public String table (String table) {
return (struct == null ? "" : '"' + struct() + '"' + ".") + '"' + table + '"';
} }
public Connection connect () throws SQLException { public Connection connect () throws SQLException {

View File

@ -0,0 +1,19 @@
plugins {
id 'java'
}
group 'cc.sukazyo'
version projVersion
repositories {
mavenCentral()
}
dependencies {
testImplementation "org.junit.jupiter:junit-jupiter-api:${lib_junit_v}"
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:${lib_junit_v}"
}
test {
useJUnitPlatform()
}

View File

@ -11,7 +11,7 @@ public class LeoNeed extends SongDefinition {
/** <a href="https://www.sekaipedia.org/wiki/Calc.">...</a> */ /** <a href="https://www.sekaipedia.org/wiki/Calc.">...</a> */
public static final Song Calc = new Song( public static final Song Calc = new Song(
243, "Calc.", SongUnit.LEO_NEED, 243, "Calc.", SongUnit.LIGHT_SOUND,
new DifficultiesSekai( new DifficultiesSekai(
new Difficulty( EASY_NAME, 7, 325), new Difficulty( EASY_NAME, 7, 325),
new Difficulty(NORMAL_NAME,13, 464), new Difficulty(NORMAL_NAME,13, 464),

View File

@ -11,7 +11,7 @@ public class Nightcord25ji extends SongDefinition {
/** <a href="https://www.sekaipedia.org/wiki/Kuyamu_to_Kaite_Mirai">...</a> */ /** <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(
60, "悔やむと書いてミライ", SongUnit.NIGHTCORD_25JI, 60, "悔やむと書いてミライ", SongUnit.SCHOOL_REFUSAL,
new DifficultiesSekai( new DifficultiesSekai(
new Difficulty( EASY_NAME, 8, 190), new Difficulty( EASY_NAME, 8, 190),
new Difficulty(NORMAL_NAME,13, 440), new Difficulty(NORMAL_NAME,13, 440),
@ -22,7 +22,7 @@ public class Nightcord25ji extends SongDefinition {
); );
/** <a href="https://www.sekaipedia.org/wiki/Keitai_Renwa">...</a> */ /** <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(
61, "携帯恋話", SongUnit.NIGHTCORD_25JI, 61, "携帯恋話", SongUnit.SCHOOL_REFUSAL,
new DifficultiesSekai( new DifficultiesSekai(
new Difficulty( EASY_NAME, 8, 204), new Difficulty( EASY_NAME, 8, 204),
new Difficulty(NORMAL_NAME, 12, 361), new Difficulty(NORMAL_NAME, 12, 361),
@ -33,7 +33,7 @@ public class Nightcord25ji extends SongDefinition {
); );
/** <a href="https://www.sekaipedia.org/wiki/ID_Smile">...</a> */ /** <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(
116, "アイディスマイル", SongUnit.NIGHTCORD_25JI, 116, "アイディスマイル", SongUnit.SCHOOL_REFUSAL,
new DifficultiesSekai( new DifficultiesSekai(
new Difficulty( EASY_NAME, 7, 263), new Difficulty( EASY_NAME, 7, 263),
new Difficulty(NORMAL_NAME,12, 439), new Difficulty(NORMAL_NAME,12, 439),
@ -44,7 +44,7 @@ public class Nightcord25ji extends SongDefinition {
); );
/** <a href="https://www.sekaipedia.org/wiki/Saisei">...</a> */ /** <a href="https://www.sekaipedia.org/wiki/Saisei">...</a> */
public static final Song Saisei = new Song( public static final Song Saisei = new Song(
142, "再生", SongUnit.NIGHTCORD_25JI, 142, "再生", SongUnit.SCHOOL_REFUSAL,
new DifficultiesSekai( new DifficultiesSekai(
new Difficulty( EASY_NAME, 5, 124), new Difficulty( EASY_NAME, 5, 124),
new Difficulty(NORMAL_NAME,11, 221), new Difficulty(NORMAL_NAME,11, 221),
@ -55,7 +55,7 @@ public class Nightcord25ji extends SongDefinition {
); );
/** <a href="https://www.sekaipedia.org/wiki/Kanade_Tomosu_Sora">...</a> */ /** <a href="https://www.sekaipedia.org/wiki/Kanade_Tomosu_Sora">...</a> */
public static final Song Kanade_Tomosu_Sora = new Song( public static final Song Kanade_Tomosu_Sora = new Song(
149, "カナデトモスソラ", SongUnit.NIGHTCORD_25JI, 149, "カナデトモスソラ", SongUnit.SCHOOL_REFUSAL,
new DifficultiesSekai( new DifficultiesSekai(
new Difficulty( EASY_NAME, 6, 213), new Difficulty( EASY_NAME, 6, 213),
new Difficulty(NORMAL_NAME,11, 312), new Difficulty(NORMAL_NAME,11, 312),

View File

@ -11,7 +11,7 @@ public class SekaiSpecial extends SongDefinition {
/** <a href="https://www.sekaipedia.org/wiki/Yoru_ni_Kakeru">...</a> */ /** <a href="https://www.sekaipedia.org/wiki/Yoru_ni_Kakeru">...</a> */
public static final Song Yoru_ni_Kakeru = new Song( public static final Song Yoru_ni_Kakeru = new Song(
139, "夜に駆ける", SongUnit.SP, 139, "夜に駆ける", SongUnit._X,
new DifficultiesSekai( new DifficultiesSekai(
new Difficulty( EASY_NAME, 6, 182), new Difficulty( EASY_NAME, 6, 182),
new Difficulty(NORMAL_NAME,11, 357), new Difficulty(NORMAL_NAME,11, 357),
@ -22,7 +22,7 @@ public class SekaiSpecial extends SongDefinition {
); );
/** <a href="https://www.sekaipedia.org/wiki/Gunjou_Sanka">...</a> */ /** <a href="https://www.sekaipedia.org/wiki/Gunjou_Sanka">...</a> */
public static final Song Gunjou_Sanka = new Song( public static final Song Gunjou_Sanka = new Song(
141, "群青讃歌", SongUnit.SP, 141, "群青讃歌", SongUnit._X,
new DifficultiesSekai( new DifficultiesSekai(
new Difficulty( EASY_NAME, 7, 199), new Difficulty( EASY_NAME, 7, 199),
new Difficulty(NORMAL_NAME,13, 344), new Difficulty(NORMAL_NAME,13, 344),
@ -33,7 +33,7 @@ public class SekaiSpecial extends SongDefinition {
); );
/** <a href="https://www.sekaipedia.org/wiki/Journey">...</a> */ /** <a href="https://www.sekaipedia.org/wiki/Journey">...</a> */
public static final Song Journey = new Song( public static final Song Journey = new Song(
235, "Journey", SongUnit.SP, 235, "Journey", SongUnit._X,
new DifficultiesSekai( new DifficultiesSekai(
new Difficulty( EASY_NAME, 6, 199), new Difficulty( EASY_NAME, 6, 199),
new Difficulty(NORMAL_NAME,12, 512), new Difficulty(NORMAL_NAME,12, 512),

View File

@ -11,7 +11,7 @@ public class VSinger extends SongDefinition {
/** <a href="https://www.sekaipedia.org/wiki/Donna_Ketsumatsu_ga_Onozomi_Dai%3F">...</a> */ /** <a href="https://www.sekaipedia.org/wiki/Donna_Ketsumatsu_ga_Onozomi_Dai%3F">...</a> */
public static final Song Luka_Luka_Night_Fever = new Song( public static final Song Luka_Luka_Night_Fever = new Song(
216, "ルカルカ★ナイトフィーバー", SongUnit.VSINGER, 216, "ルカルカ★ナイトフィーバー", SongUnit.PIAPRO,
new DifficultiesSekai( new DifficultiesSekai(
new Difficulty( EASY_NAME, 7, 218), new Difficulty( EASY_NAME, 7, 218),
new Difficulty(NORMAL_NAME,13, 457), new Difficulty(NORMAL_NAME,13, 457),

View File

@ -11,7 +11,7 @@ public class WonderlandsShowtime extends SongDefinition {
/** <a href="https://www.sekaipedia.org/wiki/Donna_Ketsumatsu_ga_Onozomi_Dai%3F">...</a> */ /** <a href="https://www.sekaipedia.org/wiki/Donna_Ketsumatsu_ga_Onozomi_Dai%3F">...</a> */
public static final Song Donna_Ketsumatsu_ga_Onozomi_Dai = new Song( public static final Song Donna_Ketsumatsu_ga_Onozomi_Dai = new Song(
290, "どんな結末がお望みだい?", SongUnit.WONDERLANDS_SHOWTIME, 290, "どんな結末がお望みだい?", SongUnit.THEME_PARK,
new DifficultiesSekai( new DifficultiesSekai(
new Difficulty( EASY_NAME, 8, 215), new Difficulty( EASY_NAME, 8, 215),
new Difficulty(NORMAL_NAME,12, 325), new Difficulty(NORMAL_NAME,12, 325),

View File

@ -1,4 +1,5 @@
rootProject.name = 'sekai-scores' rootProject.name = 'sekai-scores'
include 'sekai-cli' include 'sekai-cli'
include 'sekai-meta' include 'sekai-meta'
include 'sekai-database'

View File

@ -6,11 +6,26 @@ import javax.annotation.Nonnegative;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
public record Difficulty( public record Difficulty(
@Nonnegative String id, @Nonnull String id,
@Nonnegative int level, @Nonnegative int level,
@Nonnegative int noteCount @Nonnegative int noteCount,
int levelPlus,
int levelPlus_f,
int levelPlus_p
) { ) {
public static final int NULL = -1;
/**
* capability constructor for v0.5
*/
public Difficulty (@Nonnull String id, @Nonnegative int level, @Nonnegative int noteCount) {
this(
id, level, noteCount,
NULL, NULL, NULL
);
}
/** /**
* @since 0.4 * @since 0.4
*/ */
@ -42,6 +57,9 @@ public record Difficulty(
return String.format("{%s}", toStringSimple()); return String.format("{%s}", toStringSimple());
} }
/**
* outdated since v0.6: data type update
*/
@Nonnull @Nonnull
public String toStringSimple () { public String toStringSimple () {
return String.format( return String.format(

View File

@ -3,14 +3,39 @@ package cc.sukazyo.sekai_scores;
import cc.sukazyo.sekai_scores.util.Converter; import cc.sukazyo.sekai_scores.util.Converter;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.time.Duration;
import java.time.ZonedDateTime;
public record Song( public record Song(
int id, int id,
@Nonnull String name, @Nonnull String name,
@Nonnull SongUnit unit, @Nonnull SongUnit unit,
@Nonnull Difficulties difficulties @Nonnull Difficulties difficulties,
@Nullable String producer,
@Nullable String arranger,
@Nullable String composer,
@Nullable String lyricist,
@Nullable int[] bpm,
@Nullable Duration duration,
@Nullable ZonedDateTime releaseDate,
@Nullable String[] nameAlias
) { ) {
/**
* capability constructor for v0.5
*/
public Song (int id, @Nonnull String name, @Nonnull SongUnit unit, @Nonnull Difficulties difficulties) {
this(
id, name, unit, difficulties,
null, null, null, null,
null, null, null, null
);
}
/**
* !! outdated since v0.6: data type update
*/
@Override @Override
@Nonnull @Nonnull
public String toString () { public String toString () {

View File

@ -6,17 +6,17 @@ import javax.annotation.Nonnull;
public enum SongUnit { public enum SongUnit {
VSINGER(0, "VIRTUAL SINGER"), PIAPRO(1, "VIRTUAL SINGER"),
LEO_NEED(1, "Leo/need"), LIGHT_SOUND(2, "Leo/need"),
MORE_MORE_JUMP(2, "MORE MORE JUMP!"), IDOL(3, "MORE MORE JUMP!"),
VIVID_BAD_SQUAD(3, "Vivid BAD SQUAD"), STREET(4, "Vivid BAD SQUAD"),
WONDERLANDS_SHOWTIME(4, "ワンダーランズ×ショウタイム"), THEME_PARK(5, "ワンダーランズ×ショウタイム"),
NIGHTCORD_25JI(5, "25時、ナイトコードで。"), SCHOOL_REFUSAL(6, "25時、ナイトコードで。"),
/** /**
* Just the "other" unit in game. * Just the "other" unit in game.
* @since 0.2 * @since 0.2
*/ */
OTHER(-1, "other"), OTHER(7, "other"),
/** /**
* It collects that songs belongs to multiple units. * It collects that songs belongs to multiple units.
* <p> * <p>
@ -27,27 +27,41 @@ public enum SongUnit {
* This unit/group doesn't exist in the game. * This unit/group doesn't exist in the game.
* @since 0.2 * @since 0.2
*/ */
SP(-2, "セカイ") _X(-1, "セカイ")
; ;
public SongUnit getBySeq(int seq) {
return switch (seq) {
case 1 -> PIAPRO;
case 2 -> LIGHT_SOUND;
case 3 -> IDOL;
case 4 -> STREET;
case 5 -> THEME_PARK;
case 6 -> SCHOOL_REFUSAL;
case 7 -> OTHER;
case -1 -> _X;
default -> null;
};
}
/** /**
* An id of this group/unit. * An id of this group/unit.
* <p> * <p>
* The value start at 0 for {@link #VSINGER} * The value start at 1 for {@link #PIAPRO} which is <i>VIRTUAL SINGER</i>
* and increment according to the order of the groups/units in the game. * and increment according to the order of the groups/units in the game.
* <p> * <p>
* for some special group/unit, it has a special id: * for some special group/unit, it has a special id:
* <ul> * <ul>
* <li>{@link #OTHER}: {@link -1}, as a special group that even exists in game</li> * <li>{@link #OTHER}: {@link 7}, as a special group that even exists in game</li>
* <li>{@link #SP}: {@link -2}, as a group that doesn't exist in game</li> * <li>{@link #_X}: {@link -1}, as a group that doesn't exist in game</li>
* </ul> * </ul>
* @since 0.3 * @since 0.3
*/ */
public final int id; public final int seq;
@Nonnull public final String name; @Nonnull public final String name;
SongUnit (int id, @Nonnull String name) { SongUnit (int seq, @Nonnull String name) {
this.id = id; this.seq = seq;
this.name = name; this.name = name;
} }
@ -55,8 +69,8 @@ public enum SongUnit {
@Nonnull @Nonnull
public String toString() { public String toString() {
return String.format( return String.format(
"{\"id\":%d,\"fullname\":%s}", "{\"seq\":%d,\"fullname\":%s}",
id, seq,
Converter.parseJSONString(name) Converter.parseJSONString(name)
); );
} }