Move database to separate project, add migration tool prototype
This commit is contained in:
parent
e30d362e63
commit
e55230dc91
@ -1,4 +1,8 @@
|
||||
namespace TaikoLocalServer.Context
|
||||
using GameDatabase.Entities;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using SharedProject.Utils;
|
||||
|
||||
namespace GameDatabase.Context
|
||||
{
|
||||
public partial class TaikoDbContext : DbContext
|
||||
{
|
||||
@ -22,7 +26,7 @@
|
||||
{
|
||||
return;
|
||||
}
|
||||
var path = Path.Combine(PathHelper.GetRootPath(), Constants.DEFAULT_DB_NAME);
|
||||
var path = Path.Combine(PathHelper.GetRootPath(), "taiko.db3");
|
||||
optionsBuilder.UseSqlite($"Data Source={path}");
|
||||
}
|
||||
|
@ -1,4 +1,8 @@
|
||||
namespace TaikoLocalServer.Context;
|
||||
using GameDatabase.Entities;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using SharedProject.Enums;
|
||||
|
||||
namespace GameDatabase.Context;
|
||||
|
||||
public partial class TaikoDbContext
|
||||
{
|
@ -1,4 +1,6 @@
|
||||
namespace TaikoLocalServer.Entities;
|
||||
using SharedProject.Enums;
|
||||
|
||||
namespace GameDatabase.Entities;
|
||||
|
||||
public class AiScoreDatum
|
||||
{
|
30
GameDatabase/Entities/AiSectionScoreDatum.cs
Normal file
30
GameDatabase/Entities/AiSectionScoreDatum.cs
Normal 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!;
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
namespace TaikoLocalServer.Entities
|
||||
namespace GameDatabase.Entities
|
||||
{
|
||||
public partial class Card
|
||||
{
|
@ -1,4 +1,6 @@
|
||||
namespace TaikoLocalServer.Entities;
|
||||
using SharedProject.Enums;
|
||||
|
||||
namespace GameDatabase.Entities;
|
||||
|
||||
public class DanScoreDatum
|
||||
{
|
@ -1,4 +1,4 @@
|
||||
namespace TaikoLocalServer.Entities;
|
||||
namespace GameDatabase.Entities;
|
||||
|
||||
public class DanStageScoreDatum
|
||||
{
|
@ -1,4 +1,6 @@
|
||||
namespace TaikoLocalServer.Entities
|
||||
using SharedProject.Enums;
|
||||
|
||||
namespace GameDatabase.Entities
|
||||
{
|
||||
public partial class SongBestDatum
|
||||
{
|
@ -1,4 +1,6 @@
|
||||
namespace TaikoLocalServer.Entities;
|
||||
using SharedProject.Enums;
|
||||
|
||||
namespace GameDatabase.Entities;
|
||||
|
||||
public partial class SongBestDatum
|
||||
{
|
@ -1,4 +1,6 @@
|
||||
namespace TaikoLocalServer.Entities
|
||||
using SharedProject.Enums;
|
||||
|
||||
namespace GameDatabase.Entities
|
||||
{
|
||||
public partial class SongPlayDatum
|
||||
{
|
@ -1,4 +1,6 @@
|
||||
namespace TaikoLocalServer.Entities
|
||||
using SharedProject.Enums;
|
||||
|
||||
namespace GameDatabase.Entities
|
||||
{
|
||||
public partial class UserDatum
|
||||
{
|
22
GameDatabase/GameDatabase.csproj
Normal file
22
GameDatabase/GameDatabase.csproj
Normal 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>
|
@ -1,10 +1,10 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using GameDatabase.Context;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using TaikoLocalServer.Context;
|
||||
|
||||
#nullable disable
|
||||
|
@ -1,10 +1,10 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using GameDatabase.Context;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using TaikoLocalServer.Context;
|
||||
|
||||
#nullable disable
|
||||
|
@ -1,10 +1,10 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using GameDatabase.Context;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using TaikoLocalServer.Context;
|
||||
|
||||
#nullable disable
|
||||
|
@ -1,10 +1,10 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using GameDatabase.Context;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using TaikoLocalServer.Context;
|
||||
|
||||
#nullable disable
|
||||
|
@ -1,10 +1,10 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using GameDatabase.Context;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using TaikoLocalServer.Context;
|
||||
|
||||
#nullable disable
|
||||
|
@ -1,10 +1,10 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using GameDatabase.Context;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using TaikoLocalServer.Context;
|
||||
|
||||
#nullable disable
|
||||
|
@ -1,10 +1,10 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using GameDatabase.Context;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using TaikoLocalServer.Context;
|
||||
|
||||
#nullable disable
|
||||
|
@ -1,10 +1,10 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using GameDatabase.Context;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using TaikoLocalServer.Context;
|
||||
|
||||
#nullable disable
|
||||
|
@ -1,10 +1,10 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using GameDatabase.Context;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using TaikoLocalServer.Context;
|
||||
|
||||
#nullable disable
|
||||
|
@ -1,10 +1,10 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using GameDatabase.Context;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using TaikoLocalServer.Context;
|
||||
|
||||
#nullable disable
|
||||
|
@ -1,10 +1,10 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using GameDatabase.Context;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using TaikoLocalServer.Context;
|
||||
|
||||
#nullable disable
|
||||
|
@ -1,10 +1,10 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using GameDatabase.Context;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using TaikoLocalServer.Context;
|
||||
|
||||
#nullable disable
|
||||
|
@ -1,9 +1,9 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using GameDatabase.Context;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using TaikoLocalServer.Context;
|
||||
|
||||
#nullable disable
|
||||
|
21
LocalSaveModScoreMigrator/DateTimeConverter.cs
Normal file
21
LocalSaveModScoreMigrator/DateTimeConverter.cs
Normal 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));
|
||||
}
|
||||
}
|
24
LocalSaveModScoreMigrator/LocalSaveModScoreMigrator.csproj
Normal file
24
LocalSaveModScoreMigrator/LocalSaveModScoreMigrator.csproj
Normal 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>
|
9
LocalSaveModScoreMigrator/MusicInfo.cs
Normal file
9
LocalSaveModScoreMigrator/MusicInfo.cs
Normal file
@ -0,0 +1,9 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace LocalSaveModScoreMigrator;
|
||||
|
||||
public class MusicInfo
|
||||
{
|
||||
[JsonPropertyName("items")]
|
||||
public List<MusicInfoEntry> Items { get; set; } = new();
|
||||
}
|
12
LocalSaveModScoreMigrator/MusicInfoEntry.cs
Normal file
12
LocalSaveModScoreMigrator/MusicInfoEntry.cs
Normal 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; }
|
||||
}
|
23
LocalSaveModScoreMigrator/PlayRecordJson.cs
Normal file
23
LocalSaveModScoreMigrator/PlayRecordJson.cs
Normal 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; }
|
||||
}
|
94
LocalSaveModScoreMigrator/Program.cs
Normal file
94
LocalSaveModScoreMigrator/Program.cs
Normal 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();
|
22
LocalSaveModScoreMigrator/ScoreRankConverter.cs
Normal file
22
LocalSaveModScoreMigrator/ScoreRankConverter.cs
Normal 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());
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
namespace TaikoLocalServer.Common.Utils;
|
||||
namespace SharedProject.Utils;
|
||||
|
||||
public static class PathHelper
|
||||
{
|
@ -9,6 +9,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharedProject", "SharedProj
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TaikoWebUI", "TaikoWebUI\TaikoWebUI.csproj", "{3F02C2B8-D970-4E8D-89AA-1B938DA6E2FE}"
|
||||
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
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
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}.Release|Any CPU.ActiveCfg = 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
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
24
TaikoLocalServer/Common/Utils/Extensions.cs
Normal file
24
TaikoLocalServer/Common/Utils/Extensions.cs
Normal 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);
|
||||
}
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Specialized;
|
||||
using System.Runtime.InteropServices;
|
||||
using GameDatabase.Entities;
|
||||
|
||||
namespace TaikoLocalServer.Common.Utils;
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
using System.Text.Json;
|
||||
using GameDatabase.Entities;
|
||||
|
||||
namespace TaikoLocalServer.Common.Utils;
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
using Swan.Mapping;
|
||||
using GameDatabase.Entities;
|
||||
using Swan.Mapping;
|
||||
|
||||
namespace TaikoLocalServer.Common.Utils;
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
using System.Collections.Immutable;
|
||||
using SharedProject.Models.Responses;
|
||||
using SharedProject.Models.Responses;
|
||||
|
||||
namespace TaikoLocalServer.Controllers.Api;
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
using System.Text.Json;
|
||||
using GameDatabase.Entities;
|
||||
using Throw;
|
||||
|
||||
namespace TaikoLocalServer.Controllers.Game;
|
||||
|
@ -1,5 +1,4 @@
|
||||
using System.Runtime.InteropServices;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Microsoft.Extensions.Options;
|
||||
using TaikoLocalServer.Settings;
|
||||
|
||||
namespace TaikoLocalServer.Controllers.Game;
|
||||
|
@ -1,4 +1,6 @@
|
||||
namespace TaikoLocalServer.Controllers.Game;
|
||||
using GameDatabase.Entities;
|
||||
|
||||
namespace TaikoLocalServer.Controllers.Game;
|
||||
|
||||
[Route("/v12r03/chassis/getdanscore.php")]
|
||||
[ApiController]
|
||||
|
@ -1,4 +1,6 @@
|
||||
namespace TaikoLocalServer.Controllers.Game;
|
||||
using GameDatabase.Entities;
|
||||
|
||||
namespace TaikoLocalServer.Controllers.Game;
|
||||
|
||||
[Route("/v12r03/chassis/mydonentry.php")]
|
||||
[ApiController]
|
||||
|
@ -1,6 +1,7 @@
|
||||
using System.Buffers.Binary;
|
||||
using System.Globalization;
|
||||
using System.Text.Json;
|
||||
using GameDatabase.Entities;
|
||||
using Throw;
|
||||
|
||||
namespace TaikoLocalServer.Controllers.Game;
|
||||
|
@ -1,4 +1,5 @@
|
||||
using Throw;
|
||||
using GameDatabase.Entities;
|
||||
using Throw;
|
||||
|
||||
namespace TaikoLocalServer.Controllers.Game;
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
@ -7,8 +7,6 @@ global using SharedProject.Enums;
|
||||
global using taiko.game;
|
||||
global using TaikoLocalServer.Common;
|
||||
global using TaikoLocalServer.Common.Utils;
|
||||
global using TaikoLocalServer.Context;
|
||||
global using TaikoLocalServer.Entities;
|
||||
global using TaikoLocalServer.Models;
|
||||
global using TaikoLocalServer.Services;
|
||||
global using TaikoLocalServer.Services.Interfaces;
|
@ -1,11 +1,13 @@
|
||||
using System.Reflection;
|
||||
using System.Security.Authentication;
|
||||
using GameDatabase.Context;
|
||||
using Microsoft.AspNetCore.HttpOverrides;
|
||||
using TaikoLocalServer.Middlewares;
|
||||
using TaikoLocalServer.Services.Extentions;
|
||||
using TaikoLocalServer.Settings;
|
||||
using Throw;
|
||||
using Serilog;
|
||||
using SharedProject.Utils;
|
||||
|
||||
Log.Logger = new LoggerConfiguration()
|
||||
.WriteTo.Console()
|
||||
|
@ -1,4 +1,6 @@
|
||||
using Throw;
|
||||
using GameDatabase.Context;
|
||||
using GameDatabase.Entities;
|
||||
using Throw;
|
||||
|
||||
namespace TaikoLocalServer.Services;
|
||||
|
||||
|
@ -1,4 +1,6 @@
|
||||
using SharedProject.Models;
|
||||
using GameDatabase.Context;
|
||||
using GameDatabase.Entities;
|
||||
using SharedProject.Models;
|
||||
using Swan.Mapping;
|
||||
|
||||
namespace TaikoLocalServer.Services;
|
||||
|
@ -1,4 +1,7 @@
|
||||
namespace TaikoLocalServer.Services;
|
||||
using GameDatabase.Context;
|
||||
using GameDatabase.Entities;
|
||||
|
||||
namespace TaikoLocalServer.Services;
|
||||
|
||||
public class DanScoreDatumService : IDanScoreDatumService
|
||||
{
|
||||
|
@ -3,6 +3,7 @@ using System.Text.Json;
|
||||
using ICSharpCode.SharpZipLib.GZip;
|
||||
using Microsoft.Extensions.Options;
|
||||
using SharedProject.Models;
|
||||
using SharedProject.Utils;
|
||||
using Swan.Mapping;
|
||||
using TaikoLocalServer.Settings;
|
||||
using Throw;
|
||||
|
@ -1,4 +1,6 @@
|
||||
namespace TaikoLocalServer.Services.Interfaces;
|
||||
using GameDatabase.Entities;
|
||||
|
||||
namespace TaikoLocalServer.Services.Interfaces;
|
||||
|
||||
public interface IAiDatumService
|
||||
{
|
||||
|
@ -1,4 +1,5 @@
|
||||
using SharedProject.Models;
|
||||
using GameDatabase.Entities;
|
||||
using SharedProject.Models;
|
||||
|
||||
namespace TaikoLocalServer.Services.Interfaces;
|
||||
|
||||
|
@ -1,4 +1,6 @@
|
||||
namespace TaikoLocalServer.Services.Interfaces;
|
||||
using GameDatabase.Entities;
|
||||
|
||||
namespace TaikoLocalServer.Services.Interfaces;
|
||||
|
||||
public interface IDanScoreDatumService
|
||||
{
|
||||
|
@ -1,4 +1,5 @@
|
||||
using SharedProject.Models;
|
||||
using GameDatabase.Entities;
|
||||
using SharedProject.Models;
|
||||
|
||||
namespace TaikoLocalServer.Services.Interfaces;
|
||||
|
||||
|
@ -1,4 +1,6 @@
|
||||
namespace TaikoLocalServer.Services.Interfaces;
|
||||
using GameDatabase.Entities;
|
||||
|
||||
namespace TaikoLocalServer.Services.Interfaces;
|
||||
|
||||
public interface ISongPlayDatumService
|
||||
{
|
||||
|
@ -1,4 +1,6 @@
|
||||
namespace TaikoLocalServer.Services.Interfaces;
|
||||
using GameDatabase.Entities;
|
||||
|
||||
namespace TaikoLocalServer.Services.Interfaces;
|
||||
|
||||
public interface IUserDatumService
|
||||
{
|
||||
|
@ -1,4 +1,6 @@
|
||||
using SharedProject.Models;
|
||||
using GameDatabase.Context;
|
||||
using GameDatabase.Entities;
|
||||
using SharedProject.Models;
|
||||
using Swan.Mapping;
|
||||
using Throw;
|
||||
|
||||
|
@ -1,4 +1,7 @@
|
||||
namespace TaikoLocalServer.Services;
|
||||
using GameDatabase.Context;
|
||||
using GameDatabase.Entities;
|
||||
|
||||
namespace TaikoLocalServer.Services;
|
||||
|
||||
class SongPlayDatumService : ISongPlayDatumService
|
||||
{
|
||||
|
@ -1,4 +1,6 @@
|
||||
using System.Text.Json;
|
||||
using GameDatabase.Context;
|
||||
using GameDatabase.Entities;
|
||||
using Throw;
|
||||
|
||||
namespace TaikoLocalServer.Services;
|
||||
|
@ -76,6 +76,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\GameDatabase\GameDatabase.csproj" />
|
||||
<ProjectReference Include="..\SharedProject\SharedProject.csproj" />
|
||||
<ProjectReference Include="..\TaikoWebUI\TaikoWebUI.csproj" />
|
||||
</ItemGroup>
|
||||
|
Loading…
Reference in New Issue
Block a user