1
0
mirror of synced 2025-01-31 12:23:50 +01:00

Add dan save (test)

This commit is contained in:
asesidaa 2022-08-29 20:46:28 +08:00
parent e5141d7e37
commit e3099153d4
19 changed files with 1120 additions and 99 deletions

View File

@ -23,4 +23,8 @@ public static class Constants
public const string MUSIC_ATTRIBUTE_FILE_NAME = "music_attribute.json";
public const string DAN_DATA_FILE_NAME = "dan_data.json";
public const int MIN_DAN_ID = 1;
public const int MAX_DAN_ID = 19;
public const int GOT_DAN_BITS = MAX_DAN_ID * 4;
}

View File

@ -0,0 +1,12 @@
namespace TaikoLocalServer.Common.Enums;
public enum DanClearState
{
NotClear = 0,
RedNormalClear,
RedFullComboClear,
RedPerfectClear,
GoldNormalClear,
GoldFullComboClear,
GoldPerfectClear,
}

View File

@ -0,0 +1,9 @@
namespace TaikoLocalServer.Common.Enums;
public enum PlayMode
{
Normal = 0,
DanMode = 1,
// Not sure about this
AiBattle = 2
}

View File

@ -1,4 +1,7 @@
namespace TaikoLocalServer.Common;
using System.Collections.Specialized;
using System.Runtime.InteropServices;
namespace TaikoLocalServer.Common;
public static class FlagCalculator
{
@ -64,4 +67,43 @@ public static class FlagCalculator
return (ushort)(previous | result);
}
public static byte[] ComputeGotDanFlags(List<DanScoreDatum> danScoreData)
{
var gotDanFlagList = new List<int>();
var gotDanFlag = new BitVector32();
var section1 = BitVector32.CreateSection(8);
var section2 = BitVector32.CreateSection(8, section1);
var section3 = BitVector32.CreateSection(8, section2);
var section4 = BitVector32.CreateSection(8, section3);
var section5 = BitVector32.CreateSection(8, section4);
var section6 = BitVector32.CreateSection(8, section5);
var section7 = BitVector32.CreateSection(8, section6);
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++)
{
var danId = i;
var flag = 0;
if (danScoreData.Any(datum => datum.DanId == danId))
{
var danScore = danScoreData.First(datum => datum.DanId == danId);
flag = (int)danScore.ClearState + 1;
}
var section = sections[(danId - 1) % 8];
gotDanFlag[section] = flag;
if (!section.Equals(section8))
{
continue;
}
gotDanFlagList.Add(gotDanFlag.Data);
gotDanFlag = new BitVector32();
}
gotDanFlagList.Add(gotDanFlag.Data);
return MemoryMarshal.AsBytes(new ReadOnlySpan<int>(gotDanFlagList.ToArray())).ToArray();
}
}

View File

@ -0,0 +1,23 @@
using Swan.Mapping;
namespace TaikoLocalServer.Common.Utils;
public static class ObjectMappers
{
public static readonly IObjectMap<DanStageScoreDatum, GetDanScoreResponse.DanScoreData.DanScoreDataStage> DanStageDataMap;
static ObjectMappers()
{
var mapper = new ObjectMapper();
DanStageDataMap = mapper.AddMap<DanStageScoreDatum, GetDanScoreResponse.DanScoreData.DanScoreDataStage>()
.Add(t => t.ComboCnt, s => s.ComboCount)
.Add(t => t.GoodCnt, s => s.GoodCount)
.Add(t => t.OkCnt, s => s.OkCount)
.Add(t => t.NgCnt, s => s.BadCount)
.Add(t => t.HitCnt, s => s.TotalHitCount)
.Add(t => t.PoundCnt, s => s.DrumrollCount)
.Add(t => t.PlayScore, s => s.PlayScore)
.Add(t => t.HighScore, s => s.HighScore);
}
}

View File

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

View File

