1
0
mirror of synced 2024-11-12 01:20:51 +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 uint Baid { get; set; }
public ulong Baid { get; set; }
public uint SongId { get; set; }

View File

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

View File

@ -3,6 +3,8 @@
public partial class Card
{
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 uint Baid { get; set; }
public ulong Baid { get; set; }
public uint DanId { get; set; }
public uint ArrivalSongCount { get; set; }
public uint SoulGaugeTotal { get; set; }

View File

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

View File

@ -2,16 +2,16 @@
namespace GameDatabase.Entities
{
public partial class SongBestDatum
{
public uint Baid { get; set; }
public uint SongId { get; set; }
public Difficulty Difficulty { get; set; }
public uint BestScore { get; set; }
public uint BestRate { get; set; }
public CrownType BestCrown { get; set; }
public ScoreRank BestScoreRank { get; set; }
public partial class SongBestDatum
{
public ulong Baid { get; set; }
public uint SongId { get; set; }
public Difficulty Difficulty { get; set; }
public uint BestScore { get; set; }
public uint BestRate { get; set; }
public CrownType BestCrown { get; set; }
public ScoreRank BestScoreRank { get; set; }
public virtual Card? Ba { get; set; }
}
public virtual Card? Ba { get; set; }
}
}

View File

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

View File

@ -2,33 +2,37 @@
namespace GameDatabase.Entities
{
public partial class UserDatum
{
public uint Baid { get; set; }
public string MyDonName { get; set; } = string.Empty;
public string Title { get; set; } = string.Empty;
public uint TitlePlateId { get; set; }
public string FavoriteSongsArray { get; set; } = "[]";
public string ToneFlgArray { get; set; } = "[]";
public string TitleFlgArray { get; set; } = "[]";
public string CostumeFlgArray { get; set; } = "[[],[],[],[],[]]";
public string GenericInfoFlgArray { get; set; } = "[]";
public short OptionSetting { get; set; }
public int NotesPosition { get; set; }
public bool IsVoiceOn { get; set; }
public bool IsSkipOn { get; set; }
public uint SelectedToneId { get; set; }
public DateTime LastPlayDatetime { get; set; }
public uint LastPlayMode { get; set; }
public uint ColorBody { get; set; }
public uint ColorFace { get; set; }
public uint ColorLimb { get; set; }
public string CostumeData { get; set; } = "[[],[],[],[],[]]";
public bool DisplayDan { get; set; }
public bool DisplayAchievement { get; set; }
public Difficulty AchievementDisplayDifficulty { get; set; }
public int AiWinCount { get; set; }
public virtual Card? Ba { get; set; }
}
public partial class UserDatum
{
public ulong Baid { get; set; }
public string MyDonName { get; set; } = string.Empty;
public uint MyDonNameLanguage { get; set; }
public string Title { get; set; } = string.Empty;
public uint TitlePlateId { get; set; }
public string FavoriteSongsArray { get; set; } = "[]";
public string ToneFlgArray { get; set; } = "[]";
public string TitleFlgArray { get; set; } = "[]";
public string CostumeFlgArray { get; set; } = "[[],[],[],[],[]]";
public string GenericInfoFlgArray { get; set; } = "[]";
public short OptionSetting { get; set; }
public int NotesPosition { get; set; }
public bool IsVoiceOn { get; set; }
public bool IsSkipOn { get; set; }
public string DifficultyPlayedArray { get; set; } = "[]";
public string DifficultySettingArray { get; set; } = "[]";
public uint SelectedToneId { get; set; }
public DateTime LastPlayDatetime { get; set; }
public uint LastPlayMode { get; set; }
public uint ColorBody { get; set; }
public uint ColorFace { get; set; }
public uint ColorLimb { get; set; }
public string CostumeData { get; set; } = "[]";
public bool DisplayDan { get; set; }
public bool DisplayAchievement { get; set; }
public Difficulty AchievementDisplayDifficulty { get; set; }
public int AiWinCount { get; set; }
public string TokenCountDict { get; set; } = "{}";
public string UnlockedSongIdList { get; set; } = "[]";
public virtual Card? Ba { get; set; }
}
}

View File

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

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)
{
#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");
b.Property<uint>("SongId")
@ -36,9 +36,9 @@ namespace TaikoLocalServer.Migrations
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");
b.Property<uint>("SongId")
@ -76,14 +76,22 @@ namespace TaikoLocalServer.Migrations
b.ToTable("AiSectionScoreData");
});
modelBuilder.Entity("TaikoLocalServer.Entities.Card", b =>
modelBuilder.Entity("GameDatabase.Entities.Card", b =>
{
b.Property<string>("AccessCode")
.HasColumnType("TEXT");
b.Property<uint>("Baid")
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")
@ -92,9 +100,9 @@ namespace TaikoLocalServer.Migrations
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");
b.Property<uint>("DanId")
@ -119,9 +127,9 @@ namespace TaikoLocalServer.Migrations
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");
b.Property<uint>("DanId")
@ -159,9 +167,9 @@ namespace TaikoLocalServer.Migrations
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");
b.Property<uint>("SongId")
@ -187,13 +195,13 @@ namespace TaikoLocalServer.Migrations
b.ToTable("SongBestData");
});
modelBuilder.Entity("TaikoLocalServer.Entities.SongPlayDatum", b =>
modelBuilder.Entity("GameDatabase.Entities.SongPlayDatum", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<uint>("Baid")
b.Property<ulong>("Baid")
.HasColumnType("INTEGER");
b.Property<uint>("ComboCount")
@ -248,9 +256,9 @@ namespace TaikoLocalServer.Migrations
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");
b.Property<uint>("AchievementDisplayDifficulty")
@ -276,6 +284,14 @@ namespace TaikoLocalServer.Migrations
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("DifficultyPlayedArray")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("DifficultySettingArray")
.IsRequired()
.HasColumnType("TEXT");
b.Property<bool>("DisplayAchievement")
.HasColumnType("INTEGER");
@ -306,6 +322,9 @@ namespace TaikoLocalServer.Migrations
.IsRequired()
.HasColumnType("TEXT");
b.Property<uint>("MyDonNameLanguage")
.HasColumnType("INTEGER");
b.Property<int>("NotesPosition")
.HasColumnType("INTEGER");
@ -326,18 +345,26 @@ namespace TaikoLocalServer.Migrations
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("TaikoLocalServer.Entities.AiScoreDatum", b =>
modelBuilder.Entity("GameDatabase.Entities.AiScoreDatum", b =>
{
b.HasOne("TaikoLocalServer.Entities.Card", "Ba")
b.HasOne("GameDatabase.Entities.Card", "Ba")
.WithMany()
.HasForeignKey("Baid")
.HasPrincipalKey("Baid")
@ -347,9 +374,9 @@ namespace TaikoLocalServer.Migrations
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")
.HasForeignKey("Baid", "SongId", "Difficulty")
.OnDelete(DeleteBehavior.Cascade)
@ -358,9 +385,9 @@ namespace TaikoLocalServer.Migrations
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()
.HasForeignKey("Baid")
.HasPrincipalKey("Baid")
@ -370,9 +397,9 @@ namespace TaikoLocalServer.Migrations
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")
.HasForeignKey("Baid", "DanId")
.OnDelete(DeleteBehavior.Cascade)
@ -381,9 +408,9 @@ namespace TaikoLocalServer.Migrations
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()
.HasForeignKey("Baid")
.HasPrincipalKey("Baid")
@ -393,9 +420,9 @@ namespace TaikoLocalServer.Migrations
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()
.HasForeignKey("Baid")
.HasPrincipalKey("Baid")
@ -405,9 +432,9 @@ namespace TaikoLocalServer.Migrations
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()
.HasForeignKey("Baid")
.HasPrincipalKey("Baid")
@ -417,12 +444,12 @@ namespace TaikoLocalServer.Migrations
b.Navigation("Ba");
});
modelBuilder.Entity("TaikoLocalServer.Entities.AiScoreDatum", b =>
modelBuilder.Entity("GameDatabase.Entities.AiScoreDatum", b =>
{
b.Navigation("AiSectionScoreData");
});
modelBuilder.Entity("TaikoLocalServer.Entities.DanScoreDatum", b =>
modelBuilder.Entity("GameDatabase.Entities.DanScoreDatum", b =>
{
b.Navigation("DanStageScoreData");
});

View File

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

View File

@ -1,61 +1,61 @@
using System.CommandLine;
using System.CommandLine.Parsing;
using System.Text;
using System.Text.Json;
using GameDatabase.Context;
using GameDatabase.Context;
using GameDatabase.Entities;
using ICSharpCode.SharpZipLib.GZip;
using JorgeSerrano.Json;
using LocalSaveModScoreMigrator;
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.");
FileInfo? Parse(SymbolResult result, string defaultFileName)
{
if (result.Tokens.Count == 0)
{
return new FileInfo(defaultFileName);
}
if (result.Tokens.Count == 0)
{
return new FileInfo(defaultFileName);
}
var filePath = result.Tokens.Single().Value;
if (File.Exists(filePath))
{
return new FileInfo(filePath);
}
var filePath = result.Tokens.Single().Value;
if (File.Exists(filePath))
{
return new FileInfo(filePath);
}
result.ErrorMessage = $"File {filePath} does not exist";
return null;
result.ErrorMessage = $"File {filePath} does not exist";
return null;
}
var saveFileArgument = new Option<FileInfo?>(
name: "--save-file-path",
description: "Path to the save file from local save mod",
isDefault: true,
parseArgument: result => Parse(result, "record_enso_p1.json")
name: "--save-file-path",
description: "Path to the save file from local save mod",
isDefault: true,
parseArgument: result => Parse(result, "record_enso_p1.json")
);
saveFileArgument.AddAlias("-s");
var dbFileArgument = new Option<FileInfo?>(
name: "--db-file-path",
description: "Path to the database file for local server",
isDefault: true,
parseArgument: result => Parse(result, "wwwroot/taiko.db3")
name: "--db-file-path",
description: "Path to the database file for local server",
isDefault: true,
parseArgument: result => Parse(result, "wwwroot/taiko.db3")
);
dbFileArgument.AddAlias("-db");
var musicInfoArgument = new Option<FileInfo?>(
name: "--musicinfo-file-path",
description: "Path to the music info json/bin file",
isDefault: true,
parseArgument: result => Parse(result, "wwwroot/data/musicinfo.json")
name: "--musicinfo-file-path",
description: "Path to the music info json/bin file",
isDefault: true,
parseArgument: result => Parse(result, "wwwroot/data/musicinfo.json")
);
musicInfoArgument.AddAlias("-m");
var baidArgument = new Option<int>(
name: "--baid",
description: "Target card's baid, data will be imported to that card",
getDefaultValue: () => 1
var baidArgument = new Option<ulong>(
name: "--baid",
description: "Target card's baid, data will be imported to that card",
getDefaultValue: () => 1
);
baidArgument.AddAlias("-b");
@ -64,133 +64,133 @@ rootCommand.Add(dbFileArgument);
rootCommand.Add(musicInfoArgument);
rootCommand.Add(baidArgument);
rootCommand.SetHandler((saveFile, dbFile, musicInfoFile, baid) => Run(saveFile!, dbFile!, musicInfoFile!, baid),
saveFileArgument, dbFileArgument, musicInfoArgument, baidArgument);
rootCommand.SetHandler((saveFile, dbFile, musicInfoFile, baid) => Run(saveFile!, dbFile!, musicInfoFile!, baid),
saveFileArgument, dbFileArgument, musicInfoArgument, baidArgument);
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);
var card = db.Cards.FirstOrDefault(card1 => card1.Baid == baid);
if (card is null)
{
Console.ResetColor();
Console.ForegroundColor = ConsoleColor.Red;
Console.Error.WriteLine($"Card with baid {baid} does not exist!");
Console.ResetColor();
return;
}
Console.ResetColor();
Console.ForegroundColor = ConsoleColor.Cyan;
Console.WriteLine($"Baid: {card.Baid}");
Console.WriteLine($"Access code: {card.AccessCode}");
Console.ResetColor();
using var db = new TaikoDbContext(dbFile.FullName);
var card = db.Cards.FirstOrDefault(card1 => card1.Baid == baid);
if (card is null)
{
Console.ResetColor();
Console.ForegroundColor = ConsoleColor.Red;
Console.Error.WriteLine($"Card with baid {baid} does not exist!");
Console.ResetColor();
return;
}
var localSaveJson = File.ReadAllText(saveFile.FullName);
var options = new JsonSerializerOptions
{
PropertyNamingPolicy = new JsonSnakeCaseNamingPolicy()
};
options.Converters.Add(new DateTimeConverter());
options.Converters.Add(new ScoreRankConverter());
var playRecordJson = JsonSerializer.Deserialize<List<PlayRecordJson>>(localSaveJson, options);
if (playRecordJson is null)
{
throw new ApplicationException("Play record json is null");
}
Console.ResetColor();
Console.ForegroundColor = ConsoleColor.Cyan;
Console.WriteLine($"Baid: {card.Baid}");
Console.WriteLine($"Access code: {card.AccessCode}");
Console.ResetColor();
Console.WriteLine(playRecordJson.First().SongId);
var musicInfoJson = File.ReadAllText(musicInfoFile.FullName);
if (musicInfoFile.FullName.EndsWith(".bin"))
{
var compressed = File.OpenRead(musicInfoFile.FullName);
using var gZipInputStream = new GZipInputStream(compressed);
using var decompressed = new MemoryStream();
// Decompress
gZipInputStream.CopyTo(decompressed);
var localSaveJson = File.ReadAllText(saveFile.FullName);
var options = new JsonSerializerOptions
{
PropertyNamingPolicy = new JsonSnakeCaseNamingPolicy()
};
options.Converters.Add(new DateTimeConverter());
options.Converters.Add(new ScoreRankConverter());
var playRecordJson = JsonSerializer.Deserialize<List<PlayRecordJson>>(localSaveJson, options);
if (playRecordJson is null)
{
throw new ApplicationException("Play record json is null");
}
// Reset stream for reading
decompressed.Position = 0;
musicInfoJson = Encoding.UTF8.GetString(decompressed.ToArray());
}
var musicInfo = JsonSerializer.Deserialize<MusicInfo>(musicInfoJson);
Console.WriteLine(playRecordJson.First().SongId);
if (musicInfo is null)
{
throw new ApplicationException("Music info is null");
}
var musicInfoJson = File.ReadAllText(musicInfoFile.FullName);
if (musicInfoFile.FullName.EndsWith(".bin"))
{
var compressed = File.OpenRead(musicInfoFile.FullName);
using var gZipInputStream = new GZipInputStream(compressed);
using var decompressed = new MemoryStream();
var user = db.UserData.First();
var musicInfoMap = musicInfo.Items.DistinctBy(entry => entry.Id)
.ToDictionary(entry => entry.Id, entry => entry.SongId);
foreach (var playRecord in playRecordJson)
{
var key = playRecord.SongId.Split("_")[1];
if (!musicInfoMap.ContainsKey(key))
{
Console.ResetColor();
Console.ForegroundColor = ConsoleColor.Yellow;
Console.WriteLine($"Key {key} does not exist!!!");
Console.ResetColor();
continue;
}
var songId = musicInfoMap[key];
Console.ResetColor();
Console.ForegroundColor = ConsoleColor.Cyan;
Console.WriteLine($"Importing song with id: {songId}");
Console.WriteLine($"Song play time: {playRecord.DateTime}");
Console.ResetColor();
var playLog = new SongPlayDatum
{
Baid = user.Baid,
Difficulty = playRecord.Difficulty,
Crown = playRecord.Crown,
Score = playRecord.Score,
ScoreRank = playRecord.Scorerank,
ComboCount = playRecord.Combo,
DrumrollCount = playRecord.Drumroll,
PlayTime = playRecord.DateTime,
GoodCount = playRecord.Good,
MissCount = playRecord.Bad,
OkCount = playRecord.Ok,
Skipped = false,
SongNumber = 0,
SongId = songId
};
db.SongPlayData.Add(playLog);
// Decompress
gZipInputStream.CopyTo(decompressed);
// Reset stream for reading
decompressed.Position = 0;
musicInfoJson = Encoding.UTF8.GetString(decompressed.ToArray());
}
var musicInfo = JsonSerializer.Deserialize<MusicInfo>(musicInfoJson);
if (musicInfo is null)
{
throw new ApplicationException("Music info is null");
}
var user = db.UserData.First();
var musicInfoMap = musicInfo.Items.DistinctBy(entry => entry.Id)
.ToDictionary(entry => entry.Id, entry => entry.SongId);
foreach (var playRecord in playRecordJson)
{
var key = playRecord.SongId.Split("_")[1];
if (!musicInfoMap.ContainsKey(key))
{
Console.ResetColor();
Console.ForegroundColor = ConsoleColor.Yellow;
Console.WriteLine($"Key {key} does not exist!!!");
Console.ResetColor();
continue;
}
var songId = musicInfoMap[key];
Console.ResetColor();
Console.ForegroundColor = ConsoleColor.Cyan;
Console.WriteLine($"Importing song with id: {songId}");
Console.WriteLine($"Song play time: {playRecord.DateTime}");
Console.ResetColor();
var playLog = new SongPlayDatum
{
Baid = user.Baid,
Difficulty = playRecord.Difficulty,
Crown = playRecord.Crown,
Score = playRecord.Score,
ScoreRank = playRecord.Scorerank,
ComboCount = playRecord.Combo,
DrumrollCount = playRecord.Drumroll,
PlayTime = playRecord.DateTime,
GoodCount = playRecord.Good,
MissCount = playRecord.Bad,
OkCount = playRecord.Ok,
Skipped = false,
SongNumber = 0,
SongId = songId
};
db.SongPlayData.Add(playLog);
var best = new SongBestDatum
{
Baid = user.Baid,
Difficulty = playRecord.Difficulty,
BestCrown = playRecord.Crown,
BestScore = playRecord.Score,
BestScoreRank = playRecord.Scorerank,
SongId = songId
};
var best = new SongBestDatum
{
Baid = user.Baid,
Difficulty = playRecord.Difficulty,
BestCrown = playRecord.Crown,
BestScore = playRecord.Score,
BestScoreRank = playRecord.Scorerank,
SongId = songId
};
var existing = db.SongBestData.FirstOrDefault(datum => datum.Baid == user.Baid &&
datum.Difficulty == playLog.Difficulty &&
datum.SongId == songId);
var existing = db.SongBestData.FirstOrDefault(datum => datum.Baid == user.Baid &&
datum.Difficulty == playLog.Difficulty &&
datum.SongId == songId);
if (existing is null)
{
db.SongBestData.Add(best);
}
else
{
existing.BestCrown = (CrownType)Math.Max((int)existing.BestCrown, (int)playRecord.Crown);
existing.BestScoreRank = (ScoreRank)Math.Max((int)existing.BestScoreRank, (int)playRecord.Scorerank);
existing.BestScore = Math.Max(existing.BestScore, playRecord.Score);
db.SongBestData.Update(existing);
}
}
if (existing is null)
{
db.SongBestData.Add(best);
}
else
{
existing.BestCrown = (CrownType)Math.Max((int)existing.BestCrown, (int)playRecord.Crown);
existing.BestScoreRank = (ScoreRank)Math.Max((int)existing.BestScoreRank, (int)playRecord.Scorerank);
existing.BestScore = Math.Max(existing.BestScore, playRecord.Score);
db.SongBestData.Update(existing);
}
}
db.SaveChanges();
db.SaveChanges();
}

View File

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

View File

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

View File

@ -4,15 +4,18 @@ namespace SharedProject.Models;
public class EventFolderData
{
[JsonPropertyName("folderId")]
public uint FolderId { get; set; }
[JsonPropertyName("folderId")]
public uint FolderId { get; set; }
[JsonPropertyName("verupNo")]
public uint VerupNo { get; set; }
[JsonPropertyName("verupNo")]
public uint VerupNo { get; set; }
[JsonPropertyName("priority")]
public uint Priority { get; set; }
[JsonPropertyName("priority")]
public uint Priority { get; set; }
[JsonPropertyName("songNo")]
public uint[]? SongNo { get; set; }
[JsonPropertyName("songNo")]
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 uint Baid { get; set; }
public ulong Baid { get; set; }
public uint SongId { 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

@ -3,6 +3,10 @@
public class User
{
public string AccessCode { get; set; } = string.Empty;
public uint Baid { get; set; }
public string Password { get; set; } = string.Empty;
public string Salt { get; set; } = string.Empty;
}

View File

@ -7,49 +7,57 @@ public class UserSetting
public uint ToneId { get; set; }
public bool IsDisplayAchievement { 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 IsSkipOn { get; set; }
public Difficulty AchievementDisplayDifficulty { get; set; }
public PlaySetting PlaySetting { get; set; } = new();
public int NotesPosition { get; set; }
public string MyDonName { get; set; } = string.Empty;
public uint MyDonNameLanguage { get; set; }
public string Title { get; set; } = string.Empty;
public uint TitlePlateId { get; set; }
public uint Kigurumi { get; set; }
public uint Head { get; set; }
public uint Body { get; set; }
public uint Face { get; set; }
public uint Puchi { get; set; }
public List<uint> UnlockedKigurumi { get; set; } = new();
public List<uint> UnlockedHead { get; set; } = new();
public List<uint> UnlockedBody { get; set; } = new();
public List<uint> UnlockedFace { get; set; } = new();
public List<uint> UnlockedPuchi { get; set; } = new();
public uint FaceColor { get; set; }
public uint BodyColor { get; set; }
public uint LimbColor { get; set; }
}

View File

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

@ -2,44 +2,18 @@
public static class Constants
{
public const string DATE_TIME_FORMAT = "yyyyMMddHHmmss";
public const string DATE_TIME_FORMAT = "yyyyMMddHHmmss";
public const int MUSIC_ID_MAX = 1599;
public const int MUSIC_ID_MAX = 1599;
public const int MUSIC_ID_MAX_EXPANDED = 9000;
public const int MUSIC_ID_MAX_EXPANDED = 9000;
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_ATTRIBUTE_COMPRESSED_FILE_NAME = "music_attribute.bin";
public const string DAN_DATA_FILE_NAME = "dan_data.json";
public const string INTRO_DATA_FILE_NAME = "intro_data.json";
public const string EVENT_FOLDER_DATA_FILE_NAME = "event_folder_data.json";
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
};
public const string MUSIC_INFO_BASE_NAME = "musicinfo";
public const string WORDLIST_BASE_NAME = "wordlist";
public const string MUSIC_ORDER_BASE_NAME = "music_order";
public const string DON_COS_REWARD_BASE_NAME = "don_cos_reward";
public const string SHOUGOU_BASE_NAME = "shougou";
public const string NEIRO_BASE_NAME = "neiro";
}

View File

@ -1,4 +1,5 @@
using System.Collections;
using System.Collections.Immutable;
using System.Collections.Specialized;
using System.Runtime.InteropServices;
using GameDatabase.Entities;
@ -70,7 +71,7 @@ public static class FlagCalculator
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 gotDanFlag = new BitVector32();
@ -84,10 +85,9 @@ public static class FlagCalculator
var section8 = BitVector32.CreateSection(8, section7);
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;
if (danScoreData.Any(datum => datum.DanId == danId))
{
@ -126,4 +126,22 @@ public static class FlagCalculator
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;
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)
{
var costumeData = new List<uint> { 0, 0, 0, 0, 0 };
try
{
// logger.LogInformation(userData.CostumeData);
costumeData = JsonSerializer.Deserialize<List<uint>>(userData.CostumeData);
}
catch (JsonException e)
@ -21,13 +45,13 @@ public static class JsonHelper
{
return costumeData;
}
logger.LogWarning("Costume data is null or count less than 5!");
costumeData = new List<uint> { 0, 0, 0, 0, 0 };
return costumeData;
}
public static List<List<uint>> GetCostumeUnlockDataFromUserData(UserDatum userData, ILogger logger)
{
var costumeUnlockData = new List<List<uint>> { new(), new(), new(), new(), new() };
@ -44,7 +68,7 @@ public static class JsonHelper
{
return costumeUnlockData;
}
logger.LogWarning("Costume unlock data is null or count less than 5!");
costumeUnlockData = new List<List<uint>> { new(), new(), new(), new(), new() };

View File

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

View File

@ -2,6 +2,6 @@
"ServerSettings": {
"MuchaUrl": "https://v402-front.mucha-prd.nbgi-amnet.jp:10122",
"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]
[Route("api/[controller]")]
@ -19,4 +21,13 @@ public class CardsController : BaseController<CardsController>
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}")]
public async Task<IActionResult> GetDanBestData(uint baid)
public async Task<IActionResult> GetDanBestData(ulong baid)
{
var danScores = await danScoreDatumService.GetDanScoreDatumByBaid(baid);
var danDataList = new List<DanBestData>();

View File

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

View File

@ -1,6 +1,6 @@
using System.Text.Json;
using SharedProject.Models;
using SharedProject.Models;
using SharedProject.Utils;
using System.Text.Json;
namespace TaikoLocalServer.Controllers.Api;
@ -16,7 +16,7 @@ public class UserSettingsController : BaseController<UserSettingsController>
}
[HttpGet]
public async Task<ActionResult<UserSetting>> GetUserSetting(uint baid)
public async Task<ActionResult<UserSetting>> GetUserSetting(ulong baid)
{
var user = await userDatumService.GetFirstUserDatumOrNull(baid);
@ -25,6 +25,8 @@ public class UserSettingsController : BaseController<UserSettingsController>
return NotFound();
}
var difficultySettingArray = JsonHelper.GetUIntArrayFromJson(user.DifficultySettingArray, 3, Logger, nameof(user.DifficultySettingArray));
var costumeData = JsonHelper.GetCostumeDataFromUserData(user, Logger);
var costumeUnlockData = JsonHelper.GetCostumeUnlockDataFromUserData(user, Logger);
@ -34,12 +36,16 @@ public class UserSettingsController : BaseController<UserSettingsController>
AchievementDisplayDifficulty = user.AchievementDisplayDifficulty,
IsDisplayAchievement = user.DisplayAchievement,
IsDisplayDanOnNamePlate = user.DisplayDan,
DifficultySettingCourse = difficultySettingArray[0],
DifficultySettingStar = difficultySettingArray[1],
DifficultySettingSort = difficultySettingArray[2],
IsVoiceOn = user.IsVoiceOn,
IsSkipOn = user.IsSkipOn,
NotesPosition = user.NotesPosition,
PlaySetting = PlaySettingConverter.ShortToPlaySetting(user.OptionSetting),
ToneId = user.SelectedToneId,
MyDonName = user.MyDonName,
MyDonNameLanguage = user.MyDonNameLanguage,
Title = user.Title,
TitlePlateId = user.TitlePlateId,
Kigurumi = costumeData[0],
@ -48,9 +54,9 @@ public class UserSettingsController : BaseController<UserSettingsController>
Face = costumeData[3],
Puchi = costumeData[4],
UnlockedKigurumi = costumeUnlockData[0],
UnlockedHead = costumeUnlockData[1],
UnlockedBody = costumeUnlockData[2],
UnlockedFace = costumeUnlockData[3],
UnlockedHead = costumeUnlockData[1],
UnlockedBody = costumeUnlockData[2],
UnlockedFace = costumeUnlockData[3],
UnlockedPuchi = costumeUnlockData[4],
BodyColor = user.ColorBody,
FaceColor = user.ColorFace,
@ -60,7 +66,7 @@ public class UserSettingsController : BaseController<UserSettingsController>
}
[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);
@ -77,23 +83,31 @@ public class UserSettingsController : BaseController<UserSettingsController>
userSetting.Face,
userSetting.Puchi,
};
var difficultySettings = new List<uint>
{
userSetting.DifficultySettingCourse,
userSetting.DifficultySettingStar,
userSetting.DifficultySettingSort
};
user.IsSkipOn = userSetting.IsSkipOn;
user.IsVoiceOn = userSetting.IsVoiceOn;
user.DisplayAchievement = userSetting.IsDisplayAchievement;
user.DisplayDan = userSetting.IsDisplayDanOnNamePlate;
user.DifficultySettingArray = JsonSerializer.Serialize(difficultySettings);
user.NotesPosition = userSetting.NotesPosition;
user.SelectedToneId = userSetting.ToneId;
user.AchievementDisplayDifficulty = userSetting.AchievementDisplayDifficulty;
user.OptionSetting = PlaySettingConverter.PlaySettingToShort(userSetting.PlaySetting);
user.MyDonName = userSetting.MyDonName;
user.MyDonNameLanguage = userSetting.MyDonNameLanguage;
user.Title = userSetting.Title;
user.TitlePlateId = userSetting.TitlePlateId;
user.ColorBody = userSetting.BodyColor;
user.ColorFace = userSetting.FaceColor;
user.ColorLimb = userSetting.LimbColor;
user.CostumeData = JsonSerializer.Serialize(costumes);
await userDatumService.UpdateUserDatum(user);

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]
public class AddTokenCountController : BaseController<AddTokenCountController>
{
private readonly IUserDatumService userDatumService;
public AddTokenCountController(IUserDatumService userDatumService)
{
this.userDatumService = userDatumService;
}
[HttpPost]
[Produces("application/protobuf")]
public IActionResult AddTokenCount([FromBody] AddTokenCountRequest request)
public async Task<IActionResult> AddTokenCount([FromBody] AddTokenCountRequest request)
{
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
{
Result = 1

View File

@ -1,206 +1,200 @@
using System.Text.Json;
using GameDatabase.Entities;
using GameDatabase.Entities;
using System.Text.Json;
using Serilog;
using Throw;
namespace TaikoLocalServer.Controllers.Game;
[ApiController]
[Route("/v12r03/chassis/baidcheck.php")]
[Route("/v12r00_cn/chassis/baidcheck.php")]
public class BaidController : BaseController<BaidController>
{
private readonly IUserDatumService userDatumService;
private readonly IUserDatumService userDatumService;
private readonly ICardService cardService;
private readonly ICardService cardService;
private readonly ISongBestDatumService songBestDatumService;
private readonly ISongBestDatumService songBestDatumService;
private readonly IDanScoreDatumService danScoreDatumService;
private readonly IDanScoreDatumService danScoreDatumService;
private readonly IAiDatumService aiDatumService;
private readonly IAiDatumService aiDatumService;
private readonly IGameDataService gameDataService;
public BaidController(IUserDatumService userDatumService, ICardService cardService,
ISongBestDatumService songBestDatumService, IDanScoreDatumService danScoreDatumService, IAiDatumService aiDatumService)
{
this.userDatumService = userDatumService;
this.cardService = cardService;
this.songBestDatumService = songBestDatumService;
this.danScoreDatumService = danScoreDatumService;
this.aiDatumService = aiDatumService;
}
public BaidController(IUserDatumService userDatumService, ICardService cardService,
ISongBestDatumService songBestDatumService, IDanScoreDatumService danScoreDatumService, IAiDatumService aiDatumService,
IGameDataService gameDataService)
{
this.userDatumService = userDatumService;
this.cardService = cardService;
this.songBestDatumService = songBestDatumService;
this.danScoreDatumService = danScoreDatumService;
this.aiDatumService = aiDatumService;
this.gameDataService = gameDataService;
}
[HttpPost]
[Produces("application/protobuf")]
public async Task<IActionResult> GetBaid([FromBody] BAIDRequest request)
{
Logger.LogInformation("Baid request: {Request}", request.Stringify());
BAIDResponse response;
var card = await cardService.GetCardByAccessCode(request.AccessCode);
if (card is null)
{
Logger.LogInformation("New user with access code {AccessCode}", request.AccessCode);
var newId = cardService.GetNextBaid();
[HttpPost]
[Produces("application/protobuf")]
public async Task<IActionResult> GetBaid([FromBody] BAIDRequest request)
{
Logger.LogInformation("Baid request: {Request}", request.Stringify());
BAIDResponse response;
var card = await cardService.GetCardByAccessCode(request.WechatQrStr);
if (card is null)
{
Logger.LogInformation("New user with access code {AccessCode}", request.WechatQrStr);
var newId = cardService.GetNextBaid();
response = new BAIDResponse
{
Result = 1,
PlayerType = 1,
ComSvrResult = 1,
MbId = 1,
Baid = newId,
AccessCode = request.AccessCode,
IsPublish = true,
CardOwnNum = 1,
RegCountryId = "JPN",
PurposeId = 1,
RegionId = 1
};
response = new BAIDResponse
{
Result = 1,
PlayerType = 1,
Baid = newId,
};
return Ok(response);
}
return Ok(response);
}
var baid = card.Baid;
var baid = card.Baid;
var userData = await userDatumService.GetFirstUserDatumOrDefault(baid);
var userData = await userDatumService.GetFirstUserDatumOrDefault(baid);
var songBestData = await songBestDatumService.GetAllSongBestData(baid);
var achievementDisplayDifficulty = userData.AchievementDisplayDifficulty;
if (userData.AchievementDisplayDifficulty == Difficulty.None)
{
achievementDisplayDifficulty = songBestData.Any(datum => datum.BestCrown >= CrownType.Clear) ?
songBestData.Where(datum => datum.BestCrown >= CrownType.Clear).Max(datum => datum.Difficulty) :
Difficulty.Easy;
}
var songBestData = await songBestDatumService.GetAllSongBestData(baid);
var songCountData = songBestData.Where(datum => achievementDisplayDifficulty != Difficulty.UraOni ?
datum.Difficulty == achievementDisplayDifficulty :
datum.Difficulty is Difficulty.Oni or Difficulty.UraOni).ToList();
var achievementDisplayDifficulty = userData.AchievementDisplayDifficulty;
if (userData.AchievementDisplayDifficulty == Difficulty.None)
{
achievementDisplayDifficulty = songBestData.Any(datum => datum.BestCrown >= CrownType.Clear) ?
songBestData.Where(datum => datum.BestCrown >= CrownType.Clear).Max(datum => datum.Difficulty) :
Difficulty.Easy;
}
var crownCount = CalculateCrownCount(songCountData);
var songCountData = songBestData.Where(datum => achievementDisplayDifficulty != Difficulty.UraOni ?
datum.Difficulty == achievementDisplayDifficulty :
datum.Difficulty is Difficulty.Oni or Difficulty.UraOni).ToList();
var scoreRankCount = CalculateScoreRankCount(songCountData);
var crownCount = CalculateCrownCount(songCountData);
var scoreRankCount = CalculateScoreRankCount(songCountData);
var costumeData = JsonHelper.GetCostumeDataFromUserData(userData, Logger);
var costumeData = JsonHelper.GetCostumeDataFromUserData(userData, Logger);
var costumeArrays = JsonHelper.GetCostumeUnlockDataFromUserData(userData, Logger);
var costumeArrays = JsonHelper.GetCostumeUnlockDataFromUserData(userData, Logger);
var costumeFlagArrays = Constants.CostumeFlagArraySizes
.Select((size, index) => FlagCalculator.GetBitArrayFromIds(costumeArrays[index], size, Logger))
.ToList();
var costumeFlagArrays = gameDataService.GetCostumeFlagArraySizes()
.Select((size, index) => FlagCalculator.GetBitArrayFromIds(costumeArrays[index], size, Logger))
.ToList();
var danData = await danScoreDatumService.GetDanScoreDatumByBaid(baid);
var maxDan = danData.Where(datum => datum.ClearState != DanClearState.NotClear)
.Select(datum => datum.DanId)
.DefaultIfEmpty()
.Max();
var gotDanFlagArray = FlagCalculator.ComputeGotDanFlags(danData);
var danData = await danScoreDatumService.GetDanScoreDatumByBaid(baid);
var genericInfoFlg = Array.Empty<uint>();
try
{
genericInfoFlg = JsonSerializer.Deserialize<uint[]>(userData.GenericInfoFlgArray);
}
catch (JsonException e)
{
Logger.LogError(e, "Parsing genericinfo flg json data failed");
}
var maxDan = danData.Where(datum => datum.ClearState != DanClearState.NotClear)
.Select(datum => datum.DanId)
.DefaultIfEmpty()
.Max();
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);
// The only way to get a null is provide string "null" as input,
// which means database content need to be fixed, so better throw
genericInfoFlg.ThrowIfNull("Genericinfo flg should never be null!");
var genericInfoFlg = Array.Empty<uint>();
try
{
genericInfoFlg = JsonSerializer.Deserialize<uint[]>(userData.GenericInfoFlgArray);
}
catch (JsonException e)
{
Logger.LogError(e, "Parsing genericinfo flg json data failed");
}
var genericInfoFlgLength = genericInfoFlg.Any()? genericInfoFlg.Max() + 1 : 0;
var genericInfoFlgArray = FlagCalculator.GetBitArrayFromIds(genericInfoFlg, (int)genericInfoFlgLength, Logger);
// The only way to get a null is provide string "null" as input,
// which means database content need to be fixed, so better throw
genericInfoFlg.ThrowIfNull("Genericinfo flg should never be null!");
var aiRank = (uint)(userData.AiWinCount / 10);
if (aiRank > 11)
{
aiRank = 11;
}
response = new BAIDResponse
{
Result = 1,
PlayerType = 0,
ComSvrResult = 1,
MbId = 1,
Baid = baid,
AccessCode = request.AccessCode,
IsPublish = true,
CardOwnNum = 1,
RegCountryId = "JPN",
PurposeId = 1,
RegionId = 1,
MydonName = userData.MyDonName,
Title = userData.Title,
TitleplateId = userData.TitlePlateId,
ColorFace = userData.ColorFace,
ColorBody = userData.ColorBody,
ColorLimb = userData.ColorLimb,
AryCostumedata = new BAIDResponse.CostumeData
{
Costume1 = costumeData[0],
Costume2 = costumeData[1],
Costume3 = costumeData[2],
Costume4 = costumeData[3],
Costume5 = costumeData[4]
},
CostumeFlg1 = costumeFlagArrays[0],
CostumeFlg2 = costumeFlagArrays[1],
CostumeFlg3 = costumeFlagArrays[2],
CostumeFlg4 = costumeFlagArrays[3],
CostumeFlg5 = costumeFlagArrays[4],
LastPlayDatetime = userData.LastPlayDatetime.ToString(Constants.DATE_TIME_FORMAT),
IsDispDanOn = userData.DisplayDan,
GotDanMax = maxDan,
GotDanFlg = gotDanFlagArray,
GotDanextraFlg = new byte[20],
DefaultToneSetting = userData.SelectedToneId,
GenericInfoFlg = genericInfoFlgArray,
AryCrownCounts = crownCount,
AryScoreRankCounts = scoreRankCount,
IsDispAchievementOn = userData.DisplayAchievement,
DispAchievementType = (uint)achievementDisplayDifficulty,
IsDispAchievementTypeSet = true,
LastPlayMode = userData.LastPlayMode,
IsDispSouuchiOn = true,
AiRank = aiRank,
AiTotalWin = (uint)userData.AiWinCount,
Accesstoken = "123456",
ContentInfo = GZipBytesUtil.GetGZipBytes(new byte[10])
};
var genericInfoFlgLength = genericInfoFlg.Any() ? genericInfoFlg.Max() + 1 : 0;
var genericInfoFlgArray = FlagCalculator.GetBitArrayFromIds(genericInfoFlg, (int)genericInfoFlgLength, Logger);
return Ok(response);
}
var aiRank = (uint)(userData.AiWinCount / 10);
if (aiRank > 11)
{
aiRank = 11;
}
response = new BAIDResponse
{
Result = 1,
PlayerType = 0,
Baid = baid,
MydonName = userData.MyDonName,
MydonNameLanguage = userData.MyDonNameLanguage,
Title = userData.Title,
TitleplateId = userData.TitlePlateId,
ColorFace = userData.ColorFace,
ColorBody = userData.ColorBody,
ColorLimb = userData.ColorLimb,
AryCostumedata = new BAIDResponse.CostumeData
{
Costume1 = costumeData[0],
Costume2 = costumeData[1],
Costume3 = costumeData[2],
Costume4 = costumeData[3],
Costume5 = costumeData[4]
},
CostumeFlg1 = costumeFlagArrays[0],
CostumeFlg2 = costumeFlagArrays[1],
CostumeFlg3 = costumeFlagArrays[2],
CostumeFlg4 = costumeFlagArrays[3],
CostumeFlg5 = costumeFlagArrays[4],
LastPlayDatetime = userData.LastPlayDatetime.ToString(Constants.DATE_TIME_FORMAT),
IsDispDanOn = userData.DisplayDan,
GotDanMax = maxDan,
GotDanFlg = gotDanFlagArray,
GotDanextraFlg = gotGaidenFlagArray,
DefaultToneSetting = userData.SelectedToneId,
GenericInfoFlg = genericInfoFlgArray,
AryCrownCounts = crownCount,
AryScoreRankCounts = scoreRankCount,
IsDispAchievementOn = userData.DisplayAchievement,
DispAchievementType = (uint)achievementDisplayDifficulty,
IsDispAchievementTypeSet = true,
LastPlayMode = userData.LastPlayMode,
IsDispSouuchiOn = true
};
private static uint[] CalculateScoreRankCount(IReadOnlyCollection<SongBestDatum> songCountData)
{
var scoreRankCount = new uint[7];
foreach (var scoreRankType in Enum.GetValues<ScoreRank>())
{
if (scoreRankType != ScoreRank.None)
{
scoreRankCount[(int)scoreRankType - 2] =
(uint)songCountData.Count(datum => datum.BestScoreRank == scoreRankType);
}
}
return Ok(response);
}
return scoreRankCount;
}
private static uint[] CalculateScoreRankCount(IReadOnlyCollection<SongBestDatum> songCountData)
{
var scoreRankCount = new uint[7];
foreach (var scoreRankType in Enum.GetValues<ScoreRank>())
{
if (scoreRankType != ScoreRank.None)
{
scoreRankCount[(int)scoreRankType - 2] =
(uint)songCountData.Count(datum => datum.BestScoreRank == scoreRankType);
}
}
private static uint[] CalculateCrownCount(IReadOnlyCollection<SongBestDatum> songCountData)
{
var crownCount = new uint[3];
foreach (var crownType in Enum.GetValues<CrownType>())
{
if (crownType != CrownType.None)
{
crownCount[(int)crownType - 1] = (uint)songCountData.Count(datum => datum.BestCrown == crownType);
}
}
return scoreRankCount;
}
return crownCount;
}
private static uint[] CalculateCrownCount(IReadOnlyCollection<SongBestDatum> songCountData)
{
var crownCount = new uint[3];
foreach (var crownType in Enum.GetValues<CrownType>())
{
if (crownType != CrownType.None)
{
crownCount[(int)crownType - 1] = (uint)songCountData.Count(datum => datum.BestCrown == crownType);
}
}
return crownCount;
}
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,6 +1,6 @@
namespace TaikoLocalServer.Controllers.Game;
[Route("/v12r03/chassis/getdanodai.php")]
[Route("/v12r00_cn/chassis/getdanodai.php")]
[ApiController]
public class GetDanOdaiController : BaseController<GetDanOdaiController>
{
@ -16,29 +16,41 @@ public class GetDanOdaiController : BaseController<GetDanOdaiController>
public IActionResult GetDanOdai([FromBody] GetDanOdaiRequest request)
{
Logger.LogInformation("GetDanOdai request : {Request}", request.Stringify());
var response = new GetDanOdaiResponse
{
Result = 1
};
if (request.Type == 2)
if (request.Type == 1)
{
return Ok(response);
foreach (var danId in request.DanIds)
{
gameDataService.GetDanDataDictionary().TryGetValue(danId, out var odaiData);
if (odaiData is null)
{
Logger.LogWarning("Requested dan id {Id} does not exist!", danId);
continue;
}
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);
}
}
foreach (var danId in request.DanIds)
{
gameDataService.GetDanDataDictionary().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);
}
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,26 +1,102 @@
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]
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]
[Produces("application/protobuf")]
public IActionResult GetTokenCount([FromBody] GetTokenCountRequest request)
public async Task<IActionResult> GetTokenCount([FromBody] GetTokenCountRequest request)
{
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
{
Result = 1
};
response.AryTokenCountDatas.Add(new GetTokenCountResponse.TokenCountData
if (tokenCountDict.Count == 0) tokenCountDict.Add(1, 0);
if (shopTokenId > 0)
{
TokenCount = 10,
TokenId = 1
});
var castedShopTokenId = (uint)shopTokenId;
tokenCountDict.TryAdd(castedShopTokenId, 0);
response.AryTokenCountDatas.Add(new GetTokenCountResponse.TokenCountData
{
TokenCount = tokenCountDict[castedShopTokenId],
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);
}
}

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,21 +1,20 @@
namespace TaikoLocalServer.Controllers.Game;
[ApiController]
[Route("/v12r03/chassis/heartbeat.php")]
[Route("/v12r00_cn/chassis/heartbeat.php")]
public class HeartbeatController : BaseController<HeartbeatController>
{
[HttpPost]
[Produces("application/protobuf")]
public IActionResult HeartBeat([FromBody] HeartBeatRequest request)
{
Logger.LogInformation("Heartbeat request: {Request}", request.Stringify());
var response = new HeartBeatResponse
{
Result = 1,
ComSvrStat = 1,
GameSvrStat = 1
};
[HttpPost]
[Produces("application/protobuf")]
public IActionResult HeartBeat([FromBody] HeartBeatRequest request)
{
Logger.LogInformation("Heartbeat request: {Request}", request.Stringify());
var response = new HeartBeatResponse
{
Result = 1,
GameSvrStat = 1
};
return Ok(response);
}
return Ok(response);
}
}

View File

@ -4,114 +4,138 @@ using TaikoLocalServer.Settings;
namespace TaikoLocalServer.Controllers.Game;
[ApiController]
[Route("/v12r03/chassis/initialdatacheck.php")]
[Route("/v12r00_cn/chassis/initialdatacheck.php")]
public class InitialDataCheckController : BaseController<InitialDataCheckController>
{
private readonly IGameDataService gameDataService;
private readonly IGameDataService gameDataService;
private readonly ServerSettings settings;
private readonly ServerSettings settings;
public InitialDataCheckController(IGameDataService gameDataService, IOptions<ServerSettings> settings)
{
this.gameDataService = gameDataService;
this.settings = settings.Value;
}
public InitialDataCheckController(IGameDataService gameDataService, IOptions<ServerSettings> settings)
{
this.gameDataService = gameDataService;
this.settings = settings.Value;
}
[HttpPost]
[Produces("application/protobuf")]
public IActionResult InitialDataCheck([FromBody] InitialdatacheckRequest request)
{
Logger.LogInformation("Initial data check request: {Request}", request.Stringify());
[HttpPost]
[Produces("application/protobuf")]
public IActionResult InitialDataCheck([FromBody] InitialdatacheckRequest request)
{
Logger.LogInformation("Initial data check request: {Request}", request.Stringify());
var songIdMax = settings.EnableMoreSongs ? Constants.MUSIC_ID_MAX_EXPANDED : Constants.MUSIC_ID_MAX;
var enabledArray =
FlagCalculator.GetBitArrayFromIds(gameDataService.GetMusicList(), songIdMax, Logger);
var songIdMax = settings.EnableMoreSongs ? Constants.MUSIC_ID_MAX_EXPANDED : Constants.MUSIC_ID_MAX;
var danData = new List<InitialdatacheckResponse.InformationData>();
for (var danId = Constants.MIN_DAN_ID; danId <= Constants.MAX_DAN_ID; danId++)
{
danData.Add(new InitialdatacheckResponse.InformationData
{
InfoId = (uint)danId,
VerupNo = 1
});
}
var introData = new List<InitialdatacheckResponse.InformationData>();
for (var setId = 1; setId <= gameDataService.GetSongIntroDictionary().Count; setId++)
{
introData.Add(new InitialdatacheckResponse.InformationData
{
InfoId = (uint)setId,
VerupNo = 1
});
}
var musicList = gameDataService.GetMusicList();
var lockedSongsList = gameDataService.GetLockedSongsList();
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 enabledArray =
FlagCalculator.GetBitArrayFromIds(musicList, songIdMax, Logger);
var response = new InitialdatacheckResponse
{
Result = 1,
IsDanplay = true,
IsAibattle = true,
IsClose = false,
DefaultSongFlg = enabledArray,
AchievementSongBit = enabledArray,
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);
response.ArySongIntroductionDatas.AddRange(introData);
response.AryEventfolderDatas.AddRange(eventFolderData);
return Ok(response);
}
var defaultSongList = musicList.Except(lockedSongsList);
var defaultSongFlg =
FlagCalculator.GetBitArrayFromIds(defaultSongList, songIdMax, Logger);
var defaultSongWithUraList = gameDataService.GetMusicWithUraList();
var uraReleaseBit =
FlagCalculator.GetBitArrayFromIds(defaultSongWithUraList, songIdMax, Logger);
var response = new InitialdatacheckResponse
{
Result = 1,
DefaultSongFlg = defaultSongFlg,
AchievementSongBit = enabledArray,
UraReleaseBit = uraReleaseBit,
SongIntroductionEndDatetime = DateTime.Now.AddYears(10).ToString(Constants.DATE_TIME_FORMAT),
};
var movieDataDictionary = gameDataService.GetMovieDataDictionary();
foreach (var movieData in movieDataDictionary) response.AryMovieInfoes.Add(movieData.Value);
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);
}
}

View File

@ -2,68 +2,65 @@
namespace TaikoLocalServer.Controllers.Game;
[Route("/v12r03/chassis/mydonentry.php")]
[Route("/v12r00_cn/chassis/mydonentry.php")]
[ApiController]
public class MyDonEntryController : BaseController<MyDonEntryController>
{
private readonly IUserDatumService userDatumService;
private readonly IUserDatumService userDatumService;
private readonly ICardService cardService;
public MyDonEntryController(IUserDatumService userDatumService, ICardService cardService)
{
this.userDatumService = userDatumService;
this.cardService = cardService;
}
private readonly ICardService cardService;
[HttpPost]
[Produces("application/protobuf")]
public async Task<IActionResult> GetMyDonEntry([FromBody] MydonEntryRequest request)
{
Logger.LogInformation("MyDonEntry request : {Request}", request.Stringify());
public MyDonEntryController(IUserDatumService userDatumService, ICardService cardService)
{
this.userDatumService = userDatumService;
this.cardService = cardService;
}
var newId = cardService.GetNextBaid();
await cardService.AddCard(new Card
{
AccessCode = request.AccessCode,
Baid = newId
});
[HttpPost]
[Produces("application/protobuf")]
public async Task<IActionResult> GetMyDonEntry([FromBody] MydonEntryRequest request)
{
Logger.LogInformation("MyDonEntry request : {Request}", request.Stringify());
var newUser = new UserDatum
{
Baid = newId,
MyDonName = request.MydonName,
DisplayDan = true,
DisplayAchievement = true,
AchievementDisplayDifficulty = Difficulty.None,
ColorFace = 0,
ColorBody = 1,
ColorLimb = 3,
FavoriteSongsArray = "[]",
ToneFlgArray = "[]",
TitleFlgArray = "[]",
CostumeFlgArray = "[[],[],[],[],[]]",
GenericInfoFlgArray = "[]"
};
var newId = cardService.GetNextBaid();
await cardService.AddCard(new Card
{
AccessCode = request.WechatQrStr,
Baid = newId,
Password = "",
Salt = ""
});
await userDatumService.InsertUserDatum(newUser);
var newUser = new UserDatum
{
Baid = newId,
MyDonName = request.MydonName,
MyDonNameLanguage = 0,
DisplayDan = true,
DisplayAchievement = true,
AchievementDisplayDifficulty = Difficulty.None,
ColorFace = 0,
ColorBody = 1,
ColorLimb = 3,
FavoriteSongsArray = "[]",
ToneFlgArray = "[0]",
TitleFlgArray = "[]",
CostumeFlgArray = "[[],[],[],[],[]]",
GenericInfoFlgArray = "[]",
TokenCountDict = "{}",
UnlockedSongIdList = "[]"
};
var response = new MydonEntryResponse
{
Result = 1,
ComSvrResult = 1,
AccessCode = request.AccessCode,
Accesstoken = "12345",
Baid = newId,
MbId = 1,
MydonName = request.MydonName,
CardOwnNum = 1,
IsPublish = true,
RegCountryId = request.CountryId,
PurposeId = 1,
RegionId = 1
};
await userDatumService.InsertUserDatum(newUser);
return Ok(response);
}
var response = new MydonEntryResponse
{
Result = 1,
Baid = newId,
MydonName = request.MydonName,
MydonNameLanguage = 0
};
return Ok(response);
}
}

View File

@ -8,7 +8,7 @@ namespace TaikoLocalServer.Controllers.Game;
using StageData = PlayResultDataRequest.StageData;
[Route("/v12r03/chassis/playresult.php")]
[Route("/v12r00_cn/chassis/playresult.php")]
[ApiController]
public class PlayResultController : BaseController<PlayResultController>
{
@ -21,15 +21,19 @@ public class PlayResultController : BaseController<PlayResultController>
private readonly IDanScoreDatumService danScoreDatumService;
private readonly IAiDatumService aiDatumService;
private readonly IGameDataService gameDataService;
public PlayResultController(IUserDatumService userDatumService, ISongPlayDatumService songPlayDatumService,
ISongBestDatumService songBestDatumService, IDanScoreDatumService danScoreDatumService, IAiDatumService aiDatumService)
ISongBestDatumService songBestDatumService, IDanScoreDatumService danScoreDatumService, IAiDatumService aiDatumService,
IGameDataService gameDataService)
{
this.userDatumService = userDatumService;
this.songPlayDatumService = songPlayDatumService;
this.songBestDatumService = songBestDatumService;
this.danScoreDatumService = danScoreDatumService;
this.aiDatumService = aiDatumService;
this.gameDataService = gameDataService;
}
[HttpPost]
@ -67,17 +71,32 @@ public class PlayResultController : BaseController<PlayResultController>
var playMode = (PlayMode)playResultData.PlayMode;
if (playMode == PlayMode.DanMode)
if (playMode is PlayMode.DanMode or PlayMode.GaidenMode)
{
await UpdateDanPlayData(request, playResultData);
return Ok(response);
}
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++)
{
var stageData = playResultData.AryStageInfoes[songNumber];
if (folder9Songs.Contains(stageData.SongNo))
{
continue;
}
if (stageData.IsSkipUse)
{
await UpdatePlayData(request, songNumber, stageData, lastPlayDatetime);
@ -203,16 +222,17 @@ public class PlayResultController : BaseController<PlayResultController>
};
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
if (playMode != PlayMode.DanMode)
{
var lastStage = playResultData.AryStageInfoes.Last();
var option = BinaryPrimitives.ReadInt16LittleEndian(lastStage.OptionFlg);
userdata.OptionSetting = option;
userdata.IsSkipOn = lastStage.IsSkipOn;
userdata.IsVoiceOn = !lastStage.IsVoiceOn;
userdata.NotesPosition = lastStage.NotesPosition;
}
// if (playMode != PlayMode.DanMode)
// {
// var lastStage = playResultData.AryStageInfoes.Last();
// var option = BinaryPrimitives.ReadInt16LittleEndian(lastStage.OptionFlg);
// userdata.OptionSetting = option;
// userdata.IsSkipOn = lastStage.IsSkipOn;
// userdata.IsVoiceOn = !lastStage.IsVoiceOn;
// userdata.NotesPosition = lastStage.NotesPosition;
// }
userdata.LastPlayDatetime = lastPlayDatetime;
userdata.LastPlayMode = playResultData.PlayMode;
@ -236,6 +256,14 @@ public class PlayResultController : BaseController<PlayResultController>
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);
await userDatumService.UpdateUserDatum(userdata);
}

View File

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

View File

@ -3,7 +3,7 @@ using Throw;
namespace TaikoLocalServer.Controllers.Game;
[Route("/v12r03/chassis/selfbest.php")]
[Route("/v12r00_cn/chassis/selfbest.php")]
[ApiController]
public class SelfBestController : BaseController<SelfBestController>
{
@ -39,7 +39,7 @@ public class SelfBestController : BaseController<SelfBestController>
.ToList();
foreach (var songNo in request.ArySongNoes)
{
if (!gameDataService.GetMusicAttributes().ContainsKey(songNo))
if (!gameDataService.GetMusicList().Contains(songNo))
{
Logger.LogWarning("Music no {No} is missing!", songNo);
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]
public class SongPurchaseController : BaseController<SongPurchaseController>
{
private readonly IUserDatumService userDatumService;
public SongPurchaseController(IUserDatumService userDatumService)
{
this.userDatumService = userDatumService;
}
[HttpPost]
[Produces("application/protobuf")]
public IActionResult SongPurchase([FromBody] SongPurchaseRequest request)
public async Task<IActionResult> SongPurchase([FromBody] SongPurchaseRequest request)
{
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
{
Result = 1,
TokenCount = (int)(10 - request.Price)
TokenCount = tokenCountDict[request.TokenId]
};
return Ok(response);

View File

@ -1,6 +1,6 @@
namespace TaikoLocalServer.Controllers.Game;
[Route("/v12r03/chassis/tournamentcheck.php")]
[Route("/v12r00_cn/chassis/tournamentcheck.php")]
[ApiController]
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 Microsoft.Extensions.Options;
using TaikoLocalServer.Settings;
using Throw;
namespace TaikoLocalServer.Controllers.Game;
[Route("/v12r03/chassis/userdata.php")]
[Route("/v12r00_cn/chassis/userdata.php")]
[ApiController]
public class UserDataController : BaseController<UserDataController>
{
@ -17,8 +17,8 @@ public class UserDataController : BaseController<UserDataController>
private readonly IGameDataService gameDataService;
private readonly ServerSettings settings;
public UserDataController(IUserDatumService userDatumService, ISongPlayDatumService songPlayDatumService,
public UserDataController(IUserDatumService userDatumService, ISongPlayDatumService songPlayDatumService,
IGameDataService gameDataService, IOptions<ServerSettings> settings)
{
this.userDatumService = userDatumService;
@ -34,13 +34,34 @@ public class UserDataController : BaseController<UserDataController>
Logger.LogInformation("UserData request : {Request}", request.Stringify());
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 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>();
try
@ -55,8 +76,16 @@ public class UserDataController : BaseController<UserDataController>
// The only way to get a null is provide string "null" as input,
// which means database content need to be fixed, so better throw
toneFlg.ThrowIfNull("Tone flg should never be null!");
// 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, Constants.TONE_UID_MAX, Logger);
var toneArray = FlagCalculator.GetBitArrayFromIds(toneFlg, gameDataService.GetToneFlagArraySize(), Logger);
var titleFlg = Array.Empty<uint>();
try
@ -72,7 +101,7 @@ public class UserDataController : BaseController<UserDataController>
// which means database content need to be fixed, so better throw
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))
.AsEnumerable()
@ -80,7 +109,7 @@ public class UserDataController : BaseController<UserDataController>
.ThenByDescending(datum => datum.SongNumber)
.Select(datum => datum.SongId)
.ToArray();
// Use custom implementation as distinctby cannot guarantee preserved element
var recentSet = new OrderedSet<uint>();
foreach (var id in recentSongs)
@ -110,7 +139,18 @@ public class UserDataController : BaseController<UserDataController>
var defaultOptions = new byte[2];
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
{
Result = 1,
@ -118,14 +158,20 @@ public class UserDataController : BaseController<UserDataController>
TitleFlg = titleArray,
ReleaseSongFlg = releaseSongArray,
UraReleaseSongFlg = uraSongArray,
DefaultOptionSetting = defaultOptions,
IsVoiceOn = userData.IsVoiceOn,
IsSkipOn = userData.IsSkipOn,
IsChallengecompe = false,
SongRecentCnt = (uint)recentSongs.Length,
AryFavoriteSongNoes = favoriteSongs,
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);

View File

@ -1,19 +1,35 @@
namespace TaikoLocalServer.Controllers.Game;
[Route("/v12r03/chassis/verifyqrcode.php")]
[Route("/v12r00_cn/chassis/verifyqrcode.php")]
[ApiController]
public class VerifyQrCodeController : BaseController<VerifyQrCodeController>
{
private readonly IGameDataService gameDataService;
public VerifyQrCodeController(IGameDataService gameDataService)
{
this.gameDataService = gameDataService;
}
[HttpPost]
[Produces("application/protobuf")]
public IActionResult VerifyQrCode([FromBody] VerifyQrcodeRequest request)
{
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
{
Result = 1,
QrcodeId = 1
QrcodeId = qrCodeId
};
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,249 +8,248 @@
#pragma warning disable CS0612, CS0618, CS1591, CS3021, IDE0079, IDE1006, RCS1036, RCS1057, RCS1085, RCS1192
namespace taiko.vsinterface
{
[global::ProtoBuf.ProtoContract()]
public partial class StartupAuthRequest : global::ProtoBuf.IExtensible
{
private global::ProtoBuf.IExtension __pbn__extensionData;
global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing)
=> global::ProtoBuf.Extensible.GetExtensionObject(ref __pbn__extensionData, createIfMissing);
[global::ProtoBuf.ProtoContract()]
public partial class StartupAuthRequest : global::ProtoBuf.IExtensible
{
private global::ProtoBuf.IExtension __pbn__extensionData;
global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing)
=> global::ProtoBuf.Extensible.GetExtensionObject(ref __pbn__extensionData, createIfMissing);
[global::ProtoBuf.ProtoMember(1, Name = @"chassis_id", IsRequired = true)]
public string ChassisId { get; set; }
[global::ProtoBuf.ProtoMember(1, Name = @"chassis_id", IsRequired = true)]
public string ChassisId { get; set; }
[global::ProtoBuf.ProtoMember(2, Name = @"usbmem_key")]
[global::System.ComponentModel.DefaultValue("")]
public string UsbmemKey
{
get => __pbn__UsbmemKey ?? "";
set => __pbn__UsbmemKey = value;
}
public bool ShouldSerializeUsbmemKey() => __pbn__UsbmemKey != null;
public void ResetUsbmemKey() => __pbn__UsbmemKey = null;
private string __pbn__UsbmemKey;
[global::ProtoBuf.ProtoMember(2, Name = @"usbmem_key")]
[global::System.ComponentModel.DefaultValue("")]
public string UsbmemKey
{
get => __pbn__UsbmemKey ?? "";
set => __pbn__UsbmemKey = value;
}
public bool ShouldSerializeUsbmemKey() => __pbn__UsbmemKey != null;
public void ResetUsbmemKey() => __pbn__UsbmemKey = null;
private string __pbn__UsbmemKey;
[global::ProtoBuf.ProtoMember(3, Name = @"hdd_ver", IsRequired = true)]
public uint HddVer { get; set; }
[global::ProtoBuf.ProtoMember(3, Name = @"hdd_ver", IsRequired = true)]
public uint HddVer { get; set; }
[global::ProtoBuf.ProtoMember(4, Name = @"usbmem_ver")]
public uint UsbmemVer
{
get => __pbn__UsbmemVer.GetValueOrDefault();
set => __pbn__UsbmemVer = value;
}
public bool ShouldSerializeUsbmemVer() => __pbn__UsbmemVer != null;
public void ResetUsbmemVer() => __pbn__UsbmemVer = null;
private uint? __pbn__UsbmemVer;
[global::ProtoBuf.ProtoMember(4, Name = @"usbmem_ver")]
public uint UsbmemVer
{
get => __pbn__UsbmemVer.GetValueOrDefault();
set => __pbn__UsbmemVer = value;
}
public bool ShouldSerializeUsbmemVer() => __pbn__UsbmemVer != null;
public void ResetUsbmemVer() => __pbn__UsbmemVer = null;
private uint? __pbn__UsbmemVer;
[global::ProtoBuf.ProtoMember(5, Name = @"shop_id", IsRequired = true)]
public string ShopId { get; set; }
[global::ProtoBuf.ProtoMember(5, Name = @"shop_id", IsRequired = true)]
public string ShopId { get; set; }
[global::ProtoBuf.ProtoMember(6, Name = @"rack_id")]
[global::System.ComponentModel.DefaultValue("")]
public string RackId
{
get => __pbn__RackId ?? "";
set => __pbn__RackId = value;
}
public bool ShouldSerializeRackId() => __pbn__RackId != null;
public void ResetRackId() => __pbn__RackId = null;
private string __pbn__RackId;
[global::ProtoBuf.ProtoMember(6, Name = @"rack_id")]
[global::System.ComponentModel.DefaultValue("")]
public string RackId
{
get => __pbn__RackId ?? "";
set => __pbn__RackId = value;
}
public bool ShouldSerializeRackId() => __pbn__RackId != null;
public void ResetRackId() => __pbn__RackId = null;
private string __pbn__RackId;
[global::ProtoBuf.ProtoMember(7, Name = @"country_id")]
[global::System.ComponentModel.DefaultValue("")]
public string CountryId
{
get => __pbn__CountryId ?? "";
set => __pbn__CountryId = value;
}
public bool ShouldSerializeCountryId() => __pbn__CountryId != null;
public void ResetCountryId() => __pbn__CountryId = null;
private string __pbn__CountryId;
[global::ProtoBuf.ProtoMember(7, Name = @"country_id")]
[global::System.ComponentModel.DefaultValue("")]
public string CountryId
{
get => __pbn__CountryId ?? "";
set => __pbn__CountryId = value;
}
public bool ShouldSerializeCountryId() => __pbn__CountryId != null;
public void ResetCountryId() => __pbn__CountryId = null;
private string __pbn__CountryId;
[global::ProtoBuf.ProtoMember(8, Name = @"ary_operation_info")]
public global::System.Collections.Generic.List<OperationData> AryOperationInfoes { get; } = new global::System.Collections.Generic.List<OperationData>();
[global::ProtoBuf.ProtoMember(8, Name = @"ary_operation_info")]
public global::System.Collections.Generic.List<OperationData> AryOperationInfoes { get; } = new global::System.Collections.Generic.List<OperationData>();
[global::ProtoBuf.ProtoContract()]
public partial class OperationData : global::ProtoBuf.IExtensible
{
private global::ProtoBuf.IExtension __pbn__extensionData;
global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing)
=> global::ProtoBuf.Extensible.GetExtensionObject(ref __pbn__extensionData, createIfMissing);
[global::ProtoBuf.ProtoContract()]
public partial class OperationData : global::ProtoBuf.IExtensible
{
private global::ProtoBuf.IExtension __pbn__extensionData;
global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing)
=> global::ProtoBuf.Extensible.GetExtensionObject(ref __pbn__extensionData, createIfMissing);
[global::ProtoBuf.ProtoMember(1, Name = @"key_data", IsRequired = true)]
public uint KeyData { get; set; }
[global::ProtoBuf.ProtoMember(1, Name = @"key_data", IsRequired = true)]
public uint KeyData { get; set; }
[global::ProtoBuf.ProtoMember(2, Name = @"value_data", IsRequired = true)]
public byte[] ValueData { get; set; }
[global::ProtoBuf.ProtoMember(2, Name = @"value_data", IsRequired = true)]
public byte[] ValueData { get; set; }
}
}
}
}
[global::ProtoBuf.ProtoContract()]
public partial class StartupAuthResponse : global::ProtoBuf.IExtensible
{
private global::ProtoBuf.IExtension __pbn__extensionData;
global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing)
=> global::ProtoBuf.Extensible.GetExtensionObject(ref __pbn__extensionData, createIfMissing);
[global::ProtoBuf.ProtoContract()]
public partial class StartupAuthResponse : global::ProtoBuf.IExtensible
{
private global::ProtoBuf.IExtension __pbn__extensionData;
global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing)
=> global::ProtoBuf.Extensible.GetExtensionObject(ref __pbn__extensionData, createIfMissing);
[global::ProtoBuf.ProtoMember(1, Name = @"result", IsRequired = true)]
public uint Result { get; set; }
[global::ProtoBuf.ProtoMember(1, Name = @"result", IsRequired = true)]
public uint Result { get; set; }
[global::ProtoBuf.ProtoMember(2, Name = @"ary_movie_info")]
public global::System.Collections.Generic.List<MovieData> AryMovieInfoes { get; } = new global::System.Collections.Generic.List<MovieData>();
[global::ProtoBuf.ProtoMember(2, Name = @"ary_movie_info")]
public global::System.Collections.Generic.List<MovieData> AryMovieInfoes { get; } = new global::System.Collections.Generic.List<MovieData>();
[global::ProtoBuf.ProtoMember(3, Name = @"ary_operation_info")]
public global::System.Collections.Generic.List<OperationData> AryOperationInfoes { get; } = new global::System.Collections.Generic.List<OperationData>();
[global::ProtoBuf.ProtoMember(3, Name = @"ary_operation_info")]
public global::System.Collections.Generic.List<OperationData> AryOperationInfoes { get; } = new global::System.Collections.Generic.List<OperationData>();
[global::ProtoBuf.ProtoContract()]
public partial class MovieData : global::ProtoBuf.IExtensible
{
private global::ProtoBuf.IExtension __pbn__extensionData;
global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing)
=> global::ProtoBuf.Extensible.GetExtensionObject(ref __pbn__extensionData, createIfMissing);
[global::ProtoBuf.ProtoContract()]
public partial class MovieData : global::ProtoBuf.IExtensible
{
private global::ProtoBuf.IExtension __pbn__extensionData;
global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing)
=> global::ProtoBuf.Extensible.GetExtensionObject(ref __pbn__extensionData, createIfMissing);
[global::ProtoBuf.ProtoMember(1, Name = @"movie_id", IsRequired = true)]
public uint MovieId { get; set; }
[global::ProtoBuf.ProtoMember(1, Name = @"movie_id", IsRequired = true)]
public uint MovieId { get; set; }
[global::ProtoBuf.ProtoMember(2, Name = @"enable_days", IsRequired = true)]
public uint EnableDays { get; set; }
[global::ProtoBuf.ProtoMember(2, Name = @"enable_days", IsRequired = true)]
public uint EnableDays { get; set; }
}
}
[global::ProtoBuf.ProtoContract()]
public partial class OperationData : global::ProtoBuf.IExtensible
{
private global::ProtoBuf.IExtension __pbn__extensionData;
global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing)
=> global::ProtoBuf.Extensible.GetExtensionObject(ref __pbn__extensionData, createIfMissing);
[global::ProtoBuf.ProtoContract()]
public partial class OperationData : global::ProtoBuf.IExtensible
{
private global::ProtoBuf.IExtension __pbn__extensionData;
global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing)
=> global::ProtoBuf.Extensible.GetExtensionObject(ref __pbn__extensionData, createIfMissing);
[global::ProtoBuf.ProtoMember(1, Name = @"key_data", IsRequired = true)]
public uint KeyData { get; set; }
[global::ProtoBuf.ProtoMember(1, Name = @"key_data", IsRequired = true)]
public uint KeyData { get; set; }
[global::ProtoBuf.ProtoMember(2, Name = @"value_data", IsRequired = true)]
public byte[] ValueData { get; set; }
[global::ProtoBuf.ProtoMember(2, Name = @"value_data", IsRequired = true)]
public byte[] ValueData { get; set; }
}
}
}
}
[global::ProtoBuf.ProtoContract()]
public partial class VerupAuthRequest : global::ProtoBuf.IExtensible
{
private global::ProtoBuf.IExtension __pbn__extensionData;
global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing)
=> global::ProtoBuf.Extensible.GetExtensionObject(ref __pbn__extensionData, createIfMissing);
[global::ProtoBuf.ProtoContract()]
public partial class VerupAuthRequest : global::ProtoBuf.IExtensible
{
private global::ProtoBuf.IExtension __pbn__extensionData;
global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing)
=> global::ProtoBuf.Extensible.GetExtensionObject(ref __pbn__extensionData, createIfMissing);
[global::ProtoBuf.ProtoMember(1, Name = @"chassis_id", IsRequired = true)]
public string ChassisId { get; set; }
[global::ProtoBuf.ProtoMember(1, Name = @"chassis_id", IsRequired = true)]
public string ChassisId { get; set; }
[global::ProtoBuf.ProtoMember(2, Name = @"usbmem_key", IsRequired = true)]
public string UsbmemKey { get; set; }
[global::ProtoBuf.ProtoMember(2, Name = @"usbmem_key", IsRequired = true)]
public string UsbmemKey { get; set; }
[global::ProtoBuf.ProtoMember(3, Name = @"hdd_ver", IsRequired = true)]
public uint HddVer { get; set; }
[global::ProtoBuf.ProtoMember(3, Name = @"hdd_ver", IsRequired = true)]
public uint HddVer { get; set; }
[global::ProtoBuf.ProtoMember(4, Name = @"usbmem_ver", IsRequired = true)]
public uint UsbmemVer { get; set; }
[global::ProtoBuf.ProtoMember(4, Name = @"usbmem_ver", IsRequired = true)]
public uint UsbmemVer { get; set; }
[global::ProtoBuf.ProtoMember(5, Name = @"shop_id", IsRequired = true)]
public string ShopId { get; set; }
[global::ProtoBuf.ProtoMember(5, Name = @"shop_id", IsRequired = true)]
public string ShopId { get; set; }
[global::ProtoBuf.ProtoMember(6, Name = @"rack_id")]
[global::System.ComponentModel.DefaultValue("")]
public string RackId
{
get => __pbn__RackId ?? "";
set => __pbn__RackId = value;
}
public bool ShouldSerializeRackId() => __pbn__RackId != null;
public void ResetRackId() => __pbn__RackId = null;
private string __pbn__RackId;
[global::ProtoBuf.ProtoMember(6, Name = @"rack_id")]
[global::System.ComponentModel.DefaultValue("")]
public string RackId
{
get => __pbn__RackId ?? "";
set => __pbn__RackId = value;
}
public bool ShouldSerializeRackId() => __pbn__RackId != null;
public void ResetRackId() => __pbn__RackId = null;
private string __pbn__RackId;
[global::ProtoBuf.ProtoMember(7, Name = @"country_id")]
[global::System.ComponentModel.DefaultValue("")]
public string CountryId
{
get => __pbn__CountryId ?? "";
set => __pbn__CountryId = value;
}
public bool ShouldSerializeCountryId() => __pbn__CountryId != null;
public void ResetCountryId() => __pbn__CountryId = null;
private string __pbn__CountryId;
[global::ProtoBuf.ProtoMember(7, Name = @"country_id")]
[global::System.ComponentModel.DefaultValue("")]
public string CountryId
{
get => __pbn__CountryId ?? "";
set => __pbn__CountryId = value;
}
public bool ShouldSerializeCountryId() => __pbn__CountryId != null;
public void ResetCountryId() => __pbn__CountryId = null;
private string __pbn__CountryId;
}
}
[global::ProtoBuf.ProtoContract()]
public partial class VerupAuthResponse : global::ProtoBuf.IExtensible
{
private global::ProtoBuf.IExtension __pbn__extensionData;
global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing)
=> global::ProtoBuf.Extensible.GetExtensionObject(ref __pbn__extensionData, createIfMissing);
[global::ProtoBuf.ProtoContract()]
public partial class VerupAuthResponse : global::ProtoBuf.IExtensible
{
private global::ProtoBuf.IExtension __pbn__extensionData;
global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing)
=> global::ProtoBuf.Extensible.GetExtensionObject(ref __pbn__extensionData, createIfMissing);
[global::ProtoBuf.ProtoMember(1, Name = @"result", IsRequired = true)]
public uint Result { get; set; }
[global::ProtoBuf.ProtoMember(1, Name = @"result", IsRequired = true)]
public uint Result { get; set; }
}
}
[global::ProtoBuf.ProtoContract()]
public partial class VerupCompleteRequest : global::ProtoBuf.IExtensible
{
private global::ProtoBuf.IExtension __pbn__extensionData;
global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing)
=> global::ProtoBuf.Extensible.GetExtensionObject(ref __pbn__extensionData, createIfMissing);
[global::ProtoBuf.ProtoContract()]
public partial class VerupCompleteRequest : global::ProtoBuf.IExtensible
{
private global::ProtoBuf.IExtension __pbn__extensionData;
global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing)
=> global::ProtoBuf.Extensible.GetExtensionObject(ref __pbn__extensionData, createIfMissing);
[global::ProtoBuf.ProtoMember(1, Name = @"chassis_id", IsRequired = true)]
public string ChassisId { get; set; }
[global::ProtoBuf.ProtoMember(1, Name = @"chassis_id", IsRequired = true)]
public string ChassisId { get; set; }
[global::ProtoBuf.ProtoMember(2, Name = @"usbmem_key", IsRequired = true)]
public string UsbmemKey { get; set; }
[global::ProtoBuf.ProtoMember(2, Name = @"usbmem_key", IsRequired = true)]
public string UsbmemKey { get; set; }
[global::ProtoBuf.ProtoMember(3, Name = @"hdd_ver", IsRequired = true)]
public uint HddVer { get; set; }
[global::ProtoBuf.ProtoMember(3, Name = @"hdd_ver", IsRequired = true)]
public uint HddVer { get; set; }
[global::ProtoBuf.ProtoMember(4, Name = @"usbmem_ver", IsRequired = true)]
public uint UsbmemVer { get; set; }
[global::ProtoBuf.ProtoMember(4, Name = @"usbmem_ver", IsRequired = true)]
public uint UsbmemVer { get; set; }
[global::ProtoBuf.ProtoMember(5, Name = @"shop_id", IsRequired = true)]
public string ShopId { get; set; }
[global::ProtoBuf.ProtoMember(5, Name = @"shop_id", IsRequired = true)]
public string ShopId { get; set; }
[global::ProtoBuf.ProtoMember(6, Name = @"rack_id")]
[global::System.ComponentModel.DefaultValue("")]
public string RackId
{
get => __pbn__RackId ?? "";
set => __pbn__RackId = value;
}
public bool ShouldSerializeRackId() => __pbn__RackId != null;
public void ResetRackId() => __pbn__RackId = null;
private string __pbn__RackId;
[global::ProtoBuf.ProtoMember(6, Name = @"rack_id")]
[global::System.ComponentModel.DefaultValue("")]
public string RackId
{
get => __pbn__RackId ?? "";
set => __pbn__RackId = value;
}
public bool ShouldSerializeRackId() => __pbn__RackId != null;
public void ResetRackId() => __pbn__RackId = null;
private string __pbn__RackId;
[global::ProtoBuf.ProtoMember(7, Name = @"country_id")]
[global::System.ComponentModel.DefaultValue("")]
public string CountryId
{
get => __pbn__CountryId ?? "";
set => __pbn__CountryId = value;
}
public bool ShouldSerializeCountryId() => __pbn__CountryId != null;
public void ResetCountryId() => __pbn__CountryId = null;
private string __pbn__CountryId;
[global::ProtoBuf.ProtoMember(7, Name = @"country_id")]
[global::System.ComponentModel.DefaultValue("")]
public string CountryId
{
get => __pbn__CountryId ?? "";
set => __pbn__CountryId = value;
}
public bool ShouldSerializeCountryId() => __pbn__CountryId != null;
public void ResetCountryId() => __pbn__CountryId = null;
private string __pbn__CountryId;
}
}
[global::ProtoBuf.ProtoContract()]
public partial class VerupCompleteResponse : global::ProtoBuf.IExtensible
{
private global::ProtoBuf.IExtension __pbn__extensionData;
global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing)
=> global::ProtoBuf.Extensible.GetExtensionObject(ref __pbn__extensionData, createIfMissing);
[global::ProtoBuf.ProtoContract()]
public partial class VerupCompleteResponse : global::ProtoBuf.IExtensible
{
private global::ProtoBuf.IExtension __pbn__extensionData;
global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing)
=> global::ProtoBuf.Extensible.GetExtensionObject(ref __pbn__extensionData, createIfMissing);
[global::ProtoBuf.ProtoMember(1, Name = @"result", IsRequired = true)]
public uint Result { get; set; }
[global::ProtoBuf.ProtoMember(1, Name = @"result", IsRequired = true)]
public uint Result { get; set; }
}
}
}

