1
0
mirror of synced 2024-11-28 00:20:53 +01:00

Move database to separate project, add migration tool prototype

This commit is contained in:
asesidaa 2022-10-27 00:42:11 +08:00
parent e30d362e63
commit e55230dc91
74 changed files with 393 additions and 93 deletions

View File

@ -1,4 +1,8 @@
namespace TaikoLocalServer.Context using GameDatabase.Entities;
using Microsoft.EntityFrameworkCore;
using SharedProject.Utils;
namespace GameDatabase.Context
{ {
public partial class TaikoDbContext : DbContext public partial class TaikoDbContext : DbContext
{ {
@ -22,7 +26,7 @@
{ {
return; return;
} }
var path = Path.Combine(PathHelper.GetRootPath(), Constants.DEFAULT_DB_NAME); var path = Path.Combine(PathHelper.GetRootPath(), "taiko.db3");
optionsBuilder.UseSqlite($"Data Source={path}"); optionsBuilder.UseSqlite($"Data Source={path}");
} }

View File

@ -1,4 +1,8 @@
namespace TaikoLocalServer.Context; using GameDatabase.Entities;
using Microsoft.EntityFrameworkCore;
using SharedProject.Enums;
namespace GameDatabase.Context;
public partial class TaikoDbContext public partial class TaikoDbContext
{ {

View File

@ -1,4 +1,6 @@
namespace TaikoLocalServer.Entities; using SharedProject.Enums;
namespace GameDatabase.Entities;
public class AiScoreDatum public class AiScoreDatum
{ {

View File

@ -0,0 +1,30 @@
using SharedProject.Enums;
namespace GameDatabase.Entities;
public class AiSectionScoreDatum
{
public uint Baid { get; set; }
public uint SongId { get; set; }
public Difficulty Difficulty { get; set; }
public int SectionIndex { get; set; }
public CrownType Crown { get; set; }
public bool IsWin { get; set; }
public uint Score { get; set; }
public uint GoodCount { get; set; }
public uint OkCount { get; set; }
public uint MissCount { get; set; }
public uint DrumrollCount { get; set; }
public AiScoreDatum Parent { get; set; } = null!;
}

View File

@ -1,4 +1,4 @@
namespace TaikoLocalServer.Entities namespace GameDatabase.Entities
{ {
public partial class Card public partial class Card
{ {

View File

@ -1,4 +1,6 @@
namespace TaikoLocalServer.Entities; using SharedProject.Enums;
namespace GameDatabase.Entities;
public class DanScoreDatum public class DanScoreDatum
{ {

View File

@ -1,4 +1,4 @@
namespace TaikoLocalServer.Entities; namespace GameDatabase.Entities;
public class DanStageScoreDatum public class DanStageScoreDatum
{ {

View File

@ -1,4 +1,6 @@
namespace TaikoLocalServer.Entities using SharedProject.Enums;
namespace GameDatabase.Entities
{ {
public partial class SongBestDatum public partial class SongBestDatum
{ {

View File

@ -1,4 +1,6 @@
namespace TaikoLocalServer.Entities; using SharedProject.Enums;
namespace GameDatabase.Entities;
public partial class SongBestDatum public partial class SongBestDatum
{ {

View File

@ -1,4 +1,6 @@
namespace TaikoLocalServer.Entities using SharedProject.Enums;
namespace GameDatabase.Entities
{ {
public partial class SongPlayDatum public partial class SongPlayDatum
{ {

View File

@ -1,4 +1,6 @@
namespace TaikoLocalServer.Entities using SharedProject.Enums;
namespace GameDatabase.Entities
{ {
public partial class UserDatum public partial class UserDatum
{ {

View File

@ -0,0 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<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>
</ItemGroup>
</Project>

View File

@ -1,10 +1,10 @@
// <auto-generated /> // <auto-generated />
using System; using System;
using GameDatabase.Context;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion; using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using TaikoLocalServer.Context;
#nullable disable #nullable disable

View File

@ -1,10 +1,10 @@
// <auto-generated /> // <auto-generated />
using System; using System;
using GameDatabase.Context;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion; using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using TaikoLocalServer.Context;
#nullable disable #nullable disable

View File

@ -1,10 +1,10 @@
// <auto-generated /> // <auto-generated />
using System; using System;
using GameDatabase.Context;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion; using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using TaikoLocalServer.Context;
#nullable disable #nullable disable

View File

@ -1,10 +1,10 @@
// <auto-generated /> // <auto-generated />
using System; using System;
using GameDatabase.Context;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion; using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using TaikoLocalServer.Context;
#nullable disable #nullable disable

View File

@ -1,10 +1,10 @@
// <auto-generated /> // <auto-generated />
using System; using System;
using GameDatabase.Context;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion; using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using TaikoLocalServer.Context;
#nullable disable #nullable disable

View File

@ -1,10 +1,10 @@
// <auto-generated /> // <auto-generated />
using System; using System;
using GameDatabase.Context;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion; using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using TaikoLocalServer.Context;
#nullable disable #nullable disable

View File

@ -1,10 +1,10 @@
// <auto-generated /> // <auto-generated />
using System; using System;
using GameDatabase.Context;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion; using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using TaikoLocalServer.Context;
#nullable disable #nullable disable

View File

@ -1,10 +1,10 @@
// <auto-generated /> // <auto-generated />
using System; using System;
using GameDatabase.Context;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion; using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using TaikoLocalServer.Context;
#nullable disable #nullable disable

View File

@ -1,10 +1,10 @@
// <auto-generated /> // <auto-generated />
using System; using System;
using GameDatabase.Context;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion; using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using TaikoLocalServer.Context;
#nullable disable #nullable disable

View File

@ -1,10 +1,10 @@
// <auto-generated /> // <auto-generated />
using System; using System;
using GameDatabase.Context;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion; using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using TaikoLocalServer.Context;
#nullable disable #nullable disable

View File

@ -1,10 +1,10 @@
// <auto-generated /> // <auto-generated />
using System; using System;
using GameDatabase.Context;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion; using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using TaikoLocalServer.Context;
#nullable disable #nullable disable

View File

@ -1,10 +1,10 @@
// <auto-generated /> // <auto-generated />
using System; using System;
using GameDatabase.Context;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion; using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using TaikoLocalServer.Context;
#nullable disable #nullable disable

View File

@ -1,9 +1,9 @@
// <auto-generated /> // <auto-generated />
using System; using System;
using GameDatabase.Context;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion; using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using TaikoLocalServer.Context;
#nullable disable #nullable disable

View File

@ -0,0 +1,21 @@
using System.Diagnostics;
using System.Globalization;
using System.Text.Json;
using System.Text.Json.Serialization;
namespace LocalSaveModScoreMigrator;
public class DateTimeConverter : JsonConverter<DateTime>
{
public override DateTime Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
{
Debug.Assert(typeToConvert == typeof(DateTime));
var dateTime = DateTime.ParseExact(reader.GetString() ?? string.Empty, "dd_MM_yy-HH_mm_ss", CultureInfo.InvariantCulture);
return dateTime;
}
public override void Write(Utf8JsonWriter writer, DateTime value, JsonSerializerOptions options)
{
writer.WriteStringValue(value.ToString(CultureInfo.InvariantCulture));
}
}

View File

@ -0,0 +1,24 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</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">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\GameDatabase\GameDatabase.csproj" />
</ItemGroup>
</Project>

View File

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

View File

@ -0,0 +1,12 @@
using System.Text.Json.Serialization;
namespace LocalSaveModScoreMigrator;
public class MusicInfoEntry
{
[JsonPropertyName("id")]
public string Id { get; set; } = string.Empty;
[JsonPropertyName("uniqueId")]
public uint SongId { get; set; }
}

View File

@ -0,0 +1,23 @@
using System.Text.Json.Serialization;
using SharedProject.Enums;
namespace LocalSaveModScoreMigrator;
public class PlayRecordJson
{
public string SongId { get; set; } = "tmap4";
public Difficulty Difficulty { get; set; }
[JsonPropertyName("dateTime")]
public DateTime DateTime { get; set; }
public uint Score { set; get; }
public CrownType Crown { get; set; }
[JsonPropertyName("scorerank")]
public ScoreRank Scorerank { get; set; }
public uint Good { get; set; }
public uint Ok { get; set; }
public uint Bad { get; set; }
public uint Combo { get; set; }
public uint Drumroll { get; set; }
}

View File

@ -0,0 +1,94 @@
// See https://aka.ms/new-console-template for more information
using System.Text.Json;
using GameDatabase.Context;
using GameDatabase.Entities;
using JorgeSerrano.Json;
using LocalSaveModScoreMigrator;
using SharedProject.Enums;
using var db = new TaikoDbContext();
var card = db.Cards.First();
Console.WriteLine(card.Baid);
Console.WriteLine(card.AccessCode);
var localSaveJson = File.ReadAllText("record_enso_p1.json");
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.WriteLine(playRecordJson.First().SongId);
var musicInfoJson = File.ReadAllText("musicinfo.json");
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 songId = musicInfoMap[playRecord.SongId.Split("_")[1]];
Console.WriteLine(songId);
Console.WriteLine(playRecord.DateTime);
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 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);
}
}
db.SaveChanges();

View File

@ -0,0 +1,22 @@
using System.Diagnostics;
using System.Text.Json;
using System.Text.Json.Serialization;
using SharedProject.Enums;
namespace LocalSaveModScoreMigrator;
public class ScoreRankConverter : JsonConverter<ScoreRank>
{
public override ScoreRank Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
{
Debug.Assert(typeToConvert == typeof(ScoreRank));
var scoreRankInt = reader.GetInt32() + 1;
return (ScoreRank)scoreRankInt;
}
public override void Write(Utf8JsonWriter writer, ScoreRank value, JsonSerializerOptions options)
{
var scoreRank = (int)value - 1;
writer.WriteStringValue(scoreRank.ToString());
}
}

View File

@ -1,4 +1,4 @@
namespace TaikoLocalServer.Common.Utils; namespace SharedProject.Utils;
public static class PathHelper public static class PathHelper
{ {

View File

@ -9,6 +9,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharedProject", "SharedProj
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TaikoWebUI", "TaikoWebUI\TaikoWebUI.csproj", "{3F02C2B8-D970-4E8D-89AA-1B938DA6E2FE}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TaikoWebUI", "TaikoWebUI\TaikoWebUI.csproj", "{3F02C2B8-D970-4E8D-89AA-1B938DA6E2FE}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GameDatabase", "GameDatabase\GameDatabase.csproj", "{76F2B4D1-C05E-40F4-B577-095CA7DF0528}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LocalSaveModScoreMigrator", "LocalSaveModScoreMigrator\LocalSaveModScoreMigrator.csproj", "{72FAD857-4791-4925-8536-22FABD5976EE}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
@ -27,6 +31,14 @@ Global
{3F02C2B8-D970-4E8D-89AA-1B938DA6E2FE}.Debug|Any CPU.Build.0 = Debug|Any CPU {3F02C2B8-D970-4E8D-89AA-1B938DA6E2FE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3F02C2B8-D970-4E8D-89AA-1B938DA6E2FE}.Release|Any CPU.ActiveCfg = Release|Any CPU {3F02C2B8-D970-4E8D-89AA-1B938DA6E2FE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3F02C2B8-D970-4E8D-89AA-1B938DA6E2FE}.Release|Any CPU.Build.0 = Release|Any CPU {3F02C2B8-D970-4E8D-89AA-1B938DA6E2FE}.Release|Any CPU.Build.0 = Release|Any CPU
{76F2B4D1-C05E-40F4-B577-095CA7DF0528}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{76F2B4D1-C05E-40F4-B577-095CA7DF0528}.Debug|Any CPU.Build.0 = Debug|Any CPU
{76F2B4D1-C05E-40F4-B577-095CA7DF0528}.Release|Any CPU.ActiveCfg = Release|Any CPU
{76F2B4D1-C05E-40F4-B577-095CA7DF0528}.Release|Any CPU.Build.0 = Release|Any CPU
{72FAD857-4791-4925-8536-22FABD5976EE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{72FAD857-4791-4925-8536-22FABD5976EE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{72FAD857-4791-4925-8536-22FABD5976EE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{72FAD857-4791-4925-8536-22FABD5976EE}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE

View File

@ -0,0 +1,24 @@
using GameDatabase.Entities;
using SharedProject.Utils;
namespace TaikoLocalServer.Common.Utils;
public static class Extensions
{
public static void UpdateBest(this AiSectionScoreDatum datum, PlayResultDataRequest.StageData.AiStageSectionData sectionData)
{
var crown = (CrownType)sectionData.Crown;
if (crown == CrownType.Gold && sectionData.OkCnt == 0)
{
crown = CrownType.Dondaful;
}
datum.IsWin = sectionData.IsWin ? sectionData.IsWin : datum.IsWin;
datum.Crown = ValueHelpers.Max(crown, datum.Crown);
datum.Score = ValueHelpers.Max(sectionData.Score, datum.Score);
datum.GoodCount = ValueHelpers.Max(sectionData.GoodCnt, datum.GoodCount);
datum.OkCount = ValueHelpers.Min(sectionData.OkCnt, datum.OkCount);
datum.MissCount = ValueHelpers.Min(sectionData.NgCnt, datum.MissCount);
datum.DrumrollCount = ValueHelpers.Max(sectionData.PoundCnt, datum.DrumrollCount);
}
}

View File

@ -1,6 +1,7 @@
using System.Collections; using System.Collections;
using System.Collections.Specialized; using System.Collections.Specialized;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using GameDatabase.Entities;
namespace TaikoLocalServer.Common.Utils; namespace TaikoLocalServer.Common.Utils;

View File

@ -1,4 +1,5 @@
using System.Text.Json; using System.Text.Json;
using GameDatabase.Entities;
namespace TaikoLocalServer.Common.Utils; namespace TaikoLocalServer.Common.Utils;

View File

@ -1,4 +1,5 @@
using Swan.Mapping; using GameDatabase.Entities;
using Swan.Mapping;
namespace TaikoLocalServer.Common.Utils; namespace TaikoLocalServer.Common.Utils;

View File

@ -1,5 +1,4 @@
using System.Collections.Immutable; using SharedProject.Models.Responses;
using SharedProject.Models.Responses;
namespace TaikoLocalServer.Controllers.Api; namespace TaikoLocalServer.Controllers.Api;

View File

@ -1,4 +1,5 @@
using System.Text.Json; using System.Text.Json;
using GameDatabase.Entities;
using Throw; using Throw;
namespace TaikoLocalServer.Controllers.Game; namespace TaikoLocalServer.Controllers.Game;

View File

@ -1,5 +1,4 @@
using System.Runtime.InteropServices; using Microsoft.Extensions.Options;
using Microsoft.Extensions.Options;
using TaikoLocalServer.Settings; using TaikoLocalServer.Settings;
namespace TaikoLocalServer.Controllers.Game; namespace TaikoLocalServer.Controllers.Game;

View File

@ -1,4 +1,6 @@
namespace TaikoLocalServer.Controllers.Game; using GameDatabase.Entities;
namespace TaikoLocalServer.Controllers.Game;
[Route("/v12r03/chassis/getdanscore.php")] [Route("/v12r03/chassis/getdanscore.php")]
[ApiController] [ApiController]

View File

@ -1,4 +1,6 @@
namespace TaikoLocalServer.Controllers.Game; using GameDatabase.Entities;
namespace TaikoLocalServer.Controllers.Game;
[Route("/v12r03/chassis/mydonentry.php")] [Route("/v12r03/chassis/mydonentry.php")]
[ApiController] [ApiController]

View File

@ -1,6 +1,7 @@
using System.Buffers.Binary; using System.Buffers.Binary;
using System.Globalization; using System.Globalization;
using System.Text.Json; using System.Text.Json;
using GameDatabase.Entities;
using Throw; using Throw;
namespace TaikoLocalServer.Controllers.Game; namespace TaikoLocalServer.Controllers.Game;

View File

@ -1,4 +1,5 @@
using Throw; using GameDatabase.Entities;
using Throw;
namespace TaikoLocalServer.Controllers.Game; namespace TaikoLocalServer.Controllers.Game;

View File

@ -1,47 +0,0 @@
using SharedProject.Utils;
namespace TaikoLocalServer.Entities;
public class AiSectionScoreDatum
{
public uint Baid { get; set; }
public uint SongId { get; set; }
public Difficulty Difficulty { get; set; }
public int SectionIndex { get; set; }
public CrownType Crown { get; set; }
public bool IsWin { get; set; }
public uint Score { get; set; }
public uint GoodCount { get; set; }
public uint OkCount { get; set; }
public uint MissCount { get; set; }
public uint DrumrollCount { get; set; }
public AiScoreDatum Parent { get; set; } = null!;
public void UpdateBest(PlayResultDataRequest.StageData.AiStageSectionData sectionData)
{
var crown = (CrownType)sectionData.Crown;
if (crown == CrownType.Gold && sectionData.OkCnt == 0)
{
crown = CrownType.Dondaful;
}
IsWin = sectionData.IsWin ? sectionData.IsWin : IsWin;
Crown = ValueHelpers.Max(crown, Crown);
Score = ValueHelpers.Max(sectionData.Score, Score);
GoodCount = ValueHelpers.Max(sectionData.GoodCnt, GoodCount);
OkCount = ValueHelpers.Min(sectionData.OkCnt, OkCount);
MissCount = ValueHelpers.Min(sectionData.NgCnt, MissCount);
DrumrollCount = ValueHelpers.Max(sectionData.PoundCnt, DrumrollCount);
}
}

View File

@ -7,8 +7,6 @@ global using SharedProject.Enums;
global using taiko.game; global using taiko.game;
global using TaikoLocalServer.Common; global using TaikoLocalServer.Common;
global using TaikoLocalServer.Common.Utils; global using TaikoLocalServer.Common.Utils;
global using TaikoLocalServer.Context;
global using TaikoLocalServer.Entities;
global using TaikoLocalServer.Models; global using TaikoLocalServer.Models;
global using TaikoLocalServer.Services; global using TaikoLocalServer.Services;
global using TaikoLocalServer.Services.Interfaces; global using TaikoLocalServer.Services.Interfaces;

View File

@ -1,11 +1,13 @@
using System.Reflection; using System.Reflection;
using System.Security.Authentication; using System.Security.Authentication;
using GameDatabase.Context;
using Microsoft.AspNetCore.HttpOverrides; using Microsoft.AspNetCore.HttpOverrides;
using TaikoLocalServer.Middlewares; using TaikoLocalServer.Middlewares;
using TaikoLocalServer.Services.Extentions; using TaikoLocalServer.Services.Extentions;
using TaikoLocalServer.Settings; using TaikoLocalServer.Settings;
using Throw; using Throw;
using Serilog; using Serilog;
using SharedProject.Utils;
Log.Logger = new LoggerConfiguration() Log.Logger = new LoggerConfiguration()
.WriteTo.Console() .WriteTo.Console()

View File

@ -1,4 +1,6 @@
using Throw; using GameDatabase.Context;
using GameDatabase.Entities;
using Throw;
namespace TaikoLocalServer.Services; namespace TaikoLocalServer.Services;

View File

@ -1,4 +1,6 @@
using SharedProject.Models; using GameDatabase.Context;
using GameDatabase.Entities;
using SharedProject.Models;
using Swan.Mapping; using Swan.Mapping;
namespace TaikoLocalServer.Services; namespace TaikoLocalServer.Services;

View File

@ -1,4 +1,7 @@
namespace TaikoLocalServer.Services; using GameDatabase.Context;
using GameDatabase.Entities;
namespace TaikoLocalServer.Services;
public class DanScoreDatumService : IDanScoreDatumService public class DanScoreDatumService : IDanScoreDatumService
{ {

View File

@ -3,6 +3,7 @@ using System.Text.Json;
using ICSharpCode.SharpZipLib.GZip; using ICSharpCode.SharpZipLib.GZip;
using Microsoft.Extensions.Options; using Microsoft.Extensions.Options;
using SharedProject.Models; using SharedProject.Models;
using SharedProject.Utils;
using Swan.Mapping; using Swan.Mapping;
using TaikoLocalServer.Settings; using TaikoLocalServer.Settings;
using Throw; using Throw;

View File

@ -1,4 +1,6 @@
namespace TaikoLocalServer.Services.Interfaces; using GameDatabase.Entities;
namespace TaikoLocalServer.Services.Interfaces;
public interface IAiDatumService public interface IAiDatumService
{ {

View File

@ -1,4 +1,5 @@
using SharedProject.Models; using GameDatabase.Entities;
using SharedProject.Models;
namespace TaikoLocalServer.Services.Interfaces; namespace TaikoLocalServer.Services.Interfaces;

View File

@ -1,4 +1,6 @@
namespace TaikoLocalServer.Services.Interfaces; using GameDatabase.Entities;
namespace TaikoLocalServer.Services.Interfaces;
public interface IDanScoreDatumService public interface IDanScoreDatumService
{ {

View File

@ -1,4 +1,5 @@
using SharedProject.Models; using GameDatabase.Entities;
using SharedProject.Models;
namespace TaikoLocalServer.Services.Interfaces; namespace TaikoLocalServer.Services.Interfaces;

View File

@ -1,4 +1,6 @@
namespace TaikoLocalServer.Services.Interfaces; using GameDatabase.Entities;
namespace TaikoLocalServer.Services.Interfaces;
public interface ISongPlayDatumService public interface ISongPlayDatumService
{ {

View File

@ -1,4 +1,6 @@
namespace TaikoLocalServer.Services.Interfaces; using GameDatabase.Entities;
namespace TaikoLocalServer.Services.Interfaces;
public interface IUserDatumService public interface IUserDatumService
{ {

View File

@ -1,4 +1,6 @@
using SharedProject.Models; using GameDatabase.Context;
using GameDatabase.Entities;
using SharedProject.Models;
using Swan.Mapping; using Swan.Mapping;
using Throw; using Throw;

View File

@ -1,4 +1,7 @@
namespace TaikoLocalServer.Services; using GameDatabase.Context;
using GameDatabase.Entities;
namespace TaikoLocalServer.Services;
class SongPlayDatumService : ISongPlayDatumService class SongPlayDatumService : ISongPlayDatumService
{ {

View File

@ -1,4 +1,6 @@
using System.Text.Json; using System.Text.Json;
using GameDatabase.Context;
using GameDatabase.Entities;
using Throw; using Throw;
namespace TaikoLocalServer.Services; namespace TaikoLocalServer.Services;

View File

@ -76,6 +76,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\GameDatabase\GameDatabase.csproj" />
<ProjectReference Include="..\SharedProject\SharedProject.csproj" /> <ProjectReference Include="..\SharedProject\SharedProject.csproj" />
<ProjectReference Include="..\TaikoWebUI\TaikoWebUI.csproj" /> <ProjectReference Include="..\TaikoWebUI\TaikoWebUI.csproj" />
</ItemGroup> </ItemGroup>