@ -12,12 +12,14 @@ public partial class TaikoDbContext
modelBuilder.Entity<DanScoreDatum>(entity =>
{
entity.HasKey(e => new { e.Baid, e.DanId });
entity.HasOne(d => d.Ba)
.WithMany()
.HasPrincipalKey(p => p.Baid)
.HasForeignKey(d => d.Baid)
.OnDelete(DeleteBehavior.Cascade);
entity.Property(e => e.ClearState).HasConversion<uint>().HasDefaultValue(DanClearState.NotClear);
});
modelBuilder.Entity<DanStageScoreDatum>(entity =>
@ -26,8 +28,8 @@ public partial class TaikoDbContext
entity.HasOne(d => d.Parent)
.WithMany()
.HasPrincipalKey(p => p.Baid)
.HasForeignKey(d => d.Baid)
.HasPrincipalKey(p => new {p.Baid, p.DanId})
.HasForeignKey(d => new {d.Baid, d.DanId})
.OnDelete(DeleteBehavior.Cascade);
});
}

View File

@ -1,4 +1,6 @@
using System.Text.Json;
using System.Collections;
using System.Collections.Specialized;
using System.Text.Json;
namespace TaikoLocalServer.Controllers;
@ -105,6 +107,14 @@ public class BaidController:ControllerBase
var costumeFlag = new byte[10];
Array.Fill(costumeFlag, byte.MaxValue);
var danData = context.DanScoreData.Where(datum => datum.Baid == baid).ToList();
var maxDan = danData.Where(datum => datum.ClearState != DanClearState.NotClear)
.Select(datum => datum.DanId)
.DefaultIfEmpty()
.Max();
var gotDanFlagArray = FlagCalculator.ComputeGotDanFlags(danData);
logger.LogInformation("Got dan array {Array}", gotDanFlagArray.Stringify());
response = new BAIDResponse
{
Result = 1,
@ -138,9 +148,9 @@ public class BaidController:ControllerBase
CostumeFlg4 = costumeFlag,
CostumeFlg5 = costumeFlag,
LastPlayDatetime = userData.LastPlayDatetime.ToString(Constants.DATE_TIME_FORMAT),
IsDispDanOn = userData.DisplayDan,
GotDanMax = 1,
GotDanFlg = new byte[20],
IsDispDanOn = /*userData.DisplayDan*/ true,
GotDanMax = maxDan,
GotDanFlg = gotDanFlagArray,
GotDanextraFlg = new byte[20],
DefaultToneSetting = 0,
GenericInfoFlg = new byte[10],

View File

@ -1,12 +1,20 @@
namespace TaikoLocalServer.Controllers;
using Microsoft.EntityFrameworkCore;
using Swan.Mapping;
[Route("api/[controller]")]
namespace TaikoLocalServer.Controllers;
[Route("/v12r03/chassis/getdanscore.php")]
[ApiController]
public class GetDanScoreController : ControllerBase
{
private readonly ILogger<GetDanScoreController> logger;
public GetDanScoreController(ILogger<GetDanScoreController> logger) {
private readonly TaikoDbContext context;
public GetDanScoreController(ILogger<GetDanScoreController> logger, TaikoDbContext context)
{
this.logger = logger;
this.context = context;
}
[HttpPost]
@ -20,6 +28,30 @@ public class GetDanScoreController : ControllerBase
Result = 1
};
var danScoreData = context.DanScoreData
.Where(datum => datum.Baid == request.Baid)
.Include(datum => datum.DanStageScoreData)
.ToList();
foreach (var danId in request.DanIds)
{
var datum = danScoreData.FirstOrDefault(scoreDatum => scoreDatum.DanId == danId, new DanScoreDatum());
var responseData = new GetDanScoreResponse.DanScoreData
{
DanId = danId,
ArrivalSongCnt = datum.ArrivalSongCount,
ComboCntTotal = datum.ComboCountTotal,
SoulGaugeTotal = datum.SoulGaugeTotal
};
foreach (var stageScoreDatum in datum.DanStageScoreData)
{
responseData.AryDanScoreDataStages.Add(ObjectMappers.DanStageDataMap.Apply(stageScoreDatum));
}
response.AryDanScoreDatas.Add(responseData);
}
return Ok(response);
}
}

View File

@ -31,12 +31,12 @@ public class InitialDataCheckController : ControllerBase
bitSet.CopyTo(enabledArray, 0);
var danData = new List<InitialdatacheckResponse.InformationData>();
for (var danId = 1; danId <= 19; danId++)
for (var danId = Constants.MIN_DAN_ID; danId <= Constants.MAX_DAN_ID; danId++)
{
danData.Add(new InitialdatacheckResponse.InformationData
{
InfoId = (uint)danId,
VerupNo = 0
VerupNo = 1
});
}

