1
0
mirror of https://github.com/Eyre-S/sekai-scores.git synced 2024-11-21 18:54: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
# Proj Metadata
projVersion = 0.5
projVersion = 0.6
# Dependencies

View File

@ -1,7 +1,7 @@
## Project Configurations
# Proj Metadata
moduleVersion = 0.5.1
moduleVersion = 0.5.2
# dependencies
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.Configs;
import cc.sukazyo.sekai_cli.client.Database;
import java.util.List;
@ -28,12 +29,19 @@ public class ClientMain {
if ($args.size() > 0) {
final String i0 = $args.remove(0);
if (i0.equals("add")) {
AddScore.main($args.toArray(String[]::new));
$done();
} else if (i0.equals("config")) {
Configs.main($args.toArray(String[]::new));
$done();
switch (i0) {
case "add" -> {
AddScore.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;
import cc.sukazyo.sekai_cli.db.PostgresConfig;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.io.File;
@ -25,6 +27,12 @@ public class Config {
@Nonnull public final String db_auth_pwd;
@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) {
// user config field
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() {
return struct == null ? "default" : struct;
return struct;
}
public String table (String table) {
return (struct == null ? "" : '"' + struct() + '"' + ".") + '"' + table + '"';
}
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> */
public static final Song Calc = new Song(
243, "Calc.", SongUnit.LEO_NEED,
243, "Calc.", SongUnit.LIGHT_SOUND,
new DifficultiesSekai(
new Difficulty( EASY_NAME, 7, 325),
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> */
public static final Song Kuyamu_to_Kaite_Mirai = new Song(
60, "悔やむと書いてミライ", SongUnit.NIGHTCORD_25JI,
60, "悔やむと書いてミライ", SongUnit.SCHOOL_REFUSAL,
new DifficultiesSekai(
new Difficulty( EASY_NAME, 8, 190),
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> */
public static final Song Keitai_Renwa = new Song(
61, "携帯恋話", SongUnit.NIGHTCORD_25JI,
61, "携帯恋話", SongUnit.SCHOOL_REFUSAL,
new DifficultiesSekai(
new Difficulty( EASY_NAME, 8, 204),
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> */
public static final Song ID_Smile = new Song(
116, "アイディスマイル", SongUnit.NIGHTCORD_25JI,
116, "アイディスマイル", SongUnit.SCHOOL_REFUSAL,
new DifficultiesSekai(
new Difficulty( EASY_NAME, 7, 263),
new Difficulty(NORMAL_NAME,12, 439),
@ -44,7 +44,7 @@ public class Nightcord25ji extends SongDefinition {
);
/** <a href="https://www.sekaipedia.org/wiki/Saisei">...</a> */
public static final Song Saisei = new Song(
142, "再生", SongUnit.NIGHTCORD_25JI,
142, "再生", SongUnit.SCHOOL_REFUSAL,
new DifficultiesSekai(
new Difficulty( EASY_NAME, 5, 124),
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> */
public static final Song Kanade_Tomosu_Sora = new Song(
149, "カナデトモスソラ", SongUnit.NIGHTCORD_25JI,
149, "カナデトモスソラ", SongUnit.SCHOOL_REFUSAL,
new DifficultiesSekai(
new Difficulty( EASY_NAME, 6, 213),
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> */
public static final Song Yoru_ni_Kakeru = new Song(
139, "夜に駆ける", SongUnit.SP,
139, "夜に駆ける", SongUnit._X,
new DifficultiesSekai(
new Difficulty( EASY_NAME, 6, 182),
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> */
public static final Song Gunjou_Sanka = new Song(
141, "群青讃歌", SongUnit.SP,
141, "群青讃歌", SongUnit._X,
new DifficultiesSekai(
new Difficulty( EASY_NAME, 7, 199),
new Difficulty(NORMAL_NAME,13, 344),
@ -33,7 +33,7 @@ public class SekaiSpecial extends SongDefinition {
);
/** <a href="https://www.sekaipedia.org/wiki/Journey">...</a> */
public static final Song Journey = new Song(
235, "Journey", SongUnit.SP,
235, "Journey", SongUnit._X,
new DifficultiesSekai(
new Difficulty( EASY_NAME, 6, 199),
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> */
public static final Song Luka_Luka_Night_Fever = new Song(
216, "ルカルカ★ナイトフィーバー", SongUnit.VSINGER,
216, "ルカルカ★ナイトフィーバー", SongUnit.PIAPRO,
new DifficultiesSekai(
new Difficulty( EASY_NAME, 7, 218),
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> */
public static final Song Donna_Ketsumatsu_ga_Onozomi_Dai = new Song(
290, "どんな結末がお望みだい?", SongUnit.WONDERLANDS_SHOWTIME,
290, "どんな結末がお望みだい?", SongUnit.THEME_PARK,
new DifficultiesSekai(
new Difficulty( EASY_NAME, 8, 215),
new Difficulty(NORMAL_NAME,12, 325),

View File

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

View File

@ -6,11 +6,26 @@ import javax.annotation.Nonnegative;
import javax.annotation.Nonnull;
public record Difficulty(
@Nonnegative String id,
@Nonnull String id,
@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
*/
@ -42,6 +57,9 @@ public record Difficulty(
return String.format("{%s}", toStringSimple());
}
/**
* outdated since v0.6: data type update
*/
@Nonnull
public String toStringSimple () {
return String.format(

View File

@ -3,14 +3,39 @@ package cc.sukazyo.sekai_scores;
import cc.sukazyo.sekai_scores.util.Converter;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.time.Duration;
import java.time.ZonedDateTime;
public record Song(
int id,
@Nonnull String name,
@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
@Nonnull
public String toString () {

View File

@ -6,17 +6,17 @@ import javax.annotation.Nonnull;
public enum SongUnit {
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時、ナイトコードで。"),
PIAPRO(1, "VIRTUAL SINGER"),
LIGHT_SOUND(2, "Leo/need"),
IDOL(3, "MORE MORE JUMP!"),
STREET(4, "Vivid BAD SQUAD"),
THEME_PARK(5, "ワンダーランズ×ショウタイム"),
SCHOOL_REFUSAL(6, "25時、ナイトコードで。"),
/**
* Just the "other" unit in game.
* @since 0.2
*/
OTHER(-1, "other"),
OTHER(7, "other"),
/**
* It collects that songs belongs to multiple units.
* <p>
@ -27,27 +27,41 @@ public enum SongUnit {
* This unit/group doesn't exist in the game.
* @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.
* <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.
* <p>
* for some special group/unit, it has a special id:
* <ul>
* <li>{@link #OTHER}: {@link -1}, 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 #OTHER}: {@link 7}, as a special group that even exists in game</li>
* <li>{@link #_X}: {@link -1}, as a group that doesn't exist in game</li>
* </ul>
* @since 0.3
*/
public final int id;
public final int seq;
@Nonnull public final String name;
SongUnit (int id, @Nonnull String name) {
this.id = id;
SongUnit (int seq, @Nonnull String name) {
this.seq = seq;
this.name = name;
}
@ -55,8 +69,8 @@ public enum SongUnit {
@Nonnull
public String toString() {
return String.format(
"{\"id\":%d,\"fullname\":%s}",
id,
"{\"seq\":%d,\"fullname\":%s}",
seq,
Converter.parseJSONString(name)
);
}