1
0
mirror of synced 2024-11-27 16:10:53 +01:00

Reimplemented getTokenCount and songPurchase

This commit is contained in:
S-Sebb?? 2023-09-17 00:40:07 +08:00
parent 05071be3ca
commit 8a4fee9b04
11 changed files with 642 additions and 48 deletions

View File

@ -27,8 +27,9 @@ namespace GameDatabase.Entities
public bool DisplayDan { get; set; } public bool DisplayDan { get; set; }
public bool DisplayAchievement { get; set; } public bool DisplayAchievement { get; set; }
public Difficulty AchievementDisplayDifficulty { get; set; } public Difficulty AchievementDisplayDifficulty { get; set; }
public int AiWinCount { get; set; } public int AiWinCount { get; set; }
public string TokenCountDict { get; set; } = "{}";
public string UnlockedSongIdList { get; set; } = "[]";
public virtual Card? Ba { get; set; } public virtual Card? Ba { get; set; }
} }
} }

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net8.0</TargetFramework> <TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
</PropertyGroup> </PropertyGroup>

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

@ -15,11 +15,11 @@ namespace TaikoLocalServer.Migrations
protected override void BuildModel(ModelBuilder modelBuilder) protected override void BuildModel(ModelBuilder modelBuilder)
{ {
#pragma warning disable 612, 618 #pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "7.0.0-preview.7.22376.2"); modelBuilder.HasAnnotation("ProductVersion", "7.0.0-rc.1.22426.7");
modelBuilder.Entity("TaikoLocalServer.Entities.AiScoreDatum", b => modelBuilder.Entity("GameDatabase.Entities.AiScoreDatum", b =>
{ {
b.Property<uint>("Baid") b.Property<ulong>("Baid")
.HasColumnType("INTEGER"); .HasColumnType("INTEGER");
b.Property<uint>("SongId") b.Property<uint>("SongId")
@ -36,9 +36,9 @@ namespace TaikoLocalServer.Migrations
b.ToTable("AiScoreData"); b.ToTable("AiScoreData");
}); });
modelBuilder.Entity("TaikoLocalServer.Entities.AiSectionScoreDatum", b => modelBuilder.Entity("GameDatabase.Entities.AiSectionScoreDatum", b =>
{ {
b.Property<uint>("Baid") b.Property<ulong>("Baid")
.HasColumnType("INTEGER"); .HasColumnType("INTEGER");
b.Property<uint>("SongId") b.Property<uint>("SongId")
@ -76,12 +76,12 @@ namespace TaikoLocalServer.Migrations
b.ToTable("AiSectionScoreData"); b.ToTable("AiSectionScoreData");
}); });
modelBuilder.Entity("TaikoLocalServer.Entities.Card", b => modelBuilder.Entity("GameDatabase.Entities.Card", b =>
{ {
b.Property<string>("AccessCode") b.Property<string>("AccessCode")
.HasColumnType("TEXT"); .HasColumnType("TEXT");
b.Property<uint>("Baid") b.Property<ulong>("Baid")
.HasColumnType("INTEGER"); .HasColumnType("INTEGER");
b.HasKey("AccessCode"); b.HasKey("AccessCode");
@ -92,9 +92,9 @@ namespace TaikoLocalServer.Migrations
b.ToTable("Card", (string)null); b.ToTable("Card", (string)null);
}); });
modelBuilder.Entity("TaikoLocalServer.Entities.DanScoreDatum", b => modelBuilder.Entity("GameDatabase.Entities.DanScoreDatum", b =>
{ {
b.Property<uint>("Baid") b.Property<ulong>("Baid")
.HasColumnType("INTEGER"); .HasColumnType("INTEGER");
b.Property<uint>("DanId") b.Property<uint>("DanId")
@ -119,9 +119,9 @@ namespace TaikoLocalServer.Migrations
b.ToTable("DanScoreData"); b.ToTable("DanScoreData");
}); });
modelBuilder.Entity("TaikoLocalServer.Entities.DanStageScoreDatum", b => modelBuilder.Entity("GameDatabase.Entities.DanStageScoreDatum", b =>
{ {
b.Property<uint>("Baid") b.Property<ulong>("Baid")
.HasColumnType("INTEGER"); .HasColumnType("INTEGER");
b.Property<uint>("DanId") b.Property<uint>("DanId")
@ -159,9 +159,9 @@ namespace TaikoLocalServer.Migrations
b.ToTable("DanStageScoreData"); b.ToTable("DanStageScoreData");
}); });
modelBuilder.Entity("TaikoLocalServer.Entities.SongBestDatum", b => modelBuilder.Entity("GameDatabase.Entities.SongBestDatum", b =>
{ {
b.Property<uint>("Baid") b.Property<ulong>("Baid")
.HasColumnType("INTEGER"); .HasColumnType("INTEGER");
b.Property<uint>("SongId") b.Property<uint>("SongId")
@ -187,13 +187,13 @@ namespace TaikoLocalServer.Migrations
b.ToTable("SongBestData"); b.ToTable("SongBestData");
}); });
modelBuilder.Entity("TaikoLocalServer.Entities.SongPlayDatum", b => modelBuilder.Entity("GameDatabase.Entities.SongPlayDatum", b =>
{ {
b.Property<long>("Id") b.Property<long>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("INTEGER"); .HasColumnType("INTEGER");
b.Property<uint>("Baid") b.Property<ulong>("Baid")
.HasColumnType("INTEGER"); .HasColumnType("INTEGER");
b.Property<uint>("ComboCount") b.Property<uint>("ComboCount")
@ -248,9 +248,9 @@ namespace TaikoLocalServer.Migrations
b.ToTable("SongPlayData"); b.ToTable("SongPlayData");
}); });
modelBuilder.Entity("TaikoLocalServer.Entities.UserDatum", b => modelBuilder.Entity("GameDatabase.Entities.UserDatum", b =>
{ {
b.Property<uint>("Baid") b.Property<ulong>("Baid")
.HasColumnType("INTEGER"); .HasColumnType("INTEGER");
b.Property<uint>("AchievementDisplayDifficulty") b.Property<uint>("AchievementDisplayDifficulty")
@ -326,18 +326,26 @@ namespace TaikoLocalServer.Migrations
b.Property<uint>("TitlePlateId") b.Property<uint>("TitlePlateId")
.HasColumnType("INTEGER"); .HasColumnType("INTEGER");
b.Property<string>("TokenCountDict")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("ToneFlgArray") b.Property<string>("ToneFlgArray")
.IsRequired() .IsRequired()
.HasColumnType("TEXT"); .HasColumnType("TEXT");
b.Property<string>("UnlockedSongIdList")
.IsRequired()
.HasColumnType("TEXT");
b.HasKey("Baid"); b.HasKey("Baid");
b.ToTable("UserData"); b.ToTable("UserData");
}); });
modelBuilder.Entity("TaikoLocalServer.Entities.AiScoreDatum", b => modelBuilder.Entity("GameDatabase.Entities.AiScoreDatum", b =>
{ {
b.HasOne("TaikoLocalServer.Entities.Card", "Ba") b.HasOne("GameDatabase.Entities.Card", "Ba")
.WithMany() .WithMany()
.HasForeignKey("Baid") .HasForeignKey("Baid")
.HasPrincipalKey("Baid") .HasPrincipalKey("Baid")
@ -347,9 +355,9 @@ namespace TaikoLocalServer.Migrations
b.Navigation("Ba"); b.Navigation("Ba");
}); });
modelBuilder.Entity("TaikoLocalServer.Entities.AiSectionScoreDatum", b => modelBuilder.Entity("GameDatabase.Entities.AiSectionScoreDatum", b =>
{ {
b.HasOne("TaikoLocalServer.Entities.AiScoreDatum", "Parent") b.HasOne("GameDatabase.Entities.AiScoreDatum", "Parent")
.WithMany("AiSectionScoreData") .WithMany("AiSectionScoreData")
.HasForeignKey("Baid", "SongId", "Difficulty") .HasForeignKey("Baid", "SongId", "Difficulty")
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
@ -358,9 +366,9 @@ namespace TaikoLocalServer.Migrations
b.Navigation("Parent"); b.Navigation("Parent");
}); });
modelBuilder.Entity("TaikoLocalServer.Entities.DanScoreDatum", b => modelBuilder.Entity("GameDatabase.Entities.DanScoreDatum", b =>
{ {
b.HasOne("TaikoLocalServer.Entities.Card", "Ba") b.HasOne("GameDatabase.Entities.Card", "Ba")
.WithMany() .WithMany()
.HasForeignKey("Baid") .HasForeignKey("Baid")
.HasPrincipalKey("Baid") .HasPrincipalKey("Baid")
@ -370,9 +378,9 @@ namespace TaikoLocalServer.Migrations
b.Navigation("Ba"); b.Navigation("Ba");
}); });
modelBuilder.Entity("TaikoLocalServer.Entities.DanStageScoreDatum", b => modelBuilder.Entity("GameDatabase.Entities.DanStageScoreDatum", b =>
{ {
b.HasOne("TaikoLocalServer.Entities.DanScoreDatum", "Parent") b.HasOne("GameDatabase.Entities.DanScoreDatum", "Parent")
.WithMany("DanStageScoreData") .WithMany("DanStageScoreData")
.HasForeignKey("Baid", "DanId") .HasForeignKey("Baid", "DanId")
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
@ -381,9 +389,9 @@ namespace TaikoLocalServer.Migrations
b.Navigation("Parent"); b.Navigation("Parent");
}); });
modelBuilder.Entity("TaikoLocalServer.Entities.SongBestDatum", b => modelBuilder.Entity("GameDatabase.Entities.SongBestDatum", b =>
{ {
b.HasOne("TaikoLocalServer.Entities.Card", "Ba") b.HasOne("GameDatabase.Entities.Card", "Ba")
.WithMany() .WithMany()
.HasForeignKey("Baid") .HasForeignKey("Baid")
.HasPrincipalKey("Baid") .HasPrincipalKey("Baid")
@ -393,9 +401,9 @@ namespace TaikoLocalServer.Migrations
b.Navigation("Ba"); b.Navigation("Ba");
}); });
modelBuilder.Entity("TaikoLocalServer.Entities.SongPlayDatum", b => modelBuilder.Entity("GameDatabase.Entities.SongPlayDatum", b =>
{ {
b.HasOne("TaikoLocalServer.Entities.Card", "Ba") b.HasOne("GameDatabase.Entities.Card", "Ba")
.WithMany() .WithMany()
.HasForeignKey("Baid") .HasForeignKey("Baid")
.HasPrincipalKey("Baid") .HasPrincipalKey("Baid")
@ -405,9 +413,9 @@ namespace TaikoLocalServer.Migrations
b.Navigation("Ba"); b.Navigation("Ba");
}); });
modelBuilder.Entity("TaikoLocalServer.Entities.UserDatum", b => modelBuilder.Entity("GameDatabase.Entities.UserDatum", b =>
{ {
b.HasOne("TaikoLocalServer.Entities.Card", "Ba") b.HasOne("GameDatabase.Entities.Card", "Ba")
.WithMany() .WithMany()
.HasForeignKey("Baid") .HasForeignKey("Baid")
.HasPrincipalKey("Baid") .HasPrincipalKey("Baid")
@ -417,12 +425,12 @@ namespace TaikoLocalServer.Migrations
b.Navigation("Ba"); b.Navigation("Ba");
}); });
modelBuilder.Entity("TaikoLocalServer.Entities.AiScoreDatum", b => modelBuilder.Entity("GameDatabase.Entities.AiScoreDatum", b =>
{ {
b.Navigation("AiSectionScoreData"); b.Navigation("AiSectionScoreData");
}); });
modelBuilder.Entity("TaikoLocalServer.Entities.DanScoreDatum", b => modelBuilder.Entity("GameDatabase.Entities.DanScoreDatum", b =>
{ {
b.Navigation("DanStageScoreData"); b.Navigation("DanStageScoreData");
}); });

View File

@ -2,7 +2,7 @@
<PropertyGroup> <PropertyGroup>
<OutputType>Exe</OutputType> <OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework> <TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<Version>1.0.0-beta1</Version> <Version>1.0.0-beta1</Version>

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net8.0</TargetFramework> <TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
</PropertyGroup> </PropertyGroup>

View File

@ -1,15 +1,56 @@
namespace TaikoLocalServer.Controllers.Game; using System.Text.Json;
using Throw;
namespace TaikoLocalServer.Controllers.Game;
[Route("/v12r00_cn/chassis/gettokencount.php")] [Route("/v12r00_cn/chassis/gettokencount.php")]
[ApiController] [ApiController]
public class GetTokenCountController : BaseController<GetTokenCountController> public class GetTokenCountController : BaseController<GetTokenCountController>
{ {
private readonly IGameDataService gameDataService;
private readonly IUserDatumService userDatumService;
public GetTokenCountController(IUserDatumService userDatumService, IGameDataService gameDataService)
{
this.userDatumService = userDatumService;
this.gameDataService = gameDataService;
}
[HttpPost] [HttpPost]
[Produces("application/protobuf")] [Produces("application/protobuf")]
public IActionResult GetTokenCount([FromBody] GetTokenCountRequest request) public async Task<IActionResult> GetTokenCount([FromBody] GetTokenCountRequest request)
{ {
Logger.LogInformation("GetTokenCount request : {Request}", request.Stringify()); Logger.LogInformation("GetTokenCount request : {Request}", request.Stringify());
var user = await userDatumService.GetFirstUserDatumOrNull(request.Baid);
var tokenDataDictionary = gameDataService.GetTokenDataDictionary();
tokenDataDictionary.TryGetValue("shopTokenId", out var shopTokenId);
tokenDataDictionary.TryGetValue("kaTokenId", out var kaTokenId);
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");
if (tokenCountDict.Count == 0) tokenCountDict.Add(shopTokenId, 0);
tokenCountDict.TryAdd(shopTokenId, 0);
tokenCountDict.TryAdd(kaTokenId, 0);
user.TokenCountDict = JsonSerializer.Serialize(tokenCountDict);
await userDatumService.UpdateUserDatum(user);
var response = new GetTokenCountResponse var response = new GetTokenCountResponse
{ {
Result = 1 Result = 1
@ -17,8 +58,14 @@ public class GetTokenCountController : BaseController<GetTokenCountController>
response.AryTokenCountDatas.Add(new GetTokenCountResponse.TokenCountData response.AryTokenCountDatas.Add(new GetTokenCountResponse.TokenCountData
{ {
TokenCount = 10, TokenCount = tokenCountDict[shopTokenId],
TokenId = 1 TokenId = shopTokenId
});
response.AryTokenCountDatas.Add(new GetTokenCountResponse.TokenCountData
{
TokenCount = tokenCountDict[kaTokenId],
TokenId = kaTokenId
}); });
return Ok(response); return Ok(response);

View File

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

View File

@ -118,14 +118,15 @@ public class UserDataController : BaseController<UserDataController>
TitleFlg = titleArray, TitleFlg = titleArray,
ReleaseSongFlg = releaseSongArray, ReleaseSongFlg = releaseSongArray,
UraReleaseSongFlg = uraSongArray, UraReleaseSongFlg = uraSongArray,
AryFavoriteSongNoes = favoriteSongs,
AryRecentSongNoes = recentSongs,
DefaultOptionSetting = defaultOptions, DefaultOptionSetting = defaultOptions,
NotesPosition = userData.NotesPosition,
IsVoiceOn = userData.IsVoiceOn, IsVoiceOn = userData.IsVoiceOn,
IsSkipOn = userData.IsSkipOn, IsSkipOn = userData.IsSkipOn,
IsChallengecompe = false, IsChallengecompe = false,
SongRecentCnt = (uint)recentSongs.Length, SongRecentCnt = (uint)recentSongs.Length,
AryFavoriteSongNoes = favoriteSongs, TotalCreditCnt = 99
AryRecentSongNoes = recentSongs,
NotesPosition = userData.NotesPosition
}; };
return Ok(response); return Ok(response);

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly"> <Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net8.0</TargetFramework> <TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup> </PropertyGroup>