forked from akanyan/mu3-mods
feat(MPO): implement TYPE-D
This commit is contained in:
@ -10,6 +10,89 @@ using System.Reflection;
|
||||
namespace MU3.Mod;
|
||||
|
||||
public static class CustomRating {
|
||||
private static patch_UserOption.eRating eRating => (patch_UserOption.eRating)Singleton<UserManager>.instance.userOption.customSet.Rating;
|
||||
|
||||
public static int GetNaive() {
|
||||
int res = 0;
|
||||
foreach(Rating best in calcNaive().Take(45)) {
|
||||
res += best.rate100;
|
||||
}
|
||||
return res / 45;
|
||||
}
|
||||
|
||||
public static int GetReachable() {
|
||||
FieldInfo piOld = typeof(UserRating).GetField("_bestOldList", BindingFlags.Instance | BindingFlags.NonPublic);
|
||||
FieldInfo piNew = typeof(UserRating).GetField("_bestNewList", BindingFlags.Instance | BindingFlags.NonPublic);
|
||||
|
||||
var ur = Singleton<UserManager>.instance.userRating;
|
||||
|
||||
int res = 0;
|
||||
int top = 0;
|
||||
foreach(Rating src in ((RatingList)piOld.GetValue(ur))) {
|
||||
res += src.rate100;
|
||||
|
||||
if(src.level100 == 0 || src.musicTbl.isLunatic || src.musicTbl.isBonusTrack) {
|
||||
continue;
|
||||
}
|
||||
top = Math.Max(top, src.rate100);
|
||||
}
|
||||
foreach(Rating src in ((RatingList)piNew.GetValue(ur))) {
|
||||
res += src.rate100;
|
||||
|
||||
if(src.level100 == 0 || src.musicTbl.isLunatic || src.musicTbl.isBonusTrack) {
|
||||
continue;
|
||||
}
|
||||
top = Math.Max(top, src.rate100);
|
||||
}
|
||||
|
||||
res += top * 10;
|
||||
|
||||
return res / 55;
|
||||
}
|
||||
|
||||
public static int GetRecent() {
|
||||
FieldInfo piHot = typeof(UserRating).GetField("_hotList", BindingFlags.Instance | BindingFlags.NonPublic);
|
||||
|
||||
var ur = Singleton<UserManager>.instance.userRating;
|
||||
|
||||
int res = 0;
|
||||
foreach(Rating src in ((RatingList)piHot.GetValue(ur))) {
|
||||
res += src.rate100;
|
||||
}
|
||||
|
||||
return res / 10;
|
||||
}
|
||||
|
||||
public static bool IsEnabled() {
|
||||
return eRating >= patch_UserOption.eRating.Naive;
|
||||
}
|
||||
|
||||
public static int Get() {
|
||||
switch(eRating) {
|
||||
case patch_UserOption.eRating.Naive:
|
||||
return GetNaive();
|
||||
case patch_UserOption.eRating.Reachable:
|
||||
return GetReachable();
|
||||
case patch_UserOption.eRating.Recent:
|
||||
return GetRecent();
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public static byte GetSuffix() {
|
||||
switch(eRating) {
|
||||
case patch_UserOption.eRating.Naive:
|
||||
return MU3CounterBase.FigurePlus;
|
||||
case patch_UserOption.eRating.Reachable:
|
||||
return MU3CounterBase.FigureMinus;
|
||||
case patch_UserOption.eRating.Recent:
|
||||
return MU3CounterBase.FigureComma;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Adapted from MU3.User.UserRating.calcBest()
|
||||
private static RatingList calcNaive() {
|
||||
RatingList ratingList = [];
|
||||
@ -41,67 +124,4 @@ public static class CustomRating {
|
||||
ratingList.Sort();
|
||||
return ratingList;
|
||||
}
|
||||
public static int GetNaive() {
|
||||
int res = 0;
|
||||
foreach(Rating best in calcNaive().Take(45)) {
|
||||
res += best.rate100;
|
||||
}
|
||||
return res / 45;
|
||||
}
|
||||
|
||||
public static int GetReachable() {
|
||||
FieldInfo piOld = typeof(UserRating).GetField("_bestOldList", BindingFlags.Instance | BindingFlags.NonPublic);
|
||||
FieldInfo piNew = typeof(UserRating).GetField("_bestNewList", BindingFlags.Instance | BindingFlags.NonPublic);
|
||||
|
||||
var ur = Singleton<UserManager>.instance.userRating;
|
||||
|
||||
int res = 0;
|
||||
int top = 0;
|
||||
foreach(Rating best in ((RatingList)piOld.GetValue(ur))) {
|
||||
res += best.rate100;
|
||||
if(best.musicID < 7000) {
|
||||
top = Math.Max(top, best.rate100);
|
||||
}
|
||||
}
|
||||
foreach(Rating best in ((RatingList)piNew.GetValue(ur))) {
|
||||
res += best.rate100;
|
||||
if(best.musicID < 7000) {
|
||||
top = Math.Max(top, best.rate100);
|
||||
}
|
||||
}
|
||||
|
||||
res += top * 10;
|
||||
|
||||
return res / 55;
|
||||
}
|
||||
|
||||
private static bool isNaiveEnabled() {
|
||||
return Singleton<UserManager>.instance.userOption.customSet.Rating == (UserOption.eRating)patch_UserOption.eRating.Naive;
|
||||
}
|
||||
private static bool isReachableEnabled() {
|
||||
return Singleton<UserManager>.instance.userOption.customSet.Rating == (UserOption.eRating)patch_UserOption.eRating.Reachable;
|
||||
}
|
||||
public static bool IsEnabled() {
|
||||
return isNaiveEnabled() || isReachableEnabled();
|
||||
}
|
||||
|
||||
public static int Get() {
|
||||
if(isNaiveEnabled()) {
|
||||
return GetNaive();
|
||||
} else if(isReachableEnabled()) {
|
||||
return GetReachable();
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public static byte GetSuffix() {
|
||||
if(isNaiveEnabled()) {
|
||||
return MU3CounterBase.FigurePlus;
|
||||
} else if(isReachableEnabled()) {
|
||||
return MU3CounterBase.FigureMinus;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user