1
0
mirror of synced 2024-11-14 10:27:48 +01:00

Merge pull request #20 from asesidaa/CHN

Merge from TaikoLocalServer-CHN repo
This commit is contained in:
asesidaa 2023-10-16 17:42:53 +08:00 committed by GitHub
commit 05e43bfd2e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
844 changed files with 10284 additions and 5356 deletions

View File

@ -4,7 +4,7 @@ namespace GameDatabase.Entities;
public class AiScoreDatum public class AiScoreDatum
{ {
public uint Baid { get; set; } public ulong Baid { get; set; }
public uint SongId { get; set; } public uint SongId { get; set; }

View File

@ -4,7 +4,7 @@ namespace GameDatabase.Entities;
public class AiSectionScoreDatum public class AiSectionScoreDatum
{ {
public uint Baid { get; set; } public ulong Baid { get; set; }
public uint SongId { get; set; } public uint SongId { get; set; }

View File

@ -3,6 +3,8 @@
public partial class Card public partial class Card
{ {
public string AccessCode { get; set; } = null!; public string AccessCode { get; set; } = null!;
public uint Baid { get; set; } public ulong Baid { get; set; }
public string Password { get; set; } = null!;
public string Salt { get; set; } = null!;
} }
} }

View File

@ -4,7 +4,7 @@ namespace GameDatabase.Entities;
public class DanScoreDatum public class DanScoreDatum
{ {
public uint Baid { get; set; } public ulong Baid { get; set; }
public uint DanId { get; set; } public uint DanId { get; set; }
public uint ArrivalSongCount { get; set; } public uint ArrivalSongCount { get; set; }
public uint SoulGaugeTotal { get; set; } public uint SoulGaugeTotal { get; set; }

View File

@ -2,7 +2,7 @@
public class DanStageScoreDatum public class DanStageScoreDatum
{ {
public uint Baid { get; set; } public ulong Baid { get; set; }
public uint DanId { get; set; } public uint DanId { get; set; }

View File

@ -4,7 +4,7 @@ namespace GameDatabase.Entities
{ {
public partial class SongBestDatum public partial class SongBestDatum
{ {
public uint Baid { get; set; } public ulong Baid { get; set; }
public uint SongId { get; set; } public uint SongId { get; set; }
public Difficulty Difficulty { get; set; } public Difficulty Difficulty { get; set; }
public uint BestScore { get; set; } public uint BestScore { get; set; }

View File

@ -5,7 +5,7 @@ namespace GameDatabase.Entities
public partial class SongPlayDatum public partial class SongPlayDatum
{ {
public long Id { get; set; } public long Id { get; set; }
public uint Baid { get; set; } public ulong Baid { get; set; }
public uint SongNumber { get; set; } public uint SongNumber { get; set; }

View File

@ -4,8 +4,9 @@ namespace GameDatabase.Entities
{ {
public partial class UserDatum public partial class UserDatum
{ {
public uint Baid { get; set; } public ulong Baid { get; set; }
public string MyDonName { get; set; } = string.Empty; public string MyDonName { get; set; } = string.Empty;
public uint MyDonNameLanguage { get; set; }
public string Title { get; set; } = string.Empty; public string Title { get; set; } = string.Empty;
public uint TitlePlateId { get; set; } public uint TitlePlateId { get; set; }
public string FavoriteSongsArray { get; set; } = "[]"; public string FavoriteSongsArray { get; set; } = "[]";
@ -17,18 +18,21 @@ namespace GameDatabase.Entities
public int NotesPosition { get; set; } public int NotesPosition { get; set; }
public bool IsVoiceOn { get; set; } public bool IsVoiceOn { get; set; }
public bool IsSkipOn { get; set; } public bool IsSkipOn { get; set; }
public string DifficultyPlayedArray { get; set; } = "[]";
public string DifficultySettingArray { get; set; } = "[]";
public uint SelectedToneId { get; set; } public uint SelectedToneId { get; set; }
public DateTime LastPlayDatetime { get; set; } public DateTime LastPlayDatetime { get; set; }
public uint LastPlayMode { get; set; } public uint LastPlayMode { get; set; }
public uint ColorBody { get; set; } public uint ColorBody { get; set; }
public uint ColorFace { get; set; } public uint ColorFace { get; set; }
public uint ColorLimb { get; set; } public uint ColorLimb { get; set; }
public string CostumeData { get; set; } = "[[],[],[],[],[]]"; public string CostumeData { get; set; } = "[]";
public bool DisplayDan { get; set; } public bool DisplayDan { get; set; }
public bool DisplayAchievement { get; set; } public bool DisplayAchievement { get; set; }
public Difficulty AchievementDisplayDifficulty { get; set; } public Difficulty AchievementDisplayDifficulty { get; set; }
public int AiWinCount { get; set; } public int AiWinCount { get; set; }
public string TokenCountDict { get; set; } = "{}";
public string UnlockedSongIdList { get; set; } = "[]";
public virtual Card? Ba { get; set; } public virtual Card? Ba { get; set; }
} }
} }

View File

@ -1,9 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net6.0</TargetFramework> <TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<LangVersion>11</LangVersion>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
@ -11,9 +12,9 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.0-rc.1.22426.7" /> <PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.0-rc.1.23419.6" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="7.0.0-rc.1.22426.7" /> <PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.0-rc.1.23419.6" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.0-rc.1.22426.7"> <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.0-rc.1.23419.6">
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference> </PackageReference>

View File

@ -0,0 +1,443 @@
// <auto-generated />
using System;
using GameDatabase.Context;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace TaikoLocalServer.Migrations
{
[DbContext(typeof(TaikoDbContext))]
[Migration("20230916161613_AddTokenCountDictAndUnlockedSongIdListToUserdata")]
partial class AddTokenCountDictAndUnlockedSongIdListToUserdata
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "7.0.0-rc.1.22426.7");
modelBuilder.Entity("GameDatabase.Entities.AiScoreDatum", b =>
{
b.Property<ulong>("Baid")
.HasColumnType("INTEGER");
b.Property<uint>("SongId")
.HasColumnType("INTEGER");
b.Property<uint>("Difficulty")
.HasColumnType("INTEGER");
b.Property<bool>("IsWin")
.HasColumnType("INTEGER");
b.HasKey("Baid", "SongId", "Difficulty");
b.ToTable("AiScoreData");
});
modelBuilder.Entity("GameDatabase.Entities.AiSectionScoreDatum", b =>
{
b.Property<ulong>("Baid")
.HasColumnType("INTEGER");
b.Property<uint>("SongId")
.HasColumnType("INTEGER");
b.Property<uint>("Difficulty")
.HasColumnType("INTEGER");
b.Property<int>("SectionIndex")
.HasColumnType("INTEGER");
b.Property<int>("Crown")
.HasColumnType("INTEGER");
b.Property<uint>("DrumrollCount")
.HasColumnType("INTEGER");
b.Property<uint>("GoodCount")
.HasColumnType("INTEGER");
b.Property<bool>("IsWin")
.HasColumnType("INTEGER");
b.Property<uint>("MissCount")
.HasColumnType("INTEGER");
b.Property<uint>("OkCount")
.HasColumnType("INTEGER");
b.Property<uint>("Score")
.HasColumnType("INTEGER");
b.HasKey("Baid", "SongId", "Difficulty", "SectionIndex");
b.ToTable("AiSectionScoreData");
});
modelBuilder.Entity("GameDatabase.Entities.Card", b =>
{
b.Property<string>("AccessCode")
.HasColumnType("TEXT");
b.Property<ulong>("Baid")
.HasColumnType("INTEGER");
b.HasKey("AccessCode");
b.HasIndex(new[] { "Baid" }, "IX_Card_Baid")
.IsUnique();
b.ToTable("Card", (string)null);
});
modelBuilder.Entity("GameDatabase.Entities.DanScoreDatum", b =>
{
b.Property<ulong>("Baid")
.HasColumnType("INTEGER");
b.Property<uint>("DanId")
.HasColumnType("INTEGER");
b.Property<uint>("ArrivalSongCount")
.HasColumnType("INTEGER");
b.Property<uint>("ClearState")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER")
.HasDefaultValue(0u);
b.Property<uint>("ComboCountTotal")
.HasColumnType("INTEGER");
b.Property<uint>("SoulGaugeTotal")
.HasColumnType("INTEGER");
b.HasKey("Baid", "DanId");
b.ToTable("DanScoreData");
});
modelBuilder.Entity("GameDatabase.Entities.DanStageScoreDatum", b =>
{
b.Property<ulong>("Baid")
.HasColumnType("INTEGER");
b.Property<uint>("DanId")
.HasColumnType("INTEGER");
b.Property<uint>("SongNumber")
.HasColumnType("INTEGER");
b.Property<uint>("BadCount")
.HasColumnType("INTEGER");
b.Property<uint>("ComboCount")
.HasColumnType("INTEGER");
b.Property<uint>("DrumrollCount")
.HasColumnType("INTEGER");
b.Property<uint>("GoodCount")
.HasColumnType("INTEGER");
b.Property<uint>("HighScore")
.HasColumnType("INTEGER");
b.Property<uint>("OkCount")
.HasColumnType("INTEGER");
b.Property<uint>("PlayScore")
.HasColumnType("INTEGER");
b.Property<uint>("TotalHitCount")
.HasColumnType("INTEGER");
b.HasKey("Baid", "DanId", "SongNumber");
b.ToTable("DanStageScoreData");
});
modelBuilder.Entity("GameDatabase.Entities.SongBestDatum", b =>
{
b.Property<ulong>("Baid")
.HasColumnType("INTEGER");
b.Property<uint>("SongId")
.HasColumnType("INTEGER");
b.Property<uint>("Difficulty")
.HasColumnType("INTEGER");
b.Property<uint>("BestCrown")
.HasColumnType("INTEGER");
b.Property<uint>("BestRate")
.HasColumnType("INTEGER");
b.Property<uint>("BestScore")
.HasColumnType("INTEGER");
b.Property<uint>("BestScoreRank")
.HasColumnType("INTEGER");
b.HasKey("Baid", "SongId", "Difficulty");
b.ToTable("SongBestData");
});
modelBuilder.Entity("GameDatabase.Entities.SongPlayDatum", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<ulong>("Baid")
.HasColumnType("INTEGER");
b.Property<uint>("ComboCount")
.HasColumnType("INTEGER");
b.Property<uint>("Crown")
.HasColumnType("INTEGER");
b.Property<uint>("Difficulty")
.HasColumnType("INTEGER");
b.Property<uint>("DrumrollCount")
.HasColumnType("INTEGER");
b.Property<uint>("GoodCount")
.HasColumnType("INTEGER");
b.Property<uint>("HitCount")
.HasColumnType("INTEGER");
b.Property<uint>("MissCount")
.HasColumnType("INTEGER");
b.Property<uint>("OkCount")
.HasColumnType("INTEGER");
b.Property<DateTime>("PlayTime")
.HasColumnType("datetime");
b.Property<uint>("Score")
.HasColumnType("INTEGER");
b.Property<uint>("ScoreRank")
.HasColumnType("INTEGER");
b.Property<uint>("ScoreRate")
.HasColumnType("INTEGER");
b.Property<bool>("Skipped")
.HasColumnType("INTEGER");
b.Property<uint>("SongId")
.HasColumnType("INTEGER");
b.Property<uint>("SongNumber")
.HasColumnType("INTEGER");
b.HasKey("Id");
b.HasIndex("Baid");
b.ToTable("SongPlayData");
});
modelBuilder.Entity("GameDatabase.Entities.UserDatum", b =>
{
b.Property<ulong>("Baid")
.HasColumnType("INTEGER");
b.Property<uint>("AchievementDisplayDifficulty")
.HasColumnType("INTEGER");
b.Property<int>("AiWinCount")
.HasColumnType("INTEGER");
b.Property<uint>("ColorBody")
.HasColumnType("INTEGER");
b.Property<uint>("ColorFace")
.HasColumnType("INTEGER");
b.Property<uint>("ColorLimb")
.HasColumnType("INTEGER");
b.Property<string>("CostumeData")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("CostumeFlgArray")
.IsRequired()
.HasColumnType("TEXT");
b.Property<bool>("DisplayAchievement")
.HasColumnType("INTEGER");
b.Property<bool>("DisplayDan")
.HasColumnType("INTEGER");
b.Property<string>("FavoriteSongsArray")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("GenericInfoFlgArray")
.IsRequired()
.HasColumnType("TEXT");
b.Property<bool>("IsSkipOn")
.HasColumnType("INTEGER");
b.Property<bool>("IsVoiceOn")
.HasColumnType("INTEGER");
b.Property<DateTime>("LastPlayDatetime")
.HasColumnType("datetime");
b.Property<uint>("LastPlayMode")
.HasColumnType("INTEGER");
b.Property<string>("MyDonName")
.IsRequired()
.HasColumnType("TEXT");
b.Property<int>("NotesPosition")
.HasColumnType("INTEGER");
b.Property<short>("OptionSetting")
.HasColumnType("INTEGER");
b.Property<uint>("SelectedToneId")
.HasColumnType("INTEGER");
b.Property<string>("Title")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("TitleFlgArray")
.IsRequired()
.HasColumnType("TEXT");
b.Property<uint>("TitlePlateId")
.HasColumnType("INTEGER");
b.Property<string>("TokenCountDict")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("ToneFlgArray")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("UnlockedSongIdList")
.IsRequired()
.HasColumnType("TEXT");
b.HasKey("Baid");
b.ToTable("UserData");
});
modelBuilder.Entity("GameDatabase.Entities.AiScoreDatum", b =>
{
b.HasOne("GameDatabase.Entities.Card", "Ba")
.WithMany()
.HasForeignKey("Baid")
.HasPrincipalKey("Baid")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Ba");
});
modelBuilder.Entity("GameDatabase.Entities.AiSectionScoreDatum", b =>
{
b.HasOne("GameDatabase.Entities.AiScoreDatum", "Parent")
.WithMany("AiSectionScoreData")
.HasForeignKey("Baid", "SongId", "Difficulty")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Parent");
});
modelBuilder.Entity("GameDatabase.Entities.DanScoreDatum", b =>
{
b.HasOne("GameDatabase.Entities.Card", "Ba")
.WithMany()
.HasForeignKey("Baid")
.HasPrincipalKey("Baid")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Ba");
});
modelBuilder.Entity("GameDatabase.Entities.DanStageScoreDatum", b =>
{
b.HasOne("GameDatabase.Entities.DanScoreDatum", "Parent")
.WithMany("DanStageScoreData")
.HasForeignKey("Baid", "DanId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Parent");
});
modelBuilder.Entity("GameDatabase.Entities.SongBestDatum", b =>
{
b.HasOne("GameDatabase.Entities.Card", "Ba")
.WithMany()
.HasForeignKey("Baid")
.HasPrincipalKey("Baid")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Ba");
});
modelBuilder.Entity("GameDatabase.Entities.SongPlayDatum", b =>
{
b.HasOne("GameDatabase.Entities.Card", "Ba")
.WithMany()
.HasForeignKey("Baid")
.HasPrincipalKey("Baid")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Ba");
});
modelBuilder.Entity("GameDatabase.Entities.UserDatum", b =>
{
b.HasOne("GameDatabase.Entities.Card", "Ba")
.WithMany()
.HasForeignKey("Baid")
.HasPrincipalKey("Baid")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Ba");
});
modelBuilder.Entity("GameDatabase.Entities.AiScoreDatum", b =>
{
b.Navigation("AiSectionScoreData");
});
modelBuilder.Entity("GameDatabase.Entities.DanScoreDatum", b =>
{
b.Navigation("DanStageScoreData");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,40 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace TaikoLocalServer.Migrations
{
/// <inheritdoc />
public partial class AddTokenCountDictAndUnlockedSongIdListToUserdata : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<string>(
name: "TokenCountDict",
table: "UserData",
type: "TEXT",
nullable: false,
defaultValue: "");
migrationBuilder.AddColumn<string>(
name: "UnlockedSongIdList",
table: "UserData",
type: "TEXT",
nullable: false,
defaultValue: "");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "TokenCountDict",
table: "UserData");
migrationBuilder.DropColumn(
name: "UnlockedSongIdList",
table: "UserData");
}
}
}

View File

@ -0,0 +1,451 @@
// <auto-generated />
using System;
using GameDatabase.Context;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace TaikoLocalServer.Migrations
{
[DbContext(typeof(TaikoDbContext))]
[Migration("20230918052543_AddDifficultyPlayedArrayAndDifficultySettingArrayToUserData")]
partial class AddDifficultyPlayedArrayAndDifficultySettingArrayToUserData
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "7.0.0-rc.1.22426.7");
modelBuilder.Entity("GameDatabase.Entities.AiScoreDatum", b =>
{
b.Property<ulong>("Baid")
.HasColumnType("INTEGER");
b.Property<uint>("SongId")
.HasColumnType("INTEGER");
b.Property<uint>("Difficulty")
.HasColumnType("INTEGER");
b.Property<bool>("IsWin")
.HasColumnType("INTEGER");
b.HasKey("Baid", "SongId", "Difficulty");
b.ToTable("AiScoreData");
});
modelBuilder.Entity("GameDatabase.Entities.AiSectionScoreDatum", b =>
{
b.Property<ulong>("Baid")
.HasColumnType("INTEGER");
b.Property<uint>("SongId")
.HasColumnType("INTEGER");
b.Property<uint>("Difficulty")
.HasColumnType("INTEGER");
b.Property<int>("SectionIndex")
.HasColumnType("INTEGER");
b.Property<int>("Crown")
.HasColumnType("INTEGER");
b.Property<uint>("DrumrollCount")
.HasColumnType("INTEGER");
b.Property<uint>("GoodCount")
.HasColumnType("INTEGER");
b.Property<bool>("IsWin")
.HasColumnType("INTEGER");
b.Property<uint>("MissCount")
.HasColumnType("INTEGER");
b.Property<uint>("OkCount")
.HasColumnType("INTEGER");
b.Property<uint>("Score")
.HasColumnType("INTEGER");
b.HasKey("Baid", "SongId", "Difficulty", "SectionIndex");
b.ToTable("AiSectionScoreData");
});
modelBuilder.Entity("GameDatabase.Entities.Card", b =>
{
b.Property<string>("AccessCode")
.HasColumnType("TEXT");
b.Property<ulong>("Baid")
.HasColumnType("INTEGER");
b.HasKey("AccessCode");
b.HasIndex(new[] { "Baid" }, "IX_Card_Baid")
.IsUnique();
b.ToTable("Card", (string)null);
});
modelBuilder.Entity("GameDatabase.Entities.DanScoreDatum", b =>
{
b.Property<ulong>("Baid")
.HasColumnType("INTEGER");
b.Property<uint>("DanId")
.HasColumnType("INTEGER");
b.Property<uint>("ArrivalSongCount")
.HasColumnType("INTEGER");
b.Property<uint>("ClearState")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER")
.HasDefaultValue(0u);
b.Property<uint>("ComboCountTotal")
.HasColumnType("INTEGER");
b.Property<uint>("SoulGaugeTotal")
.HasColumnType("INTEGER");
b.HasKey("Baid", "DanId");
b.ToTable("DanScoreData");
});
modelBuilder.Entity("GameDatabase.Entities.DanStageScoreDatum", b =>
{
b.Property<ulong>("Baid")
.HasColumnType("INTEGER");
b.Property<uint>("DanId")
.HasColumnType("INTEGER");
b.Property<uint>("SongNumber")
.HasColumnType("INTEGER");
b.Property<uint>("BadCount")
.HasColumnType("INTEGER");
b.Property<uint>("ComboCount")
.HasColumnType("INTEGER");
b.Property<uint>("DrumrollCount")
.HasColumnType("INTEGER");
b.Property<uint>("GoodCount")
.HasColumnType("INTEGER");
b.Property<uint>("HighScore")
.HasColumnType("INTEGER");
b.Property<uint>("OkCount")
.HasColumnType("INTEGER");
b.Property<uint>("PlayScore")
.HasColumnType("INTEGER");
b.Property<uint>("TotalHitCount")
.HasColumnType("INTEGER");
b.HasKey("Baid", "DanId", "SongNumber");
b.ToTable("DanStageScoreData");
});
modelBuilder.Entity("GameDatabase.Entities.SongBestDatum", b =>
{
b.Property<ulong>("Baid")
.HasColumnType("INTEGER");
b.Property<uint>("SongId")
.HasColumnType("INTEGER");
b.Property<uint>("Difficulty")
.HasColumnType("INTEGER");
b.Property<uint>("BestCrown")
.HasColumnType("INTEGER");
b.Property<uint>("BestRate")
.HasColumnType("INTEGER");
b.Property<uint>("BestScore")
.HasColumnType("INTEGER");
b.Property<uint>("BestScoreRank")
.HasColumnType("INTEGER");
b.HasKey("Baid", "SongId", "Difficulty");
b.ToTable("SongBestData");
});
modelBuilder.Entity("GameDatabase.Entities.SongPlayDatum", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<ulong>("Baid")
.HasColumnType("INTEGER");
b.Property<uint>("ComboCount")
.HasColumnType("INTEGER");
b.Property<uint>("Crown")
.HasColumnType("INTEGER");
b.Property<uint>("Difficulty")
.HasColumnType("INTEGER");
b.Property<uint>("DrumrollCount")
.HasColumnType("INTEGER");
b.Property<uint>("GoodCount")
.HasColumnType("INTEGER");
b.Property<uint>("HitCount")
.HasColumnType("INTEGER");
b.Property<uint>("MissCount")
.HasColumnType("INTEGER");
b.Property<uint>("OkCount")
.HasColumnType("INTEGER");
b.Property<DateTime>("PlayTime")
.HasColumnType("datetime");
b.Property<uint>("Score")
.HasColumnType("INTEGER");
b.Property<uint>("ScoreRank")
.HasColumnType("INTEGER");
b.Property<uint>("ScoreRate")
.HasColumnType("INTEGER");
b.Property<bool>("Skipped")
.HasColumnType("INTEGER");
b.Property<uint>("SongId")
.HasColumnType("INTEGER");
b.Property<uint>("SongNumber")
.HasColumnType("INTEGER");
b.HasKey("Id");
b.HasIndex("Baid");
b.ToTable("SongPlayData");
});
modelBuilder.Entity("GameDatabase.Entities.UserDatum", b =>
{
b.Property<ulong>("Baid")
.HasColumnType("INTEGER");
b.Property<uint>("AchievementDisplayDifficulty")
.HasColumnType("INTEGER");
b.Property<int>("AiWinCount")
.HasColumnType("INTEGER");
b.Property<uint>("ColorBody")
.HasColumnType("INTEGER");
b.Property<uint>("ColorFace")
.HasColumnType("INTEGER");
b.Property<uint>("ColorLimb")
.HasColumnType("INTEGER");
b.Property<string>("CostumeData")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("CostumeFlgArray")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("DifficultyPlayedArray")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("DifficultySettingArray")
.IsRequired()
.HasColumnType("TEXT");
b.Property<bool>("DisplayAchievement")
.HasColumnType("INTEGER");
b.Property<bool>("DisplayDan")
.HasColumnType("INTEGER");
b.Property<string>("FavoriteSongsArray")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("GenericInfoFlgArray")
.IsRequired()
.HasColumnType("TEXT");
b.Property<bool>("IsSkipOn")
.HasColumnType("INTEGER");
b.Property<bool>("IsVoiceOn")
.HasColumnType("INTEGER");
b.Property<DateTime>("LastPlayDatetime")
.HasColumnType("datetime");
b.Property<uint>("LastPlayMode")
.HasColumnType("INTEGER");
b.Property<string>("MyDonName")
.IsRequired()
.HasColumnType("TEXT");
b.Property<int>("NotesPosition")
.HasColumnType("INTEGER");
b.Property<short>("OptionSetting")
.HasColumnType("INTEGER");
b.Property<uint>("SelectedToneId")
.HasColumnType("INTEGER");
b.Property<string>("Title")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("TitleFlgArray")
.IsRequired()
.HasColumnType("TEXT");
b.Property<uint>("TitlePlateId")
.HasColumnType("INTEGER");
b.Property<string>("TokenCountDict")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("ToneFlgArray")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("UnlockedSongIdList")
.IsRequired()
.HasColumnType("TEXT");
b.HasKey("Baid");
b.ToTable("UserData");
});
modelBuilder.Entity("GameDatabase.Entities.AiScoreDatum", b =>
{
b.HasOne("GameDatabase.Entities.Card", "Ba")
.WithMany()
.HasForeignKey("Baid")
.HasPrincipalKey("Baid")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Ba");
});
modelBuilder.Entity("GameDatabase.Entities.AiSectionScoreDatum", b =>
{
b.HasOne("GameDatabase.Entities.AiScoreDatum", "Parent")
.WithMany("AiSectionScoreData")
.HasForeignKey("Baid", "SongId", "Difficulty")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Parent");
});
modelBuilder.Entity("GameDatabase.Entities.DanScoreDatum", b =>
{
b.HasOne("GameDatabase.Entities.Card", "Ba")
.WithMany()
.HasForeignKey("Baid")
.HasPrincipalKey("Baid")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Ba");
});
modelBuilder.Entity("GameDatabase.Entities.DanStageScoreDatum", b =>
{
b.HasOne("GameDatabase.Entities.DanScoreDatum", "Parent")
.WithMany("DanStageScoreData")
.HasForeignKey("Baid", "DanId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Parent");
});
modelBuilder.Entity("GameDatabase.Entities.SongBestDatum", b =>
{
b.HasOne("GameDatabase.Entities.Card", "Ba")
.WithMany()
.HasForeignKey("Baid")
.HasPrincipalKey("Baid")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Ba");
});
modelBuilder.Entity("GameDatabase.Entities.SongPlayDatum", b =>
{
b.HasOne("GameDatabase.Entities.Card", "Ba")
.WithMany()
.HasForeignKey("Baid")
.HasPrincipalKey("Baid")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Ba");
});
modelBuilder.Entity("GameDatabase.Entities.UserDatum", b =>
{
b.HasOne("GameDatabase.Entities.Card", "Ba")
.WithMany()
.HasForeignKey("Baid")
.HasPrincipalKey("Baid")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Ba");
});
modelBuilder.Entity("GameDatabase.Entities.AiScoreDatum", b =>
{
b.Navigation("AiSectionScoreData");
});
modelBuilder.Entity("GameDatabase.Entities.DanScoreDatum", b =>
{
b.Navigation("DanStageScoreData");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,40 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace TaikoLocalServer.Migrations
{
/// <inheritdoc />
public partial class AddDifficultyPlayedArrayAndDifficultySettingArrayToUserData : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<string>(
name: "DifficultyPlayedArray",
table: "UserData",
type: "TEXT",
nullable: false,
defaultValue: "[]");
migrationBuilder.AddColumn<string>(
name: "DifficultySettingArray",
table: "UserData",
type: "TEXT",
nullable: false,
defaultValue: "[]");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "DifficultyPlayedArray",
table: "UserData");
migrationBuilder.DropColumn(
name: "DifficultySettingArray",
table: "UserData");
}
}
}

View File

@ -0,0 +1,454 @@
// <auto-generated />
using System;
using GameDatabase.Context;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace TaikoLocalServer.Migrations
{
[DbContext(typeof(TaikoDbContext))]
[Migration("20230918101009_AddMyDonNameLanguageToUserData")]
partial class AddMyDonNameLanguageToUserData
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "7.0.0-rc.1.22426.7");
modelBuilder.Entity("GameDatabase.Entities.AiScoreDatum", b =>
{
b.Property<ulong>("Baid")
.HasColumnType("INTEGER");
b.Property<uint>("SongId")
.HasColumnType("INTEGER");
b.Property<uint>("Difficulty")
.HasColumnType("INTEGER");
b.Property<bool>("IsWin")
.HasColumnType("INTEGER");
b.HasKey("Baid", "SongId", "Difficulty");
b.ToTable("AiScoreData");
});
modelBuilder.Entity("GameDatabase.Entities.AiSectionScoreDatum", b =>
{
b.Property<ulong>("Baid")
.HasColumnType("INTEGER");
b.Property<uint>("SongId")
.HasColumnType("INTEGER");
b.Property<uint>("Difficulty")
.HasColumnType("INTEGER");
b.Property<int>("SectionIndex")
.HasColumnType("INTEGER");
b.Property<int>("Crown")
.HasColumnType("INTEGER");
b.Property<uint>("DrumrollCount")
.HasColumnType("INTEGER");
b.Property<uint>("GoodCount")
.HasColumnType("INTEGER");
b.Property<bool>("IsWin")
.HasColumnType("INTEGER");
b.Property<uint>("MissCount")
.HasColumnType("INTEGER");
b.Property<uint>("OkCount")
.HasColumnType("INTEGER");
b.Property<uint>("Score")
.HasColumnType("INTEGER");
b.HasKey("Baid", "SongId", "Difficulty", "SectionIndex");
b.ToTable("AiSectionScoreData");
});
modelBuilder.Entity("GameDatabase.Entities.Card", b =>
{
b.Property<string>("AccessCode")
.HasColumnType("TEXT");
b.Property<ulong>("Baid")
.HasColumnType("INTEGER");
b.HasKey("AccessCode");
b.HasIndex(new[] { "Baid" }, "IX_Card_Baid")
.IsUnique();
b.ToTable("Card", (string)null);
});
modelBuilder.Entity("GameDatabase.Entities.DanScoreDatum", b =>
{
b.Property<ulong>("Baid")
.HasColumnType("INTEGER");
b.Property<uint>("DanId")
.HasColumnType("INTEGER");
b.Property<uint>("ArrivalSongCount")
.HasColumnType("INTEGER");
b.Property<uint>("ClearState")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER")
.HasDefaultValue(0u);
b.Property<uint>("ComboCountTotal")
.HasColumnType("INTEGER");
b.Property<uint>("SoulGaugeTotal")
.HasColumnType("INTEGER");
b.HasKey("Baid", "DanId");
b.ToTable("DanScoreData");
});
modelBuilder.Entity("GameDatabase.Entities.DanStageScoreDatum", b =>
{
b.Property<ulong>("Baid")
.HasColumnType("INTEGER");
b.Property<uint>("DanId")
.HasColumnType("INTEGER");
b.Property<uint>("SongNumber")
.HasColumnType("INTEGER");
b.Property<uint>("BadCount")
.HasColumnType("INTEGER");
b.Property<uint>("ComboCount")
.HasColumnType("INTEGER");
b.Property<uint>("DrumrollCount")
.HasColumnType("INTEGER");
b.Property<uint>("GoodCount")
.HasColumnType("INTEGER");
b.Property<uint>("HighScore")
.HasColumnType("INTEGER");
b.Property<uint>("OkCount")
.HasColumnType("INTEGER");
b.Property<uint>("PlayScore")
.HasColumnType("INTEGER");
b.Property<uint>("TotalHitCount")
.HasColumnType("INTEGER");
b.HasKey("Baid", "DanId", "SongNumber");
b.ToTable("DanStageScoreData");
});
modelBuilder.Entity("GameDatabase.Entities.SongBestDatum", b =>
{
b.Property<ulong>("Baid")
.HasColumnType("INTEGER");
b.Property<uint>("SongId")
.HasColumnType("INTEGER");
b.Property<uint>("Difficulty")
.HasColumnType("INTEGER");
b.Property<uint>("BestCrown")
.HasColumnType("INTEGER");
b.Property<uint>("BestRate")
.HasColumnType("INTEGER");
b.Property<uint>("BestScore")
.HasColumnType("INTEGER");
b.Property<uint>("BestScoreRank")
.HasColumnType("INTEGER");
b.HasKey("Baid", "SongId", "Difficulty");
b.ToTable("SongBestData");
});
modelBuilder.Entity("GameDatabase.Entities.SongPlayDatum", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<ulong>("Baid")
.HasColumnType("INTEGER");
b.Property<uint>("ComboCount")
.HasColumnType("INTEGER");
b.Property<uint>("Crown")
.HasColumnType("INTEGER");
b.Property<uint>("Difficulty")
.HasColumnType("INTEGER");
b.Property<uint>("DrumrollCount")
.HasColumnType("INTEGER");
b.Property<uint>("GoodCount")
.HasColumnType("INTEGER");
b.Property<uint>("HitCount")
.HasColumnType("INTEGER");
b.Property<uint>("MissCount")
.HasColumnType("INTEGER");
b.Property<uint>("OkCount")
.HasColumnType("INTEGER");
b.Property<DateTime>("PlayTime")
.HasColumnType("datetime");
b.Property<uint>("Score")
.HasColumnType("INTEGER");
b.Property<uint>("ScoreRank")
.HasColumnType("INTEGER");
b.Property<uint>("ScoreRate")
.HasColumnType("INTEGER");
b.Property<bool>("Skipped")
.HasColumnType("INTEGER");
b.Property<uint>("SongId")
.HasColumnType("INTEGER");
b.Property<uint>("SongNumber")
.HasColumnType("INTEGER");
b.HasKey("Id");
b.HasIndex("Baid");
b.ToTable("SongPlayData");
});
modelBuilder.Entity("GameDatabase.Entities.UserDatum", b =>
{
b.Property<ulong>("Baid")
.HasColumnType("INTEGER");
b.Property<uint>("AchievementDisplayDifficulty")
.HasColumnType("INTEGER");
b.Property<int>("AiWinCount")
.HasColumnType("INTEGER");
b.Property<uint>("ColorBody")
.HasColumnType("INTEGER");
b.Property<uint>("ColorFace")
.HasColumnType("INTEGER");
b.Property<uint>("ColorLimb")
.HasColumnType("INTEGER");
b.Property<string>("CostumeData")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("CostumeFlgArray")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("DifficultyPlayedArray")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("DifficultySettingArray")
.IsRequired()
.HasColumnType("TEXT");
b.Property<bool>("DisplayAchievement")
.HasColumnType("INTEGER");
b.Property<bool>("DisplayDan")
.HasColumnType("INTEGER");
b.Property<string>("FavoriteSongsArray")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("GenericInfoFlgArray")
.IsRequired()
.HasColumnType("TEXT");
b.Property<bool>("IsSkipOn")
.HasColumnType("INTEGER");
b.Property<bool>("IsVoiceOn")
.HasColumnType("INTEGER");
b.Property<DateTime>("LastPlayDatetime")
.HasColumnType("datetime");
b.Property<uint>("LastPlayMode")
.HasColumnType("INTEGER");
b.Property<string>("MyDonName")
.IsRequired()
.HasColumnType("TEXT");
b.Property<uint>("MyDonNameLanguage")
.HasColumnType("INTEGER");
b.Property<int>("NotesPosition")
.HasColumnType("INTEGER");
b.Property<short>("OptionSetting")
.HasColumnType("INTEGER");
b.Property<uint>("SelectedToneId")
.HasColumnType("INTEGER");
b.Property<string>("Title")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("TitleFlgArray")
.IsRequired()
.HasColumnType("TEXT");
b.Property<uint>("TitlePlateId")
.HasColumnType("INTEGER");
b.Property<string>("TokenCountDict")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("ToneFlgArray")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("UnlockedSongIdList")
.IsRequired()
.HasColumnType("TEXT");
b.HasKey("Baid");
b.ToTable("UserData");
});
modelBuilder.Entity("GameDatabase.Entities.AiScoreDatum", b =>
{
b.HasOne("GameDatabase.Entities.Card", "Ba")
.WithMany()
.HasForeignKey("Baid")
.HasPrincipalKey("Baid")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Ba");
});
modelBuilder.Entity("GameDatabase.Entities.AiSectionScoreDatum", b =>
{
b.HasOne("GameDatabase.Entities.AiScoreDatum", "Parent")
.WithMany("AiSectionScoreData")
.HasForeignKey("Baid", "SongId", "Difficulty")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Parent");
});
modelBuilder.Entity("GameDatabase.Entities.DanScoreDatum", b =>
{
b.HasOne("GameDatabase.Entities.Card", "Ba")
.WithMany()
.HasForeignKey("Baid")
.HasPrincipalKey("Baid")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Ba");
});
modelBuilder.Entity("GameDatabase.Entities.DanStageScoreDatum", b =>
{
b.HasOne("GameDatabase.Entities.DanScoreDatum", "Parent")
.WithMany("DanStageScoreData")
.HasForeignKey("Baid", "DanId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Parent");
});
modelBuilder.Entity("GameDatabase.Entities.SongBestDatum", b =>
{
b.HasOne("GameDatabase.Entities.Card", "Ba")
.WithMany()
.HasForeignKey("Baid")
.HasPrincipalKey("Baid")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Ba");
});
modelBuilder.Entity("GameDatabase.Entities.SongPlayDatum", b =>
{
b.HasOne("GameDatabase.Entities.Card", "Ba")
.WithMany()
.HasForeignKey("Baid")
.HasPrincipalKey("Baid")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Ba");
});
modelBuilder.Entity("GameDatabase.Entities.UserDatum", b =>
{
b.HasOne("GameDatabase.Entities.Card", "Ba")
.WithMany()
.HasForeignKey("Baid")
.HasPrincipalKey("Baid")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Ba");
});
modelBuilder.Entity("GameDatabase.Entities.AiScoreDatum", b =>
{
b.Navigation("AiSectionScoreData");
});
modelBuilder.Entity("GameDatabase.Entities.DanScoreDatum", b =>
{
b.Navigation("DanStageScoreData");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,29 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace TaikoLocalServer.Migrations
{
/// <inheritdoc />
public partial class AddMyDonNameLanguageToUserData : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<uint>(
name: "MyDonNameLanguage",
table: "UserData",
type: "INTEGER",
nullable: false,
defaultValue: 0u);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "MyDonNameLanguage",
table: "UserData");
}
}
}

View File

@ -0,0 +1,462 @@
// <auto-generated />
using System;
using GameDatabase.Context;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace TaikoLocalServer.Migrations
{
[DbContext(typeof(TaikoDbContext))]
[Migration("20230928150650_AddPasswordAndSaltToCard")]
partial class AddPasswordAndSaltToCard
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "8.0.0-rc.1.23419.6");
modelBuilder.Entity("GameDatabase.Entities.AiScoreDatum", b =>
{
b.Property<ulong>("Baid")
.HasColumnType("INTEGER");
b.Property<uint>("SongId")
.HasColumnType("INTEGER");
b.Property<uint>("Difficulty")
.HasColumnType("INTEGER");
b.Property<bool>("IsWin")
.HasColumnType("INTEGER");
b.HasKey("Baid", "SongId", "Difficulty");
b.ToTable("AiScoreData");
});
modelBuilder.Entity("GameDatabase.Entities.AiSectionScoreDatum", b =>
{
b.Property<ulong>("Baid")
.HasColumnType("INTEGER");
b.Property<uint>("SongId")
.HasColumnType("INTEGER");
b.Property<uint>("Difficulty")
.HasColumnType("INTEGER");
b.Property<int>("SectionIndex")
.HasColumnType("INTEGER");
b.Property<int>("Crown")
.HasColumnType("INTEGER");
b.Property<uint>("DrumrollCount")
.HasColumnType("INTEGER");
b.Property<uint>("GoodCount")
.HasColumnType("INTEGER");
b.Property<bool>("IsWin")
.HasColumnType("INTEGER");
b.Property<uint>("MissCount")
.HasColumnType("INTEGER");
b.Property<uint>("OkCount")
.HasColumnType("INTEGER");
b.Property<uint>("Score")
.HasColumnType("INTEGER");
b.HasKey("Baid", "SongId", "Difficulty", "SectionIndex");
b.ToTable("AiSectionScoreData");
});
modelBuilder.Entity("GameDatabase.Entities.Card", b =>
{
b.Property<string>("AccessCode")
.HasColumnType("TEXT");
b.Property<ulong>("Baid")
.HasColumnType("INTEGER");
b.Property<string>("Password")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("Salt")
.IsRequired()
.HasColumnType("TEXT");
b.HasKey("AccessCode");
b.HasIndex(new[] { "Baid" }, "IX_Card_Baid")
.IsUnique();
b.ToTable("Card", (string)null);
});
modelBuilder.Entity("GameDatabase.Entities.DanScoreDatum", b =>
{
b.Property<ulong>("Baid")
.HasColumnType("INTEGER");
b.Property<uint>("DanId")
.HasColumnType("INTEGER");
b.Property<uint>("ArrivalSongCount")
.HasColumnType("INTEGER");
b.Property<uint>("ClearState")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER")
.HasDefaultValue(0u);
b.Property<uint>("ComboCountTotal")
.HasColumnType("INTEGER");
b.Property<uint>("SoulGaugeTotal")
.HasColumnType("INTEGER");
b.HasKey("Baid", "DanId");
b.ToTable("DanScoreData");
});
modelBuilder.Entity("GameDatabase.Entities.DanStageScoreDatum", b =>
{
b.Property<ulong>("Baid")
.HasColumnType("INTEGER");
b.Property<uint>("DanId")
.HasColumnType("INTEGER");
b.Property<uint>("SongNumber")
.HasColumnType("INTEGER");
b.Property<uint>("BadCount")
.HasColumnType("INTEGER");
b.Property<uint>("ComboCount")
.HasColumnType("INTEGER");
b.Property<uint>("DrumrollCount")
.HasColumnType("INTEGER");
b.Property<uint>("GoodCount")
.HasColumnType("INTEGER");
b.Property<uint>("HighScore")
.HasColumnType("INTEGER");
b.Property<uint>("OkCount")
.HasColumnType("INTEGER");
b.Property<uint>("PlayScore")
.HasColumnType("INTEGER");
b.Property<uint>("TotalHitCount")
.HasColumnType("INTEGER");
b.HasKey("Baid", "DanId", "SongNumber");
b.ToTable("DanStageScoreData");
});
modelBuilder.Entity("GameDatabase.Entities.SongBestDatum", b =>
{
b.Property<ulong>("Baid")
.HasColumnType("INTEGER");
b.Property<uint>("SongId")
.HasColumnType("INTEGER");
b.Property<uint>("Difficulty")
.HasColumnType("INTEGER");
b.Property<uint>("BestCrown")
.HasColumnType("INTEGER");
b.Property<uint>("BestRate")
.HasColumnType("INTEGER");
b.Property<uint>("BestScore")
.HasColumnType("INTEGER");
b.Property<uint>("BestScoreRank")
.HasColumnType("INTEGER");
b.HasKey("Baid", "SongId", "Difficulty");
b.ToTable("SongBestData");
});
modelBuilder.Entity("GameDatabase.Entities.SongPlayDatum", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<ulong>("Baid")
.HasColumnType("INTEGER");
b.Property<uint>("ComboCount")
.HasColumnType("INTEGER");
b.Property<uint>("Crown")
.HasColumnType("INTEGER");
b.Property<uint>("Difficulty")
.HasColumnType("INTEGER");
b.Property<uint>("DrumrollCount")
.HasColumnType("INTEGER");
b.Property<uint>("GoodCount")
.HasColumnType("INTEGER");
b.Property<uint>("HitCount")
.HasColumnType("INTEGER");
b.Property<uint>("MissCount")
.HasColumnType("INTEGER");
b.Property<uint>("OkCount")
.HasColumnType("INTEGER");
b.Property<DateTime>("PlayTime")
.HasColumnType("datetime");
b.Property<uint>("Score")
.HasColumnType("INTEGER");
b.Property<uint>("ScoreRank")
.HasColumnType("INTEGER");
b.Property<uint>("ScoreRate")
.HasColumnType("INTEGER");
b.Property<bool>("Skipped")
.HasColumnType("INTEGER");
b.Property<uint>("SongId")
.HasColumnType("INTEGER");
b.Property<uint>("SongNumber")
.HasColumnType("INTEGER");
b.HasKey("Id");
b.HasIndex("Baid");
b.ToTable("SongPlayData");
});
modelBuilder.Entity("GameDatabase.Entities.UserDatum", b =>
{
b.Property<ulong>("Baid")
.HasColumnType("INTEGER");
b.Property<uint>("AchievementDisplayDifficulty")
.HasColumnType("INTEGER");
b.Property<int>("AiWinCount")
.HasColumnType("INTEGER");
b.Property<uint>("ColorBody")
.HasColumnType("INTEGER");
b.Property<uint>("ColorFace")
.HasColumnType("INTEGER");
b.Property<uint>("ColorLimb")
.HasColumnType("INTEGER");
b.Property<string>("CostumeData")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("CostumeFlgArray")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("DifficultyPlayedArray")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("DifficultySettingArray")
.IsRequired()
.HasColumnType("TEXT");
b.Property<bool>("DisplayAchievement")
.HasColumnType("INTEGER");
b.Property<bool>("DisplayDan")
.HasColumnType("INTEGER");
b.Property<string>("FavoriteSongsArray")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("GenericInfoFlgArray")
.IsRequired()
.HasColumnType("TEXT");
b.Property<bool>("IsSkipOn")
.HasColumnType("INTEGER");
b.Property<bool>("IsVoiceOn")
.HasColumnType("INTEGER");
b.Property<DateTime>("LastPlayDatetime")
.HasColumnType("datetime");
b.Property<uint>("LastPlayMode")
.HasColumnType("INTEGER");
b.Property<string>("MyDonName")
.IsRequired()
.HasColumnType("TEXT");
b.Property<uint>("MyDonNameLanguage")
.HasColumnType("INTEGER");
b.Property<int>("NotesPosition")
.HasColumnType("INTEGER");
b.Property<short>("OptionSetting")
.HasColumnType("INTEGER");
b.Property<uint>("SelectedToneId")
.HasColumnType("INTEGER");
b.Property<string>("Title")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("TitleFlgArray")
.IsRequired()
.HasColumnType("TEXT");
b.Property<uint>("TitlePlateId")
.HasColumnType("INTEGER");
b.Property<string>("TokenCountDict")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("ToneFlgArray")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("UnlockedSongIdList")
.IsRequired()
.HasColumnType("TEXT");
b.HasKey("Baid");
b.ToTable("UserData");
});
modelBuilder.Entity("GameDatabase.Entities.AiScoreDatum", b =>
{
b.HasOne("GameDatabase.Entities.Card", "Ba")
.WithMany()
.HasForeignKey("Baid")
.HasPrincipalKey("Baid")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Ba");
});
modelBuilder.Entity("GameDatabase.Entities.AiSectionScoreDatum", b =>
{
b.HasOne("GameDatabase.Entities.AiScoreDatum", "Parent")
.WithMany("AiSectionScoreData")
.HasForeignKey("Baid", "SongId", "Difficulty")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Parent");
});
modelBuilder.Entity("GameDatabase.Entities.DanScoreDatum", b =>
{
b.HasOne("GameDatabase.Entities.Card", "Ba")
.WithMany()
.HasForeignKey("Baid")
.HasPrincipalKey("Baid")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Ba");
});
modelBuilder.Entity("GameDatabase.Entities.DanStageScoreDatum", b =>
{
b.HasOne("GameDatabase.Entities.DanScoreDatum", "Parent")
.WithMany("DanStageScoreData")
.HasForeignKey("Baid", "DanId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Parent");
});
modelBuilder.Entity("GameDatabase.Entities.SongBestDatum", b =>
{
b.HasOne("GameDatabase.Entities.Card", "Ba")
.WithMany()
.HasForeignKey("Baid")
.HasPrincipalKey("Baid")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Ba");
});
modelBuilder.Entity("GameDatabase.Entities.SongPlayDatum", b =>
{
b.HasOne("GameDatabase.Entities.Card", "Ba")
.WithMany()
.HasForeignKey("Baid")
.HasPrincipalKey("Baid")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Ba");
});
modelBuilder.Entity("GameDatabase.Entities.UserDatum", b =>
{
b.HasOne("GameDatabase.Entities.Card", "Ba")
.WithMany()
.HasForeignKey("Baid")
.HasPrincipalKey("Baid")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Ba");
});
modelBuilder.Entity("GameDatabase.Entities.AiScoreDatum", b =>
{
b.Navigation("AiSectionScoreData");
});
modelBuilder.Entity("GameDatabase.Entities.DanScoreDatum", b =>
{
b.Navigation("DanStageScoreData");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,40 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace TaikoLocalServer.Migrations
{
/// <inheritdoc />
public partial class AddPasswordAndSaltToCard : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<string>(
name: "Password",
table: "Card",
type: "TEXT",
nullable: false,
defaultValue: "");
migrationBuilder.AddColumn<string>(
name: "Salt",
table: "Card",
type: "TEXT",
nullable: false,
defaultValue: "");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "Password",
table: "Card");
migrationBuilder.DropColumn(
name: "Salt",
table: "Card");
}
}
}

View File

@ -15,11 +15,11 @@ namespace TaikoLocalServer.Migrations
protected override void BuildModel(ModelBuilder modelBuilder) protected override void BuildModel(ModelBuilder modelBuilder)
{ {
#pragma warning disable 612, 618 #pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "7.0.0-preview.7.22376.2"); modelBuilder.HasAnnotation("ProductVersion", "8.0.0-rc.1.23419.6");
modelBuilder.Entity("TaikoLocalServer.Entities.AiScoreDatum", b => modelBuilder.Entity("GameDatabase.Entities.AiScoreDatum", b =>
{ {
b.Property<uint>("Baid") b.Property<ulong>("Baid")
.HasColumnType("INTEGER"); .HasColumnType("INTEGER");
b.Property<uint>("SongId") b.Property<uint>("SongId")
@ -36,9 +36,9 @@ namespace TaikoLocalServer.Migrations
b.ToTable("AiScoreData"); b.ToTable("AiScoreData");
}); });
modelBuilder.Entity("TaikoLocalServer.Entities.AiSectionScoreDatum", b => modelBuilder.Entity("GameDatabase.Entities.AiSectionScoreDatum", b =>
{ {
b.Property<uint>("Baid") b.Property<ulong>("Baid")
.HasColumnType("INTEGER"); .HasColumnType("INTEGER");
b.Property<uint>("SongId") b.Property<uint>("SongId")
@ -76,14 +76,22 @@ namespace TaikoLocalServer.Migrations
b.ToTable("AiSectionScoreData"); b.ToTable("AiSectionScoreData");
}); });
modelBuilder.Entity("TaikoLocalServer.Entities.Card", b => modelBuilder.Entity("GameDatabase.Entities.Card", b =>
{ {
b.Property<string>("AccessCode") b.Property<string>("AccessCode")
.HasColumnType("TEXT"); .HasColumnType("TEXT");
b.Property<uint>("Baid") b.Property<ulong>("Baid")
.HasColumnType("INTEGER"); .HasColumnType("INTEGER");
b.Property<string>("Password")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("Salt")
.IsRequired()
.HasColumnType("TEXT");
b.HasKey("AccessCode"); b.HasKey("AccessCode");
b.HasIndex(new[] { "Baid" }, "IX_Card_Baid") b.HasIndex(new[] { "Baid" }, "IX_Card_Baid")
@ -92,9 +100,9 @@ namespace TaikoLocalServer.Migrations
b.ToTable("Card", (string)null); b.ToTable("Card", (string)null);
}); });
modelBuilder.Entity("TaikoLocalServer.Entities.DanScoreDatum", b => modelBuilder.Entity("GameDatabase.Entities.DanScoreDatum", b =>
{ {
b.Property<uint>("Baid") b.Property<ulong>("Baid")
.HasColumnType("INTEGER"); .HasColumnType("INTEGER");
b.Property<uint>("DanId") b.Property<uint>("DanId")
@ -119,9 +127,9 @@ namespace TaikoLocalServer.Migrations
b.ToTable("DanScoreData"); b.ToTable("DanScoreData");
}); });
modelBuilder.Entity("TaikoLocalServer.Entities.DanStageScoreDatum", b => modelBuilder.Entity("GameDatabase.Entities.DanStageScoreDatum", b =>
{ {
b.Property<uint>("Baid") b.Property<ulong>("Baid")
.HasColumnType("INTEGER"); .HasColumnType("INTEGER");
b.Property<uint>("DanId") b.Property<uint>("DanId")
@ -159,9 +167,9 @@ namespace TaikoLocalServer.Migrations
b.ToTable("DanStageScoreData"); b.ToTable("DanStageScoreData");
}); });
modelBuilder.Entity("TaikoLocalServer.Entities.SongBestDatum", b => modelBuilder.Entity("GameDatabase.Entities.SongBestDatum", b =>
{ {
b.Property<uint>("Baid") b.Property<ulong>("Baid")
.HasColumnType("INTEGER"); .HasColumnType("INTEGER");
b.Property<uint>("SongId") b.Property<uint>("SongId")
@ -187,13 +195,13 @@ namespace TaikoLocalServer.Migrations
b.ToTable("SongBestData"); b.ToTable("SongBestData");
}); });
modelBuilder.Entity("TaikoLocalServer.Entities.SongPlayDatum", b => modelBuilder.Entity("GameDatabase.Entities.SongPlayDatum", b =>
{ {
b.Property<long>("Id") b.Property<long>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("INTEGER"); .HasColumnType("INTEGER");
b.Property<uint>("Baid") b.Property<ulong>("Baid")
.HasColumnType("INTEGER"); .HasColumnType("INTEGER");
b.Property<uint>("ComboCount") b.Property<uint>("ComboCount")
@ -248,9 +256,9 @@ namespace TaikoLocalServer.Migrations
b.ToTable("SongPlayData"); b.ToTable("SongPlayData");
}); });
modelBuilder.Entity("TaikoLocalServer.Entities.UserDatum", b => modelBuilder.Entity("GameDatabase.Entities.UserDatum", b =>
{ {
b.Property<uint>("Baid") b.Property<ulong>("Baid")
.HasColumnType("INTEGER"); .HasColumnType("INTEGER");
b.Property<uint>("AchievementDisplayDifficulty") b.Property<uint>("AchievementDisplayDifficulty")
@ -276,6 +284,14 @@ namespace TaikoLocalServer.Migrations
.IsRequired() .IsRequired()
.HasColumnType("TEXT"); .HasColumnType("TEXT");
b.Property<string>("DifficultyPlayedArray")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("DifficultySettingArray")
.IsRequired()
.HasColumnType("TEXT");
b.Property<bool>("DisplayAchievement") b.Property<bool>("DisplayAchievement")
.HasColumnType("INTEGER"); .HasColumnType("INTEGER");
@ -306,6 +322,9 @@ namespace TaikoLocalServer.Migrations
.IsRequired() .IsRequired()
.HasColumnType("TEXT"); .HasColumnType("TEXT");
b.Property<uint>("MyDonNameLanguage")
.HasColumnType("INTEGER");
b.Property<int>("NotesPosition") b.Property<int>("NotesPosition")
.HasColumnType("INTEGER"); .HasColumnType("INTEGER");
@ -326,18 +345,26 @@ namespace TaikoLocalServer.Migrations
b.Property<uint>("TitlePlateId") b.Property<uint>("TitlePlateId")
.HasColumnType("INTEGER"); .HasColumnType("INTEGER");
b.Property<string>("TokenCountDict")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("ToneFlgArray") b.Property<string>("ToneFlgArray")
.IsRequired() .IsRequired()
.HasColumnType("TEXT"); .HasColumnType("TEXT");
b.Property<string>("UnlockedSongIdList")
.IsRequired()
.HasColumnType("TEXT");
b.HasKey("Baid"); b.HasKey("Baid");
b.ToTable("UserData"); b.ToTable("UserData");
}); });
modelBuilder.Entity("TaikoLocalServer.Entities.AiScoreDatum", b => modelBuilder.Entity("GameDatabase.Entities.AiScoreDatum", b =>
{ {
b.HasOne("TaikoLocalServer.Entities.Card", "Ba") b.HasOne("GameDatabase.Entities.Card", "Ba")
.WithMany() .WithMany()
.HasForeignKey("Baid") .HasForeignKey("Baid")
.HasPrincipalKey("Baid") .HasPrincipalKey("Baid")
@ -347,9 +374,9 @@ namespace TaikoLocalServer.Migrations
b.Navigation("Ba"); b.Navigation("Ba");
}); });
modelBuilder.Entity("TaikoLocalServer.Entities.AiSectionScoreDatum", b => modelBuilder.Entity("GameDatabase.Entities.AiSectionScoreDatum", b =>
{ {
b.HasOne("TaikoLocalServer.Entities.AiScoreDatum", "Parent") b.HasOne("GameDatabase.Entities.AiScoreDatum", "Parent")
.WithMany("AiSectionScoreData") .WithMany("AiSectionScoreData")
.HasForeignKey("Baid", "SongId", "Difficulty") .HasForeignKey("Baid", "SongId", "Difficulty")
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
@ -358,9 +385,9 @@ namespace TaikoLocalServer.Migrations
b.Navigation("Parent"); b.Navigation("Parent");
}); });
modelBuilder.Entity("TaikoLocalServer.Entities.DanScoreDatum", b => modelBuilder.Entity("GameDatabase.Entities.DanScoreDatum", b =>
{ {
b.HasOne("TaikoLocalServer.Entities.Card", "Ba") b.HasOne("GameDatabase.Entities.Card", "Ba")
.WithMany() .WithMany()
.HasForeignKey("Baid") .HasForeignKey("Baid")
.HasPrincipalKey("Baid") .HasPrincipalKey("Baid")
@ -370,9 +397,9 @@ namespace TaikoLocalServer.Migrations
b.Navigation("Ba"); b.Navigation("Ba");
}); });
modelBuilder.Entity("TaikoLocalServer.Entities.DanStageScoreDatum", b => modelBuilder.Entity("GameDatabase.Entities.DanStageScoreDatum", b =>
{ {
b.HasOne("TaikoLocalServer.Entities.DanScoreDatum", "Parent") b.HasOne("GameDatabase.Entities.DanScoreDatum", "Parent")
.WithMany("DanStageScoreData") .WithMany("DanStageScoreData")
.HasForeignKey("Baid", "DanId") .HasForeignKey("Baid", "DanId")
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
@ -381,9 +408,9 @@ namespace TaikoLocalServer.Migrations
b.Navigation("Parent"); b.Navigation("Parent");
}); });
modelBuilder.Entity("TaikoLocalServer.Entities.SongBestDatum", b => modelBuilder.Entity("GameDatabase.Entities.SongBestDatum", b =>
{ {
b.HasOne("TaikoLocalServer.Entities.Card", "Ba") b.HasOne("GameDatabase.Entities.Card", "Ba")
.WithMany() .WithMany()
.HasForeignKey("Baid") .HasForeignKey("Baid")
.HasPrincipalKey("Baid") .HasPrincipalKey("Baid")
@ -393,9 +420,9 @@ namespace TaikoLocalServer.Migrations
b.Navigation("Ba"); b.Navigation("Ba");
}); });
modelBuilder.Entity("TaikoLocalServer.Entities.SongPlayDatum", b => modelBuilder.Entity("GameDatabase.Entities.SongPlayDatum", b =>
{ {
b.HasOne("TaikoLocalServer.Entities.Card", "Ba") b.HasOne("GameDatabase.Entities.Card", "Ba")
.WithMany() .WithMany()
.HasForeignKey("Baid") .HasForeignKey("Baid")
.HasPrincipalKey("Baid") .HasPrincipalKey("Baid")
@ -405,9 +432,9 @@ namespace TaikoLocalServer.Migrations
b.Navigation("Ba"); b.Navigation("Ba");
}); });
modelBuilder.Entity("TaikoLocalServer.Entities.UserDatum", b => modelBuilder.Entity("GameDatabase.Entities.UserDatum", b =>
{ {
b.HasOne("TaikoLocalServer.Entities.Card", "Ba") b.HasOne("GameDatabase.Entities.Card", "Ba")
.WithMany() .WithMany()
.HasForeignKey("Baid") .HasForeignKey("Baid")
.HasPrincipalKey("Baid") .HasPrincipalKey("Baid")
@ -417,12 +444,12 @@ namespace TaikoLocalServer.Migrations
b.Navigation("Ba"); b.Navigation("Ba");
}); });
modelBuilder.Entity("TaikoLocalServer.Entities.AiScoreDatum", b => modelBuilder.Entity("GameDatabase.Entities.AiScoreDatum", b =>
{ {
b.Navigation("AiSectionScoreData"); b.Navigation("AiSectionScoreData");
}); });
modelBuilder.Entity("TaikoLocalServer.Entities.DanScoreDatum", b => modelBuilder.Entity("GameDatabase.Entities.DanScoreDatum", b =>
{ {
b.Navigation("DanStageScoreData"); b.Navigation("DanStageScoreData");
}); });

View File

@ -2,17 +2,18 @@
<PropertyGroup> <PropertyGroup>
<OutputType>Exe</OutputType> <OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework> <TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<Version>1.0.0-beta1</Version> <Version>1.0.0-beta1</Version>
<LangVersion>11</LangVersion>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="JorgeSerrano.Json.JsonSnakeCaseNamingPolicy" Version="0.9.0" /> <PackageReference Include="JorgeSerrano.Json.JsonSnakeCaseNamingPolicy" Version="0.9.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.0-rc.1.22426.7" /> <PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.0-rc.1.23419.6" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="7.0.0-rc.1.22426.7" /> <PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.0-rc.1.23419.6" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.0-rc.1.22426.7"> <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.0-rc.1.23419.6">
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference> </PackageReference>

View File

@ -1,13 +1,13 @@
using System.CommandLine; using GameDatabase.Context;
using System.CommandLine.Parsing;
using System.Text;
using System.Text.Json;
using GameDatabase.Context;
using GameDatabase.Entities; using GameDatabase.Entities;
using ICSharpCode.SharpZipLib.GZip; using ICSharpCode.SharpZipLib.GZip;
using JorgeSerrano.Json; using JorgeSerrano.Json;
using LocalSaveModScoreMigrator; using LocalSaveModScoreMigrator;
using SharedProject.Enums; using SharedProject.Enums;
using System.CommandLine;
using System.CommandLine.Parsing;
using System.Text;
using System.Text.Json;
var rootCommand = new RootCommand("Command-line tool to migrate saves from local save mod to local server database."); var rootCommand = new RootCommand("Command-line tool to migrate saves from local save mod to local server database.");
@ -52,7 +52,7 @@ var musicInfoArgument = new Option<FileInfo?>(
); );
musicInfoArgument.AddAlias("-m"); musicInfoArgument.AddAlias("-m");
var baidArgument = new Option<int>( var baidArgument = new Option<ulong>(
name: "--baid", name: "--baid",
description: "Target card's baid, data will be imported to that card", description: "Target card's baid, data will be imported to that card",
getDefaultValue: () => 1 getDefaultValue: () => 1
@ -69,7 +69,7 @@ rootCommand.SetHandler((saveFile, dbFile, musicInfoFile, baid) => Run(saveFile!,
await rootCommand.InvokeAsync(args); await rootCommand.InvokeAsync(args);
void Run(FileSystemInfo saveFile, FileSystemInfo dbFile, FileSystemInfo musicInfoFile, int baid) void Run(FileSystemInfo saveFile, FileSystemInfo dbFile, FileSystemInfo musicInfoFile, ulong baid)
{ {
using var db = new TaikoDbContext(dbFile.FullName); using var db = new TaikoDbContext(dbFile.FullName);
var card = db.Cards.FirstOrDefault(card1 => card1.Baid == baid); var card = db.Cards.FirstOrDefault(card1 => card1.Baid == baid);

View File

@ -4,6 +4,6 @@ public enum PlayMode
{ {
Normal = 0, Normal = 0,
DanMode = 1, DanMode = 1,
// Not sure about this GaidenMode = 4,
AiBattle = 6 AiBattle = 6
} }

View File

@ -8,6 +8,6 @@ public enum SongGenre
Vocaloid = 3, Vocaloid = 3,
GameMusic = 4, GameMusic = 4,
NamcoOriginal = 5, NamcoOriginal = 5,
Variety = 7, Variety = 6,
Classical = 8 Classical = 7
} }

View File

@ -15,4 +15,7 @@ public class EventFolderData
[JsonPropertyName("songNo")] [JsonPropertyName("songNo")]
public uint[]? SongNo { get; set; } public uint[]? SongNo { get; set; }
[JsonPropertyName("parentFolderId")]
public uint ParentFolderId { get; set; }
} }

View File

@ -0,0 +1,12 @@
using System.Text.Json.Serialization;
namespace SharedProject.Models;
public class MovieData
{
[JsonPropertyName("movie_id")]
public uint MovieId { get; set; }
[JsonPropertyName("enable_days")]
public uint EnableDays { get; set; }
}

View File

@ -0,0 +1,10 @@
using System.Text.Json.Serialization;
namespace SharedProject.Models;
public class QRCodeData
{
[JsonPropertyName("serial")] public string Serial { get; set; } = null!;
[JsonPropertyName("id")] public uint Id { get; set; }
}

View File

@ -2,7 +2,7 @@
public class SetFavoriteRequest public class SetFavoriteRequest
{ {
public uint Baid { get; set; } public ulong Baid { get; set; }
public uint SongId { get; set; } public uint SongId { get; set; }
public bool IsFavorite { get; set; } public bool IsFavorite { get; set; }
} }

View File

@ -0,0 +1,8 @@
namespace SharedProject.Models.Requests;
public class SetPasswordRequest
{
public string AccessCode { get; set; } = default!;
public string Password { get; set; } = default!;
public string Salt { get; set; } = default!;
}

View File

@ -0,0 +1,10 @@
using System.Text.Json.Serialization;
namespace SharedProject.Models;
public class ShopFolderData
{
[JsonPropertyName("songNo")] public uint SongNo { get; set; }
[JsonPropertyName("price")] public uint Price { get; set; }
}

View File

@ -5,4 +5,8 @@ public class User
public string AccessCode { get; set; } = string.Empty; public string AccessCode { get; set; } = string.Empty;
public uint Baid { get; set; } public uint Baid { get; set; }
public string Password { get; set; } = string.Empty;
public string Salt { get; set; } = string.Empty;
} }

View File

@ -10,6 +10,12 @@ public class UserSetting
public bool IsDisplayDanOnNamePlate { get; set; } public bool IsDisplayDanOnNamePlate { get; set; }
public uint DifficultySettingCourse { get; set; }
public uint DifficultySettingStar { get; set; }
public uint DifficultySettingSort { get; set; }
public bool IsVoiceOn { get; set; } public bool IsVoiceOn { get; set; }
public bool IsSkipOn { get; set; } public bool IsSkipOn { get; set; }
@ -22,6 +28,8 @@ public class UserSetting
public string MyDonName { get; set; } = string.Empty; public string MyDonName { get; set; } = string.Empty;
public uint MyDonNameLanguage { get; set; }
public string Title { get; set; } = string.Empty; public string Title { get; set; } = string.Empty;
public uint TitlePlateId { get; set; } public uint TitlePlateId { get; set; }

View File

@ -1,9 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net6.0</TargetFramework> <TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<LangVersion>11</LangVersion>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>

View File

@ -1 +1,3 @@
wwwroot/data/music_attribute.json wwwroot/data/music_order.json
wwwroot/data/musicinfo.json
wwwroot/data/wordlist.json

View File

@ -10,36 +10,10 @@ public static class Constants
public const string DEFAULT_DB_NAME = "taiko.db3"; public const string DEFAULT_DB_NAME = "taiko.db3";
public const string MUSIC_ATTRIBUTE_FILE_NAME = "music_attribute.json"; public const string MUSIC_INFO_BASE_NAME = "musicinfo";
public const string MUSIC_ATTRIBUTE_COMPRESSED_FILE_NAME = "music_attribute.bin"; public const string WORDLIST_BASE_NAME = "wordlist";
public const string MUSIC_ORDER_BASE_NAME = "music_order";
public const string DAN_DATA_FILE_NAME = "dan_data.json"; public const string DON_COS_REWARD_BASE_NAME = "don_cos_reward";
public const string INTRO_DATA_FILE_NAME = "intro_data.json"; public const string SHOUGOU_BASE_NAME = "shougou";
public const string EVENT_FOLDER_DATA_FILE_NAME = "event_folder_data.json"; public const string NEIRO_BASE_NAME = "neiro";
public static readonly int[] EVENT_FOLDER_IDS = {
1, 2, 3, 4, 5, 6, 7, 8, 12, 13, 14
};
public const int MIN_DAN_ID = 1;
public const int MAX_DAN_ID = 19;
public const int TONE_UID_MAX = 19;
public const int TITLE_UID_MAX = 814;
private const int COSTUME_FLAG_1_ARRAY_SIZE = 154;
private const int COSTUME_FLAG_2_ARRAY_SIZE = 140;
private const int COSTUME_FLAG_3_ARRAY_SIZE = 156;
private const int COSTUME_FLAG_4_ARRAY_SIZE = 58;
private const int COSTUME_FLAG_5_ARRAY_SIZE = 129;
public static readonly int[] CostumeFlagArraySizes =
{
COSTUME_FLAG_1_ARRAY_SIZE,
COSTUME_FLAG_2_ARRAY_SIZE,
COSTUME_FLAG_3_ARRAY_SIZE,
COSTUME_FLAG_4_ARRAY_SIZE,
COSTUME_FLAG_5_ARRAY_SIZE
};
} }

View File

@ -1,4 +1,5 @@
using System.Collections; using System.Collections;
using System.Collections.Immutable;
using System.Collections.Specialized; using System.Collections.Specialized;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using GameDatabase.Entities; using GameDatabase.Entities;
@ -70,7 +71,7 @@ public static class FlagCalculator
return (ushort)(previous | result); return (ushort)(previous | result);
} }
public static byte[] ComputeGotDanFlags(List<DanScoreDatum> danScoreData) public static byte[] ComputeGotDanFlags(List<DanScoreDatum> danScoreData, List<uint> danIdList)
{ {
var gotDanFlagList = new List<int>(); var gotDanFlagList = new List<int>();
var gotDanFlag = new BitVector32(); var gotDanFlag = new BitVector32();
@ -85,9 +86,8 @@ public static class FlagCalculator
var sections = new[] { section1, section2, section3, section4, section5, section6, section7, section8 }; var sections = new[] { section1, section2, section3, section4, section5, section6, section7, section8 };
for (var i = Constants.MIN_DAN_ID; i < Constants.MAX_DAN_ID; i++) foreach (var danId in danIdList)
{ {
var danId = i;
var flag = 0; var flag = 0;
if (danScoreData.Any(datum => datum.DanId == danId)) if (danScoreData.Any(datum => datum.DanId == danId))
{ {
@ -126,4 +126,22 @@ public static class FlagCalculator
return result; return result;
} }
public static byte[] GetBitArrayTrue(int bitArraySize)
{
var result = new byte[(bitArraySize / 8) + 1];
var bitSet = new BitArray(bitArraySize, true);
bitSet.CopyTo(result, 0);
return result;
}
public static byte[] GetBitArrayFalse(int bitArraySize)
{
var result = new byte[(bitArraySize / 8) + 1];
var bitSet = new BitArray(bitArraySize, false);
bitSet.CopyTo(result, 0);
return result;
}
} }

View File

@ -1,15 +1,39 @@
using System.Text.Json; using GameDatabase.Entities;
using GameDatabase.Entities; using System.Text.Json;
namespace TaikoLocalServer.Common.Utils; namespace TaikoLocalServer.Common.Utils;
public static class JsonHelper public static class JsonHelper
{ {
public static uint[] GetUIntArrayFromJson(string data, int length, ILogger logger, string fieldName)
{
var array = new uint[length];
try
{
array = JsonSerializer.Deserialize<uint[]>(data);
}
catch (JsonException e)
{
logger.LogError(e, "Parsing {FieldName} json data failed", fieldName);
}
if (array != null && array.Length >= length)
{
return array;
}
logger.LogWarning($"{fieldName} is null or length less than {length}!");
array = new uint[length];
return array;
}
public static List<uint> GetCostumeDataFromUserData(UserDatum userData, ILogger logger) public static List<uint> GetCostumeDataFromUserData(UserDatum userData, ILogger logger)
{ {
var costumeData = new List<uint> { 0, 0, 0, 0, 0 }; var costumeData = new List<uint> { 0, 0, 0, 0, 0 };
try try
{ {
// logger.LogInformation(userData.CostumeData);
costumeData = JsonSerializer.Deserialize<List<uint>>(userData.CostumeData); costumeData = JsonSerializer.Deserialize<List<uint>>(userData.CostumeData);
} }
catch (JsonException e) catch (JsonException e)

View File

@ -4,17 +4,8 @@
"BaseServer": { "BaseServer": {
"Url": "http://0.0.0.0:5000" "Url": "http://0.0.0.0:5000"
}, },
"AmAuthServer": {
"Url": "http://0.0.0.0:80"
},
"MuchaServer": {
"Url": "https://0.0.0.0:10122"
},
"GameServer1": { "GameServer1": {
"Url": "https://0.0.0.0:54430" "Url": "https://0.0.0.0:57402"
},
"GameServer2": {
"Url": "https://0.0.0.0:54431"
} }
}, },
"Certificates": { "Certificates": {

View File

@ -2,6 +2,6 @@
"ServerSettings": { "ServerSettings": {
"MuchaUrl": "https://v402-front.mucha-prd.nbgi-amnet.jp:10122", "MuchaUrl": "https://v402-front.mucha-prd.nbgi-amnet.jp:10122",
"GameUrl": "vsapi.taiko-p.jp", "GameUrl": "vsapi.taiko-p.jp",
"EnableMoreSongs": true "EnableMoreSongs": false
} }
} }

View File

@ -1,4 +1,6 @@
namespace TaikoLocalServer.Controllers.Api; using SharedProject.Models.Requests;
namespace TaikoLocalServer.Controllers.Api;
[ApiController] [ApiController]
[Route("api/[controller]")] [Route("api/[controller]")]
@ -19,4 +21,13 @@ public class CardsController : BaseController<CardsController>
return result ? NoContent() : NotFound(); return result ? NoContent() : NotFound();
} }
[HttpPost]
public async Task<IActionResult> UpdatePassword(SetPasswordRequest request)
{
var accessCode = request.AccessCode;
var password = request.Password;
var salt = request.Salt;
var result = await cardService.UpdatePassword(accessCode, password, salt);
return result ? NoContent() : NotFound();
}
} }

View File

@ -15,7 +15,7 @@ public class DanBestDataController : BaseController<DanBestDataController>
} }
[HttpGet("{baid}")] [HttpGet("{baid}")]
public async Task<IActionResult> GetDanBestData(uint baid) public async Task<IActionResult> GetDanBestData(ulong baid)
{ {
var danScores = await danScoreDatumService.GetDanScoreDatumByBaid(baid); var danScores = await danScoreDatumService.GetDanScoreDatumByBaid(baid);
var danDataList = new List<DanBestData>(); var danDataList = new List<DanBestData>();

View File

@ -21,7 +21,7 @@ public class PlayDataController : BaseController<PlayDataController>
} }
[HttpGet("{baid}")] [HttpGet("{baid}")]
public async Task<ActionResult<SongBestResponse>> GetSongBestRecords(uint baid) public async Task<ActionResult<SongBestResponse>> GetSongBestRecords(ulong baid)
{ {
var user = await userDatumService.GetFirstUserDatumOrNull(baid); var user = await userDatumService.GetFirstUserDatumOrNull(baid);
if (user is null) if (user is null)

View File

@ -1,6 +1,6 @@
using System.Text.Json; using SharedProject.Models;
using SharedProject.Models;
using SharedProject.Utils; using SharedProject.Utils;
using System.Text.Json;
namespace TaikoLocalServer.Controllers.Api; namespace TaikoLocalServer.Controllers.Api;
@ -16,7 +16,7 @@ public class UserSettingsController : BaseController<UserSettingsController>
} }
[HttpGet] [HttpGet]
public async Task<ActionResult<UserSetting>> GetUserSetting(uint baid) public async Task<ActionResult<UserSetting>> GetUserSetting(ulong baid)
{ {
var user = await userDatumService.GetFirstUserDatumOrNull(baid); var user = await userDatumService.GetFirstUserDatumOrNull(baid);
@ -25,6 +25,8 @@ public class UserSettingsController : BaseController<UserSettingsController>
return NotFound(); return NotFound();
} }
var difficultySettingArray = JsonHelper.GetUIntArrayFromJson(user.DifficultySettingArray, 3, Logger, nameof(user.DifficultySettingArray));
var costumeData = JsonHelper.GetCostumeDataFromUserData(user, Logger); var costumeData = JsonHelper.GetCostumeDataFromUserData(user, Logger);
var costumeUnlockData = JsonHelper.GetCostumeUnlockDataFromUserData(user, Logger); var costumeUnlockData = JsonHelper.GetCostumeUnlockDataFromUserData(user, Logger);
@ -34,12 +36,16 @@ public class UserSettingsController : BaseController<UserSettingsController>
AchievementDisplayDifficulty = user.AchievementDisplayDifficulty, AchievementDisplayDifficulty = user.AchievementDisplayDifficulty,
IsDisplayAchievement = user.DisplayAchievement, IsDisplayAchievement = user.DisplayAchievement,
IsDisplayDanOnNamePlate = user.DisplayDan, IsDisplayDanOnNamePlate = user.DisplayDan,
DifficultySettingCourse = difficultySettingArray[0],
DifficultySettingStar = difficultySettingArray[1],
DifficultySettingSort = difficultySettingArray[2],
IsVoiceOn = user.IsVoiceOn, IsVoiceOn = user.IsVoiceOn,
IsSkipOn = user.IsSkipOn, IsSkipOn = user.IsSkipOn,
NotesPosition = user.NotesPosition, NotesPosition = user.NotesPosition,
PlaySetting = PlaySettingConverter.ShortToPlaySetting(user.OptionSetting), PlaySetting = PlaySettingConverter.ShortToPlaySetting(user.OptionSetting),
ToneId = user.SelectedToneId, ToneId = user.SelectedToneId,
MyDonName = user.MyDonName, MyDonName = user.MyDonName,
MyDonNameLanguage = user.MyDonNameLanguage,
Title = user.Title, Title = user.Title,
TitlePlateId = user.TitlePlateId, TitlePlateId = user.TitlePlateId,
Kigurumi = costumeData[0], Kigurumi = costumeData[0],
@ -60,7 +66,7 @@ public class UserSettingsController : BaseController<UserSettingsController>
} }
[HttpPost] [HttpPost]
public async Task<IActionResult> SaveUserSetting(uint baid, UserSetting userSetting) public async Task<IActionResult> SaveUserSetting(ulong baid, UserSetting userSetting)
{ {
var user = await userDatumService.GetFirstUserDatumOrNull(baid); var user = await userDatumService.GetFirstUserDatumOrNull(baid);
@ -78,15 +84,24 @@ public class UserSettingsController : BaseController<UserSettingsController>
userSetting.Puchi, userSetting.Puchi,
}; };
var difficultySettings = new List<uint>
{
userSetting.DifficultySettingCourse,
userSetting.DifficultySettingStar,
userSetting.DifficultySettingSort
};
user.IsSkipOn = userSetting.IsSkipOn; user.IsSkipOn = userSetting.IsSkipOn;
user.IsVoiceOn = userSetting.IsVoiceOn; user.IsVoiceOn = userSetting.IsVoiceOn;
user.DisplayAchievement = userSetting.IsDisplayAchievement; user.DisplayAchievement = userSetting.IsDisplayAchievement;
user.DisplayDan = userSetting.IsDisplayDanOnNamePlate; user.DisplayDan = userSetting.IsDisplayDanOnNamePlate;
user.DifficultySettingArray = JsonSerializer.Serialize(difficultySettings);
user.NotesPosition = userSetting.NotesPosition; user.NotesPosition = userSetting.NotesPosition;
user.SelectedToneId = userSetting.ToneId; user.SelectedToneId = userSetting.ToneId;
user.AchievementDisplayDifficulty = userSetting.AchievementDisplayDifficulty; user.AchievementDisplayDifficulty = userSetting.AchievementDisplayDifficulty;
user.OptionSetting = PlaySettingConverter.PlaySettingToShort(userSetting.PlaySetting); user.OptionSetting = PlaySettingConverter.PlaySettingToShort(userSetting.PlaySetting);
user.MyDonName = userSetting.MyDonName; user.MyDonName = userSetting.MyDonName;
user.MyDonNameLanguage = userSetting.MyDonNameLanguage;
user.Title = userSetting.Title; user.Title = userSetting.Title;
user.TitlePlateId = userSetting.TitlePlateId; user.TitlePlateId = userSetting.TitlePlateId;
user.ColorBody = userSetting.BodyColor; user.ColorBody = userSetting.BodyColor;
@ -94,7 +109,6 @@ public class UserSettingsController : BaseController<UserSettingsController>
user.ColorLimb = userSetting.LimbColor; user.ColorLimb = userSetting.LimbColor;
user.CostumeData = JsonSerializer.Serialize(costumes); user.CostumeData = JsonSerializer.Serialize(costumes);
await userDatumService.UpdateUserDatum(user); await userDatumService.UpdateUserDatum(user);
return NoContent(); return NoContent();