View File

@ -1,5 +1,6 @@
namespace TaikoLocalServer.Controllers;
[ApiController]
public class MuchaController : ControllerBase
{
private const string UrlBase = "https://v402-front.mucha-prd.nbgi-amnet.jp:10122";

View File

@ -11,7 +11,7 @@ public class PlayResultController : ControllerBase
private readonly ILogger<PlayResultController> logger;
private readonly TaikoDbContext context;
public PlayResultController(ILogger<PlayResultController> logger, TaikoDbContext context)
{
this.logger = logger;
@ -26,9 +26,142 @@ public class PlayResultController : ControllerBase
var decompressed = GZipBytesUtil.DecompressGZipBytes(request.PlayresultData);
var playResultData = Serializer.Deserialize<PlayResultDataRequest>(new ReadOnlySpan<byte>(decompressed));
logger.LogInformation("Play result data {Data}", playResultData.Stringify());
var response = new PlayResultResponse
{
Result = 1
};
var lastPlayDatetime = DateTime.ParseExact(playResultData.PlayDatetime, Constants.DATE_TIME_FORMAT, CultureInfo.InvariantCulture);
UpdateUserData(request, playResultData, lastPlayDatetime);
var playMode = (PlayMode)playResultData.PlayMode;
if (playMode == PlayMode.DanMode)
{
UpdateDanPlayData(request, playResultData);
context.SaveChanges();
return Ok(response);
}
var bestData = context.SongBestData.Where(datum => datum.Baid == request.BaidConf).ToList();
for (var songNumber = 0; songNumber < playResultData.AryStageInfoes.Count; songNumber++)
{
var stageData = playResultData.AryStageInfoes[songNumber];
UpdateBestData(request, stageData, bestData);
UpdatePlayData(request, songNumber, stageData, lastPlayDatetime);
}
context.SaveChanges();
return Ok(response);
}
private void UpdateDanPlayData(PlayResultRequest request, PlayResultDataRequest playResultDataRequest)
{
if (playResultDataRequest.IsNotRecordedDan)
{
return;
}
var danScoreDataQuery = context.DanScoreData
.Where(datum => datum.Baid == request.BaidConf &&
datum.DanId == playResultDataRequest.DanId);
var danScoreData = new DanScoreDatum
{
Baid = request.BaidConf,
DanId = playResultDataRequest.DanId
};
var insert = true;
if (danScoreDataQuery.Any())
{
danScoreData = danScoreDataQuery.First();
insert = false;
}
danScoreData.ClearState = (DanClearState)playResultDataRequest.DanResult;
danScoreData.ArrivalSongCount = (uint)playResultDataRequest.AryStageInfoes.Count;
danScoreData.ComboCountTotal = playResultDataRequest.ComboCntTotal;
danScoreData.SoulGaugeTotal = playResultDataRequest.SoulGaugeTotal;
UpdateDanStageData(playResultDataRequest, danScoreData);
if (insert)
{
context.DanScoreData.Add(danScoreData);
return;
}
context.DanScoreData.Update(danScoreData);
}
private void UpdateDanStageData(PlayResultDataRequest playResultDataRequest, DanScoreDatum danScoreData)
{
for (var songNumber = 0; songNumber < playResultDataRequest.AryStageInfoes.Count; songNumber++)
{
var stageData = playResultDataRequest.AryStageInfoes[songNumber];
var add = true;
var danStageData = new DanStageScoreDatum
{
Baid = danScoreData.Baid,
DanId = danScoreData.DanId,
SongNumber = (uint)songNumber
};
if (danScoreData.DanStageScoreData.Any(datum => datum.SongNumber == songNumber))
{
danStageData = danScoreData.DanStageScoreData.First(datum => datum.SongNumber == songNumber);
add = false;
}
if (danStageData.HighScore >= stageData.PlayScore)
{
continue;
}
danStageData.GoodCount = stageData.GoodCnt;
danStageData.OkCount = stageData.OkCnt;
danStageData.BadCount = stageData.NgCnt;
danStageData.PlayScore = stageData.PlayScore;
danStageData.HighScore = stageData.PlayScore;
danStageData.ComboCount = stageData.ComboCnt;
danStageData.TotalHitCount = stageData.HitCnt;
danStageData.DrumrollCount = stageData.PoundCnt;
if (add)
{
context.DanStageScoreData.Add(danStageData);
// danScoreData.DanStageScoreData.Add(danStageData);
continue;
}
context.DanStageScoreData.Update(danStageData);
// danScoreData.DanStageScoreData[songNumber] = danStageData;
}
}
private void UpdatePlayData(PlayResultRequest request, int songNumber, PlayResultDataRequest.StageData stageData, DateTime lastPlayDatetime)
{
var playData = new SongPlayDatum
{
Baid = request.BaidConf,
SongNumber = (uint)songNumber,
GoodCount = stageData.GoodCnt,
OkCount = stageData.OkCnt,
MissCount = stageData.NgCnt,
ComboCount = stageData.ComboCnt,
HitCount = stageData.HitCnt,
Crown = PlayResultToCrown(stageData),
Score = stageData.PlayScore,
ScoreRate = stageData.ScoreRate,
ScoreRank = (ScoreRank)stageData.ScoreRank,
Skipped = stageData.IsSkipUse,
SongId = stageData.SongNo,
PlayTime = lastPlayDatetime,
Difficulty = (Difficulty)stageData.Level
};
context.SongPlayData.Add(playData);
}
private void UpdateUserData(PlayResultRequest request, PlayResultDataRequest playResultData, DateTime lastPlayDatetime)
{
var userdata = new UserDatum
{
Baid = request.BaidConf
@ -50,75 +183,50 @@ public class PlayResultController : ControllerBase
};
userdata.CostumeData = JsonSerializer.Serialize(costumeData);
var lastPlayDatetime = DateTime.ParseExact(playResultData.PlayDatetime, Constants.DATE_TIME_FORMAT, CultureInfo.InvariantCulture);
userdata.LastPlayDatetime = lastPlayDatetime;
context.UserData.Update(userdata);
var bestData = context.SongBestData.Where(datum => datum.Baid == request.BaidConf).ToList();
for (var songNumber = 0; songNumber < playResultData.AryStageInfoes.Count; songNumber++)
}
private void UpdateBestData(PlayResultRequest request, PlayResultDataRequest.StageData stageData, IEnumerable<SongBestDatum> bestData)
{
var insert = false;
var data = stageData;
var bestDatum = bestData
.FirstOrDefault(datum => datum.SongId == data.SongNo &&
datum.Difficulty == (Difficulty)data.Level);
// Determine whether it is dondaful crown as this is not reflected by play result
var crown = PlayResultToCrown(stageData);
if (bestDatum is null)
{
var stageData = playResultData.AryStageInfoes[songNumber];
var insert = false;
var bestDatum = bestData
.FirstOrDefault(datum => datum.SongId == stageData.SongNo &&
datum.Difficulty == (Difficulty)stageData.Level);
// Determine whether it is dondaful crown as this is not reflected by play result
var crown = (CrownType)stageData.PlayResult;
if (crown == CrownType.Gold && stageData.OkCnt == 0)
{
crown = CrownType.Dondaful;
}
if (bestDatum is null)
{
insert = true;
bestDatum = new SongBestDatum
{
Baid = request.BaidConf,
SongId = stageData.SongNo,
Difficulty = (Difficulty)stageData.Level
};
}
bestDatum.UpdateBestData(crown, stageData.ScoreRank, stageData.PlayScore, stageData.ScoreRate);
if (insert)
{
context.SongBestData.Add(bestDatum);
}
else
{
context.SongBestData.Update(bestDatum);
}
var playData = new SongPlayDatum
insert = true;
bestDatum = new SongBestDatum
{
Baid = request.BaidConf,
SongNumber = (uint)songNumber,
GoodCount = stageData.GoodCnt,
OkCount = stageData.OkCnt,
MissCount = stageData.NgCnt,
ComboCount = stageData.ComboCnt,
HitCount = stageData.HitCnt,
Crown = crown,
Score = stageData.PlayScore,
ScoreRate = stageData.ScoreRate,
ScoreRank = (ScoreRank)stageData.ScoreRank,
Skipped = stageData.IsSkipUse,
SongId = stageData.SongNo,
PlayTime = lastPlayDatetime,
Difficulty = (Difficulty)stageData.Level
};
context.SongPlayData.Add(playData);
}
context.SaveChanges();
var response = new PlayResultResponse
{
Result = 1
};
bestDatum.UpdateBestData(crown, stageData.ScoreRank, stageData.PlayScore, stageData.ScoreRate);
return Ok(response);
if (insert)
{
context.SongBestData.Add(bestDatum);
}
else
{
context.SongBestData.Update(bestDatum);
}
}
private static CrownType PlayResultToCrown(PlayResultDataRequest.StageData stageData)
{
var crown = (CrownType)stageData.PlayResult;
if (crown == CrownType.Gold && stageData.OkCnt == 0)
{
crown = CrownType.Dondaful;
}
return crown;
}
}