View File

@ -1,6 +1,9 @@
using System.Reflection;
using System.Security.Authentication;
using Serilog.Sinks.File.Header;
using TaikoLocalServer.Logging;
using GameDatabase.Context;
using Microsoft.AspNetCore.HttpLogging;
using Microsoft.AspNetCore.HttpOverrides;
using TaikoLocalServer.Middlewares;
using TaikoLocalServer.Services.Extentions;
@ -23,26 +26,32 @@ try
{
var builder = WebApplication.CreateBuilder(args);
builder.Host.ConfigureAppConfiguration((hostingContext, config) =>
builder.Services.AddHttpLogging(options =>
{
const string configurationsDirectory = "Configurations";
config.AddJsonFile($"{configurationsDirectory}/Kestrel.json", optional: true, reloadOnChange: false);
config.AddJsonFile($"{configurationsDirectory}/Logging.json", optional: false, reloadOnChange: false);
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);
options.LoggingFields = HttpLoggingFields.All;
options.RequestBodyLogLimit = 32768;
options.ResponseBodyLogLimit = 32768;
});
// Manually enable tls 1.0
builder.WebHost.UseKestrel(kestrelOptions =>
{
kestrelOptions.ConfigureHttpsDefaults(options =>
options.SslProtocols = SslProtocols.Tls | SslProtocols.Tls11 | SslProtocols.Tls12 | SslProtocols.Tls13);
});
const string configurationsDirectory = "Configurations";
builder.Configuration.AddJsonFile($"{configurationsDirectory}/Kestrel.json", optional: true, reloadOnChange: false);
builder.Configuration.AddJsonFile($"{configurationsDirectory}/Logging.json", optional: false, reloadOnChange: false);
builder.Configuration.AddJsonFile($"{configurationsDirectory}/Database.json", optional: false, reloadOnChange: false);
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) =>
{
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"))
@ -117,6 +126,16 @@ try
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.MapFallbackToFile("index.html");

View File

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

View File

@ -13,14 +13,14 @@ public class AiDatumService : IAiDatumService
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)
.Include(datum => datum.AiSectionScoreData)
.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 &&
datum.SongId == songId &&

