1
0
mirror of synced 2025-01-19 00:04:05 +01:00

Current state (WIP)

This commit is contained in:
esuo1198 2024-03-07 19:06:45 +09:00
parent 6e059baa13
commit a3cff10634
58 changed files with 3739 additions and 3618 deletions

View File

@ -1,11 +1,10 @@
using SharedProject.Enums;
using SharedProject.Models;
namespace GameDatabase.Entities;
public class AiScoreDatum
{
public ulong Baid { get; set; }
public uint Baid { get; set; }
public uint SongId { get; set; }

View File

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

View File

@ -3,8 +3,8 @@
public partial class Card
{
public string AccessCode { get; set; } = null!;
public ulong Baid { get; set; }
public uint Baid { get; set; }
public virtual UserDatum? Ba { get; set; }
}
}

View File

@ -2,10 +2,10 @@
{
public partial class Credential
{
public ulong Baid { get; set; }
public uint Baid { get; set; }
public string Password { get; set; } = null!;
public string Salt { get; set; } = null!;
public virtual UserDatum? Ba { get; set; }
}
}

View File

@ -4,7 +4,7 @@ namespace GameDatabase.Entities;
public class DanScoreDatum
{
public ulong Baid { get; set; }
public uint Baid { get; set; }
public uint DanId { get; set; }
public DanType DanType { get; set; }
public uint ArrivalSongCount { get; set; }

View File

@ -4,10 +4,10 @@ namespace GameDatabase.Entities;
public class DanStageScoreDatum
{
public ulong Baid { get; set; }
public uint Baid { get; set; }
public uint DanId { get; set; }
public DanType DanType { get; set; }
public uint SongNumber { get; set; }

View File

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

View File

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

View File

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

View File

@ -2,7 +2,7 @@
public class SetFavoriteRequest
{
public ulong Baid { get; set; }
public uint Baid { get; set; }
public uint SongId { get; set; }
public bool IsFavorite { get; set; }
}

View File

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

View File

@ -10,12 +10,13 @@ public class DanBestDataController : BaseController<DanBestDataController>
{
private readonly IDanScoreDatumService danScoreDatumService;
public DanBestDataController(IDanScoreDatumService danScoreDatumService) {
public DanBestDataController(IDanScoreDatumService danScoreDatumService)
{
this.danScoreDatumService = danScoreDatumService;
}
[HttpGet("{baid}")]
public async Task<IActionResult> GetDanBestData(ulong baid)
public async Task<IActionResult> GetDanBestData(uint baid)
{
// FIXME: Handle gaiden in here and web ui
var danScores = await danScoreDatumService.GetDanScoreDataList(baid, DanType.Normal);

View File

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

View File

@ -17,7 +17,7 @@ public class UserSettingsController : BaseController<UserSettingsController>
}
[HttpGet]
public async Task<ActionResult<UserSetting>> GetUserSetting(ulong baid)
public async Task<ActionResult<UserSetting>> GetUserSetting(uint baid)
{
var user = await userDatumService.GetFirstUserDatumOrNull(baid);
@ -43,7 +43,7 @@ public class UserSettingsController : BaseController<UserSettingsController>
costumeUnlockData[i].Add(0);
}
}
var response = new UserSetting
{
AchievementDisplayDifficulty = user.AchievementDisplayDifficulty,
@ -81,7 +81,7 @@ public class UserSettingsController : BaseController<UserSettingsController>
}
[HttpPost]
public async Task<IActionResult> SaveUserSetting(ulong baid, UserSetting userSetting)
public async Task<IActionResult> SaveUserSetting(uint baid, UserSetting userSetting)
{
var user = await userDatumService.GetFirstUserDatumOrNull(baid);

View File

@ -3,7 +3,7 @@ using Throw;
namespace TaikoLocalServer.Controllers.Game;
[Route("/v12r00_cn/chassis/addtokencount.php")]
[Route("/v12r08_ww/chassis/addtokencount.php")]
[ApiController]
public class AddTokenCountController : BaseController<AddTokenCountController>
{

View File

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

View File

@ -1,7 +1,7 @@
namespace TaikoLocalServer.Controllers.Game;
[ApiController]
[Route("/v12r00_cn/chassis/bookkeeping.php")]
[Route("/v12r08_ww/chassis/bookkeeping_s4esi5un.php")]
public class BookkeepingController : BaseController<BookkeepingController>
{
[HttpPost]
@ -13,9 +13,9 @@ public class BookkeepingController : BaseController<BookkeepingController>
{
Result = 1
};
return Ok(response);
}
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,6 +1,6 @@
namespace TaikoLocalServer.Controllers.Game;
[Route("/v12r00_cn/chassis/getdanodai.php")]
[Route("/v12r08_ww/chassis/getdanodai_ela9zu1a.php")]
[ApiController]
public class GetDanOdaiController : BaseController<GetDanOdaiController>
{
@ -16,7 +16,7 @@ public class GetDanOdaiController : BaseController<GetDanOdaiController>
public IActionResult GetDanOdai([FromBody] GetDanOdaiRequest request)
{
Logger.LogInformation("GetDanOdai request : {Request}", request.Stringify());
var response = new GetDanOdaiResponse
{
Result = 1
@ -50,7 +50,7 @@ public class GetDanOdaiController : BaseController<GetDanOdaiController>
response.AryOdaiDatas.Add(odaiData);
}
}
return Ok(response);
}
}

View File

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

View File

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

View File

@ -1,24 +1,24 @@
namespace TaikoLocalServer.Controllers.Game;
[ApiController]
[Route("/v12r00_cn/chassis/getgenericmaster.php")]
[Route("/v12r08_ww/chassis/getgenericmaster_ts8om3qd.php")]
public class GetGenericMasterController : BaseController<GetGenericMasterController>
{
[HttpPost]
[Produces("application/protobuf")]
public IActionResult GetGenericMaster([FromBody] GetGenericMasterRequest request)
{
Logger.LogInformation("GetGenericMasterRequest: {Request}", request.Stringify());
[HttpPost]
[Produces("application/protobuf")]
public IActionResult GetGenericMaster([FromBody] GetGenericMasterRequest request)
{
Logger.LogInformation("GetGenericMasterRequest: {Request}", request.Stringify());
var response = new GetGenericMasterResponse
{
Result = 1,
VerupNo = 2,
EnableIdBit = FlagCalculator.GetBitArrayTrue(5000)
};
var response = new GetGenericMasterResponse
{
Result = 1,
VerupNo = 2,
EnableIdBit = FlagCalculator.GetBitArrayTrue(5000)
};
return Ok(response);
}
return Ok(response);
}
}

View File

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

View File

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

View File

@ -1,6 +1,6 @@
namespace TaikoLocalServer.Controllers.Game;
[Route("/v12r00_cn/chassis/getsongintroduction.php")]
[Route("/v12r08_ww/chassis/getsongintroduction_66blw6is.php")]
[ApiController]
public class GetSongIntroductionController : BaseController<GetSongIntroductionController>
{
@ -21,7 +21,7 @@ public class GetSongIntroductionController : BaseController<GetSongIntroductionC
{
Result = 1
};
foreach (var setId in request.SetIds)
{
gameDataService.GetSongIntroDictionary().TryGetValue(setId, out var introData);

View File

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

View File

@ -3,7 +3,7 @@ using Throw;
namespace TaikoLocalServer.Controllers.Game;
[Route("/v12r00_cn/chassis/gettokencount.php")]
[Route("/v12r08_ww/chassis/gettokencount.php")]
[ApiController]
public class GetTokenCountController : BaseController<GetTokenCountController>
{

View File

@ -1,39 +0,0 @@
namespace TaikoLocalServer.Controllers.Game;
[ApiController]
[Route("/v12r00_cn/chassis/headclerk2.php")]
public class Headclerk2Controller : BaseController<Headclerk2Controller>
{
[HttpPost]
[Produces("application/protobuf")]
public IActionResult Headclerk2([FromBody] HeadClerk2Request request)
{
Logger.LogInformation("Headclerk2 request: {Request}", request.Stringify());
/*var chassisId = request.ChassisId;
var shopId = request.ShopId;
foreach (var playInfo in request.AryPlayInfoes)
{
var baid = playInfo.Baid;
var playedAt = playInfo.PlayedAt;
var isRight = playInfo.IsRight;
var type = playInfo.Type;
var amount = playInfo.Amount;
Logger.LogInformation("CSV WRITE: \n" +
"ChassisId:{ChassisId},\n" +
"ShopId:{ShopId},\n" +
"Baid:{Baid},\n" +
"PlayedAt{PlayedAt},\n" +
"IsRight:{IsRight},\n" +
"Type:{Type},\n" +
"Amount{Amount}", chassisId, shopId, baid, playedAt, isRight, type, amount);
}*/
var response = new HeadClerk2Response
{
Result = 1
};
return Ok(response);
}
}

View File

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

View File

@ -4,138 +4,138 @@ using TaikoLocalServer.Settings;
namespace TaikoLocalServer.Controllers.Game;
[ApiController]
[Route("/v12r00_cn/chassis/initialdatacheck.php")]
[Route("/v12r08_ww/chassis/initialdatacheck_vaosv643.php")]
public class InitialDataCheckController : BaseController<InitialDataCheckController>
{
private readonly IGameDataService gameDataService;
private readonly IGameDataService gameDataService;
private readonly ServerSettings settings;
private readonly ServerSettings settings;
public InitialDataCheckController(IGameDataService gameDataService, IOptions<ServerSettings> settings)
{
this.gameDataService = gameDataService;
this.settings = settings.Value;
}
public InitialDataCheckController(IGameDataService gameDataService, IOptions<ServerSettings> settings)
{
this.gameDataService = gameDataService;
this.settings = settings.Value;
}
[HttpPost]
[Produces("application/protobuf")]
public IActionResult InitialDataCheck([FromBody] InitialdatacheckRequest request)
{
Logger.LogInformation("Initial data check request: {Request}", request.Stringify());
[HttpPost]
[Produces("application/protobuf")]
public IActionResult InitialDataCheck([FromBody] InitialdatacheckRequest request)
{
Logger.LogInformation("Initial data check request: {Request}", request.Stringify());
var songIdMax = settings.EnableMoreSongs ? Constants.MUSIC_ID_MAX_EXPANDED : Constants.MUSIC_ID_MAX;
var songIdMax = settings.EnableMoreSongs ? Constants.MUSIC_ID_MAX_EXPANDED : Constants.MUSIC_ID_MAX;
var musicList = gameDataService.GetMusicList();
var lockedSongsList = gameDataService.GetLockedSongsList();
var musicList = gameDataService.GetMusicList();
var lockedSongsList = gameDataService.GetLockedSongsList();
var enabledArray =
FlagCalculator.GetBitArrayFromIds(musicList, songIdMax, Logger);
var enabledArray =
FlagCalculator.GetBitArrayFromIds(musicList, songIdMax, Logger);
var defaultSongList = musicList.Except(lockedSongsList);
var defaultSongFlg =
FlagCalculator.GetBitArrayFromIds(defaultSongList, songIdMax, Logger);
var defaultSongList = musicList.Except(lockedSongsList);
var defaultSongFlg =
FlagCalculator.GetBitArrayFromIds(defaultSongList, songIdMax, Logger);
var defaultSongWithUraList = gameDataService.GetMusicWithUraList();
var uraReleaseBit =
FlagCalculator.GetBitArrayFromIds(defaultSongWithUraList, songIdMax, Logger);
var defaultSongWithUraList = gameDataService.GetMusicWithUraList();
var uraReleaseBit =
FlagCalculator.GetBitArrayFromIds(defaultSongWithUraList, songIdMax, Logger);
var response = new InitialdatacheckResponse
{
Result = 1,
DefaultSongFlg = defaultSongFlg,
AchievementSongBit = enabledArray,
UraReleaseBit = uraReleaseBit,
SongIntroductionEndDatetime = DateTime.Now.AddYears(10).ToString(Constants.DATE_TIME_FORMAT),
};
var response = new InitialdatacheckResponse
{
Result = 1,
DefaultSongFlg = defaultSongFlg,
AchievementSongBit = enabledArray,
UraReleaseBit = uraReleaseBit,
SongIntroductionEndDatetime = DateTime.Now.AddYears(10).ToString(Constants.DATE_TIME_FORMAT),
};
var movieDataDictionary = gameDataService.GetMovieDataDictionary();
foreach (var movieData in movieDataDictionary) response.AryMovieInfoes.Add(movieData.Value);
var movieDataDictionary = gameDataService.GetMovieDataDictionary();
foreach (var movieData in movieDataDictionary) response.AryMovieInfoes.Add(movieData.Value);
var verupNo1 = new uint[] { 2, 3, 4, 5, 6, 7, 8, 13, 15, 24, 25, 26, 27, 28, 29, 30, 31, 104 };
var aryVerUp = verupNo1.Select(i => new InitialdatacheckResponse.VerupNoData1
{
MasterType = i,
VerupNo = 1
})
.ToList();
response.AryVerupNoData1s.AddRange(aryVerUp);
var verupNo1 = new uint[] { 2, 3, 4, 5, 6, 7, 8, 13, 15, 24, 25, 26, 27, 28, 29, 30, 31, 104 };
var aryVerUp = verupNo1.Select(i => new InitialdatacheckResponse.VerupNoData1
{
MasterType = i,
VerupNo = 1
})
.ToList();
response.AryVerupNoData1s.AddRange(aryVerUp);
var danData = new List<InitialdatacheckResponse.VerupNoData2.InformationData>();
var danDataDictionary = gameDataService.GetDanDataDictionary();
foreach (var danId in danDataDictionary.Keys)
{
gameDataService.GetDanDataDictionary().TryGetValue(danId, out var odaiData);
danData.Add(new InitialdatacheckResponse.VerupNoData2.InformationData
{
InfoId = danId,
VerupNo = odaiData?.VerupNo ?? 1
});
}
var verUp2Type101 = new InitialdatacheckResponse.VerupNoData2
{
MasterType = 101,
};
verUp2Type101.AryInformationDatas.AddRange(danData);
response.AryVerupNoData2s.Add(verUp2Type101);
var danData = new List<InitialdatacheckResponse.VerupNoData2.InformationData>();
var danDataDictionary = gameDataService.GetDanDataDictionary();
foreach (var danId in danDataDictionary.Keys)
{
gameDataService.GetDanDataDictionary().TryGetValue(danId, out var odaiData);
danData.Add(new InitialdatacheckResponse.VerupNoData2.InformationData
{
InfoId = danId,
VerupNo = odaiData?.VerupNo ?? 1
});
}
var verUp2Type101 = new InitialdatacheckResponse.VerupNoData2
{
MasterType = 101,
};
verUp2Type101.AryInformationDatas.AddRange(danData);
response.AryVerupNoData2s.Add(verUp2Type101);
var gaidenData = new List<InitialdatacheckResponse.VerupNoData2.InformationData>();
var gaidenDataDictionary = gameDataService.GetGaidenDataDictionary();
foreach (var gaidenId in gaidenDataDictionary.Keys)
{
gaidenDataDictionary.TryGetValue(gaidenId, out var odaiData);
gaidenData.Add(new InitialdatacheckResponse.VerupNoData2.InformationData
{
InfoId = gaidenId,
VerupNo = odaiData?.VerupNo ?? 1
});
}
var gaidenData = new List<InitialdatacheckResponse.VerupNoData2.InformationData>();
var gaidenDataDictionary = gameDataService.GetGaidenDataDictionary();
foreach (var gaidenId in gaidenDataDictionary.Keys)
{
gaidenDataDictionary.TryGetValue(gaidenId, out var odaiData);
gaidenData.Add(new InitialdatacheckResponse.VerupNoData2.InformationData
{
InfoId = gaidenId,
VerupNo = odaiData?.VerupNo ?? 1
});
}
var verUp2Type102 = new InitialdatacheckResponse.VerupNoData2
{
MasterType = 102,
};
verUp2Type102.AryInformationDatas.AddRange(gaidenData);
response.AryVerupNoData2s.Add(verUp2Type102);
var verUp2Type102 = new InitialdatacheckResponse.VerupNoData2
{
MasterType = 102,
};
verUp2Type102.AryInformationDatas.AddRange(gaidenData);
response.AryVerupNoData2s.Add(verUp2Type102);
var eventFolderData = new List<InitialdatacheckResponse.VerupNoData2.InformationData>();
var eventFolderDictionary = gameDataService.GetFolderDictionary();
foreach (var folderId in eventFolderDictionary.Keys)
{
eventFolderDictionary.TryGetValue(folderId, out var folderData);
eventFolderData.Add(new InitialdatacheckResponse.VerupNoData2.InformationData
{
InfoId = folderId,
VerupNo = folderData?.VerupNo ?? 1
});
}
var verUp2Type103 = new InitialdatacheckResponse.VerupNoData2
{
MasterType = 103,
};
verUp2Type103.AryInformationDatas.AddRange(eventFolderData);
response.AryVerupNoData2s.Add(verUp2Type103);
var eventFolderData = new List<InitialdatacheckResponse.VerupNoData2.InformationData>();
var eventFolderDictionary = gameDataService.GetFolderDictionary();
foreach (var folderId in eventFolderDictionary.Keys)
{
eventFolderDictionary.TryGetValue(folderId, out var folderData);
eventFolderData.Add(new InitialdatacheckResponse.VerupNoData2.InformationData
{
InfoId = folderId,
VerupNo = folderData?.VerupNo ?? 1
});
}
var verUp2Type103 = new InitialdatacheckResponse.VerupNoData2
{
MasterType = 103,
};
verUp2Type103.AryInformationDatas.AddRange(eventFolderData);
response.AryVerupNoData2s.Add(verUp2Type103);
var songIntroData = new List<InitialdatacheckResponse.VerupNoData2.InformationData>();
var songIntroDictionary = gameDataService.GetSongIntroDictionary();
foreach (var setId in songIntroDictionary.Select(item => item.Value.SetId))
{
songIntroDictionary.TryGetValue(setId, out var introData);
songIntroData.Add(new InitialdatacheckResponse.VerupNoData2.InformationData
{
InfoId = setId,
VerupNo = introData?.VerupNo ?? 1
});
}
var verUp2Type105 = new InitialdatacheckResponse.VerupNoData2
{
MasterType = 105,
};
verUp2Type105.AryInformationDatas.AddRange(songIntroData);
response.AryVerupNoData2s.Add(verUp2Type105);
var songIntroData = new List<InitialdatacheckResponse.VerupNoData2.InformationData>();
var songIntroDictionary = gameDataService.GetSongIntroDictionary();
foreach (var setId in songIntroDictionary.Select(item => item.Value.SetId))
{
songIntroDictionary.TryGetValue(setId, out var introData);
songIntroData.Add(new InitialdatacheckResponse.VerupNoData2.InformationData
{
InfoId = setId,
VerupNo = introData?.VerupNo ?? 1
});
}
var verUp2Type105 = new InitialdatacheckResponse.VerupNoData2
{
MasterType = 105,
};
verUp2Type105.AryInformationDatas.AddRange(songIntroData);
response.AryVerupNoData2s.Add(verUp2Type105);
response.AryChassisFunctionIds = new uint[] { 1, 2, 3 };
response.AryChassisFunctionIds = new uint[] { 1, 2, 3 };
return Ok(response);
}
return Ok(response);
}
}

View File

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

View File

@ -8,7 +8,7 @@ namespace TaikoLocalServer.Controllers.Game;
using StageData = PlayResultDataRequest.StageData;
[Route("/v12r00_cn/chassis/playresult.php")]
[Route("/v12r08_ww/chassis/playresult.php")]
[ApiController]
public class PlayResultController : BaseController<PlayResultController>
{

View File

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

View File

@ -3,7 +3,7 @@ using Throw;
namespace TaikoLocalServer.Controllers.Game;
[Route("/v12r00_cn/chassis/selfbest.php")]
[Route("/v12r08_ww/chassis/selfbest.php")]
[ApiController]
public class SelfBestController : BaseController<SelfBestController>
{

View File

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

View File

@ -3,7 +3,7 @@ using Throw;
namespace TaikoLocalServer.Controllers.Game;
[Route("/v12r00_cn/chassis/songpurchase.php")]
[Route("/v12r08_ww/chassis/songpurchase.php")]
[ApiController]
public class SongPurchaseController : BaseController<SongPurchaseController>
{

View File

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

View File

@ -6,7 +6,7 @@ using Throw;
namespace TaikoLocalServer.Controllers.Game;
[Route("/v12r00_cn/chassis/userdata.php")]
[Route("/v12r08_ww/chassis/userdata.php")]
[ApiController]
public class UserDataController : BaseController<UserDataController>
{

View File

@ -1,16 +1,16 @@
namespace TaikoLocalServer.Controllers.Game;
[Route("/v12r00_cn/chassis/verifyqrcode.php")]
[Route("/v12r08_ww/chassis/verifyqrcode_ku5ra5q7.php")]
[ApiController]
public class VerifyQrCodeController : BaseController<VerifyQrCodeController>
{
private readonly IGameDataService gameDataService;
public VerifyQrCodeController(IGameDataService gameDataService)
{
this.gameDataService = gameDataService;
}
[HttpPost]
[Produces("application/protobuf")]
public IActionResult VerifyQrCode([FromBody] VerifyQrcodeRequest request)
@ -20,7 +20,7 @@ public class VerifyQrCodeController : BaseController<VerifyQrCodeController>
var qrCodeDataDictionary = gameDataService.GetQRCodeDataDictionary();
qrCodeDataDictionary.TryGetValue(request.QrcodeSerial, out var qrCodeId);
if (qrCodeId == 0)
{
Logger.LogWarning("Requested QR code serial {Serial} does not exist!", request.QrcodeSerial);

File diff suppressed because it is too large Load Diff

View File

@ -13,14 +13,14 @@ public class AiDatumService : IAiDatumService
this.context = context;
}
public async Task<List<AiScoreDatum>> GetAllAiScoreById(ulong baid)
public async Task<List<AiScoreDatum>> GetAllAiScoreById(uint baid)
{
return await context.AiScoreData.Where(datum => datum.Baid == baid)
.Include(datum => datum.AiSectionScoreData)
.ToListAsync();
}
public async Task<AiScoreDatum?> GetSongAiScore(ulong baid, uint songId, Difficulty difficulty)
public async Task<AiScoreDatum?> GetSongAiScore(uint baid, uint songId, Difficulty difficulty)
{
return await context.AiScoreData.Where(datum => datum.Baid == baid &&
datum.SongId == songId &&

View File

@ -1,55 +1,53 @@
using GameDatabase.Context;
using GameDatabase.Entities;
using OneOf.Types;
using SharedProject.Models;
using Swan.Mapping;
namespace TaikoLocalServer.Services;
public class CardService : ICardService
{
private readonly TaikoDbContext context;
private readonly TaikoDbContext context;
public CardService(TaikoDbContext context)
{
this.context = context;
}
public CardService(TaikoDbContext context)
{
this.context = context;
}
public async Task<Card?> GetCardByAccessCode(string accessCode)
{
return await context.Cards.FindAsync(accessCode);
}
public async Task<Card?> GetCardByAccessCode(string accessCode)
{
return await context.Cards.FindAsync(accessCode);
}
public ulong GetNextBaid()
{
return context.Cards.Any() ? context.Cards.ToList().Max(card => card.Baid) + 1 : 1;
}
public uint GetNextBaid()
{
return context.Cards.Any() ? context.Cards.ToList().Max(card => card.Baid) + 1 : 1;
}
public async Task<List<User>> GetUsersFromCards()
{
var cardEntries = await context.Cards.ToListAsync();
var userEntries = await context.UserData.ToListAsync();
var users = userEntries.Select(userEntry => new User
{
Baid = (uint)userEntry.Baid,
AccessCodes = cardEntries.Where(cardEntry => cardEntry.Baid == userEntry.Baid).Select(cardEntry => cardEntry.AccessCode).ToList(),
IsAdmin = userEntry.IsAdmin
}).ToList();
return users;
}
public async Task<List<User>> GetUsersFromCards()
{
var cardEntries = await context.Cards.ToListAsync();
var userEntries = await context.UserData.ToListAsync();
var users = userEntries.Select(userEntry => new User
{
Baid = (uint)userEntry.Baid,
AccessCodes = cardEntries.Where(cardEntry => cardEntry.Baid == userEntry.Baid).Select(cardEntry => cardEntry.AccessCode).ToList(),
IsAdmin = userEntry.IsAdmin
}).ToList();
return users;
}
public async Task AddCard(Card card)
{
context.Add(card);
await context.SaveChangesAsync();
}
public async Task<bool> DeleteCard(string accessCode)
{
var card = await context.Cards.FindAsync(accessCode);
if (card == null) return false;
context.Cards.Remove(card);
await context.SaveChangesAsync();
return true;
}
public async Task AddCard(Card card)
{
context.Add(card);
await context.SaveChangesAsync();
}
public async Task<bool> DeleteCard(string accessCode)
{
var card = await context.Cards.FindAsync(accessCode);
if (card == null) return false;
context.Cards.Remove(card);
await context.SaveChangesAsync();
return true;
}
}

View File

@ -13,7 +13,7 @@ public class CredentialService : ICredentialService
{
this.context = context;
}
public async Task<List<UserCredential>> GetUserCredentialsFromCredentials()
{
return await context.Credentials.Select(credential => credential.CopyPropertiesToNew<UserCredential>(null)).ToListAsync();
@ -27,7 +27,7 @@ public class CredentialService : ICredentialService
public async Task<bool> DeleteCredential(uint baid)
{
var credential = await context.Credentials.FindAsync((ulong)baid);
var credential = await context.Credentials.FindAsync(baid);
if (credential is null) return false;
@ -36,10 +36,10 @@ public class CredentialService : ICredentialService
return true;
}
public async Task<bool> UpdatePassword(uint baid, string password, string salt)
{
var credential = await context.Credentials.FindAsync((ulong)baid);
var credential = await context.Credentials.FindAsync(baid);
if (credential is null) return false;

View File

@ -12,14 +12,14 @@ public class DanScoreDatumService : IDanScoreDatumService
this.context = context;
}
public async Task<List<DanScoreDatum>> GetDanScoreDataList(ulong baid, DanType danType)
public async Task<List<DanScoreDatum>> GetDanScoreDataList(uint baid, DanType danType)
{
return await context.DanScoreData.Where(datum => datum.Baid == baid && datum.DanType == danType)
.Include(datum => datum.DanStageScoreData)
.ToListAsync();
}
public async Task<DanScoreDatum?> GetSingleDanScoreDatum(ulong baid, uint danId, DanType danType)
public async Task<DanScoreDatum?> GetSingleDanScoreDatum(uint baid, uint danId, DanType danType)
{
return await context.DanScoreData.Include(datum => datum.DanStageScoreData)
.FirstOrDefaultAsync(datum => datum.Baid == baid &&

View File

@ -4,9 +4,9 @@ namespace TaikoLocalServer.Services.Interfaces;
public interface IAiDatumService
{
public Task<List<AiScoreDatum>> GetAllAiScoreById(ulong baid);
public Task<List<AiScoreDatum>> GetAllAiScoreById(uint baid);
public Task<AiScoreDatum?> GetSongAiScore(ulong baid, uint songId, Difficulty difficulty);
public Task<AiScoreDatum?> GetSongAiScore(uint baid, uint songId, Difficulty difficulty);
public Task UpdateSongAiScore(AiScoreDatum datum);

View File

@ -5,13 +5,13 @@ namespace TaikoLocalServer.Services.Interfaces;
public interface ICardService
{
public Task<Card?> GetCardByAccessCode(string accessCode);
public Task<Card?> GetCardByAccessCode(string accessCode);
public ulong GetNextBaid();
public uint GetNextBaid();
public Task<List<User>> GetUsersFromCards();
public Task<List<User>> GetUsersFromCards();
public Task AddCard(Card card);
public Task<bool> DeleteCard(string accessCode);
public Task AddCard(Card card);
public Task<bool> DeleteCard(string accessCode);
}

View File

@ -4,9 +4,9 @@ namespace TaikoLocalServer.Services.Interfaces;
public interface IDanScoreDatumService
{
public Task<List<DanScoreDatum>> GetDanScoreDataList(ulong baid, DanType danType);
public Task<DanScoreDatum?> GetSingleDanScoreDatum(ulong baid, uint danId, DanType danType);
public Task<List<DanScoreDatum>> GetDanScoreDataList(uint baid, DanType danType);
public Task<DanScoreDatum?> GetSingleDanScoreDatum(uint baid, uint danId, DanType danType);
public Task InsertOrUpdateDanScoreDatum(DanScoreDatum datum);

View File

@ -5,13 +5,13 @@ namespace TaikoLocalServer.Services.Interfaces;
public interface ISongBestDatumService
{
public Task<List<SongBestDatum>> GetAllSongBestData(ulong baid);
public Task<List<SongBestDatum>> GetAllSongBestData(uint baid);
public Task<SongBestDatum?> GetSongBestData(ulong baid, uint songId, Difficulty difficulty);
public Task<SongBestDatum?> GetSongBestData(uint baid, uint songId, Difficulty difficulty);
public Task UpdateSongBestData(SongBestDatum datum);
public Task InsertSongBestData(SongBestDatum datum);
public Task<List<SongBestData>> GetAllSongBestAsModel(ulong baid);
public Task<List<SongBestData>> GetAllSongBestAsModel(uint baid);
}

View File

@ -4,7 +4,7 @@ namespace TaikoLocalServer.Services.Interfaces;
public interface ISongPlayDatumService
{
public Task<List<SongPlayDatum>> GetSongPlayDatumByBaid(ulong baid);
public Task<List<SongPlayDatum>> GetSongPlayDatumByBaid(uint baid);
public Task AddSongPlayDatum(SongPlayDatum datum);
public Task AddSongPlayDatum(SongPlayDatum datum);
}

View File

@ -4,21 +4,21 @@ namespace TaikoLocalServer.Services.Interfaces;
public interface IUserDatumService
{
public Task<UserDatum?> GetFirstUserDatumOrNull(ulong baid);
public Task<UserDatum?> GetFirstUserDatumOrNull(uint baid);
public Task<UserDatum> GetFirstUserDatumOrDefault(ulong baid);
public Task<UserDatum> GetFirstUserDatumOrDefault(uint baid);
public Task<List<UserDatum>> GetAllUserData();
public Task<List<UserDatum>> GetAllUserData();
public Task UpdateOrInsertUserDatum(UserDatum userDatum);
public Task UpdateOrInsertUserDatum(UserDatum userDatum);
public Task InsertUserDatum(UserDatum userDatum);
public Task InsertUserDatum(UserDatum userDatum);
public Task UpdateUserDatum(UserDatum userDatum);
public Task UpdateUserDatum(UserDatum userDatum);
public Task<bool> DeleteUser(uint baid);
public Task<bool> DeleteUser(uint baid);
public Task<List<uint>> GetFavoriteSongIds(ulong baid);
public Task<List<uint>> GetFavoriteSongIds(uint baid);
public Task UpdateFavoriteSong(ulong baid, uint songId, bool isFavorite);
public Task UpdateFavoriteSong(uint baid, uint songId, bool isFavorite);
}

View File

@ -15,12 +15,12 @@ public class SongBestDatumService : ISongBestDatumService
this.context = context;
}
public async Task<List<SongBestDatum>> GetAllSongBestData(ulong baid)
public async Task<List<SongBestDatum>> GetAllSongBestData(uint baid)
{
return await context.SongBestData.Where(datum => datum.Baid == baid).ToListAsync();
}
public async Task<SongBestDatum?> GetSongBestData(ulong baid, uint songId, Difficulty difficulty)
public async Task<SongBestDatum?> GetSongBestData(uint baid, uint songId, Difficulty difficulty)
{
return await context.SongBestData.Where(datum => datum.Baid == baid &&
datum.SongId == songId &&
@ -48,7 +48,7 @@ public class SongBestDatumService : ISongBestDatumService
await context.SaveChangesAsync();
}
public async Task<List<SongBestData>> GetAllSongBestAsModel(ulong baid)
public async Task<List<SongBestData>> GetAllSongBestAsModel(uint baid)
{
var songbestDbData = await context.SongBestData.Where(datum => datum.Baid == baid)
.ToListAsync();
@ -70,7 +70,7 @@ public class SongBestDatumService : ISongBestDatumService
var lastPlayLog = songPlayDatums
.MaxBy(datum => datum.PlayTime);
bestData.LastPlayTime = lastPlayLog!.PlayTime;
var bestLog = songPlayDatums
.MaxBy(datum => datum.Score);
bestLog.CopyOnlyPropertiesTo(bestData,

View File

@ -12,7 +12,7 @@ class SongPlayDatumService : ISongPlayDatumService
this.context = context;
}
public async Task<List<SongPlayDatum>> GetSongPlayDatumByBaid(ulong baid)
public async Task<List<SongPlayDatum>> GetSongPlayDatumByBaid(uint baid)
{
return await context.SongPlayData.Where(datum => datum.Baid == baid).ToListAsync();
}

View File

@ -1,6 +1,6 @@
using System.Text.Json;
using GameDatabase.Context;
using GameDatabase.Context;
using GameDatabase.Entities;
using System.Text.Json;
using Throw;
namespace TaikoLocalServer.Services;
@ -17,12 +17,12 @@ public class UserDatumService : IUserDatumService
this.logger = logger;
}
public async Task<UserDatum?> GetFirstUserDatumOrNull(ulong baid)
public async Task<UserDatum?> GetFirstUserDatumOrNull(uint baid)
{
return await context.UserData.FindAsync(baid);
}
public async Task<UserDatum> GetFirstUserDatumOrDefault(ulong baid)
public async Task<UserDatum> GetFirstUserDatumOrDefault(uint baid)
{
return await context.UserData.FindAsync(baid) ?? new UserDatum();
}
@ -56,10 +56,10 @@ public class UserDatumService : IUserDatumService
context.Update(userDatum);
await context.SaveChangesAsync();
}
public async Task<bool> DeleteUser(uint baid)
{
var userDatum = await context.UserData.FindAsync((ulong)baid);
var userDatum = await context.UserData.FindAsync(baid);
if (userDatum == null) return false;
context.UserData.Remove(userDatum);
await context.SaveChangesAsync();
@ -67,7 +67,7 @@ public class UserDatumService : IUserDatumService
return true;
}
public async Task<List<uint>> GetFavoriteSongIds(ulong baid)
public async Task<List<uint>> GetFavoriteSongIds(uint baid)
{
var userDatum = await context.UserData.FindAsync(baid);
userDatum.ThrowIfNull($"User with baid: {baid} not found!");
@ -87,7 +87,7 @@ public class UserDatumService : IUserDatumService
return result;
}
public async Task UpdateFavoriteSong(ulong baid, uint songId, bool isFavorite)
public async Task UpdateFavoriteSong(uint baid, uint songId, bool isFavorite)
{
var userDatum = await context.UserData.FindAsync(baid);
userDatum.ThrowIfNull($"User with baid: {baid} not found!");
@ -124,5 +124,5 @@ public class UserDatumService : IUserDatumService
context.Update(userDatum);
await context.SaveChangesAsync();
}
}