View File

@ -7,6 +7,7 @@ public class DanScoreDatum
public uint ArrivalSongCount { get; set; }
public uint SoulGaugeTotal { get; set; }
public uint ComboCountTotal { get; set; }
public DanClearState ClearState { get; set; }
public List<DanStageScoreDatum> DanStageScoreData { get; set; } = new();
public virtual Card? Ba { get; set; }

View File

@ -0,0 +1,327 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using TaikoLocalServer.Context;
#nullable disable
namespace TaikoLocalServer.Migrations
{
[DbContext(typeof(TaikoDbContext))]
[Migration("20220828171353_AddClearState")]
partial class AddClearState
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "7.0.0-preview.7.22376.2");
modelBuilder.Entity("TaikoLocalServer.Entities.Card", b =>
{
b.Property<string>("AccessCode")
.HasColumnType("TEXT");
b.Property<uint>("Baid")
.HasColumnType("INTEGER");
b.HasKey("AccessCode");
b.HasIndex(new[] { "Baid" }, "IX_Card_Baid")
.IsUnique();
b.ToTable("Card", (string)null);
});
modelBuilder.Entity("TaikoLocalServer.Entities.DanScoreDatum", b =>
{
b.Property<uint>("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("TaikoLocalServer.Entities.DanStageScoreDatum", b =>
{
b.Property<uint>("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("TaikoLocalServer.Entities.SongBestDatum", b =>
{
b.Property<uint>("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("TaikoLocalServer.Entities.SongPlayDatum", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<uint>("Baid")
.HasColumnType("INTEGER");
b.Property<uint>("ComboCount")
.HasColumnType("INTEGER");
b.Property<uint>("Crown")
.HasColumnType("INTEGER");
b.Property<uint>("Difficulty")
.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("TaikoLocalServer.Entities.UserDatum", b =>
{
b.Property<uint>("Baid")
.HasColumnType("INTEGER");
b.Property<uint>("AchievementDisplayDifficulty")
.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<bool>("DisplayAchievement")
.HasColumnType("INTEGER");
b.Property<bool>("DisplayDan")
.HasColumnType("INTEGER");
b.Property<string>("FavoriteSongsArray")
.IsRequired()
.HasColumnType("TEXT");
b.Property<bool>("IsSkipOn")
.HasColumnType("INTEGER");
b.Property<bool>("IsVoiceOn")
.HasColumnType("INTEGER");
b.Property<DateTime>("LastPlayDatetime")
.HasColumnType("datetime");
b.Property<long>("LastPlayMode")
.HasColumnType("INTEGER");
b.Property<string>("MyDonName")
.IsRequired()
.HasColumnType("TEXT");
b.Property<int>("OptionSetting")
.HasColumnType("INTEGER");
b.Property<string>("Title")
.IsRequired()
.HasColumnType("TEXT");
b.Property<uint>("TitlePlateId")
.HasColumnType("INTEGER");
b.HasKey("Baid");
b.ToTable("UserData");
});
modelBuilder.Entity("TaikoLocalServer.Entities.DanScoreDatum", b =>
{
b.HasOne("TaikoLocalServer.Entities.Card", "Ba")
.WithMany()
.HasForeignKey("Baid")
.HasPrincipalKey("Baid")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Ba");
});
modelBuilder.Entity("TaikoLocalServer.Entities.DanStageScoreDatum", b =>
{
b.HasOne("TaikoLocalServer.Entities.DanScoreDatum", "Parent")
.WithMany()
.HasForeignKey("Baid")
.HasPrincipalKey("Baid")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("TaikoLocalServer.Entities.DanScoreDatum", null)
.WithMany("DanStageScoreData")
.HasForeignKey("Baid", "DanId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Parent");
});
modelBuilder.Entity("TaikoLocalServer.Entities.SongBestDatum", b =>
{
b.HasOne("TaikoLocalServer.Entities.Card", "Ba")
.WithMany()
.HasForeignKey("Baid")
.HasPrincipalKey("Baid")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Ba");
});
modelBuilder.Entity("TaikoLocalServer.Entities.SongPlayDatum", b =>
{
b.HasOne("TaikoLocalServer.Entities.Card", "Ba")
.WithMany()
.HasForeignKey("Baid")
.HasPrincipalKey("Baid")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Ba");
});
modelBuilder.Entity("TaikoLocalServer.Entities.UserDatum", b =>
{
b.HasOne("TaikoLocalServer.Entities.Card", "Ba")
.WithMany()
.HasForeignKey("Baid")
.HasPrincipalKey("Baid")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Ba");
});
modelBuilder.Entity("TaikoLocalServer.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 AddClearState : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<uint>(
name: "ClearState",
table: "DanScoreData",
type: "INTEGER",
nullable: false,
defaultValue: 0u);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "ClearState",
table: "DanScoreData");
}
}
}

View File

@ -0,0 +1,332 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using TaikoLocalServer.Context;
#nullable disable
namespace TaikoLocalServer.Migrations
{
[DbContext(typeof(TaikoDbContext))]
[Migration("20220829101052_AdjustDanDb")]
partial class AdjustDanDb
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "7.0.0-preview.7.22376.2");
modelBuilder.Entity("TaikoLocalServer.Entities.Card", b =>
{
b.Property<string>("AccessCode")
.HasColumnType("TEXT");
b.Property<uint>("Baid")
.HasColumnType("INTEGER");
b.HasKey("AccessCode");
b.HasIndex(new[] { "Baid" }, "IX_Card_Baid")
.IsUnique();
b.ToTable("Card", (string)null);
});
modelBuilder.Entity("TaikoLocalServer.Entities.DanScoreDatum", b =>
{
b.Property<uint>("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("TaikoLocalServer.Entities.DanStageScoreDatum", b =>
{
b.Property<uint>("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?>("DanScoreDatumBaid")
.HasColumnType("INTEGER");
b.Property<uint?>("DanScoreDatumDanId")
.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.HasIndex("DanScoreDatumBaid", "DanScoreDatumDanId");
b.ToTable("DanStageScoreData");
});
modelBuilder.Entity("TaikoLocalServer.Entities.SongBestDatum", b =>
{
b.Property<uint>("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("TaikoLocalServer.Entities.SongPlayDatum", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<uint>("Baid")
.HasColumnType("INTEGER");
b.Property<uint>("ComboCount")
.HasColumnType("INTEGER");
b.Property<uint>("Crown")
.HasColumnType("INTEGER");
b.Property<uint>("Difficulty")
.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("TaikoLocalServer.Entities.UserDatum", b =>
{
b.Property<uint>("Baid")
.HasColumnType("INTEGER");
b.Property<uint>("AchievementDisplayDifficulty")
.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<bool>("DisplayAchievement")
.HasColumnType("INTEGER");
b.Property<bool>("DisplayDan")
.HasColumnType("INTEGER");
b.Property<string>("FavoriteSongsArray")
.IsRequired()
.HasColumnType("TEXT");
b.Property<bool>("IsSkipOn")
.HasColumnType("INTEGER");
b.Property<bool>("IsVoiceOn")
.HasColumnType("INTEGER");
b.Property<DateTime>("LastPlayDatetime")
.HasColumnType("datetime");
b.Property<long>("LastPlayMode")
.HasColumnType("INTEGER");
b.Property<string>("MyDonName")
.IsRequired()
.HasColumnType("TEXT");
b.Property<int>("OptionSetting")
.HasColumnType("INTEGER");
b.Property<string>("Title")
.IsRequired()
.HasColumnType("TEXT");
b.Property<uint>("TitlePlateId")
.HasColumnType("INTEGER");
b.HasKey("Baid");
b.ToTable("UserData");
});
modelBuilder.Entity("TaikoLocalServer.Entities.DanScoreDatum", b =>
{
b.HasOne("TaikoLocalServer.Entities.Card", "Ba")
.WithMany()
.HasForeignKey("Baid")
.HasPrincipalKey("Baid")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Ba");
});
modelBuilder.Entity("TaikoLocalServer.Entities.DanStageScoreDatum", b =>
{
b.HasOne("TaikoLocalServer.Entities.DanScoreDatum", "Parent")
.WithMany()
.HasForeignKey("Baid", "DanId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("TaikoLocalServer.Entities.DanScoreDatum", null)
.WithMany("DanStageScoreData")
.HasForeignKey("DanScoreDatumBaid", "DanScoreDatumDanId");
b.Navigation("Parent");
});
modelBuilder.Entity("TaikoLocalServer.Entities.SongBestDatum", b =>
{
b.HasOne("TaikoLocalServer.Entities.Card", "Ba")
.WithMany()
.HasForeignKey("Baid")
.HasPrincipalKey("Baid")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Ba");
});
modelBuilder.Entity("TaikoLocalServer.Entities.SongPlayDatum", b =>
{
b.HasOne("TaikoLocalServer.Entities.Card", "Ba")
.WithMany()
.HasForeignKey("Baid")
.HasPrincipalKey("Baid")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Ba");
});
modelBuilder.Entity("TaikoLocalServer.Entities.UserDatum", b =>
{
b.HasOne("TaikoLocalServer.Entities.Card", "Ba")
.WithMany()
.HasForeignKey("Baid")
.HasPrincipalKey("Baid")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Ba");
});
modelBuilder.Entity("TaikoLocalServer.Entities.DanScoreDatum", b =>
{
b.Navigation("DanStageScoreData");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,79 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace TaikoLocalServer.Migrations
{
/// <inheritdoc />
public partial class AdjustDanDb : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_DanStageScoreData_DanScoreData_Baid",
table: "DanStageScoreData");
migrationBuilder.DropUniqueConstraint(
name: "AK_DanScoreData_Baid",
table: "DanScoreData");
migrationBuilder.AddColumn<uint>(
name: "DanScoreDatumBaid",
table: "DanStageScoreData",
type: "INTEGER",
nullable: true);
migrationBuilder.AddColumn<uint>(
name: "DanScoreDatumDanId",
table: "DanStageScoreData",
type: "INTEGER",
nullable: true);
migrationBuilder.CreateIndex(
name: "IX_DanStageScoreData_DanScoreDatumBaid_DanScoreDatumDanId",
table: "DanStageScoreData",
columns: new[] { "DanScoreDatumBaid", "DanScoreDatumDanId" });
migrationBuilder.AddForeignKey(
name: "FK_DanStageScoreData_DanScoreData_DanScoreDatumBaid_DanScoreDatumDanId",
table: "DanStageScoreData",
columns: new[] { "DanScoreDatumBaid", "DanScoreDatumDanId" },
principalTable: "DanScoreData",
principalColumns: new[] { "Baid", "DanId" });
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_DanStageScoreData_DanScoreData_DanScoreDatumBaid_DanScoreDatumDanId",
table: "DanStageScoreData");
migrationBuilder.DropIndex(
name: "IX_DanStageScoreData_DanScoreDatumBaid_DanScoreDatumDanId",
table: "DanStageScoreData");
migrationBuilder.DropColumn(
name: "DanScoreDatumBaid",
table: "DanStageScoreData");
migrationBuilder.DropColumn(
name: "DanScoreDatumDanId",
table: "DanStageScoreData");
migrationBuilder.AddUniqueConstraint(
name: "AK_DanScoreData_Baid",
table: "DanScoreData",
column: "Baid");
migrationBuilder.AddForeignKey(
name: "FK_DanStageScoreData_DanScoreData_Baid",
table: "DanStageScoreData",
column: "Baid",
principalTable: "DanScoreData",
principalColumn: "Baid",
onDelete: ReferentialAction.Cascade);
}
}
}

View File

@ -44,6 +44,11 @@ namespace TaikoLocalServer.Migrations
b.Property<uint>("ArrivalSongCount")
.HasColumnType("INTEGER");
b.Property<uint>("ClearState")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER")
.HasDefaultValue(0u);
b.Property<uint>("ComboCountTotal")
.HasColumnType("INTEGER");
@ -72,6 +77,12 @@ namespace TaikoLocalServer.Migrations
b.Property<uint>("ComboCount")
.HasColumnType("INTEGER");
b.Property<uint?>("DanScoreDatumBaid")
.HasColumnType("INTEGER");
b.Property<uint?>("DanScoreDatumDanId")
.HasColumnType("INTEGER");
b.Property<uint>("DrumrollCount")
.HasColumnType("INTEGER");
@ -92,6 +103,8 @@ namespace TaikoLocalServer.Migrations
b.HasKey("Baid", "DanId", "SongNumber");
b.HasIndex("DanScoreDatumBaid", "DanScoreDatumDanId");
b.ToTable("DanStageScoreData");
});
@ -259,16 +272,13 @@ namespace TaikoLocalServer.Migrations
{
b.HasOne("TaikoLocalServer.Entities.DanScoreDatum", "Parent")
.WithMany()
.HasForeignKey("Baid")
.HasPrincipalKey("Baid")
.HasForeignKey("Baid", "DanId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("TaikoLocalServer.Entities.DanScoreDatum", null)
.WithMany("DanStageScoreData")
.HasForeignKey("Baid", "DanId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
.HasForeignKey("DanScoreDatumBaid", "DanScoreDatumDanId");
b.Navigation("Parent");
});

View File

@ -1,7 +1,7 @@
[
{
"danId":1,
"verupNo":0,
"verupNo":1,
"title":"5kyuu",
"aryOdaiSong":[
{
@ -37,7 +37,7 @@
},
{
"danId":2,
"verupNo":0,
"verupNo":1,
"title":"4kyuu",
"aryOdaiSong":[
{
@ -79,7 +79,7 @@
},
{
"danId":3,
"verupNo":0,
"verupNo":1,
"title":"3kyuu",
"aryOdaiSong":[
{
@ -121,7 +121,7 @@
},
{
"danId":4,
"verupNo":0,
"verupNo":1,
"title":"2kyuu",
"aryOdaiSong":[
{
@ -163,7 +163,7 @@
},
{
"danId":5,
"verupNo":0,
"verupNo":1,
"title":"1kyuu",
"aryOdaiSong":[
{
@ -205,7 +205,7 @@
},
{
"danId":6,
"verupNo":0,
"verupNo":1,
"title":"1dan",
"aryOdaiSong":[
{
@ -257,7 +257,7 @@
},
{
"danId":7,
"verupNo":0,
"verupNo":1,
"title":"2dan",
"aryOdaiSong":[
{
@ -309,7 +309,7 @@
},
{
"danId":8,
"verupNo":0,
"verupNo":1,
"title":"3dan",
"aryOdaiSong":[
{
@ -361,7 +361,7 @@
},
{
"danId":9,
"verupNo":0,
"verupNo":1,
"title":"4dan",
"aryOdaiSong":[
{
@ -413,7 +413,7 @@
},
{
"danId":10,
"verupNo":0,
"verupNo":1,
"title":"5dan",
"aryOdaiSong":[
{
@ -465,7 +465,7 @@
},
{
"danId":11,
"verupNo":0,
"verupNo":1,
"title":"6dan",
"aryOdaiSong":[
{
@ -517,7 +517,7 @@
},
{
"danId":12,
"verupNo":0,
"verupNo":1,
"title":"7dan",
"aryOdaiSong":[
{
@ -569,7 +569,7 @@
},
{
"danId":13,
"verupNo":0,
"verupNo":1,
"title":"8dan",
"aryOdaiSong":[
{
@ -621,7 +621,7 @@
},
{
"danId":14,
"verupNo":0,
"verupNo":1,
"title":"9dan",
"aryOdaiSong":[
{
@ -673,7 +673,7 @@
},
{
"danId":15,
"verupNo":0,
"verupNo":1,
"title":"10dan",
"aryOdaiSong":[
{
@ -729,7 +729,7 @@
},
{
"danId":16,
"verupNo":0,
"verupNo":1,
"title":"11dan",
"aryOdaiSong":[
{
@ -781,7 +781,7 @@
},
{
"danId":17,
"verupNo":0,
"verupNo":1,
"title":"12dan",
"aryOdaiSong":[
{
@ -833,7 +833,7 @@
},
{
"danId":18,
"verupNo":0,
"verupNo":1,
"title":"13dan",
"aryOdaiSong":[
{
@ -885,7 +885,7 @@
},
{
"danId":19,
"verupNo":0,
"verupNo":1,
"title":"14dan",
"aryOdaiSong":[
{