View File

@ -1,15 +1,56 @@
namespace TaikoLocalServer.Controllers.Game; using System.Text.Json;
using Throw;
[Route("/v12r03/chassis/addtokencount.php")] namespace TaikoLocalServer.Controllers.Game;
[Route("/v12r00_cn/chassis/addtokencount.php")]
[ApiController] [ApiController]
public class AddTokenCountController : BaseController<AddTokenCountController> public class AddTokenCountController : BaseController<AddTokenCountController>
{ {
private readonly IUserDatumService userDatumService;
public AddTokenCountController(IUserDatumService userDatumService)
{
this.userDatumService = userDatumService;
}
[HttpPost] [HttpPost]
[Produces("application/protobuf")] [Produces("application/protobuf")]
public IActionResult AddTokenCount([FromBody] AddTokenCountRequest request) public async Task<IActionResult> AddTokenCount([FromBody] AddTokenCountRequest request)
{ {
Logger.LogInformation("AddTokenCount request : {Request}", request.Stringify()); Logger.LogInformation("AddTokenCount request : {Request}", request.Stringify());
var user = await userDatumService.GetFirstUserDatumOrNull(request.Baid);
user.ThrowIfNull($"User with baid {request.Baid} does not exist!");
var tokenCountDict = new Dictionary<uint, int>();
try
{
tokenCountDict = !string.IsNullOrEmpty(user.TokenCountDict)
? JsonSerializer.Deserialize<Dictionary<uint, int>>(user.TokenCountDict)
: new Dictionary<uint, int>();
}
catch (JsonException e)
{
Logger.LogError(e, "Parsing TokenCountDict data for user with baid {Request} failed!", request.Baid);
}
tokenCountDict.ThrowIfNull("TokenCountDict should never be null");
foreach (var addTokenCountData in request.AryAddTokenCountDatas)
{
var tokenId = addTokenCountData.TokenId;
var addTokenCount = addTokenCountData.AddTokenCount;
if (tokenCountDict.ContainsKey(tokenId))
tokenCountDict[tokenId] += addTokenCount;
else
tokenCountDict.Add(tokenId, addTokenCount);
}
user.TokenCountDict = JsonSerializer.Serialize(tokenCountDict);
await userDatumService.UpdateUserDatum(user);
var response = new AddTokenCountResponse var response = new AddTokenCountResponse
{ {
Result = 1 Result = 1

View File

@ -1,11 +1,12 @@
using System.Text.Json; using GameDatabase.Entities;
using GameDatabase.Entities; using System.Text.Json;
using Serilog;
using Throw; using Throw;
namespace TaikoLocalServer.Controllers.Game; namespace TaikoLocalServer.Controllers.Game;
[ApiController] [ApiController]
[Route("/v12r03/chassis/baidcheck.php")] [Route("/v12r00_cn/chassis/baidcheck.php")]
public class BaidController : BaseController<BaidController> public class BaidController : BaseController<BaidController>
{ {
private readonly IUserDatumService userDatumService; private readonly IUserDatumService userDatumService;
@ -18,14 +19,18 @@ public class BaidController : BaseController<BaidController>
private readonly IAiDatumService aiDatumService; private readonly IAiDatumService aiDatumService;
private readonly IGameDataService gameDataService;
public BaidController(IUserDatumService userDatumService, ICardService cardService, public BaidController(IUserDatumService userDatumService, ICardService cardService,
ISongBestDatumService songBestDatumService, IDanScoreDatumService danScoreDatumService, IAiDatumService aiDatumService) ISongBestDatumService songBestDatumService, IDanScoreDatumService danScoreDatumService, IAiDatumService aiDatumService,
IGameDataService gameDataService)
{ {
this.userDatumService = userDatumService; this.userDatumService = userDatumService;
this.cardService = cardService; this.cardService = cardService;
this.songBestDatumService = songBestDatumService; this.songBestDatumService = songBestDatumService;
this.danScoreDatumService = danScoreDatumService; this.danScoreDatumService = danScoreDatumService;
this.aiDatumService = aiDatumService; this.aiDatumService = aiDatumService;
this.gameDataService = gameDataService;
} }
@ -35,25 +40,17 @@ public class BaidController : BaseController<BaidController>
{ {
Logger.LogInformation("Baid request: {Request}", request.Stringify()); Logger.LogInformation("Baid request: {Request}", request.Stringify());
BAIDResponse response; BAIDResponse response;
var card = await cardService.GetCardByAccessCode(request.AccessCode); var card = await cardService.GetCardByAccessCode(request.WechatQrStr);
if (card is null) if (card is null)
{ {
Logger.LogInformation("New user with access code {AccessCode}", request.AccessCode); Logger.LogInformation("New user with access code {AccessCode}", request.WechatQrStr);
var newId = cardService.GetNextBaid(); var newId = cardService.GetNextBaid();
response = new BAIDResponse response = new BAIDResponse
{ {
Result = 1, Result = 1,
PlayerType = 1, PlayerType = 1,
ComSvrResult = 1,
MbId = 1,
Baid = newId, Baid = newId,
AccessCode = request.AccessCode,
IsPublish = true,
CardOwnNum = 1,
RegCountryId = "JPN",
PurposeId = 1,
RegionId = 1
}; };
return Ok(response); return Ok(response);
@ -86,7 +83,7 @@ public class BaidController : BaseController<BaidController>
var costumeArrays = JsonHelper.GetCostumeUnlockDataFromUserData(userData, Logger); var costumeArrays = JsonHelper.GetCostumeUnlockDataFromUserData(userData, Logger);
var costumeFlagArrays = Constants.CostumeFlagArraySizes var costumeFlagArrays = gameDataService.GetCostumeFlagArraySizes()
.Select((size, index) => FlagCalculator.GetBitArrayFromIds(costumeArrays[index], size, Logger)) .Select((size, index) => FlagCalculator.GetBitArrayFromIds(costumeArrays[index], size, Logger))
.ToList(); .ToList();
@ -96,7 +93,15 @@ public class BaidController : BaseController<BaidController>
.Select(datum => datum.DanId) .Select(datum => datum.DanId)
.DefaultIfEmpty() .DefaultIfEmpty()
.Max(); .Max();
var gotDanFlagArray = FlagCalculator.ComputeGotDanFlags(danData);
var danDataDictionary = gameDataService.GetDanDataDictionary();
var danIdList = danDataDictionary.Keys.ToList();
var gotDanFlagArray = FlagCalculator.ComputeGotDanFlags(danData, danIdList);
var gaidenDataDictionary = gameDataService.GetGaidenDataDictionary();
var gaidenIdList = gaidenDataDictionary.Keys.ToList();
danIdList.AddRange(gaidenIdList);
var gotGaidenFlagArray = FlagCalculator.ComputeGotDanFlags(danData, danIdList);
var genericInfoFlg = Array.Empty<uint>(); var genericInfoFlg = Array.Empty<uint>();
try try
@ -112,7 +117,7 @@ public class BaidController : BaseController<BaidController>
// which means database content need to be fixed, so better throw // which means database content need to be fixed, so better throw
genericInfoFlg.ThrowIfNull("Genericinfo flg should never be null!"); genericInfoFlg.ThrowIfNull("Genericinfo flg should never be null!");
var genericInfoFlgLength = genericInfoFlg.Any()? genericInfoFlg.Max() + 1 : 0; var genericInfoFlgLength = genericInfoFlg.Any() ? genericInfoFlg.Max() + 1 : 0;
var genericInfoFlgArray = FlagCalculator.GetBitArrayFromIds(genericInfoFlg, (int)genericInfoFlgLength, Logger); var genericInfoFlgArray = FlagCalculator.GetBitArrayFromIds(genericInfoFlg, (int)genericInfoFlgLength, Logger);
var aiRank = (uint)(userData.AiWinCount / 10); var aiRank = (uint)(userData.AiWinCount / 10);
@ -124,16 +129,9 @@ public class BaidController : BaseController<BaidController>
{ {
Result = 1, Result = 1,
PlayerType = 0, PlayerType = 0,
ComSvrResult = 1,
MbId = 1,
Baid = baid, Baid = baid,
AccessCode = request.AccessCode,
IsPublish = true,
CardOwnNum = 1,
RegCountryId = "JPN",
PurposeId = 1,
RegionId = 1,
MydonName = userData.MyDonName, MydonName = userData.MyDonName,
MydonNameLanguage = userData.MyDonNameLanguage,
Title = userData.Title, Title = userData.Title,
TitleplateId = userData.TitlePlateId, TitleplateId = userData.TitlePlateId,
ColorFace = userData.ColorFace, ColorFace = userData.ColorFace,
@ -156,7 +154,7 @@ public class BaidController : BaseController<BaidController>
IsDispDanOn = userData.DisplayDan, IsDispDanOn = userData.DisplayDan,
GotDanMax = maxDan, GotDanMax = maxDan,
GotDanFlg = gotDanFlagArray, GotDanFlg = gotDanFlagArray,
GotDanextraFlg = new byte[20], GotDanextraFlg = gotGaidenFlagArray,
DefaultToneSetting = userData.SelectedToneId, DefaultToneSetting = userData.SelectedToneId,
GenericInfoFlg = genericInfoFlgArray, GenericInfoFlg = genericInfoFlgArray,
AryCrownCounts = crownCount, AryCrownCounts = crownCount,
@ -165,11 +163,7 @@ public class BaidController : BaseController<BaidController>
DispAchievementType = (uint)achievementDisplayDifficulty, DispAchievementType = (uint)achievementDisplayDifficulty,
IsDispAchievementTypeSet = true, IsDispAchievementTypeSet = true,
LastPlayMode = userData.LastPlayMode, LastPlayMode = userData.LastPlayMode,
IsDispSouuchiOn = true, IsDispSouuchiOn = true
AiRank = aiRank,
AiTotalWin = (uint)userData.AiWinCount,
Accesstoken = "123456",
ContentInfo = GZipBytesUtil.GetGZipBytes(new byte[10])
}; };
return Ok(response); return Ok(response);

View File

@ -1,7 +1,7 @@
namespace TaikoLocalServer.Controllers.Game; namespace TaikoLocalServer.Controllers.Game;
[ApiController] [ApiController]
[Route("/v12r03/chassis/bookkeeping.php")] [Route("/v12r00_cn/chassis/bookkeeping.php")]
public class BookkeepingController : BaseController<BookkeepingController> public class BookkeepingController : BaseController<BookkeepingController>
{ {
[HttpPost] [HttpPost]

View File

@ -1,6 +1,6 @@
namespace TaikoLocalServer.Controllers.Game; namespace TaikoLocalServer.Controllers.Game;
[Route("/v12r03/chassis/challengecompe.php")] [Route("/v12r00_cn/chassis/challengecompe.php")]
[ApiController] [ApiController]
public class ChallengeCompetitionController : BaseController<ChallengeCompetitionController> public class ChallengeCompetitionController : BaseController<ChallengeCompetitionController>
{ {

View File

@ -3,7 +3,7 @@ using TaikoLocalServer.Settings;
namespace TaikoLocalServer.Controllers.Game; namespace TaikoLocalServer.Controllers.Game;
[Route("/v12r03/chassis/crownsdata.php")] [Route("/v12r00_cn/chassis/crownsdata.php")]
[ApiController] [ApiController]
public class CrownsDataController : BaseController<CrownsDataController> public class CrownsDataController : BaseController<CrownsDataController>
{ {

View File

@ -1,6 +1,6 @@
namespace TaikoLocalServer.Controllers.Game; namespace TaikoLocalServer.Controllers.Game;
[Route("/v12r03/chassis/executeqrcode.php")] [Route("/v12r00_cn/chassis/executeqrcode.php")]
[ApiController] [ApiController]
public class ExecuteQrCodeController : BaseController<ExecuteQrCodeController> public class ExecuteQrCodeController : BaseController<ExecuteQrCodeController>
{ {

View File

@ -2,7 +2,7 @@
namespace TaikoLocalServer.Controllers.Game; namespace TaikoLocalServer.Controllers.Game;
[Route("/v12r03/chassis/getaidata.php")] [Route("/v12r00_cn/chassis/getaidata.php")]
[ApiController] [ApiController]
public class GetAiDataController : BaseController<GetAiDataController> public class GetAiDataController : BaseController<GetAiDataController>
{ {

View File

@ -2,7 +2,7 @@
namespace TaikoLocalServer.Controllers.Game; namespace TaikoLocalServer.Controllers.Game;
[Route("/v12r03/chassis/getaiscore.php")] [Route("/v12r00_cn/chassis/getaiscore.php")]
[ApiController] [ApiController]
public class GetAiScoreController : BaseController<GetAiScoreController> public class GetAiScoreController : BaseController<GetAiScoreController>
{ {

View File

@ -1,6 +1,6 @@
namespace TaikoLocalServer.Controllers.Game; namespace TaikoLocalServer.Controllers.Game;
[Route("/v12r03/chassis/getapplicationurl.php")] [Route("/v12r00_cn/chassis/getapplicationurl.php")]
[ApiController] [ApiController]
public class GetApplicationUrlController : BaseController<GetApplicationUrlController> public class GetApplicationUrlController : BaseController<GetApplicationUrlController>
{ {

View File

@ -1,6 +1,6 @@
namespace TaikoLocalServer.Controllers.Game; namespace TaikoLocalServer.Controllers.Game;
[Route("/v12r03/chassis/getdanodai.php")] [Route("/v12r00_cn/chassis/getdanodai.php")]
[ApiController] [ApiController]
public class GetDanOdaiController : BaseController<GetDanOdaiController> public class GetDanOdaiController : BaseController<GetDanOdaiController>
{ {
@ -22,11 +22,8 @@ public class GetDanOdaiController : BaseController<GetDanOdaiController>
Result = 1 Result = 1
}; };
if (request.Type == 2) if (request.Type == 1)
{ {
return Ok(response);
}
foreach (var danId in request.DanIds) foreach (var danId in request.DanIds)
{ {
gameDataService.GetDanDataDictionary().TryGetValue(danId, out var odaiData); gameDataService.GetDanDataDictionary().TryGetValue(danId, out var odaiData);
@ -38,6 +35,21 @@ public class GetDanOdaiController : BaseController<GetDanOdaiController>
response.AryOdaiDatas.Add(odaiData); response.AryOdaiDatas.Add(odaiData);
} }
}
else if (request.Type == 2)
{
foreach (var danId in request.DanIds)
{
gameDataService.GetGaidenDataDictionary().TryGetValue(danId, out var odaiData);
if (odaiData is null)
{
Logger.LogWarning("Requested dan id {Id} does not exist!", danId);
continue;
}
response.AryOdaiDatas.Add(odaiData);
}
}
return Ok(response); return Ok(response);
} }

View File

@ -2,7 +2,7 @@
namespace TaikoLocalServer.Controllers.Game; namespace TaikoLocalServer.Controllers.Game;
[Route("/v12r03/chassis/getdanscore.php")] [Route("/v12r00_cn/chassis/getdanscore.php")]
[ApiController] [ApiController]
public class GetDanScoreController : BaseController<GetDanScoreController> public class GetDanScoreController : BaseController<GetDanScoreController>
{ {

View File

@ -1,6 +1,6 @@
namespace TaikoLocalServer.Controllers.Game; namespace TaikoLocalServer.Controllers.Game;
[Route("/v12r03/chassis/getfolder.php")] [Route("/v12r00_cn/chassis/getfolder.php")]
[ApiController] [ApiController]
public class GetFolderController : BaseController<GetFolderController> public class GetFolderController : BaseController<GetFolderController>
{ {

View File

@ -0,0 +1,24 @@
namespace TaikoLocalServer.Controllers.Game;
[ApiController]
[Route("/v12r00_cn/chassis/getgenericmaster.php")]
public class GetGenericMasterController : BaseController<GetGenericMasterController>
{
[HttpPost]
[Produces("application/protobuf")]
public IActionResult GetGenericMaster([FromBody] GetGenericMasterRequest request)
{
Logger.LogInformation("GetGenericMasterRequest: {Request}", request.Stringify());
var response = new GetGenericMasterResponse
{
Result = 1,
VerupNo = 2,
EnableIdBit = FlagCalculator.GetBitArrayTrue(5000)
};
return Ok(response);
}
}

View File

@ -3,7 +3,7 @@ using TaikoLocalServer.Settings;
namespace TaikoLocalServer.Controllers.Game; namespace TaikoLocalServer.Controllers.Game;
[Route("/v12r03/chassis/getscorerank.php")] [Route("/v12r00_cn/chassis/getscorerank.php")]
[ApiController] [ApiController]
public class GetScoreRankController : BaseController<GetScoreRankController> public class GetScoreRankController : BaseController<GetScoreRankController>
{ {

View File

@ -1,27 +1,34 @@
namespace TaikoLocalServer.Controllers.Game; namespace TaikoLocalServer.Controllers.Game;
[Route("/v12r03/chassis/getshopfolder.php")] [Route("/v12r00_cn/chassis/getshopfolder.php")]
[ApiController] [ApiController]
public class GetShopFolderController : BaseController<GetShopFolderController> public class GetShopFolderController : BaseController<GetShopFolderController>
{ {
private readonly IGameDataService gameDataService;
public GetShopFolderController(IGameDataService gameDataService)
{
this.gameDataService = gameDataService;
}
[HttpPost] [HttpPost]
[Produces("application/protobuf")] [Produces("application/protobuf")]
public IActionResult GetShopFolder([FromBody] GetShopFolderRequest request) public IActionResult GetShopFolder([FromBody] GetShopFolderRequest request)
{ {
Logger.LogInformation("GetShopFolder request : {Request}", request.Stringify()); Logger.LogInformation("GetShopFolder request : {Request}", request.Stringify());
gameDataService.GetTokenDataDictionary().TryGetValue("shopTokenId", out var shopTokenId);
var shopFolderList = gameDataService.GetShopFolderList();
var response = new GetShopFolderResponse var response = new GetShopFolderResponse
{ {
Result = 1, Result = 1,
TokenId = 1, TokenId = shopTokenId > 0 ? (uint)shopTokenId : 1,
VerupNo = 2 VerupNo = 2
}; };
response.AryShopFolderDatas.Add(new GetShopFolderResponse.ShopFolderData response.AryShopFolderDatas.AddRange(shopFolderList);
{
Price = 1,
SongNo = 2
});
return Ok(response); return Ok(response);
} }

View File

@ -1,6 +1,6 @@
namespace TaikoLocalServer.Controllers.Game; namespace TaikoLocalServer.Controllers.Game;
[Route("/v12r03/chassis/getsongintroduction.php")] [Route("/v12r00_cn/chassis/getsongintroduction.php")]
[ApiController] [ApiController]
public class GetSongIntroductionController : BaseController<GetSongIntroductionController> public class GetSongIntroductionController : BaseController<GetSongIntroductionController>
{ {

View File

@ -1,6 +1,6 @@
namespace TaikoLocalServer.Controllers.Game; namespace TaikoLocalServer.Controllers.Game;
[Route("/v12r03/chassis/gettelop.php")] [Route("/v12r00_cn/chassis/gettelop.php")]
[ApiController] [ApiController]
public class GetTelopController : BaseController<GetTelopController> public class GetTelopController : BaseController<GetTelopController>
{ {

View File

@ -1,25 +1,101 @@
namespace TaikoLocalServer.Controllers.Game; using System.Text.Json;
using Throw;
[Route("/v12r03/chassis/gettokencount.php")] namespace TaikoLocalServer.Controllers.Game;
[Route("/v12r00_cn/chassis/gettokencount.php")]
[ApiController] [ApiController]
public class GetTokenCountController : BaseController<GetTokenCountController> public class GetTokenCountController : BaseController<GetTokenCountController>
{ {
private readonly IGameDataService gameDataService;
private readonly IUserDatumService userDatumService;
public GetTokenCountController(IUserDatumService userDatumService, IGameDataService gameDataService)
{
this.userDatumService = userDatumService;
this.gameDataService = gameDataService;
}
[HttpPost] [HttpPost]
[Produces("application/protobuf")] [Produces("application/protobuf")]
public IActionResult GetTokenCount([FromBody] GetTokenCountRequest request) public async Task<IActionResult> GetTokenCount([FromBody] GetTokenCountRequest request)
{ {
Logger.LogInformation("GetTokenCount request : {Request}", request.Stringify()); Logger.LogInformation("GetTokenCount request : {Request}", request.Stringify());
var user = await userDatumService.GetFirstUserDatumOrNull(request.Baid);
var tokenDataDictionary = gameDataService.GetTokenDataDictionary();
tokenDataDictionary.TryGetValue("shopTokenId", out var shopTokenId);
tokenDataDictionary.TryGetValue("kaTokenId", out var kaTokenId);
tokenDataDictionary.TryGetValue("onePieceTokenId", out var onePieceTokenId);
tokenDataDictionary.TryGetValue("soshinaTokenId", out var soshinaTokenId);
user.ThrowIfNull($"User with baid {request.Baid} does not exist!");
var tokenCountDict = new Dictionary<uint, int>();
try
{
tokenCountDict = !string.IsNullOrEmpty(user.TokenCountDict)
? JsonSerializer.Deserialize<Dictionary<uint, int>>(user.TokenCountDict)
: new Dictionary<uint, int>();
}
catch (JsonException e)
{
Logger.LogError(e, "Parsing TokenCountDict data for user with baid {Request} failed!", request.Baid);
}
tokenCountDict.ThrowIfNull("TokenCountDict should never be null");
var response = new GetTokenCountResponse var response = new GetTokenCountResponse
{ {
Result = 1 Result = 1
}; };
if (tokenCountDict.Count == 0) tokenCountDict.Add(1, 0);
if (shopTokenId > 0)
{
var castedShopTokenId = (uint)shopTokenId;
tokenCountDict.TryAdd(castedShopTokenId, 0);
response.AryTokenCountDatas.Add(new GetTokenCountResponse.TokenCountData response.AryTokenCountDatas.Add(new GetTokenCountResponse.TokenCountData
{ {
TokenCount = 10, TokenCount = tokenCountDict[castedShopTokenId],
TokenId = 1 TokenId = castedShopTokenId
}); });
}
if (kaTokenId > 0)
{
var castedKaTokenId = (uint)kaTokenId;
tokenCountDict.TryAdd(castedKaTokenId, 0);
response.AryTokenCountDatas.Add(new GetTokenCountResponse.TokenCountData
{
TokenCount = tokenCountDict[castedKaTokenId],
TokenId = castedKaTokenId
});
}
if (onePieceTokenId > 0)
{
var castedOnePieceTokenId = (uint)onePieceTokenId;
tokenCountDict.TryAdd(castedOnePieceTokenId, 0);
response.AryTokenCountDatas.Add(new GetTokenCountResponse.TokenCountData
{
TokenCount = tokenCountDict[castedOnePieceTokenId],
TokenId = castedOnePieceTokenId
});
}
if (soshinaTokenId > 0)
{
var castedSoshinaTokenId = (uint)soshinaTokenId;
tokenCountDict.TryAdd(castedSoshinaTokenId, 0);
response.AryTokenCountDatas.Add(new GetTokenCountResponse.TokenCountData
{
TokenCount = tokenCountDict[castedSoshinaTokenId],
TokenId = castedSoshinaTokenId
});
}
user.TokenCountDict = JsonSerializer.Serialize(tokenCountDict);
await userDatumService.UpdateUserDatum(user);
return Ok(response); return Ok(response);
} }

View File

@ -0,0 +1,39 @@
namespace TaikoLocalServer.Controllers.Game;
[ApiController]
[Route("/v12r00_cn/chassis/headclerk2.php")]
public class Headclerk2Controller : BaseController<Headclerk2Controller>
{
[HttpPost]
[Produces("application/protobuf")]
public IActionResult Headclerk2([FromBody] HeadClerk2Request request)
{
Logger.LogInformation("Headclerk2 request: {Request}", request.Stringify());
var chassisId = request.ChassisId;
var shopId = request.ShopId;
foreach (var playInfo in request.AryPlayInfoes)
{
var baid = playInfo.Baid;
var playedAt = playInfo.PlayedAt;
var isRight = playInfo.IsRight;
var type = playInfo.Type;
var amount = playInfo.Amount;
Logger.LogInformation("CSV WRITE: \n" +
"ChassisId:{ChassisId},\n" +
"ShopId:{ShopId},\n" +
"Baid:{Baid},\n" +
"PlayedAt{PlayedAt},\n" +
"IsRight:{IsRight},\n" +
"Type:{Type},\n" +
"Amount{Amount}", chassisId, shopId, baid, playedAt, isRight, type, amount);
}
var response = new HeadClerk2Response
{
Result = 1
};
return Ok(response);
}
}

View File

@ -1,7 +1,7 @@
namespace TaikoLocalServer.Controllers.Game; namespace TaikoLocalServer.Controllers.Game;
[ApiController] [ApiController]
[Route("/v12r03/chassis/heartbeat.php")] [Route("/v12r00_cn/chassis/heartbeat.php")]
public class HeartbeatController : BaseController<HeartbeatController> public class HeartbeatController : BaseController<HeartbeatController>
{ {
[HttpPost] [HttpPost]
@ -12,7 +12,6 @@ public class HeartbeatController : BaseController<HeartbeatController>
var response = new HeartBeatResponse var response = new HeartBeatResponse
{ {
Result = 1, Result = 1,
ComSvrStat = 1,
GameSvrStat = 1 GameSvrStat = 1
}; };

View File

@ -4,7 +4,7 @@ using TaikoLocalServer.Settings;
namespace TaikoLocalServer.Controllers.Game; namespace TaikoLocalServer.Controllers.Game;
[ApiController] [ApiController]
[Route("/v12r03/chassis/initialdatacheck.php")] [Route("/v12r00_cn/chassis/initialdatacheck.php")]
public class InitialDataCheckController : BaseController<InitialDataCheckController> public class InitialDataCheckController : BaseController<InitialDataCheckController>
{ {
private readonly IGameDataService gameDataService; private readonly IGameDataService gameDataService;
@ -24,93 +24,117 @@ public class InitialDataCheckController : BaseController<InitialDataCheckControl
Logger.LogInformation("Initial data check request: {Request}", request.Stringify()); Logger.LogInformation("Initial data check request: {Request}", request.Stringify());
var songIdMax = settings.EnableMoreSongs ? Constants.MUSIC_ID_MAX_EXPANDED : Constants.MUSIC_ID_MAX; var songIdMax = settings.EnableMoreSongs ? Constants.MUSIC_ID_MAX_EXPANDED : Constants.MUSIC_ID_MAX;
var musicList = gameDataService.GetMusicList();
var lockedSongsList = gameDataService.GetLockedSongsList();
var enabledArray = var enabledArray =
FlagCalculator.GetBitArrayFromIds(gameDataService.GetMusicList(), songIdMax, Logger); FlagCalculator.GetBitArrayFromIds(musicList, songIdMax, Logger);
var danData = new List<InitialdatacheckResponse.InformationData>(); var defaultSongList = musicList.Except(lockedSongsList);
for (var danId = Constants.MIN_DAN_ID; danId <= Constants.MAX_DAN_ID; danId++) var defaultSongFlg =
{ FlagCalculator.GetBitArrayFromIds(defaultSongList, songIdMax, Logger);
danData.Add(new InitialdatacheckResponse.InformationData
{
InfoId = (uint)danId,
VerupNo = 1
});
}
var introData = new List<InitialdatacheckResponse.InformationData>(); var defaultSongWithUraList = gameDataService.GetMusicWithUraList();
for (var setId = 1; setId <= gameDataService.GetSongIntroDictionary().Count; setId++) var uraReleaseBit =
{ FlagCalculator.GetBitArrayFromIds(defaultSongWithUraList, songIdMax, Logger);
introData.Add(new InitialdatacheckResponse.InformationData
{
InfoId = (uint)setId,
VerupNo = 1
});
}
var eventFolderData = new List<InitialdatacheckResponse.InformationData>();
foreach (var folderId in Constants.EVENT_FOLDER_IDS)
{
eventFolderData.Add(new InitialdatacheckResponse.InformationData
{
InfoId = (uint)folderId,
VerupNo = 0
});
}
var response = new InitialdatacheckResponse var response = new InitialdatacheckResponse
{ {
Result = 1, Result = 1,
IsDanplay = true, DefaultSongFlg = defaultSongFlg,
IsAibattle = true,
IsClose = false,
DefaultSongFlg = enabledArray,
AchievementSongBit = enabledArray, AchievementSongBit = enabledArray,
UraReleaseBit = uraReleaseBit,
SongIntroductionEndDatetime = DateTime.Now.AddYears(10).ToString(Constants.DATE_TIME_FORMAT), SongIntroductionEndDatetime = DateTime.Now.AddYears(10).ToString(Constants.DATE_TIME_FORMAT),
AryShopFolderDatas =
{
new InitialdatacheckResponse.InformationData
{
InfoId = 1,
VerupNo = 2
}
},
/*AryTelopDatas =
{
new InitialdatacheckResponse.InformationData
{
InfoId = 1,
VerupNo = 1
}
},
AryDanextraOdaiDatas =
{
new InitialdatacheckResponse.InformationData
{
InfoId = 1,
VerupNo = 1
}
},
AryAiEventDatas =
{
new InitialdatacheckResponse.AiEventData
{
AiEventId = 1,
TokenId = 1
}
},
AryMovieInfos =
{
new InitialdatacheckResponse.MovieData
{
MovieId = 2,
EnableDays = 9999
}
}*/
}; };
response.AryDanOdaiDatas.AddRange(danData); var movieDataDictionary = gameDataService.GetMovieDataDictionary();
response.ArySongIntroductionDatas.AddRange(introData); foreach (var movieData in movieDataDictionary) response.AryMovieInfoes.Add(movieData.Value);
response.AryEventfolderDatas.AddRange(eventFolderData);
var verupNo1 = new uint[] { 2, 3, 4, 5, 6, 7, 8, 13, 15, 24, 25, 26, 27, 28, 29, 30, 31, 104 };
var aryVerUp = verupNo1.Select(i => new InitialdatacheckResponse.VerupNoData1
{
MasterType = i,
VerupNo = 1
})
.ToList();
response.AryVerupNoData1s.AddRange(aryVerUp);
var danData = new List<InitialdatacheckResponse.VerupNoData2.InformationData>();
var danDataDictionary = gameDataService.GetDanDataDictionary();
foreach (var danId in danDataDictionary.Keys)
{
gameDataService.GetDanDataDictionary().TryGetValue(danId, out var odaiData);
danData.Add(new InitialdatacheckResponse.VerupNoData2.InformationData
{
InfoId = danId,
VerupNo = odaiData?.VerupNo ?? 1
});
}
var verUp2Type101 = new InitialdatacheckResponse.VerupNoData2
{
MasterType = 101,
};
verUp2Type101.AryInformationDatas.AddRange(danData);
response.AryVerupNoData2s.Add(verUp2Type101);
var gaidenData = new List<InitialdatacheckResponse.VerupNoData2.InformationData>();
var gaidenDataDictionary = gameDataService.GetGaidenDataDictionary();
foreach (var gaidenId in gaidenDataDictionary.Keys)
{
gaidenDataDictionary.TryGetValue(gaidenId, out var odaiData);
gaidenData.Add(new InitialdatacheckResponse.VerupNoData2.InformationData
{
InfoId = gaidenId,
VerupNo = odaiData?.VerupNo ?? 1
});
}
var verUp2Type102 = new InitialdatacheckResponse.VerupNoData2
{
MasterType = 102,
};
verUp2Type102.AryInformationDatas.AddRange(gaidenData);
response.AryVerupNoData2s.Add(verUp2Type102);
var eventFolderData = new List<InitialdatacheckResponse.VerupNoData2.InformationData>();
var eventFolderDictionary = gameDataService.GetFolderDictionary();
foreach (var folderId in eventFolderDictionary.Keys)
{
eventFolderDictionary.TryGetValue(folderId, out var folderData);
eventFolderData.Add(new InitialdatacheckResponse.VerupNoData2.InformationData
{
InfoId = folderId,
VerupNo = folderData?.VerupNo ?? 1
});
}
var verUp2Type103 = new InitialdatacheckResponse.VerupNoData2
{
MasterType = 103,
};
verUp2Type103.AryInformationDatas.AddRange(eventFolderData);
response.AryVerupNoData2s.Add(verUp2Type103);
var songIntroData = new List<InitialdatacheckResponse.VerupNoData2.InformationData>();
var songIntroDictionary = gameDataService.GetSongIntroDictionary();
foreach (var setId in songIntroDictionary.Select(item => item.Value.SetId))
{
songIntroDictionary.TryGetValue(setId, out var introData);
songIntroData.Add(new InitialdatacheckResponse.VerupNoData2.InformationData
{
InfoId = setId,
VerupNo = introData?.VerupNo ?? 1
});
}
var verUp2Type105 = new InitialdatacheckResponse.VerupNoData2
{
MasterType = 105,
};
verUp2Type105.AryInformationDatas.AddRange(songIntroData);
response.AryVerupNoData2s.Add(verUp2Type105);
response.AryChassisFunctionIds = new uint[] { 1, 2, 3 };
return Ok(response); return Ok(response);
} }

View File

@ -2,7 +2,7 @@
namespace TaikoLocalServer.Controllers.Game; namespace TaikoLocalServer.Controllers.Game;
[Route("/v12r03/chassis/mydonentry.php")] [Route("/v12r00_cn/chassis/mydonentry.php")]
[ApiController] [ApiController]
public class MyDonEntryController : BaseController<MyDonEntryController> public class MyDonEntryController : BaseController<MyDonEntryController>
{ {
@ -25,14 +25,17 @@ public class MyDonEntryController : BaseController<MyDonEntryController>
var newId = cardService.GetNextBaid(); var newId = cardService.GetNextBaid();
await cardService.AddCard(new Card await cardService.AddCard(new Card
{ {
AccessCode = request.AccessCode, AccessCode = request.WechatQrStr,
Baid = newId Baid = newId,
Password = "",
Salt = ""
}); });
var newUser = new UserDatum var newUser = new UserDatum
{ {
Baid = newId, Baid = newId,
MyDonName = request.MydonName, MyDonName = request.MydonName,
MyDonNameLanguage = 0,
DisplayDan = true, DisplayDan = true,
DisplayAchievement = true, DisplayAchievement = true,
AchievementDisplayDifficulty = Difficulty.None, AchievementDisplayDifficulty = Difficulty.None,
@ -40,10 +43,12 @@ public class MyDonEntryController : BaseController<MyDonEntryController>
ColorBody = 1, ColorBody = 1,
ColorLimb = 3, ColorLimb = 3,
FavoriteSongsArray = "[]", FavoriteSongsArray = "[]",
ToneFlgArray = "[]", ToneFlgArray = "[0]",
TitleFlgArray = "[]", TitleFlgArray = "[]",
CostumeFlgArray = "[[],[],[],[],[]]", CostumeFlgArray = "[[],[],[],[],[]]",
GenericInfoFlgArray = "[]" GenericInfoFlgArray = "[]",
TokenCountDict = "{}",
UnlockedSongIdList = "[]"
}; };
await userDatumService.InsertUserDatum(newUser); await userDatumService.InsertUserDatum(newUser);
@ -51,17 +56,9 @@ public class MyDonEntryController : BaseController<MyDonEntryController>
var response = new MydonEntryResponse var response = new MydonEntryResponse
{ {
Result = 1, Result = 1,
ComSvrResult = 1,
AccessCode = request.AccessCode,
Accesstoken = "12345",
Baid = newId, Baid = newId,
MbId = 1,
MydonName = request.MydonName, MydonName = request.MydonName,
CardOwnNum = 1, MydonNameLanguage = 0
IsPublish = true,
RegCountryId = request.CountryId,
PurposeId = 1,
RegionId = 1
}; };
return Ok(response); return Ok(response);

View File

@ -8,7 +8,7 @@ namespace TaikoLocalServer.Controllers.Game;
using StageData = PlayResultDataRequest.StageData; using StageData = PlayResultDataRequest.StageData;
[Route("/v12r03/chassis/playresult.php")] [Route("/v12r00_cn/chassis/playresult.php")]
[ApiController] [ApiController]
public class PlayResultController : BaseController<PlayResultController> public class PlayResultController : BaseController<PlayResultController>
{ {
@ -22,14 +22,18 @@ public class PlayResultController : BaseController<PlayResultController>
private readonly IAiDatumService aiDatumService; private readonly IAiDatumService aiDatumService;
private readonly IGameDataService gameDataService;
public PlayResultController(IUserDatumService userDatumService, ISongPlayDatumService songPlayDatumService, public PlayResultController(IUserDatumService userDatumService, ISongPlayDatumService songPlayDatumService,
ISongBestDatumService songBestDatumService, IDanScoreDatumService danScoreDatumService, IAiDatumService aiDatumService) ISongBestDatumService songBestDatumService, IDanScoreDatumService danScoreDatumService, IAiDatumService aiDatumService,
IGameDataService gameDataService)
{ {
this.userDatumService = userDatumService; this.userDatumService = userDatumService;
this.songPlayDatumService = songPlayDatumService; this.songPlayDatumService = songPlayDatumService;
this.songBestDatumService = songBestDatumService; this.songBestDatumService = songBestDatumService;
this.danScoreDatumService = danScoreDatumService; this.danScoreDatumService = danScoreDatumService;
this.aiDatumService = aiDatumService; this.aiDatumService = aiDatumService;
this.gameDataService = gameDataService;
} }
[HttpPost] [HttpPost]
@ -67,17 +71,32 @@ public class PlayResultController : BaseController<PlayResultController>
var playMode = (PlayMode)playResultData.PlayMode; var playMode = (PlayMode)playResultData.PlayMode;
if (playMode == PlayMode.DanMode) if (playMode is PlayMode.DanMode or PlayMode.GaidenMode)
{ {
await UpdateDanPlayData(request, playResultData); await UpdateDanPlayData(request, playResultData);
return Ok(response); return Ok(response);
} }
var bestData = await songBestDatumService.GetAllSongBestData(request.BaidConf); var bestData = await songBestDatumService.GetAllSongBestData(request.BaidConf);
gameDataService.GetFolderDictionary().TryGetValue(9, out var folder9Data);
var folder9Songs = new List<uint>();
if (folder9Data is not null)
{
folder9Songs.AddRange(folder9Data.SongNoes);
}
for (var songNumber = 0; songNumber < playResultData.AryStageInfoes.Count; songNumber++) for (var songNumber = 0; songNumber < playResultData.AryStageInfoes.Count; songNumber++)
{ {
var stageData = playResultData.AryStageInfoes[songNumber]; var stageData = playResultData.AryStageInfoes[songNumber];
if (folder9Songs.Contains(stageData.SongNo))
{
continue;
}
if (stageData.IsSkipUse) if (stageData.IsSkipUse)
{ {
await UpdatePlayData(request, songNumber, stageData, lastPlayDatetime); await UpdatePlayData(request, songNumber, stageData, lastPlayDatetime);
@ -203,16 +222,17 @@ public class PlayResultController : BaseController<PlayResultController>
}; };
userdata.CostumeData = JsonSerializer.Serialize(costumeData); userdata.CostumeData = JsonSerializer.Serialize(costumeData);
// Skip user setting altogether following official logic
// Skip user setting saving when in dan mode as dan mode uses its own default setting // Skip user setting saving when in dan mode as dan mode uses its own default setting
if (playMode != PlayMode.DanMode) // if (playMode != PlayMode.DanMode)
{ // {
var lastStage = playResultData.AryStageInfoes.Last(); // var lastStage = playResultData.AryStageInfoes.Last();
var option = BinaryPrimitives.ReadInt16LittleEndian(lastStage.OptionFlg); // var option = BinaryPrimitives.ReadInt16LittleEndian(lastStage.OptionFlg);
userdata.OptionSetting = option; // userdata.OptionSetting = option;
userdata.IsSkipOn = lastStage.IsSkipOn; // userdata.IsSkipOn = lastStage.IsSkipOn;
userdata.IsVoiceOn = !lastStage.IsVoiceOn; // userdata.IsVoiceOn = !lastStage.IsVoiceOn;
userdata.NotesPosition = lastStage.NotesPosition; // userdata.NotesPosition = lastStage.NotesPosition;
} // }
userdata.LastPlayDatetime = lastPlayDatetime; userdata.LastPlayDatetime = lastPlayDatetime;
userdata.LastPlayMode = playResultData.PlayMode; userdata.LastPlayMode = playResultData.PlayMode;
@ -236,6 +256,14 @@ public class PlayResultController : BaseController<PlayResultController>
userdata.GenericInfoFlgArray = userdata.GenericInfoFlgArray =
UpdateJsonUintFlagArray(userdata.GenericInfoFlgArray, playResultData.GetGenericInfoNoes, nameof(userdata.GenericInfoFlgArray)); UpdateJsonUintFlagArray(userdata.GenericInfoFlgArray, playResultData.GetGenericInfoNoes, nameof(userdata.GenericInfoFlgArray));
var difficultyPlayedArray = new List<uint>
{
playResultData.DifficultyPlayedCourse,
playResultData.DifficultyPlayedStar,
playResultData.DifficultyPlayedSort
};
userdata.DifficultyPlayedArray = JsonSerializer.Serialize(difficultyPlayedArray);
userdata.AiWinCount += playResultData.AryStageInfoes.Count(data => data.IsWin); userdata.AiWinCount += playResultData.AryStageInfoes.Count(data => data.IsWin);
await userDatumService.UpdateUserDatum(userdata); await userDatumService.UpdateUserDatum(userdata);
} }

View File

@ -1,6 +1,6 @@
namespace TaikoLocalServer.Controllers.Game; namespace TaikoLocalServer.Controllers.Game;
[Route("/v12r03/chassis/rewarditem.php")] [Route("/v12r00_cn/chassis/rewarditem.php")]
[ApiController] [ApiController]
public class RewardItemController : BaseController<RewardItemController> public class RewardItemController : BaseController<RewardItemController>
{ {

View File

@ -3,7 +3,7 @@ using Throw;
namespace TaikoLocalServer.Controllers.Game; namespace TaikoLocalServer.Controllers.Game;
[Route("/v12r03/chassis/selfbest.php")] [Route("/v12r00_cn/chassis/selfbest.php")]
[ApiController] [ApiController]
public class SelfBestController : BaseController<SelfBestController> public class SelfBestController : BaseController<SelfBestController>
{ {
@ -39,7 +39,7 @@ public class SelfBestController : BaseController<SelfBestController>
.ToList(); .ToList();
foreach (var songNo in request.ArySongNoes) foreach (var songNo in request.ArySongNoes)
{ {
if (!gameDataService.GetMusicAttributes().ContainsKey(songNo)) if (!gameDataService.GetMusicList().Contains(songNo))
{ {
Logger.LogWarning("Music no {No} is missing!", songNo); Logger.LogWarning("Music no {No} is missing!", songNo);
continue; continue;

View File

@ -0,0 +1,20 @@
namespace TaikoLocalServer.Controllers.Game;
[Route("/v12r00_cn/chassis/setanystring.php")]
[ApiController]
public class SetAnyStringController : BaseController<SetAnyStringController>
{
[HttpPost]
[Produces("application/protobuf")]
public IActionResult SetAnyString([FromBody] SetAnyStringRequest request)
{
Logger.LogInformation("SetAnyString request : {Request}", request.Stringify());
var response = new SetAnyStringResponse
{
Result = 1,
};
return Ok(response);
}
}

View File

@ -1,19 +1,73 @@
namespace TaikoLocalServer.Controllers.Game; using System.Text.Json;
using Throw;
[Route("/v12r03/chassis/songpurchase.php")] namespace TaikoLocalServer.Controllers.Game;
[Route("/v12r00_cn/chassis/songpurchase.php")]
[ApiController] [ApiController]
public class SongPurchaseController : BaseController<SongPurchaseController> public class SongPurchaseController : BaseController<SongPurchaseController>
{ {
private readonly IUserDatumService userDatumService;
public SongPurchaseController(IUserDatumService userDatumService)
{
this.userDatumService = userDatumService;
}
[HttpPost] [HttpPost]
[Produces("application/protobuf")] [Produces("application/protobuf")]
public IActionResult SongPurchase([FromBody] SongPurchaseRequest request) public async Task<IActionResult> SongPurchase([FromBody] SongPurchaseRequest request)
{ {
Logger.LogInformation("SongPurchase request : {Request}", request.Stringify()); Logger.LogInformation("SongPurchase request : {Request}", request.Stringify());
var user = await userDatumService.GetFirstUserDatumOrNull(request.Baid);
user.ThrowIfNull($"User with baid {request.Baid} does not exist!");
var tokenCountDict = new Dictionary<uint, int>();
try
{
tokenCountDict = !string.IsNullOrEmpty(user.TokenCountDict)
? JsonSerializer.Deserialize<Dictionary<uint, int>>(user.TokenCountDict)
: new Dictionary<uint, int>();
}
catch (JsonException e)
{
Logger.LogError(e, "Parsing TokenCountDict data for user with baid {Request} failed!", request.Baid);
}
tokenCountDict.ThrowIfNull("TokenCountDict should never be null");
Logger.LogInformation("Original UnlockedSongIdList: {UnlockedSongIdList}", user.UnlockedSongIdList);
var unlockedSongIdList = new List<uint>();
try
{
unlockedSongIdList = !string.IsNullOrEmpty(user.UnlockedSongIdList)
? JsonSerializer.Deserialize<List<uint>>(user.UnlockedSongIdList)
: new List<uint>();
}
catch (JsonException e)
{
Logger.LogError(e, "Parsing UnlockedSongIdList data for user with baid {Request} failed!", request.Baid);
}
unlockedSongIdList.ThrowIfNull("UnlockedSongIdList should never be null");
if (tokenCountDict.ContainsKey(request.TokenId)) tokenCountDict[request.TokenId] -= (int)request.Price;
if (!unlockedSongIdList.Contains(request.SongNo)) unlockedSongIdList.Add(request.SongNo);
user.TokenCountDict = JsonSerializer.Serialize(tokenCountDict);
user.UnlockedSongIdList = JsonSerializer.Serialize(unlockedSongIdList);
Logger.LogInformation("Updated UnlockedSongIdList: {UnlockedSongIdList}", user.UnlockedSongIdList);
await userDatumService.UpdateUserDatum(user);
var response = new SongPurchaseResponse var response = new SongPurchaseResponse
{ {
Result = 1, Result = 1,
TokenCount = (int)(10 - request.Price) TokenCount = tokenCountDict[request.TokenId]
}; };
return Ok(response); return Ok(response);

View File

@ -1,6 +1,6 @@
namespace TaikoLocalServer.Controllers.Game; namespace TaikoLocalServer.Controllers.Game;
[Route("/v12r03/chassis/tournamentcheck.php")] [Route("/v12r00_cn/chassis/tournamentcheck.php")]
[ApiController] [ApiController]
public class TournamentCheckController : BaseController<TournamentCheckController> public class TournamentCheckController : BaseController<TournamentCheckController>
{ {

View File

@ -1,12 +1,12 @@
using System.Buffers.Binary; using Microsoft.Extensions.Options;
using System.Buffers.Binary;
using System.Text.Json; using System.Text.Json;
using Microsoft.Extensions.Options;
using TaikoLocalServer.Settings; using TaikoLocalServer.Settings;
using Throw; using Throw;
namespace TaikoLocalServer.Controllers.Game; namespace TaikoLocalServer.Controllers.Game;
[Route("/v12r03/chassis/userdata.php")] [Route("/v12r00_cn/chassis/userdata.php")]
[ApiController] [ApiController]
public class UserDataController : BaseController<UserDataController> public class UserDataController : BaseController<UserDataController>
{ {
@ -34,14 +34,35 @@ public class UserDataController : BaseController<UserDataController>
Logger.LogInformation("UserData request : {Request}", request.Stringify()); Logger.LogInformation("UserData request : {Request}", request.Stringify());
var songIdMax = settings.EnableMoreSongs ? Constants.MUSIC_ID_MAX_EXPANDED : Constants.MUSIC_ID_MAX; var songIdMax = settings.EnableMoreSongs ? Constants.MUSIC_ID_MAX_EXPANDED : Constants.MUSIC_ID_MAX;
var releaseSongArray =
FlagCalculator.GetBitArrayFromIds(gameDataService.GetMusicList(), songIdMax, Logger);
var uraSongArray =
FlagCalculator.GetBitArrayFromIds(gameDataService.GetMusicWithUraList(), songIdMax, Logger);
var userData = await userDatumService.GetFirstUserDatumOrDefault(request.Baid); var userData = await userDatumService.GetFirstUserDatumOrDefault(request.Baid);
var unlockedSongIdList = new List<uint>();
try
{
unlockedSongIdList = !string.IsNullOrEmpty(userData.UnlockedSongIdList)
? JsonSerializer.Deserialize<List<uint>>(userData.UnlockedSongIdList)
: new List<uint>();
}
catch (JsonException e)
{
Logger.LogError(e, "Parsing UnlockedSongIdList data for user with baid {Request} failed!", request.Baid);
}
unlockedSongIdList.ThrowIfNull("UnlockedSongIdList should never be null");
var musicList = gameDataService.GetMusicList();
var lockedSongsList = gameDataService.GetLockedSongsList();
lockedSongsList = lockedSongsList.Except(unlockedSongIdList).ToList();
var enabledMusicList = musicList.Except(lockedSongsList);
var releaseSongArray =
FlagCalculator.GetBitArrayFromIds(enabledMusicList, songIdMax, Logger);
var defaultSongWithUraList = gameDataService.GetMusicWithUraList();
var enabledUraMusicList = defaultSongWithUraList.Except(lockedSongsList);
var uraSongArray =
FlagCalculator.GetBitArrayFromIds(enabledUraMusicList, songIdMax, Logger);
var toneFlg = Array.Empty<uint>(); var toneFlg = Array.Empty<uint>();
try try
{ {
@ -56,7 +77,15 @@ public class UserDataController : BaseController<UserDataController>
// which means database content need to be fixed, so better throw // which means database content need to be fixed, so better throw
toneFlg.ThrowIfNull("Tone flg should never be null!"); toneFlg.ThrowIfNull("Tone flg should never be null!");
var toneArray = FlagCalculator.GetBitArrayFromIds(toneFlg, Constants.TONE_UID_MAX, Logger); // If toneFlg is empty, add 0 to it
if (toneFlg.Length == 0)
{
toneFlg = new uint[] { 0 };
userData.ToneFlgArray = JsonSerializer.Serialize(toneFlg);
await userDatumService.UpdateUserDatum(userData);
}
var toneArray = FlagCalculator.GetBitArrayFromIds(toneFlg, gameDataService.GetToneFlagArraySize(), Logger);
var titleFlg = Array.Empty<uint>(); var titleFlg = Array.Empty<uint>();
try try
@ -72,7 +101,7 @@ public class UserDataController : BaseController<UserDataController>
// which means database content need to be fixed, so better throw // which means database content need to be fixed, so better throw
titleFlg.ThrowIfNull("Title flg should never be null!"); titleFlg.ThrowIfNull("Title flg should never be null!");
var titleArray = FlagCalculator.GetBitArrayFromIds(titleFlg, Constants.TITLE_UID_MAX, Logger); var titleArray = FlagCalculator.GetBitArrayFromIds(titleFlg, gameDataService.GetTitleFlagArraySize(), Logger);
var recentSongs = (await songPlayDatumService.GetSongPlayDatumByBaid(request.Baid)) var recentSongs = (await songPlayDatumService.GetSongPlayDatumByBaid(request.Baid))
.AsEnumerable() .AsEnumerable()
@ -111,6 +140,17 @@ public class UserDataController : BaseController<UserDataController>
var defaultOptions = new byte[2]; var defaultOptions = new byte[2];
BinaryPrimitives.WriteInt16LittleEndian(defaultOptions, userData.OptionSetting); BinaryPrimitives.WriteInt16LittleEndian(defaultOptions, userData.OptionSetting);
var difficultySettingArray = JsonHelper.GetUIntArrayFromJson(userData.DifficultySettingArray, 3, Logger, nameof(userData.DifficultySettingArray));
for (int i = 0; i < 3; i++)
{
if (difficultySettingArray[i] >= 2)
{
difficultySettingArray[i] -= 1;
}
}
var difficultyPlayedArray = JsonHelper.GetUIntArrayFromJson(userData.DifficultyPlayedArray, 3, Logger, nameof(userData.DifficultyPlayedArray));
var response = new UserDataResponse var response = new UserDataResponse
{ {
Result = 1, Result = 1,
@ -118,14 +158,20 @@ public class UserDataController : BaseController<UserDataController>
TitleFlg = titleArray, TitleFlg = titleArray,
ReleaseSongFlg = releaseSongArray, ReleaseSongFlg = releaseSongArray,
UraReleaseSongFlg = uraSongArray, UraReleaseSongFlg = uraSongArray,
DefaultOptionSetting = defaultOptions,
IsVoiceOn = userData.IsVoiceOn,
IsSkipOn = userData.IsSkipOn,
IsChallengecompe = false,
SongRecentCnt = (uint)recentSongs.Length,
AryFavoriteSongNoes = favoriteSongs, AryFavoriteSongNoes = favoriteSongs,
AryRecentSongNoes = recentSongs, AryRecentSongNoes = recentSongs,
NotesPosition = userData.NotesPosition DefaultOptionSetting = defaultOptions,
NotesPosition = userData.NotesPosition,
IsVoiceOn = userData.IsVoiceOn,
IsSkipOn = userData.IsSkipOn,
DifficultySettingCourse = difficultySettingArray[0],
DifficultySettingStar = difficultySettingArray[1],
DifficultySettingSort = difficultySettingArray[2],
DifficultyPlayedCourse = difficultyPlayedArray[0],
DifficultyPlayedStar = difficultyPlayedArray[1],
DifficultyPlayedSort = difficultyPlayedArray[2],
IsChallengecompe = false,
SongRecentCnt = (uint)recentSongs.Length
}; };
return Ok(response); return Ok(response);

View File

@ -1,19 +1,35 @@
namespace TaikoLocalServer.Controllers.Game; namespace TaikoLocalServer.Controllers.Game;
[Route("/v12r03/chassis/verifyqrcode.php")] [Route("/v12r00_cn/chassis/verifyqrcode.php")]
[ApiController] [ApiController]
public class VerifyQrCodeController : BaseController<VerifyQrCodeController> public class VerifyQrCodeController : BaseController<VerifyQrCodeController>
{ {
private readonly IGameDataService gameDataService;
public VerifyQrCodeController(IGameDataService gameDataService)
{
this.gameDataService = gameDataService;
}
[HttpPost] [HttpPost]
[Produces("application/protobuf")] [Produces("application/protobuf")]
public IActionResult VerifyQrCode([FromBody] VerifyQrcodeRequest request) public IActionResult VerifyQrCode([FromBody] VerifyQrcodeRequest request)
{ {
Logger.LogInformation("VerifyQrCode request : {Request}", request.Stringify()); Logger.LogInformation("VerifyQrCode request : {Request}", request.Stringify());
var qrCodeDataDictionary = gameDataService.GetQRCodeDataDictionary();
qrCodeDataDictionary.TryGetValue(request.QrcodeSerial, out var qrCodeId);
if (qrCodeId == 0)
{
Logger.LogWarning("Requested QR code serial {Serial} does not exist!", request.QrcodeSerial);
}
var response = new VerifyQrcodeResponse var response = new VerifyQrcodeResponse
{ {
Result = 1, Result = 1,
QrcodeId = 1 QrcodeId = qrCodeId
}; };
return Ok(response); return Ok(response);

View File

@ -0,0 +1,35 @@
using Serilog.Events;
using Serilog.Formatting;
namespace TaikoLocalServer.Logging;
public class CsvFormatter: ITextFormatter
{
public void Format(LogEvent logEvent, TextWriter output)
{
logEvent.Properties.TryGetValue("ChassisId", out var chassisId);
logEvent.Properties.TryGetValue("ShopId", out var shopId);
logEvent.Properties.TryGetValue("Baid", out var baid);
logEvent.Properties.TryGetValue("PlayedAt", out var playedAt);
logEvent.Properties.TryGetValue("IsRight", out var isRight);
logEvent.Properties.TryGetValue("Type", out var type);
logEvent.Properties.TryGetValue("Amount", out var amount);
output.Write(logEvent.Timestamp.ToString("yyyy-MM-dd"));
output.Write(",");
output.Write(chassisId);
output.Write(",");
output.Write(shopId);
output.Write(",");
output.Write(baid);
output.Write(",");
output.Write(playedAt);
output.Write(",");
output.Write(isRight);
output.Write(",");
output.Write(type);
output.Write(",");
output.Write(amount);
output.WriteLine();
}
}

View File

@ -0,0 +1,12 @@
using System.Text.Json.Serialization;
namespace TaikoLocalServer.Models;
public class DonCosRewardEntry
{
[JsonPropertyName("cosType")]
public string cosType { get; set; } = null!;
[JsonPropertyName("uniqueId")]
public uint uniqueId { get; set; }
}

View File

@ -0,0 +1,9 @@
using System.Text.Json.Serialization;
namespace TaikoLocalServer.Models;
public class DonCosRewards
{
[JsonPropertyName("items")]
public List<DonCosRewardEntry> DonCosRewardEntries { get; set; } = new();
}

File diff suppressed because it is too large Load Diff

View File

@ -1,12 +0,0 @@
using System.Text.Json.Serialization;
namespace TaikoLocalServer.Models;
public class MusicAttributeEntry
{
[JsonPropertyName("uniqueId")]
public uint MusicId { get; set; }
[JsonPropertyName("canPlayUra")]
public bool HasUra { get; set; }
}

View File

@ -1,9 +0,0 @@
using System.Text.Json.Serialization;
namespace TaikoLocalServer.Models;
public class MusicAttributes
{
[JsonPropertyName("items")]
public List<MusicAttributeEntry> MusicAttributeEntries { get; set; } = new();
}

View File

@ -0,0 +1,12 @@
using System.Text.Json.Serialization;
namespace TaikoLocalServer.Models;
public class MusicInfoEntry
{
[JsonPropertyName("uniqueId")]
public uint MusicId { get; set; }
[JsonPropertyName("starUra")]
public uint starUra { get; set; }
}

View File

@ -0,0 +1,9 @@
using System.Text.Json.Serialization;
namespace TaikoLocalServer.Models;
public class MusicInfoes
{
[JsonPropertyName("items")]
public List<MusicInfoEntry> MusicInfoEntries { get; set; } = new();
}

View File

@ -0,0 +1,9 @@
using System.Text.Json.Serialization;
namespace TaikoLocalServer.Models;
public class NeiroEntry
{
[JsonPropertyName("uniqueId")]
public uint uniqueId { get; set; }
}

View File

@ -0,0 +1,9 @@
using System.Text.Json.Serialization;
namespace TaikoLocalServer.Models;
public class Neiros
{
[JsonPropertyName("items")]
public List<NeiroEntry> NeiroEntries { get; set; } = new();
}

View File

@ -0,0 +1,9 @@
using System.Text.Json.Serialization;
namespace TaikoLocalServer.Models;
public class ShougouEntry
{
[JsonPropertyName("uniqueId")]
public uint uniqueId { get; set; }
}

View File

@ -0,0 +1,9 @@
using System.Text.Json.Serialization;
namespace TaikoLocalServer.Models;
public class Shougous
{
[JsonPropertyName("items")]
public List<ShougouEntry> ShougouEntries { get; set; } = new();
}

View File

@ -8,7 +8,6 @@
#pragma warning disable CS0612, CS0618, CS1591, CS3021, IDE0079, IDE1006, RCS1036, RCS1057, RCS1085, RCS1192 #pragma warning disable CS0612, CS0618, CS1591, CS3021, IDE0079, IDE1006, RCS1036, RCS1057, RCS1085, RCS1192
namespace taiko.vsinterface namespace taiko.vsinterface
{ {
[global::ProtoBuf.ProtoContract()] [global::ProtoBuf.ProtoContract()]
public partial class StartupAuthRequest : global::ProtoBuf.IExtensible public partial class StartupAuthRequest : global::ProtoBuf.IExtensible
{ {

View File

@ -1,6 +1,9 @@
using System.Reflection; using System.Reflection;
using System.Security.Authentication; using System.Security.Authentication;
using Serilog.Sinks.File.Header;
using TaikoLocalServer.Logging;
using GameDatabase.Context; using GameDatabase.Context;
using Microsoft.AspNetCore.HttpLogging;
using Microsoft.AspNetCore.HttpOverrides; using Microsoft.AspNetCore.HttpOverrides;
using TaikoLocalServer.Middlewares; using TaikoLocalServer.Middlewares;
using TaikoLocalServer.Services.Extentions; using TaikoLocalServer.Services.Extentions;
@ -23,26 +26,32 @@ try
{ {
var builder = WebApplication.CreateBuilder(args); var builder = WebApplication.CreateBuilder(args);
builder.Host.ConfigureAppConfiguration((hostingContext, config) => builder.Services.AddHttpLogging(options =>
{ {
const string configurationsDirectory = "Configurations"; options.LoggingFields = HttpLoggingFields.All;
config.AddJsonFile($"{configurationsDirectory}/Kestrel.json", optional: true, reloadOnChange: false); options.RequestBodyLogLimit = 32768;
config.AddJsonFile($"{configurationsDirectory}/Logging.json", optional: false, reloadOnChange: false); options.ResponseBodyLogLimit = 32768;
config.AddJsonFile($"{configurationsDirectory}/Database.json", optional: false, reloadOnChange: false);
config.AddJsonFile($"{configurationsDirectory}/ServerSettings.json", optional: false, reloadOnChange: false);
config.AddJsonFile($"{configurationsDirectory}/DataSettings.json", optional: true, reloadOnChange: false);
}); });
// Manually enable tls 1.0 const string configurationsDirectory = "Configurations";
builder.WebHost.UseKestrel(kestrelOptions => builder.Configuration.AddJsonFile($"{configurationsDirectory}/Kestrel.json", optional: true, reloadOnChange: false);
{ builder.Configuration.AddJsonFile($"{configurationsDirectory}/Logging.json", optional: false, reloadOnChange: false);
kestrelOptions.ConfigureHttpsDefaults(options => builder.Configuration.AddJsonFile($"{configurationsDirectory}/Database.json", optional: false, reloadOnChange: false);
options.SslProtocols = SslProtocols.Tls | SslProtocols.Tls11 | SslProtocols.Tls12 | SslProtocols.Tls13); builder.Configuration.AddJsonFile($"{configurationsDirectory}/ServerSettings.json", optional: false, reloadOnChange: false);
}); builder.Configuration.AddJsonFile($"{configurationsDirectory}/DataSettings.json", optional: true, reloadOnChange: false);
builder.Host.UseSerilog((context, configuration) => builder.Host.UseSerilog((context, configuration) =>
{ {
configuration.WriteTo.Console().ReadFrom.Configuration(context.Configuration); configuration
.WriteTo.Console().ReadFrom.Configuration(context.Configuration)
.WriteTo.Logger(x =>
{
x.WriteTo.File(new CsvFormatter(),
path: "./Logs/HeadClerkLog-.csv",
hooks: new HeaderWriter("Date,ChassisId,ShopId,Baid,PlayedAt,IsRight,Type,Amount"),
rollingInterval: RollingInterval.Day);
x.Filter.ByIncludingOnly("StartsWith(@m, 'CSV WRITE:')");
});
}); });
if (builder.Configuration.GetValue<bool>("ServerSettings:EnableMoreSongs")) if (builder.Configuration.GetValue<bool>("ServerSettings:EnableMoreSongs"))
@ -117,6 +126,16 @@ try
app.UseHttpLogging(); app.UseHttpLogging();
app.Use(async (context, next) =>
{
await next();
if (context.Response.StatusCode >= 400)
{
Log.Error("Unknown request from: {RemoteIpAddress} {Method} {Path} {StatusCode}",
context.Connection.RemoteIpAddress, context.Request.Method, context.Request.Path, context.Response.StatusCode);
}
});
app.MapControllers(); app.MapControllers();
app.MapFallbackToFile("index.html"); app.MapFallbackToFile("index.html");

View File

@ -12,7 +12,7 @@
"TaikoLocalServer": { "TaikoLocalServer": {
"commandName": "Project", "commandName": "Project",
"dotnetRunMessages": true, "dotnetRunMessages": true,
"launchBrowser": true, "launchBrowser": false,
"launchUrl": "", "launchUrl": "",
"applicationUrl": "http://localhost:5000", "applicationUrl": "http://localhost:5000",
"environmentVariables": { "environmentVariables": {
@ -21,7 +21,7 @@
}, },
"IIS Express": { "IIS Express": {
"commandName": "IISExpress", "commandName": "IISExpress",
"launchBrowser": true, "launchBrowser": false,
"launchUrl": "swagger", "launchUrl": "swagger",
"environmentVariables": { "environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development" "ASPNETCORE_ENVIRONMENT": "Development"

View File

@ -13,14 +13,14 @@ public class AiDatumService : IAiDatumService
this.context = context; this.context = context;
} }
public async Task<List<AiScoreDatum>> GetAllAiScoreById(uint baid) public async Task<List<AiScoreDatum>> GetAllAiScoreById(ulong baid)
{ {
return await context.AiScoreData.Where(datum => datum.Baid == baid) return await context.AiScoreData.Where(datum => datum.Baid == baid)
.Include(datum => datum.AiSectionScoreData) .Include(datum => datum.AiSectionScoreData)
.ToListAsync(); .ToListAsync();
} }
public async Task<AiScoreDatum?> GetSongAiScore(uint baid, uint songId, Difficulty difficulty) public async Task<AiScoreDatum?> GetSongAiScore(ulong baid, uint songId, Difficulty difficulty)
{ {
return await context.AiScoreData.Where(datum => datum.Baid == baid && return await context.AiScoreData.Where(datum => datum.Baid == baid &&
datum.SongId == songId && datum.SongId == songId &&

View File

@ -19,9 +19,9 @@ public class CardService : ICardService
return await context.Cards.FindAsync(accessCode); return await context.Cards.FindAsync(accessCode);
} }
public uint GetNextBaid() public ulong GetNextBaid()
{ {
return context.Cards.Any() ? context.Cards.Max(card => card.Baid) + 1 : 1; return context.Cards.Any() ? context.Cards.ToList().Max(card => card.Baid) + 1 : 1;
} }
public async Task<List<User>> GetUsersFromCards() public async Task<List<User>> GetUsersFromCards()
@ -49,4 +49,17 @@ public class CardService : ICardService
return true; return true;
} }
public async Task<bool> UpdatePassword(string accessCode, string password, string salt)
{
var card = await context.Cards.FindAsync(accessCode);
if (card is null) return false;
card.Password = password;
card.Salt = salt;
await context.SaveChangesAsync();
return true;
}
} }

View File

@ -12,14 +12,14 @@ public class DanScoreDatumService : IDanScoreDatumService
this.context = context; this.context = context;
} }
public async Task<List<DanScoreDatum>> GetDanScoreDatumByBaid(uint baid) public async Task<List<DanScoreDatum>> GetDanScoreDatumByBaid(ulong baid)
{ {
return await context.DanScoreData.Where(datum => datum.Baid == baid) return await context.DanScoreData.Where(datum => datum.Baid == baid)
.Include(datum => datum.DanStageScoreData) .Include(datum => datum.DanStageScoreData)
.ToListAsync(); .ToListAsync();
} }
public async Task<DanScoreDatum?> GetSingleDanScoreDatum(uint baid, uint danId) public async Task<DanScoreDatum?> GetSingleDanScoreDatum(ulong baid, uint danId)
{ {
return await context.DanScoreData.Include(datum => datum.DanStageScoreData) return await context.DanScoreData.Include(datum => datum.DanStageScoreData)
.FirstOrDefaultAsync(datum => datum.Baid == baid && .FirstOrDefaultAsync(datum => datum.Baid == baid &&

View File

@ -1,10 +1,12 @@
using System.Collections.Immutable; using ICSharpCode.SharpZipLib.GZip;
using System.Text.Json;
using ICSharpCode.SharpZipLib.GZip;
using Microsoft.Extensions.Options; using Microsoft.Extensions.Options;
using SharedProject.Models; using SharedProject.Models;
using SharedProject.Utils; using SharedProject.Utils;
using Swan.Mapping; using Swan.Mapping;
using System.Collections.Immutable;
using System.IO.Compression;
using System.Security.Cryptography;
using System.Text.Json;
using TaikoLocalServer.Settings; using TaikoLocalServer.Settings;
using Throw; using Throw;
@ -12,22 +14,42 @@ namespace TaikoLocalServer.Services;
public class GameDataService : IGameDataService public class GameDataService : IGameDataService
{ {
private ImmutableDictionary<uint, MusicInfoEntry> musicInfoes =
ImmutableDictionary<uint, MusicInfoEntry>.Empty;
private ImmutableDictionary<uint, GetDanOdaiResponse.OdaiData> danDataDictionary = private ImmutableDictionary<uint, GetDanOdaiResponse.OdaiData> danDataDictionary =
ImmutableDictionary<uint, GetDanOdaiResponse.OdaiData>.Empty; ImmutableDictionary<uint, GetDanOdaiResponse.OdaiData>.Empty;
private ImmutableDictionary<uint, GetDanOdaiResponse.OdaiData> gaidenDataDictionary =
ImmutableDictionary<uint, GetDanOdaiResponse.OdaiData>.Empty;
private ImmutableDictionary<uint, GetSongIntroductionResponse.SongIntroductionData> introDataDictionary = private ImmutableDictionary<uint, GetSongIntroductionResponse.SongIntroductionData> introDataDictionary =
ImmutableDictionary<uint, GetSongIntroductionResponse.SongIntroductionData>.Empty; ImmutableDictionary<uint, GetSongIntroductionResponse.SongIntroductionData>.Empty;
private ImmutableDictionary<uint, MusicAttributeEntry> musicAttributes = private ImmutableDictionary<uint, InitialdatacheckResponse.MovieData> movieDataDictionary =
ImmutableDictionary<uint, MusicAttributeEntry>.Empty; ImmutableDictionary<uint, InitialdatacheckResponse.MovieData>.Empty;
private ImmutableDictionary<uint, GetfolderResponse.EventfolderData> folderDictionary = private ImmutableDictionary<uint, GetfolderResponse.EventfolderData> folderDictionary =
ImmutableDictionary<uint, GetfolderResponse.EventfolderData>.Empty; ImmutableDictionary<uint, GetfolderResponse.EventfolderData>.Empty;
private ImmutableDictionary<string, uint> qrCodeDataDictionary = ImmutableDictionary<string, uint>.Empty;
private List<GetShopFolderResponse.ShopFolderData> shopFolderList = new();
private List<uint> musics = new(); private List<uint> musics = new();
private List<uint> musicsWithUra = new(); private List<uint> musicsWithUra = new();
private List<uint> lockedSongsList = new();
private List<int> costumeFlagArraySizes = new();
private int titleFlagArraySize;
private int toneFlagArraySize;
private Dictionary<string, int> tokenDataDictionary = new();
private readonly DataSettings settings; private readonly DataSettings settings;
public GameDataService(IOptions<DataSettings> settings) public GameDataService(IOptions<DataSettings> settings)
@ -45,9 +67,9 @@ public class GameDataService : IGameDataService
return musicsWithUra; return musicsWithUra;
} }
public ImmutableDictionary<uint, MusicAttributeEntry> GetMusicAttributes() public ImmutableDictionary<uint, MusicInfoEntry> GetMusicInfoes()
{ {
return musicAttributes; return musicInfoes;
} }
public ImmutableDictionary<uint, GetDanOdaiResponse.OdaiData> GetDanDataDictionary() public ImmutableDictionary<uint, GetDanOdaiResponse.OdaiData> GetDanDataDictionary()
@ -55,58 +77,217 @@ public class GameDataService : IGameDataService
return danDataDictionary; return danDataDictionary;
} }
public ImmutableDictionary<uint, GetDanOdaiResponse.OdaiData> GetGaidenDataDictionary()
{
return gaidenDataDictionary;
}
public ImmutableDictionary<uint, GetSongIntroductionResponse.SongIntroductionData> GetSongIntroDictionary() public ImmutableDictionary<uint, GetSongIntroductionResponse.SongIntroductionData> GetSongIntroDictionary()
{ {
return introDataDictionary; return introDataDictionary;
} }
public ImmutableDictionary<uint, InitialdatacheckResponse.MovieData> GetMovieDataDictionary()
{
return movieDataDictionary;
}
public ImmutableDictionary<uint, GetfolderResponse.EventfolderData> GetFolderDictionary() public ImmutableDictionary<uint, GetfolderResponse.EventfolderData> GetFolderDictionary()
{ {
return folderDictionary; return folderDictionary;
} }
public List<GetShopFolderResponse.ShopFolderData> GetShopFolderList()
{
return shopFolderList;
}
public Dictionary<string, int> GetTokenDataDictionary()
{
return tokenDataDictionary;
}
public List<uint> GetLockedSongsList()
{
return lockedSongsList;
}
public List<int> GetCostumeFlagArraySizes()
{
return costumeFlagArraySizes;
}
public int GetTitleFlagArraySize()
{
return titleFlagArraySize;
}
public int GetToneFlagArraySize()
{
return toneFlagArraySize;
}
public ImmutableDictionary<string, uint> GetQRCodeDataDictionary()
{
return qrCodeDataDictionary;
}
public async Task InitializeAsync() public async Task InitializeAsync()
{ {
var dataPath = PathHelper.GetDataPath(); var dataPath = PathHelper.GetDataPath();
var musicAttributePath = Path.Combine(dataPath, Constants.MUSIC_ATTRIBUTE_FILE_NAME);
var compressedMusicAttributePath = Path.Combine(dataPath, Constants.MUSIC_ATTRIBUTE_COMPRESSED_FILE_NAME); var musicInfoPath = Path.Combine(dataPath, $"{Constants.MUSIC_INFO_BASE_NAME}.json");
var encryptedInfo = Path.Combine(dataPath, $"{Constants.MUSIC_INFO_BASE_NAME}.bin");
var wordlistPath = Path.Combine(dataPath, $"{Constants.WORDLIST_BASE_NAME}.json");
var encryptedWordlist = Path.Combine(dataPath, $"{Constants.WORDLIST_BASE_NAME}.bin");
var musicOrderPath = Path.Combine(dataPath, $"{Constants.MUSIC_ORDER_BASE_NAME}.json");
var encryptedMusicOrder = Path.Combine(dataPath, $"{Constants.MUSIC_ORDER_BASE_NAME}.bin");
var donCosRewardPath = Path.Combine(dataPath, $"{Constants.DON_COS_REWARD_BASE_NAME}.json");
var encryptedDonCosReward = Path.Combine(dataPath, $"{Constants.DON_COS_REWARD_BASE_NAME}.bin");
var shougouPath = Path.Combine(dataPath, $"{Constants.SHOUGOU_BASE_NAME}.json");
var encryptedShougou = Path.Combine(dataPath, $"{Constants.SHOUGOU_BASE_NAME}.bin");
var neiroPath = Path.Combine(dataPath, $"{Constants.NEIRO_BASE_NAME}.json");
var encryptedNeiro = Path.Combine(dataPath, $"{Constants.NEIRO_BASE_NAME}.bin");
var danDataPath = Path.Combine(dataPath, settings.DanDataFileName); var danDataPath = Path.Combine(dataPath, settings.DanDataFileName);
var gaidenDataPath = Path.Combine(dataPath, settings.GaidenDataFileName);
var songIntroDataPath = Path.Combine(dataPath, settings.IntroDataFileName); var songIntroDataPath = Path.Combine(dataPath, settings.IntroDataFileName);
var movieDataPath = Path.Combine(dataPath, settings.MovieDataFileName);
var eventFolderDataPath = Path.Combine(dataPath, settings.EventFolderDataFileName); var eventFolderDataPath = Path.Combine(dataPath, settings.EventFolderDataFileName);
var shopFolderDataPath = Path.Combine(dataPath, settings.ShopFolderDataFileName);
var tokenDataPath = Path.Combine(dataPath, settings.TokenDataFileName);
var lockedSongsDataPath = Path.Combine(dataPath, settings.LockedSongsDataFileName);
var qrCodeDataPath = Path.Combine(dataPath, settings.QRCodeDataFileName);
if (File.Exists(compressedMusicAttributePath)) if (File.Exists(encryptedInfo))
{ {
TryDecompressMusicAttribute(); DecryptDataTable(encryptedInfo, musicInfoPath);
} }
await using var musicAttributeFile = File.OpenRead(musicAttributePath); if (File.Exists(encryptedWordlist))
{
DecryptDataTable(encryptedWordlist, wordlistPath);
}
if (File.Exists(encryptedMusicOrder))
{
DecryptDataTable(encryptedMusicOrder, musicOrderPath);
}
if (File.Exists(encryptedDonCosReward))
{
DecryptDataTable(encryptedDonCosReward, donCosRewardPath);
}
if (File.Exists(encryptedShougou))
{
DecryptDataTable(encryptedShougou, shougouPath);
}
if (File.Exists(encryptedNeiro))
{
DecryptDataTable(encryptedNeiro, neiroPath);
}
if (!File.Exists(musicInfoPath))
{
throw new FileNotFoundException("Music info file not found!");
}
if (!File.Exists(wordlistPath))
{
throw new FileNotFoundException("Wordlist file not found!");
}
if (!File.Exists(musicOrderPath))
{
throw new FileNotFoundException("Music order file not found!");
}
if (!File.Exists(donCosRewardPath))
{
throw new FileNotFoundException("Don cos reward file not found!");
}
if (!File.Exists(shougouPath))
{
throw new FileNotFoundException("Shougou file not found!");
}
if (!File.Exists(neiroPath))
{
throw new FileNotFoundException("Neiro file not found!");
}
await using var musicInfoFile = File.OpenRead(musicInfoPath);
await using var danDataFile = File.OpenRead(danDataPath); await using var danDataFile = File.OpenRead(danDataPath);
await using var gaidenDataFile = File.OpenRead(gaidenDataPath);
await using var songIntroDataFile = File.OpenRead(songIntroDataPath); await using var songIntroDataFile = File.OpenRead(songIntroDataPath);
await using var movieDataFile = File.OpenRead(movieDataPath);
await using var eventFolderDataFile = File.OpenRead(eventFolderDataPath); await using var eventFolderDataFile = File.OpenRead(eventFolderDataPath);
await using var shopFolderDataFile = File.OpenRead(shopFolderDataPath);
await using var tokenDataFile = File.OpenRead(tokenDataPath);
await using var lockedSongsDataFile = File.OpenRead(lockedSongsDataPath);
await using var donCosRewardFile = File.OpenRead(donCosRewardPath);
await using var shougouFile = File.OpenRead(shougouPath);
await using var neiroFile = File.OpenRead(neiroPath);
await using var qrCodeDataFile = File.OpenRead(qrCodeDataPath);
var attributesData = await JsonSerializer.DeserializeAsync<MusicAttributes>(musicAttributeFile); var infoesData = await JsonSerializer.DeserializeAsync<MusicInfoes>(musicInfoFile);
var danData = await JsonSerializer.DeserializeAsync<List<DanData>>(danDataFile); var danData = await JsonSerializer.DeserializeAsync<List<DanData>>(danDataFile);
var gaidenData = await JsonSerializer.DeserializeAsync<List<DanData>>(gaidenDataFile);
var introData = await JsonSerializer.DeserializeAsync<List<SongIntroductionData>>(songIntroDataFile); var introData = await JsonSerializer.DeserializeAsync<List<SongIntroductionData>>(songIntroDataFile);
var movieData = await JsonSerializer.DeserializeAsync<List<MovieData>>(movieDataFile);
var eventFolderData = await JsonSerializer.DeserializeAsync<List<EventFolderData>>(eventFolderDataFile); var eventFolderData = await JsonSerializer.DeserializeAsync<List<EventFolderData>>(eventFolderDataFile);
var shopFolderData = await JsonSerializer.DeserializeAsync<List<ShopFolderData>>(shopFolderDataFile);
var tokenData = await JsonSerializer.DeserializeAsync<Dictionary<string, int>>(tokenDataFile);
var lockedSongsData = await JsonSerializer.DeserializeAsync<Dictionary<string, uint[]>>(lockedSongsDataFile);
var donCosRewardData = await JsonSerializer.DeserializeAsync<DonCosRewards>(donCosRewardFile);
var shougouData = await JsonSerializer.DeserializeAsync<Shougous>(shougouFile);
var neiroData = await JsonSerializer.DeserializeAsync<Neiros>(neiroFile);
var qrCodeData = await JsonSerializer.DeserializeAsync<List<QRCodeData>>(qrCodeDataFile);
InitializeMusicAttributes(attributesData); InitializeMusicInfoes(infoesData);
InitializeDanData(danData); InitializeDanData(danData);
InitializeGaidenData(gaidenData);
InitializeIntroData(introData); InitializeIntroData(introData);
InitializeMovieData(movieData);
InitializeEventFolderData(eventFolderData); InitializeEventFolderData(eventFolderData);
InitializeShopFolderData(shopFolderData);
InitializeTokenData(tokenData);
InitializeLockedSongsData(lockedSongsData);
InitializeCostumeFlagArraySizes(donCosRewardData);
InitializeTitleFlagArraySize(shougouData);
InitializeToneFlagArraySize(neiroData);
InitializeQrCodeData(qrCodeData);
} }
private static void TryDecompressMusicAttribute() private static void DecryptDataTable(string inputFileName, string outputFileName)
{ {
var dataPath = PathHelper.GetDataPath(); var aes = Aes.Create();
var musicAttributePath = Path.Combine(dataPath, Constants.MUSIC_ATTRIBUTE_FILE_NAME); aes.Mode = CipherMode.CBC;
var compressedMusicAttributePath = Path.Combine(dataPath, Constants.MUSIC_ATTRIBUTE_COMPRESSED_FILE_NAME); aes.KeySize = 256;
aes.Padding = PaddingMode.PKCS7;
using var compressed = File.Open(compressedMusicAttributePath, FileMode.Open); aes.Key = Convert.FromHexString("3530304242323633353537423431384139353134383346433246464231354534");
using var output = File.Create(musicAttributePath); var iv = new byte[16];
using var fs = File.OpenRead(inputFileName);
GZip.Decompress(compressed, output, true); var count = fs.Read(iv, 0, 16);
count.Throw("Read IV for datatable failed!").IfNotEquals(16);
aes.IV = iv;
using var cs = new CryptoStream(fs, aes.CreateDecryptor(), CryptoStreamMode.Read);
using var ms = new MemoryStream();
cs.CopyTo(ms);
ms.Position = 0;
using var gz = new GZipStream(ms, CompressionMode.Decompress);
using var output = File.Create(outputFileName);
gz.CopyTo(output);
} }
private void InitializeIntroData(List<SongIntroductionData>? introData) private void InitializeIntroData(List<SongIntroductionData>? introData)
@ -115,34 +296,114 @@ public class GameDataService : IGameDataService
introDataDictionary = introData.ToImmutableDictionary(data => data.SetId, ToResponseIntroData); introDataDictionary = introData.ToImmutableDictionary(data => data.SetId, ToResponseIntroData);
} }
private void InitializeMovieData(List<MovieData>? movieData)
{
movieData.ThrowIfNull("Shouldn't happen!");
movieDataDictionary = movieData.ToImmutableDictionary(data => data.MovieId, ToResponseMovieData);
}
private void InitializeDanData(List<DanData>? danData) private void InitializeDanData(List<DanData>? danData)
{ {
danData.ThrowIfNull("Shouldn't happen!"); danData.ThrowIfNull("Shouldn't happen!");
danDataDictionary = danData.ToImmutableDictionary(data => data.DanId, ToResponseOdaiData); danDataDictionary = danData.ToImmutableDictionary(data => data.DanId, ToResponseOdaiData);
} }
private void InitializeGaidenData(List<DanData>? gaidenData)
{
gaidenData.ThrowIfNull("Shouldn't happen!");
gaidenDataDictionary = gaidenData.ToImmutableDictionary(data => data.DanId, ToResponseOdaiData);
}
private void InitializeEventFolderData(List<EventFolderData>? eventFolderData) private void InitializeEventFolderData(List<EventFolderData>? eventFolderData)
{ {
eventFolderData.ThrowIfNull("Shouldn't happen!"); eventFolderData.ThrowIfNull("Shouldn't happen!");
folderDictionary = eventFolderData.ToImmutableDictionary(data => data.FolderId, ToResponseEventFolderData); folderDictionary = eventFolderData.ToImmutableDictionary(data => data.FolderId, ToResponseEventFolderData);
} }
private void InitializeMusicAttributes(MusicAttributes? attributesData) private void InitializeMusicInfoes(MusicInfoes? infoesData)
{ {
attributesData.ThrowIfNull("Shouldn't happen!"); infoesData.ThrowIfNull("Shouldn't happen!");
musicAttributes = attributesData.MusicAttributeEntries.ToImmutableDictionary(attribute => attribute.MusicId); musicInfoes = infoesData.MusicInfoEntries.ToImmutableDictionary(info => info.MusicId);
musics = musicAttributes.Select(pair => pair.Key) musics = musicInfoes.Select(pair => pair.Key)
.ToList(); .ToList();
musics.Sort(); musics.Sort();
musicsWithUra = musicAttributes.Where(attribute => attribute.Value.HasUra) musicsWithUra = musicInfoes.Where(info => info.Value.starUra > 0)
.Select(pair => pair.Key) .Select(pair => pair.Key)
.ToList(); .ToList();
musicsWithUra.Sort(); musicsWithUra.Sort();
} }
private void InitializeShopFolderData(List<ShopFolderData>? shopFolderData)
{
shopFolderData.ThrowIfNull("Shouldn't happen!");
foreach (var folderData in shopFolderData)
{
shopFolderList.Add(ToResponseShopFolderData(folderData));
}
}
private void InitializeTokenData(Dictionary<string, int>? tokenData)
{
tokenData.ThrowIfNull("Shouldn't happen!");
tokenDataDictionary = tokenData;
}
private void InitializeLockedSongsData(Dictionary<string, uint[]>? lockedSongsData)
{
lockedSongsData.ThrowIfNull("Shouldn't happen!");
lockedSongsList = lockedSongsData["songNo"].ToList();
}
private void InitializeCostumeFlagArraySizes(DonCosRewards? donCosRewardData)
{
donCosRewardData.ThrowIfNull("Shouldn't happen!");
var kigurumiUniqueIdList = donCosRewardData.DonCosRewardEntries
.Where(entry => entry.cosType == "kigurumi")
.Select(entry => entry.uniqueId);
var headUniqueIdList = donCosRewardData.DonCosRewardEntries
.Where(entry => entry.cosType == "head")
.Select(entry => entry.uniqueId);
var bodyUniqueIdList = donCosRewardData.DonCosRewardEntries
.Where(entry => entry.cosType == "body")
.Select(entry => entry.uniqueId);
var faceUniqueIdList = donCosRewardData.DonCosRewardEntries
.Where(entry => entry.cosType == "face")
.Select(entry => entry.uniqueId);
var puchiUniqueIdList = donCosRewardData.DonCosRewardEntries
.Where(entry => entry.cosType == "puchi")
.Select(entry => entry.uniqueId);
costumeFlagArraySizes = new List<int>
{
(int)kigurumiUniqueIdList.Max() + 1,
(int)headUniqueIdList.Max() + 1,
(int)bodyUniqueIdList.Max() + 1,
(int)faceUniqueIdList.Max() + 1,
(int)puchiUniqueIdList.Max() + 1
};
}
private void InitializeTitleFlagArraySize(Shougous? shougouData)
{
shougouData.ThrowIfNull("Shouldn't happen!");
titleFlagArraySize = (int)shougouData.ShougouEntries.Max(entry => entry.uniqueId) + 1;
}
private void InitializeToneFlagArraySize(Neiros? neiroData)
{
neiroData.ThrowIfNull("Shouldn't happen!");
toneFlagArraySize = (int)neiroData.NeiroEntries.Max(entry => entry.uniqueId) + 1;
}
private void InitializeQrCodeData(List<QRCodeData>? qrCodeData)
{
qrCodeData.ThrowIfNull("Shouldn't happen!");
qrCodeDataDictionary = qrCodeData.ToImmutableDictionary(data => data.Serial, data => data.Id);
}
private static GetDanOdaiResponse.OdaiData ToResponseOdaiData(DanData data) private static GetDanOdaiResponse.OdaiData ToResponseOdaiData(DanData data)
{ {
var responseOdaiData = new GetDanOdaiResponse.OdaiData var responseOdaiData = new GetDanOdaiResponse.OdaiData
@ -163,7 +424,7 @@ public class GameDataService : IGameDataService
private static GetSongIntroductionResponse.SongIntroductionData ToResponseIntroData(SongIntroductionData data) private static GetSongIntroductionResponse.SongIntroductionData ToResponseIntroData(SongIntroductionData data)
{ {
var responseOdaiData = new GetSongIntroductionResponse.SongIntroductionData var responseIntroData = new GetSongIntroductionResponse.SongIntroductionData
{ {
SetId = data.SetId, SetId = data.SetId,
VerupNo = data.VerupNo, VerupNo = data.VerupNo,
@ -171,7 +432,18 @@ public class GameDataService : IGameDataService
SubSongNoes = data.SubSongNo SubSongNoes = data.SubSongNo
}; };
return responseOdaiData; return responseIntroData;
}
private static InitialdatacheckResponse.MovieData ToResponseMovieData(MovieData data)
{
var responseMovieData = new InitialdatacheckResponse.MovieData
{
MovieId = data.MovieId,
EnableDays = data.EnableDays
};
return responseMovieData;
} }
private static GetfolderResponse.EventfolderData ToResponseEventFolderData(EventFolderData data) private static GetfolderResponse.EventfolderData ToResponseEventFolderData(EventFolderData data)
@ -181,9 +453,21 @@ public class GameDataService : IGameDataService
FolderId = data.FolderId, FolderId = data.FolderId,
VerupNo = data.VerupNo, VerupNo = data.VerupNo,
Priority = data.Priority, Priority = data.Priority,
SongNoes = data.SongNo SongNoes = data.SongNo,
ParentFolderId = data.ParentFolderId
}; };
return responseEventFolderData; return responseEventFolderData;
} }
private static GetShopFolderResponse.ShopFolderData ToResponseShopFolderData(ShopFolderData data)
{
var responseShopFolderData = new GetShopFolderResponse.ShopFolderData
{
SongNo = data.SongNo,
Price = data.Price
};
return responseShopFolderData;
}
} }

View File

@ -4,9 +4,9 @@ namespace TaikoLocalServer.Services.Interfaces;
public interface IAiDatumService public interface IAiDatumService
{ {
public Task<List<AiScoreDatum>> GetAllAiScoreById(uint baid); public Task<List<AiScoreDatum>> GetAllAiScoreById(ulong baid);
public Task<AiScoreDatum?> GetSongAiScore(uint baid, uint songId, Difficulty difficulty); public Task<AiScoreDatum?> GetSongAiScore(ulong baid, uint songId, Difficulty difficulty);
public Task UpdateSongAiScore(AiScoreDatum datum); public Task UpdateSongAiScore(AiScoreDatum datum);

View File

@ -7,11 +7,13 @@ public interface ICardService
{ {
public Task<Card?> GetCardByAccessCode(string accessCode); public Task<Card?> GetCardByAccessCode(string accessCode);
public uint GetNextBaid(); public ulong GetNextBaid();
public Task<List<User>> GetUsersFromCards(); public Task<List<User>> GetUsersFromCards();
public Task AddCard(Card card); public Task AddCard(Card card);
public Task<bool> DeleteCard(string accessCode); public Task<bool> DeleteCard(string accessCode);
public Task<bool> UpdatePassword(string accessCode, string password, string salt);
} }

View File

@ -4,9 +4,9 @@ namespace TaikoLocalServer.Services.Interfaces;
public interface IDanScoreDatumService public interface IDanScoreDatumService
{ {
public Task<List<DanScoreDatum>> GetDanScoreDatumByBaid(uint baid); public Task<List<DanScoreDatum>> GetDanScoreDatumByBaid(ulong baid);
public Task<DanScoreDatum?> GetSingleDanScoreDatum(uint baid, uint danId); public Task<DanScoreDatum?> GetSingleDanScoreDatum(ulong baid, uint danId);
public Task InsertOrUpdateDanScoreDatum(DanScoreDatum datum); public Task InsertOrUpdateDanScoreDatum(DanScoreDatum datum);
} }

View File

@ -1,4 +1,5 @@
using System.Collections.Immutable; using System.Collections.Immutable;
using SharedProject.Models;
namespace TaikoLocalServer.Services.Interfaces; namespace TaikoLocalServer.Services.Interfaces;
@ -10,12 +11,30 @@ public interface IGameDataService
public List<uint> GetMusicWithUraList(); public List<uint> GetMusicWithUraList();
public ImmutableDictionary<uint, MusicAttributeEntry> GetMusicAttributes(); public ImmutableDictionary<uint, MusicInfoEntry> GetMusicInfoes();
public ImmutableDictionary<uint, GetDanOdaiResponse.OdaiData> GetDanDataDictionary(); public ImmutableDictionary<uint, GetDanOdaiResponse.OdaiData> GetDanDataDictionary();
public ImmutableDictionary<uint, GetDanOdaiResponse.OdaiData> GetGaidenDataDictionary();
public ImmutableDictionary<uint, GetSongIntroductionResponse.SongIntroductionData> GetSongIntroDictionary(); public ImmutableDictionary<uint, GetSongIntroductionResponse.SongIntroductionData> GetSongIntroDictionary();
public ImmutableDictionary<uint, InitialdatacheckResponse.MovieData> GetMovieDataDictionary();
public ImmutableDictionary<uint, GetfolderResponse.EventfolderData> GetFolderDictionary(); public ImmutableDictionary<uint, GetfolderResponse.EventfolderData> GetFolderDictionary();
public List<GetShopFolderResponse.ShopFolderData> GetShopFolderList();
public Dictionary<string, int> GetTokenDataDictionary();
public List<uint> GetLockedSongsList();
public List<int> GetCostumeFlagArraySizes();
public int GetTitleFlagArraySize();
public int GetToneFlagArraySize();
public ImmutableDictionary<string, uint> GetQRCodeDataDictionary();
} }

View File

@ -5,9 +5,9 @@ namespace TaikoLocalServer.Services.Interfaces;
public interface ISongBestDatumService public interface ISongBestDatumService
{ {
public Task<List<SongBestDatum>> GetAllSongBestData(uint baid); public Task<List<SongBestDatum>> GetAllSongBestData(ulong baid);
public Task UpdateOrInsertSongBestDatum(SongBestDatum datum); public Task UpdateOrInsertSongBestDatum(SongBestDatum datum);
public Task<List<SongBestData>> GetAllSongBestAsModel(uint baid); public Task<List<SongBestData>> GetAllSongBestAsModel(ulong baid);
} }

View File

@ -4,7 +4,7 @@ namespace TaikoLocalServer.Services.Interfaces;
public interface ISongPlayDatumService public interface ISongPlayDatumService
{ {
public Task<List<SongPlayDatum>> GetSongPlayDatumByBaid(uint baid); public Task<List<SongPlayDatum>> GetSongPlayDatumByBaid(ulong baid);
public Task AddSongPlayDatum(SongPlayDatum datum); public Task AddSongPlayDatum(SongPlayDatum datum);
} }

View File

@ -4,9 +4,9 @@ namespace TaikoLocalServer.Services.Interfaces;
public interface IUserDatumService public interface IUserDatumService
{ {
public Task<UserDatum?> GetFirstUserDatumOrNull(uint baid); public Task<UserDatum?> GetFirstUserDatumOrNull(ulong baid);
public Task<UserDatum> GetFirstUserDatumOrDefault(uint baid); public Task<UserDatum> GetFirstUserDatumOrDefault(ulong baid);
public Task<List<UserDatum>> GetAllUserData(); public Task<List<UserDatum>> GetAllUserData();
@ -16,9 +16,9 @@ public interface IUserDatumService
public Task UpdateUserDatum(UserDatum userDatum); public Task UpdateUserDatum(UserDatum userDatum);
public Task<List<uint>> GetFavoriteSongIds(uint baid); public Task<List<uint>> GetFavoriteSongIds(ulong baid);
public Task UpdateFavoriteSong(uint baid, uint songId, bool isFavorite); public Task UpdateFavoriteSong(ulong baid, uint songId, bool isFavorite);
} }

View File

@ -15,7 +15,7 @@ public class SongBestDatumService : ISongBestDatumService
this.context = context; this.context = context;
} }
public async Task<List<SongBestDatum>> GetAllSongBestData(uint baid) public async Task<List<SongBestDatum>> GetAllSongBestData(ulong baid)
{ {
return await context.SongBestData.Where(datum => datum.Baid == baid).ToListAsync(); return await context.SongBestData.Where(datum => datum.Baid == baid).ToListAsync();
} }
@ -37,7 +37,7 @@ public class SongBestDatumService : ISongBestDatumService
await context.SaveChangesAsync(); await context.SaveChangesAsync();
} }
public async Task<List<SongBestData>> GetAllSongBestAsModel(uint baid) public async Task<List<SongBestData>> GetAllSongBestAsModel(ulong baid)
{ {
var songbestDbData = await context.SongBestData.Where(datum => datum.Baid == baid) var songbestDbData = await context.SongBestData.Where(datum => datum.Baid == baid)
.ToListAsync(); .ToListAsync();

View File

@ -12,7 +12,7 @@ class SongPlayDatumService : ISongPlayDatumService
this.context = context; this.context = context;
} }
public async Task<List<SongPlayDatum>> GetSongPlayDatumByBaid(uint baid) public async Task<List<SongPlayDatum>> GetSongPlayDatumByBaid(ulong baid)
{ {
return await context.SongPlayData.Where(datum => datum.Baid == baid).ToListAsync(); return await context.SongPlayData.Where(datum => datum.Baid == baid).ToListAsync();
} }

View File

@ -17,12 +17,12 @@ public class UserDatumService : IUserDatumService
this.logger = logger; this.logger = logger;
} }
public async Task<UserDatum?> GetFirstUserDatumOrNull(uint baid) public async Task<UserDatum?> GetFirstUserDatumOrNull(ulong baid)
{ {
return await context.UserData.FindAsync(baid); return await context.UserData.FindAsync(baid);
} }
public async Task<UserDatum> GetFirstUserDatumOrDefault(uint baid) public async Task<UserDatum> GetFirstUserDatumOrDefault(ulong baid)
{ {
return await context.UserData.FindAsync(baid) ?? new UserDatum(); return await context.UserData.FindAsync(baid) ?? new UserDatum();
} }
@ -57,7 +57,7 @@ public class UserDatumService : IUserDatumService
await context.SaveChangesAsync(); await context.SaveChangesAsync();
} }
public async Task<List<uint>> GetFavoriteSongIds(uint baid) public async Task<List<uint>> GetFavoriteSongIds(ulong baid)
{ {
var userDatum = await context.UserData.FindAsync(baid); var userDatum = await context.UserData.FindAsync(baid);
userDatum.ThrowIfNull($"User with baid: {baid} not found!"); userDatum.ThrowIfNull($"User with baid: {baid} not found!");
@ -77,7 +77,7 @@ public class UserDatumService : IUserDatumService
return result; return result;
} }
public async Task UpdateFavoriteSong(uint baid, uint songId, bool isFavorite) public async Task UpdateFavoriteSong(ulong baid, uint songId, bool isFavorite)
{ {
var userDatum = await context.UserData.FindAsync(baid); var userDatum = await context.UserData.FindAsync(baid);
userDatum.ThrowIfNull($"User with baid: {baid} not found!"); userDatum.ThrowIfNull($"User with baid: {baid} not found!");

Some files were not shown because too many files have changed in this diff Show More