View File

@ -7,46 +7,59 @@ namespace TaikoLocalServer.Services;
public class CardService : ICardService
{
private readonly TaikoDbContext context;
private readonly TaikoDbContext context;
public CardService(TaikoDbContext context)
{
this.context = context;
}
public CardService(TaikoDbContext context)
{
this.context = context;
}
public async Task<Card?> GetCardByAccessCode(string accessCode)
{
return await context.Cards.FindAsync(accessCode);
}
public async Task<Card?> GetCardByAccessCode(string accessCode)
{
return await context.Cards.FindAsync(accessCode);
}
public uint GetNextBaid()
{
return context.Cards.Any() ? context.Cards.Max(card => card.Baid) + 1 : 1;
}
public ulong GetNextBaid()
{
return context.Cards.Any() ? context.Cards.ToList().Max(card => card.Baid) + 1 : 1;
}
public async Task<List<User>> GetUsersFromCards()
{
return await context.Cards.Select(card => card.CopyPropertiesToNew<User>(null)).ToListAsync();
}
public async Task<List<User>> GetUsersFromCards()
{
return await context.Cards.Select(card => card.CopyPropertiesToNew<User>(null)).ToListAsync();
}
public async Task AddCard(Card card)
{
context.Add(card);
await context.SaveChangesAsync();
}
public async Task AddCard(Card card)
{
context.Add(card);
await context.SaveChangesAsync();
}
public async Task<bool> DeleteCard(string accessCode)
{
var card = await context.Cards.FindAsync(accessCode);
public async Task<bool> DeleteCard(string accessCode)
{
var card = await context.Cards.FindAsync(accessCode);
if (card is null)
{
return false;
}
if (card is null)
{
return false;
}
context.Cards.Remove(card);
await context.SaveChangesAsync();
context.Cards.Remove(card);
await context.SaveChangesAsync();
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;
}
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)
.Include(datum => datum.DanStageScoreData)
.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)
.FirstOrDefaultAsync(datum => datum.Baid == baid &&

View File

@ -1,10 +1,12 @@
using System.Collections.Immutable;
using System.Text.Json;
using ICSharpCode.SharpZipLib.GZip;
using ICSharpCode.SharpZipLib.GZip;
using Microsoft.Extensions.Options;
using SharedProject.Models;
using SharedProject.Utils;
using Swan.Mapping;
using System.Collections.Immutable;
using System.IO.Compression;
using System.Security.Cryptography;
using System.Text.Json;
using TaikoLocalServer.Settings;
using Throw;
@ -12,178 +14,460 @@ namespace TaikoLocalServer.Services;
public class GameDataService : IGameDataService
{
private ImmutableDictionary<uint, GetDanOdaiResponse.OdaiData> danDataDictionary =
ImmutableDictionary<uint, GetDanOdaiResponse.OdaiData>.Empty;
private ImmutableDictionary<uint, MusicInfoEntry> musicInfoes =
ImmutableDictionary<uint, MusicInfoEntry>.Empty;
private ImmutableDictionary<uint, GetSongIntroductionResponse.SongIntroductionData> introDataDictionary =
ImmutableDictionary<uint, GetSongIntroductionResponse.SongIntroductionData>.Empty;
private ImmutableDictionary<uint, MusicAttributeEntry> musicAttributes =
ImmutableDictionary<uint, MusicAttributeEntry>.Empty;
private ImmutableDictionary<uint, GetDanOdaiResponse.OdaiData> danDataDictionary =
ImmutableDictionary<uint, GetDanOdaiResponse.OdaiData>.Empty;
private ImmutableDictionary<uint, GetfolderResponse.EventfolderData> folderDictionary =
ImmutableDictionary<uint, GetfolderResponse.EventfolderData>.Empty;
private ImmutableDictionary<uint, GetDanOdaiResponse.OdaiData> gaidenDataDictionary =
ImmutableDictionary<uint, GetDanOdaiResponse.OdaiData>.Empty;
private List<uint> musics = new();
private ImmutableDictionary<uint, GetSongIntroductionResponse.SongIntroductionData> introDataDictionary =
ImmutableDictionary<uint, GetSongIntroductionResponse.SongIntroductionData>.Empty;
private List<uint> musicsWithUra = new();
private readonly DataSettings settings;
private ImmutableDictionary<uint, InitialdatacheckResponse.MovieData> movieDataDictionary =
ImmutableDictionary<uint, InitialdatacheckResponse.MovieData>.Empty;
public GameDataService(IOptions<DataSettings> settings)
{
this.settings = settings.Value;
}
private ImmutableDictionary<uint, GetfolderResponse.EventfolderData> folderDictionary =
ImmutableDictionary<uint, GetfolderResponse.EventfolderData>.Empty;
public List<uint> GetMusicList()
{
return musics;
}
private ImmutableDictionary<string, uint> qrCodeDataDictionary = ImmutableDictionary<string, uint>.Empty;
private List<GetShopFolderResponse.ShopFolderData> shopFolderList = new();
public List<uint> GetMusicWithUraList()
{
return musicsWithUra;
}
private List<uint> musics = new();
public ImmutableDictionary<uint, MusicAttributeEntry> GetMusicAttributes()
{
return musicAttributes;
}
private List<uint> musicsWithUra = new();
public ImmutableDictionary<uint, GetDanOdaiResponse.OdaiData> GetDanDataDictionary()
{
return danDataDictionary;
}
public ImmutableDictionary<uint, GetSongIntroductionResponse.SongIntroductionData> GetSongIntroDictionary()
{
return introDataDictionary;
}
private List<uint> lockedSongsList = new();
private List<int> costumeFlagArraySizes = new();
private int titleFlagArraySize;
private int toneFlagArraySize;
public ImmutableDictionary<uint, GetfolderResponse.EventfolderData> GetFolderDictionary()
{
return folderDictionary;
}
private Dictionary<string, int> tokenDataDictionary = new();
public async Task InitializeAsync()
{
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 danDataPath = Path.Combine(dataPath, settings.DanDataFileName);
var songIntroDataPath = Path.Combine(dataPath, settings.IntroDataFileName);
var eventFolderDataPath = Path.Combine(dataPath, settings.EventFolderDataFileName);
private readonly DataSettings settings;
if (File.Exists(compressedMusicAttributePath))
{
TryDecompressMusicAttribute();
}
await using var musicAttributeFile = File.OpenRead(musicAttributePath);
await using var danDataFile = File.OpenRead(danDataPath);
await using var songIntroDataFile = File.OpenRead(songIntroDataPath);
await using var eventFolderDataFile = File.OpenRead(eventFolderDataPath);
public GameDataService(IOptions<DataSettings> settings)
{
this.settings = settings.Value;
}
var attributesData = await JsonSerializer.DeserializeAsync<MusicAttributes>(musicAttributeFile);
var danData = await JsonSerializer.DeserializeAsync<List<DanData>>(danDataFile);
var introData = await JsonSerializer.DeserializeAsync<List<SongIntroductionData>>(songIntroDataFile);
var eventFolderData = await JsonSerializer.DeserializeAsync<List<EventFolderData>>(eventFolderDataFile);
public List<uint> GetMusicList()
{
return musics;
}
InitializeMusicAttributes(attributesData);
public List<uint> GetMusicWithUraList()
{
return musicsWithUra;
}
InitializeDanData(danData);
public ImmutableDictionary<uint, MusicInfoEntry> GetMusicInfoes()
{
return musicInfoes;
}
InitializeIntroData(introData);
public ImmutableDictionary<uint, GetDanOdaiResponse.OdaiData> GetDanDataDictionary()
{
return danDataDictionary;
}
InitializeEventFolderData(eventFolderData);
}
public ImmutableDictionary<uint, GetDanOdaiResponse.OdaiData> GetGaidenDataDictionary()
{
return gaidenDataDictionary;
}
private static void TryDecompressMusicAttribute()
{
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);
using var compressed = File.Open(compressedMusicAttributePath, FileMode.Open);
using var output = File.Create(musicAttributePath);
GZip.Decompress(compressed, output, true);
}
public ImmutableDictionary<uint, GetSongIntroductionResponse.SongIntroductionData> GetSongIntroDictionary()
{
return introDataDictionary;
}
private void InitializeIntroData(List<SongIntroductionData>? introData)
{
introData.ThrowIfNull("Shouldn't happen!");
introDataDictionary = introData.ToImmutableDictionary(data => data.SetId, ToResponseIntroData);
}
public ImmutableDictionary<uint, InitialdatacheckResponse.MovieData> GetMovieDataDictionary()
{
return movieDataDictionary;
}
private void InitializeDanData(List<DanData>? danData)
{
danData.ThrowIfNull("Shouldn't happen!");
danDataDictionary = danData.ToImmutableDictionary(data => data.DanId, ToResponseOdaiData);
}
public ImmutableDictionary<uint, GetfolderResponse.EventfolderData> GetFolderDictionary()
{
return folderDictionary;
}
private void InitializeEventFolderData(List<EventFolderData>? eventFolderData)
{
eventFolderData.ThrowIfNull("Shouldn't happen!");
folderDictionary = eventFolderData.ToImmutableDictionary(data => data.FolderId, ToResponseEventFolderData);
}
public List<GetShopFolderResponse.ShopFolderData> GetShopFolderList()
{
return shopFolderList;
}
private void InitializeMusicAttributes(MusicAttributes? attributesData)
{
attributesData.ThrowIfNull("Shouldn't happen!");
public Dictionary<string, int> GetTokenDataDictionary()
{
return tokenDataDictionary;
}
musicAttributes = attributesData.MusicAttributeEntries.ToImmutableDictionary(attribute => attribute.MusicId);
public List<uint> GetLockedSongsList()
{
return lockedSongsList;
}
public List<int> GetCostumeFlagArraySizes()
{
return costumeFlagArraySizes;
}
public int GetTitleFlagArraySize()
{
return titleFlagArraySize;
}
public int GetToneFlagArraySize()
{
return toneFlagArraySize;
}
musics = musicAttributes.Select(pair => pair.Key)
.ToList();
musics.Sort();
public ImmutableDictionary<string, uint> GetQRCodeDataDictionary()
{
return qrCodeDataDictionary;
}
musicsWithUra = musicAttributes.Where(attribute => attribute.Value.HasUra)
.Select(pair => pair.Key)
.ToList();
musicsWithUra.Sort();
}
public async Task InitializeAsync()
{
var dataPath = PathHelper.GetDataPath();
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 gaidenDataPath = Path.Combine(dataPath, settings.GaidenDataFileName);
var songIntroDataPath = Path.Combine(dataPath, settings.IntroDataFileName);
var movieDataPath = Path.Combine(dataPath, settings.MovieDataFileName);
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);
private static GetDanOdaiResponse.OdaiData ToResponseOdaiData(DanData data)
{
var responseOdaiData = new GetDanOdaiResponse.OdaiData
{
DanId = data.DanId,
Title = data.Title,
VerupNo = data.VerupNo
};
if (File.Exists(encryptedInfo))
{
DecryptDataTable(encryptedInfo, musicInfoPath);
}
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 gaidenDataFile = File.OpenRead(gaidenDataPath);
await using var songIntroDataFile = File.OpenRead(songIntroDataPath);
await using var movieDataFile = File.OpenRead(movieDataPath);
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 odaiSongs = data.OdaiSongList.Select(song => song.CopyPropertiesToNew<GetDanOdaiResponse.OdaiData.OdaiSong>());
responseOdaiData.AryOdaiSongs.AddRange(odaiSongs);
var infoesData = await JsonSerializer.DeserializeAsync<MusicInfoes>(musicInfoFile);
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 movieData = await JsonSerializer.DeserializeAsync<List<MovieData>>(movieDataFile);
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);
var odaiBorders = data.OdaiBorderList.Select(border => border.CopyPropertiesToNew<GetDanOdaiResponse.OdaiData.OdaiBorder>());
responseOdaiData.AryOdaiBorders.AddRange(odaiBorders);
InitializeMusicInfoes(infoesData);
return responseOdaiData;
}
InitializeDanData(danData);
private static GetSongIntroductionResponse.SongIntroductionData ToResponseIntroData(SongIntroductionData data)
{
var responseOdaiData = new GetSongIntroductionResponse.SongIntroductionData
{
SetId = data.SetId,
VerupNo = data.VerupNo,
MainSongNo = data.MainSongNo,
SubSongNoes = data.SubSongNo
};
InitializeGaidenData(gaidenData);
return responseOdaiData;
}
InitializeIntroData(introData);
private static GetfolderResponse.EventfolderData ToResponseEventFolderData(EventFolderData data)
{
var responseEventFolderData = new GetfolderResponse.EventfolderData
{
FolderId = data.FolderId,
VerupNo = data.VerupNo,
Priority = data.Priority,
SongNoes = data.SongNo
};
InitializeMovieData(movieData);
return responseEventFolderData;
}
InitializeEventFolderData(eventFolderData);
InitializeShopFolderData(shopFolderData);
InitializeTokenData(tokenData);
InitializeLockedSongsData(lockedSongsData);
InitializeCostumeFlagArraySizes(donCosRewardData);
InitializeTitleFlagArraySize(shougouData);
InitializeToneFlagArraySize(neiroData);
InitializeQrCodeData(qrCodeData);
}
private static void DecryptDataTable(string inputFileName, string outputFileName)
{
var aes = Aes.Create();
aes.Mode = CipherMode.CBC;
aes.KeySize = 256;
aes.Padding = PaddingMode.PKCS7;
aes.Key = Convert.FromHexString("3530304242323633353537423431384139353134383346433246464231354534");
var iv = new byte[16];
using var fs = File.OpenRead(inputFileName);
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)
{
introData.ThrowIfNull("Shouldn't happen!");
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)
{
danData.ThrowIfNull("Shouldn't happen!");
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)
{
eventFolderData.ThrowIfNull("Shouldn't happen!");
folderDictionary = eventFolderData.ToImmutableDictionary(data => data.FolderId, ToResponseEventFolderData);
}
private void InitializeMusicInfoes(MusicInfoes? infoesData)
{
infoesData.ThrowIfNull("Shouldn't happen!");
musicInfoes = infoesData.MusicInfoEntries.ToImmutableDictionary(info => info.MusicId);
musics = musicInfoes.Select(pair => pair.Key)
.ToList();
musics.Sort();
musicsWithUra = musicInfoes.Where(info => info.Value.starUra > 0)
.Select(pair => pair.Key)
.ToList();
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)
{
var responseOdaiData = new GetDanOdaiResponse.OdaiData
{
DanId = data.DanId,
Title = data.Title,
VerupNo = data.VerupNo
};
var odaiSongs = data.OdaiSongList.Select(song => song.CopyPropertiesToNew<GetDanOdaiResponse.OdaiData.OdaiSong>());
responseOdaiData.AryOdaiSongs.AddRange(odaiSongs);
var odaiBorders = data.OdaiBorderList.Select(border => border.CopyPropertiesToNew<GetDanOdaiResponse.OdaiData.OdaiBorder>());
responseOdaiData.AryOdaiBorders.AddRange(odaiBorders);
return responseOdaiData;
}
private static GetSongIntroductionResponse.SongIntroductionData ToResponseIntroData(SongIntroductionData data)
{
var responseIntroData = new GetSongIntroductionResponse.SongIntroductionData
{
SetId = data.SetId,
VerupNo = data.VerupNo,
MainSongNo = data.MainSongNo,
SubSongNoes = data.SubSongNo
};
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)
{
var responseEventFolderData = new GetfolderResponse.EventfolderData
{
FolderId = data.FolderId,
VerupNo = data.VerupNo,
Priority = data.Priority,
SongNoes = data.SongNo,
ParentFolderId = data.ParentFolderId
};
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 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);

