[+] New APIs
Build AquaMai / build (push) Has been cancelled Details

pull/78/head
Menci 2024-10-26 01:19:53 +08:00
parent f3bebc6fa2
commit 80536ef4fb
3 changed files with 39 additions and 6 deletions

View File

@ -1,8 +1,11 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using HarmonyLib;
using MAI2.Util;
using Manager;
using Manager.UserDatas;
using Net.Packet;
using Net.Packet.Mai2;
@ -64,4 +67,24 @@ public static class Shim
throw new MissingMethodException("No matching PacketUpsertUserAll constructor found");
}
})();
public static IEnumerable<UserScore>[] GetUserScoreList(UserData userData)
{
var tUserData = Traverse.Create(userData);
var tScoreList = tUserData.Property("ScoreList");
if (tScoreList.PropertyExists())
{
return tScoreList.GetValue<List<UserScore>[]>();
}
var tScoreDic = tUserData.Property("ScoreDic");
if (tScoreDic.PropertyExists())
{
var scoreDic = tScoreDic.GetValue<Dictionary<int, UserScore>[]>();
return scoreDic.Select(dic => dic.Values).ToArray();
}
throw new MissingFieldException("No matching UserData.ScoreList/ScoreDic found");
}
}

View File

@ -3,8 +3,6 @@ using System.Collections.Generic;
using System.Linq;
using AquaMai.Helpers;
using AquaMai.Resources;
using AquaMai.Utils;
using CriAtomDebugDetail;
using DB;
using HarmonyLib;
using MAI2.Util;
@ -16,7 +14,6 @@ using MelonLoader;
using Monitor.Entry.Parts.Screens;
using Net.Packet;
using Net.Packet.Helper;
using Net.Packet.Mai2;
using Process;
using Process.UserDataNet.State.UserDataULState;
using UnityEngine;
@ -109,7 +106,6 @@ public class ImmediateSave
private static void SaveDataFix(UserData userData)
{
UserDetail detail = userData.Detail;
_ = userData.ScoreList;
detail.EventWatchedDate = TimeManager.GetDateString(TimeManager.PlayBaseTime);
userData.CalcTotalValue();
float num = 0f;
@ -147,7 +143,7 @@ public class ImmediateSave
List<UserRate> list = new List<UserRate>();
List<UserRate> list2 = new List<UserRate>();
List<UserScore>[] scoreList = userData.ScoreList;
IEnumerable<UserScore>[] scoreList = Shim.GetUserScoreList(userData);
List<UserRate> ratingList = userData.RatingList.RatingList;
List<UserRate> newRatingList = userData.RatingList.NewRatingList;
int achive = RatingTableID.Rate_22.GetAchive();

View File

@ -222,6 +222,10 @@ class Maimai2ServletController(
val getGameNgMusicId = BaseHandler { mapOf("length" to 0, "musicIdList" to empty) }
val getGameRanking = BaseHandler { mapOf("type" to it["type"].toString(), "gameRankingList" to empty) }
val getGameTournamentInfo = BaseHandler { mapOf("length" to 0, "gameTournamentInfoList" to empty) }
val getGameKaleidxScope = BaseHandler { mapOf("gameKaleidxScopeList" to empty) }
val getUserKaleidxScope = UserReqHandler { _, uid -> mapOf("userId" to uid, "userKaleidxScopeList" to empty) }
val getUserNewItem = UserReqHandler { _, uid -> mapOf("userId" to uid, "itemKind" to 0, "itemId" to 0) }
val getUserNewItemList = UserReqHandler { _, uid -> mapOf("userId" to uid, "userItemList" to empty) }
val getGameSetting = BaseHandler {
// The client-side implementation for reboot time is extremely cursed.
@ -289,6 +293,15 @@ class Maimai2ServletController(
"userMissionDataList" to empty
) }
val getGameMusicScore = BaseHandler { mapOf(
"gameMusicScore" to mapOf(
"musicId" to 0,
"level" to 0,
"type" to 0,
"scoreData" to ""
)
) }
val endpointList = setOf("GetGameEventApi", "GetGameRankingApi", "GetGameSettingApi", "GetGameTournamentInfoApi", "GetGameWeeklyDataApi",
"GetTransferFriendApi", "GetUserActivityApi", "GetUserCardApi", "GetUserCharacterApi", "GetUserDataApi",
"GetUserExtendApi", "GetUserFavoriteApi", "GetUserGhostApi", "GetUserItemApi", "GetUserLoginBonusApi",
@ -303,7 +316,8 @@ class Maimai2ServletController(
"CMUpsertUserPrintlogApi", "GetUserFavoriteItemApi", "GetUserRivalDataApi", "GetUserRivalMusicApi",
"GetUserScoreRankingApi", "UpsertClientBookkeepingApi", "UpsertClientSettingApi",
"UpsertClientTestmodeApi", "UpsertClientUploadApi", "Ping", "RemoveTokenApi", "CMLoginApi", "CMLogoutApi",
"CMUpsertBuyCardApi", "GetGameSettingApi").toMutableList()
"CMUpsertBuyCardApi", "GetGameSettingApi", "GetGameKaleidxScopeApi", "GetGameMusicScoreApi",
"GetUserKaleidxScopeApi", "GetUserNewItemApi", "GetUserNewItemListApi").toMutableList()
val noopEndpoint = endpointList.popAll("GetUserScoreRankingApi", "UpsertClientBookkeepingApi",
"UpsertClientSettingApi", "UpsertClientTestmodeApi", "UpsertClientUploadApi", "Ping", "RemoveTokenApi",