feat: rework NaiveRating, improve InfiniteGP

This commit is contained in:
あかニャン 2024-06-27 08:15:42 +09:00
parent 45095b212b
commit 5bd9b5ae70
8 changed files with 136 additions and 26 deletions

View File

@ -0,0 +1,16 @@
#pragma warning disable CS0649
using MU3.Util;
namespace MU3;
public class patch_Scene_25_Login : Scene_25_Login {
private enum State {
Login = 2
}
private Mode<Scene_25_Login, State> mode_;
private void PurchaseGP_Init() {
mode_.set(State.Login);
}
}

View File

@ -0,0 +1,15 @@
#pragma warning disable CS0626
#pragma warning disable CS0649
#pragma warning disable IDE0051
#pragma warning disable IDE1006
using MU3.DB;
namespace MU3.Data;
public class patch_GameData: GameData {
public extern static RatingColorID orig_getRatingColorIDFromRating100(int rating100);
public static new RatingColorID getRatingColorIDFromRating100(int rating100) {
return orig_getRatingColorIDFromRating100(NaiveRating.Get());
}
}

View File

@ -0,0 +1,16 @@
#pragma warning disable CS0626
#pragma warning disable CS0649
#pragma warning disable IDE0051
#pragma warning disable IDE1006
using MU3.Game;
namespace MU3.User;
public class patch_UserManager: UserManager {
public extern void orig_updateUserRating(SessionInfo sessionInfo, SessionResult result);
public new void updateUserRating(SessionInfo sessionInfo, SessionResult result) {
NaiveRating.PrevRating = NaiveRating.Get();
orig_updateUserRating(sessionInfo, result);
}
}

View File

@ -0,0 +1,15 @@
#pragma warning disable CS0626
#pragma warning disable CS0649
#pragma warning disable IDE0051
#pragma warning disable IDE1006
using MonoMod;
namespace MU3.User;
[MonoModPatch("global::MU3.User.UserUtil")]
public static class patch_UserUtil {
public static float toRatingFloat(int rating) {
return NaiveRating.Get() * 0.01f + 1E-05f;
}
}

View File

@ -1,39 +1,41 @@
#pragma warning disable CS0626 #pragma warning disable CS0626
#pragma warning disable CS0649 #pragma warning disable CS0649
#pragma warning disable IDE0051 #pragma warning disable IDE0051
#pragma warning disable IDE1006 #pragma warning disable IDE1006
using MU3.Data;
using MU3.DataStudio;
using MU3.Util;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using MU3.Data;
using MU3.DataStudio;
using MU3.User;
using MU3.Util;
namespace MU3.User; namespace MU3;
public class patch_UserRating: UserRating { public static class NaiveRating {
private int _rating100; public static int PrevRating { get; set; }
private UserManager usMgr => Singleton<UserManager>.instance;
// Adaptation of calcBest() without bullshit // Adapted from MU3.User.UserRating.calcBest()
// The original lists stay intact because the game expects them to be filled private static RatingList calcSane() {
private RatingList calcSane() {
RatingList ratingList = new(); RatingList ratingList = new();
var usMgr = Singleton<UserManager>.instance;
var musicDict = usMgr.userMusic; var musicDict = usMgr.userMusic;
foreach(KeyValuePair<int, UserMusic> item in musicDict) { foreach(KeyValuePair<int, UserMusic> item in musicDict) {
MU3.Data.MusicData musicData = SingletonStateMachine<DataManager, DataManager.EState>.instance.getMusicData(item.Key); var musicData = SingletonStateMachine<DataManager, DataManager.EState>
.instance.getMusicData(item.Key);
if(musicData == null || item.Key == 1 || musicData.isBonusTrack) { if(musicData == null || item.Key == 1 || musicData.isBonusTrack) {
continue; continue;
} }
for(int i = 0; i < 5; i++) { for(int i = 0; i < 5; i++) {
FumenDifficulty fumenDifficulty = (FumenDifficulty)i; var fumenDifficulty = (FumenDifficulty)i;
UserFumen userFumen = usMgr.getUserFumen(item.Key, fumenDifficulty, create: false); var userFumen = usMgr.getUserFumen(item.Key, fumenDifficulty, create: false);
if(userFumen == null) { if(userFumen == null) {
continue; continue;
} }
Rating rating = new Rating(musicData.id, fumenDifficulty, userFumen.TechScoreMax); Rating rating = new(musicData.id, fumenDifficulty, userFumen.TechScoreMax);
if(rating.level100 == 0) { if(rating.level100 == 0) {
continue; continue;
} }
@ -42,15 +44,15 @@ public class patch_UserRating: UserRating {
} }
ratingList.Sort(); ratingList.Sort();
return ratingList; return ratingList;
} }
public static int Get() {
private void calcRate() { int res = 0;
_rating100 = 0;
foreach(Rating best in calcSane().Take(45)) { foreach(Rating best in calcSane().Take(45)) {
_rating100 += best.rate100; res += best.rate100;
} }
_rating100 /= 45; return res > 0
? res / 45
: Singleton<UserManager>.instance.Rating;
} }
} }

View File

@ -0,0 +1,21 @@
#pragma warning disable CS0626
using MU3.User;
using MU3.Util;
namespace MU3;
public class patch_ANM_SWH_Profile : ANM_SWH_Profile {
public extern void orig_setUpLogin();
// Fixes login display
public new void setUpLogin() {
UserManager instance = Singleton<UserManager>.instance;
var prev = instance.userPreview;
var temp = prev;
temp.dispRating = 0;
instance.userPreview = temp;
orig_setUpLogin();
instance.userPreview = prev;
}
}

View File

@ -0,0 +1,27 @@
#pragma warning disable CS0626
#pragma warning disable CS0649
#pragma warning disable IDE0051
#pragma warning disable IDE1006
using MU3.Sequence;
namespace MU3;
public class patch_Scene_37_Result_Score: Scene_37_Result_Score {
private PlayInfo playInfo_;
private extern void orig_TechRating_Init();
// Fixes rating+/rating- display
private void TechRating_Init() {
var origRating = playInfo_.sessionResult.rating_;
var origPrevRating = playInfo_.sessionResult.prevRating_;
playInfo_.sessionResult.rating_ = NaiveRating.Get();
playInfo_.sessionResult.prevRating_ = NaiveRating.PrevRating;
orig_TechRating_Init();
playInfo_.sessionResult.rating_ = origRating;
playInfo_.sessionResult.prevRating_ = origPrevRating;
}
}

View File

@ -23,13 +23,11 @@ Self-explanatory. Saves you time.
### NaiveRating ### NaiveRating
Replaces the in-game rating algorithm (OldBest30+NewBest15+Recent10) with Best45. This change is client-side and immediate. Replaces the in-game rating algorithm (OldBest30+NewBest15+Recent10) with Best45. Client-side and purely cosmetic.
⚠️ ACHTUNG ⚠️ I said it's client-side, but the server acknowledges it once you upload a result. If you're on a remote network, check whether it cares too much about stupid ephemeral numbers. Cozynet and Missless do, and may ban you for using this mod. ### SkipNotice ⚠️
### SkipNotice Skips the safety warning screen, event notices, ⚠login bonuses, event rewards⚠.
Skips the safety warning screen, notices, login bonuses, etc.
### SkipPreMusicRitual ### SkipPreMusicRitual