View File

@ -5,13 +5,15 @@ namespace TaikoLocalServer.Services.Interfaces;
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 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);
}

View File

@ -1,21 +1,40 @@
using System.Collections.Immutable;
using SharedProject.Models;
namespace TaikoLocalServer.Services.Interfaces;
public interface IGameDataService
{
public Task InitializeAsync();
public List<uint> GetMusicList();
public Task InitializeAsync();
public List<uint> GetMusicWithUraList();
public List<uint> GetMusicList();
public ImmutableDictionary<uint, MusicAttributeEntry> GetMusicAttributes();
public List<uint> GetMusicWithUraList();
public ImmutableDictionary<uint, GetDanOdaiResponse.OdaiData> GetDanDataDictionary();
public ImmutableDictionary<uint, MusicInfoEntry> GetMusicInfoes();
public ImmutableDictionary<uint, GetSongIntroductionResponse.SongIntroductionData> GetSongIntroDictionary();
public ImmutableDictionary<uint, GetDanOdaiResponse.OdaiData> GetDanDataDictionary();
public ImmutableDictionary<uint, GetDanOdaiResponse.OdaiData> GetGaidenDataDictionary();
public ImmutableDictionary<uint, GetfolderResponse.EventfolderData> GetFolderDictionary();
public ImmutableDictionary<uint, GetSongIntroductionResponse.SongIntroductionData> GetSongIntroDictionary();
public ImmutableDictionary<uint, InitialdatacheckResponse.MovieData> GetMovieDataDictionary();
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 Task<List<SongBestDatum>> GetAllSongBestData(uint baid);
public Task<List<SongBestDatum>> GetAllSongBestData(ulong baid);
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 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,21 +4,21 @@ namespace TaikoLocalServer.Services.Interfaces;
public interface IUserDatumService
{
public Task<UserDatum?> GetFirstUserDatumOrNull(uint baid);
public Task<UserDatum> GetFirstUserDatumOrDefault(uint baid);
public Task<UserDatum?> GetFirstUserDatumOrNull(ulong baid);
public Task<List<UserDatum>> GetAllUserData();
public Task<UserDatum> GetFirstUserDatumOrDefault(ulong baid);
public Task UpdateOrInsertUserDatum(UserDatum userDatum);
public Task InsertUserDatum(UserDatum userDatum);
public Task UpdateUserDatum(UserDatum userDatum);
public Task<List<UserDatum>> GetAllUserData();
public Task UpdateOrInsertUserDatum(UserDatum userDatum);
public Task InsertUserDatum(UserDatum userDatum);
public Task UpdateUserDatum(UserDatum userDatum);
public Task<List<uint>> GetFavoriteSongIds(ulong baid);
public Task UpdateFavoriteSong(ulong baid, uint songId, bool isFavorite);
public Task<List<uint>> GetFavoriteSongIds(uint baid);
public Task UpdateFavoriteSong(uint baid, uint songId, bool isFavorite);
}

View File

@ -15,7 +15,7 @@ public class SongBestDatumService : ISongBestDatumService
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();
}
@ -37,7 +37,7 @@ public class SongBestDatumService : ISongBestDatumService
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)
.ToListAsync();

View File

@ -12,7 +12,7 @@ class SongPlayDatumService : ISongPlayDatumService
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();
}

View File

@ -17,12 +17,12 @@ public class UserDatumService : IUserDatumService
this.logger = logger;
}
public async Task<UserDatum?> GetFirstUserDatumOrNull(uint baid)
public async Task<UserDatum?> GetFirstUserDatumOrNull(ulong 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();
}
@ -57,7 +57,7 @@ public class UserDatumService : IUserDatumService
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);
userDatum.ThrowIfNull($"User with baid: {baid} not found!");
@ -77,7 +77,7 @@ public class UserDatumService : IUserDatumService
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);
userDatum.ThrowIfNull($"User with baid: {baid} not found!");

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