Skip to content

Commit

Permalink
Merge pull request #30 from no-1-noob/v1.1.0
Browse files Browse the repository at this point in the history
V1.1.0
  • Loading branch information
no-1-noob authored Oct 19, 2024
2 parents 9b8bc33 + 3398076 commit 9715add
Show file tree
Hide file tree
Showing 60 changed files with 813 additions and 226 deletions.
7 changes: 7 additions & 0 deletions PPPredictor.sln
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UnitTests", "UnitTests\Unit
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug ACCSABERNETWORK|Any CPU = Debug ACCSABERNETWORK|Any CPU
Debug ALLNETWORK|Any CPU = Debug ALLNETWORK|Any CPU
Debug BEATLEADERNETWORK|Any CPU = Debug BEATLEADERNETWORK|Any CPU
Debug HITBLOQNETWORK|Any CPU = Debug HITBLOQNETWORK|Any CPU
Expand All @@ -19,6 +20,8 @@ Global
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{7D72F6BF-5835-49C8-ADD7-8F2F587B9588}.Debug ACCSABERNETWORK|Any CPU.ActiveCfg = Debug ACCSABERNETWORK|Any CPU
{7D72F6BF-5835-49C8-ADD7-8F2F587B9588}.Debug ACCSABERNETWORK|Any CPU.Build.0 = Debug ACCSABERNETWORK|Any CPU
{7D72F6BF-5835-49C8-ADD7-8F2F587B9588}.Debug ALLNETWORK|Any CPU.ActiveCfg = Debug ALLNETWORK|Any CPU
{7D72F6BF-5835-49C8-ADD7-8F2F587B9588}.Debug ALLNETWORK|Any CPU.Build.0 = Debug ALLNETWORK|Any CPU
{7D72F6BF-5835-49C8-ADD7-8F2F587B9588}.Debug BEATLEADERNETWORK|Any CPU.ActiveCfg = Debug BEATLEADERNETWORK|Any CPU
Expand All @@ -31,6 +34,8 @@ Global
{7D72F6BF-5835-49C8-ADD7-8F2F587B9588}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7D72F6BF-5835-49C8-ADD7-8F2F587B9588}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7D72F6BF-5835-49C8-ADD7-8F2F587B9588}.Release|Any CPU.Build.0 = Release|Any CPU
{FA9C8BD1-3460-42AF-B129-1FD95E25A5B0}.Debug ACCSABERNETWORK|Any CPU.ActiveCfg = Debug ACCSABERNETWORK|Any CPU
{FA9C8BD1-3460-42AF-B129-1FD95E25A5B0}.Debug ACCSABERNETWORK|Any CPU.Build.0 = Debug ACCSABERNETWORK|Any CPU
{FA9C8BD1-3460-42AF-B129-1FD95E25A5B0}.Debug ALLNETWORK|Any CPU.ActiveCfg = Debug|Any CPU
{FA9C8BD1-3460-42AF-B129-1FD95E25A5B0}.Debug ALLNETWORK|Any CPU.Build.0 = Debug|Any CPU
{FA9C8BD1-3460-42AF-B129-1FD95E25A5B0}.Debug BEATLEADERNETWORK|Any CPU.ActiveCfg = Debug|Any CPU
Expand All @@ -43,6 +48,8 @@ Global
{FA9C8BD1-3460-42AF-B129-1FD95E25A5B0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FA9C8BD1-3460-42AF-B129-1FD95E25A5B0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FA9C8BD1-3460-42AF-B129-1FD95E25A5B0}.Release|Any CPU.Build.0 = Release|Any CPU
{8B7FB8F5-39D5-41E8-9583-1B8B7620D389}.Debug ACCSABERNETWORK|Any CPU.ActiveCfg = Debug|Any CPU
{8B7FB8F5-39D5-41E8-9583-1B8B7620D389}.Debug ACCSABERNETWORK|Any CPU.Build.0 = Debug|Any CPU
{8B7FB8F5-39D5-41E8-9583-1B8B7620D389}.Debug ALLNETWORK|Any CPU.ActiveCfg = Debug|Any CPU
{8B7FB8F5-39D5-41E8-9583-1B8B7620D389}.Debug ALLNETWORK|Any CPU.Build.0 = Debug|Any CPU
{8B7FB8F5-39D5-41E8-9583-1B8B7620D389}.Debug BEATLEADERNETWORK|Any CPU.ActiveCfg = Debug|Any CPU
Expand Down
14 changes: 9 additions & 5 deletions PPPredictor/Counter/CounterInfoHolder.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using CountersPlus.Custom;
using CountersPlus.Utils;
using HMUI;
using PPPredictor.Data;
using PPPredictor.Interfaces;
using PPPredictor.Utilities;
using System;
Expand Down Expand Up @@ -59,12 +58,17 @@ public CounterInfoHolder(int id, Leaderboard leaderboard, CustomConfigModel sett
displayTypeOffset = -0.4f;
gainAlignment = TextAlignmentOptions.BottomRight;
}
//Ugh this shit is so ugly
useIcon = (canvas != null && Plugin.ProfileInfo.CounterUseIcons);
showInfo = leaderBoardGameplayInfo.isRanked || !Plugin.ProfileInfo.CounterHideWhenUnranked;
headerText = canvasUtility.CreateTextFromSettings(settings, new Vector3(((-1f + centerOffset) * positionScaleFactor), lineOffset, 0));
ppText = canvasUtility.CreateTextFromSettings(settings, new Vector3((0.9f + iconTextOffset + displayTypeOffset + centerOffset) * positionScaleFactor, lineOffset, 0));
ppGainText = canvasUtility.CreateTextFromSettings(settings, new Vector3((1.2f + iconTextOffset + displayTypeOffset + centerOffset) * positionScaleFactor, lineOffset, 0));
personalBestText = canvasUtility.CreateTextFromSettings(settings, new Vector3((1.2f + iconTextOffset + displayTypeOffset + centerOffset) * positionScaleFactor, lineOffset, 0));
headerText = canvasUtility.CreateTextFromSettings(settings);
headerText.rectTransform.anchoredPosition += new Vector2(((-1f + centerOffset) * positionScaleFactor), lineOffset) * positionScale;
ppText = canvasUtility.CreateTextFromSettings(settings);
ppText.rectTransform.anchoredPosition += new Vector2((0.9f + iconTextOffset + displayTypeOffset + centerOffset) * positionScaleFactor, lineOffset) * positionScale;
ppGainText = canvasUtility.CreateTextFromSettings(settings);
ppGainText.rectTransform.anchoredPosition += new Vector2((1.2f + iconTextOffset + displayTypeOffset + centerOffset) * positionScaleFactor, lineOffset) * positionScale;
personalBestText = canvasUtility.CreateTextFromSettings(settings);
personalBestText.rectTransform.anchoredPosition += new Vector2((1.2f + iconTextOffset + displayTypeOffset + centerOffset) * positionScaleFactor, lineOffset) * positionScale;
headerText.alignment = TextAlignmentOptions.BottomLeft;
ppGainText.alignment = gainAlignment;
ppText.alignment = personalBestText.alignment = TextAlignmentOptions.BottomRight;
Expand Down
64 changes: 30 additions & 34 deletions PPPredictor/Counter/PPPCounter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ namespace PPPredictor.Counter
{
class PPPCounter : CountersPlus.Counters.Custom.BasicCustomCounter
{
#pragma warning disable CS0649
[Inject] private readonly IPPPredictorMgr ppPredictorMgr;
[Inject] private readonly GamePlayMgr gamePlayMgr;
#pragma warning restore CS0649
private List<CounterInfoHolder> lsCounterInfoHolder = new List<CounterInfoHolder>();
private bool _iconMoved = false;
private bool _isCounterCreated = false;
Expand Down Expand Up @@ -80,22 +82,22 @@ private void SetupCounter(GamePlayInfo gamePlayInfo)
{
if (_isCounterCreated) return;
#if DEBUG
//Center Helper for development
/*float offsetPlus = 0.1f;
for (int i = 0; i < 5; i++)
{
TMP_Text testPlus = CanvasUtility.CreateTextFromSettings(Settings, new Vector3(offsetPlus * -(i + 1), ((i % 2) + 1) * offsetPlus, 0));
testPlus.alignment = TextAlignmentOptions.Center;
testPlus.text = "+";
}
for (int i = 0; i < 5; i++)
{
TMP_Text testPlus = CanvasUtility.CreateTextFromSettings(Settings, new Vector3(offsetPlus * (i + 1), ((i % 2) + 1) * offsetPlus, 0));
testPlus.alignment = TextAlignmentOptions.Center;
testPlus.text = "+";
}*/
//debugPercentage = CanvasUtility.CreateTextFromSettings(Settings, new Vector3(0, 0, 0));
//debugPercentage.alignment = TextAlignmentOptions.Center;
//Center Helper for development
/*float offsetPlus = 0.1f;
for (int i = 0; i < 5; i++)
{
TMP_Text testPlus = CanvasUtility.CreateTextFromSettings(Settings, new Vector3(offsetPlus * -(i + 1), ((i % 2) + 1) * offsetPlus, 0));
testPlus.alignment = TextAlignmentOptions.Center;
testPlus.text = "+";
}
for (int i = 0; i < 5; i++)
{
TMP_Text testPlus = CanvasUtility.CreateTextFromSettings(Settings, new Vector3(offsetPlus * (i + 1), ((i % 2) + 1) * offsetPlus, 0));
testPlus.alignment = TextAlignmentOptions.Center;
testPlus.text = "+";
}*/
//debugPercentage = CanvasUtility.CreateTextFromSettings(Settings, new Vector3(0, 0, 0));
//debugPercentage.alignment = TextAlignmentOptions.Center;
#endif


Expand All @@ -105,28 +107,22 @@ private void SetupCounter(GamePlayInfo gamePlayInfo)
int scoreboardCount = gamePlayInfo.scoreboardCount;
float lineOffset = (originalLineOffset * (scoreboardCount / 2)) + (originalLineOffset * (scoreboardCount % 2));
int id = 0;
LeaderBoardGameplayInfo infoScoreSaber = gamePlayInfo.lsInfo.FirstOrDefault(x => x.leaderboard == Leaderboard.ScoreSaber);
LeaderBoardGameplayInfo infoBeatLeader = gamePlayInfo.lsInfo.FirstOrDefault(x => x.leaderboard == Leaderboard.BeatLeader);
LeaderBoardGameplayInfo infoHitBloq = gamePlayInfo.lsInfo.FirstOrDefault(x => x.leaderboard == Leaderboard.HitBloq);
if (infoScoreSaber != null)
{
lsCounterInfoHolder.Add(new CounterInfoHolder(id, Leaderboard.ScoreSaber, Settings, ppPredictorMgr, canvas, CanvasUtility, lineOffset, originalLineOffset, positionScale, infoScoreSaber));
lineOffset -= originalLineOffset * 2;
id++;
}
if (infoBeatLeader != null)
{
lsCounterInfoHolder.Add(new CounterInfoHolder(id, Leaderboard.BeatLeader, Settings, ppPredictorMgr, canvas, CanvasUtility, lineOffset, originalLineOffset, positionScale, infoBeatLeader));
lineOffset -= originalLineOffset * 2;
id++;
}
if (infoHitBloq != null)
CreateCounterInfoHolder(Leaderboard.ScoreSaber, gamePlayInfo, canvas, positionScale, ref lineOffset, ref id);
CreateCounterInfoHolder(Leaderboard.BeatLeader, gamePlayInfo, canvas, positionScale, ref lineOffset, ref id);
CreateCounterInfoHolder(Leaderboard.HitBloq, gamePlayInfo, canvas, positionScale, ref lineOffset, ref id);
CreateCounterInfoHolder(Leaderboard.AccSaber, gamePlayInfo, canvas, positionScale, ref lineOffset, ref id);
_isCounterCreated = true;
}

private void CreateCounterInfoHolder(Leaderboard leaderboard, GamePlayInfo gamePlayInfo, Canvas canvas, float positionScale, ref float lineOffset, ref int id)
{
LeaderBoardGameplayInfo leaderBoardInfo = gamePlayInfo.lsInfo.FirstOrDefault(x => x.leaderboard == leaderboard);
if (leaderBoardInfo != null)
{
lsCounterInfoHolder.Add(new CounterInfoHolder(id, Leaderboard.HitBloq, Settings, ppPredictorMgr, canvas, CanvasUtility, lineOffset, originalLineOffset, positionScale, infoHitBloq));
lsCounterInfoHolder.Add(new CounterInfoHolder(id, leaderboard, Settings, ppPredictorMgr, canvas, CanvasUtility, lineOffset, originalLineOffset, positionScale, leaderBoardInfo));
lineOffset -= originalLineOffset * 2;
id++;
}
_isCounterCreated = true;
}

private void DisplayCounterText(GamePlayInfo gameplayInfo)
Expand Down
60 changes: 60 additions & 0 deletions PPPredictor/Data/Curve/CurveParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,64 @@ class CurveParser
(0.65, 0.5866010012767576),
(0.6, 0.18223233667439062),
(0.0, 0.0) });
private static readonly List<(double, double)> arrPPCurveAccSaber = new List<(double, double)>(new (double, double)[57] {
(1, 1),
(0.999798868015323, 1),
(0.998801667612258, 0.881036259003904),
(0.997597817448282, 0.807864970846212),
(0.99638391362715, 0.75398939205533),
(0.995192826072399, 0.711631856844816),
(0.993982635397878, 0.675758283217714),
(0.992777934371917, 0.645271361873838),
(0.991572321617314, 0.618720490847344),
(0.990361642931305, 0.595172789623826),
(0.989158767583543, 0.574249679995056),
(0.987946216049906, 0.555191831755976),
(0.986753843546214, 0.538101879298717),
(0.985534556510679, 0.522047289016481),
(0.984334431588307, 0.507436997518391),
(0.983122724803697, 0.493713431180267),
(0.981930401543003, 0.481080710912171),
(0.980712192241952, 0.468949988213597),
(0.979514528967426, 0.457693261261058),
(0.978307874266188, 0.446942167537732),
(0.977108280868104, 0.436772954869709),
(0.975901793480846, 0.427008348566038),
(0.974689649744553, 0.417614336191856),
(0.973487723323, 0.408667608162045),
(0.972282442566079, 0.400025710310081),
(0.971075080678785, 0.39166641973516),
(0.9698668993297, 0.383569905983769),
(0.968659134866764, 0.37571839822792),
(0.967452986936859, 0.368095908419736),
(0.96624960935703, 0.360687999490072),
(0.965050103040447, 0.353481590071579),
(0.963842342827163, 0.346388277643642),
(0.96262795728598, 0.339405506964074),
(0.961433998563471, 0.33267290950433),
(0.96022316288647, 0.325967205856964),
(0.95902216724236, 0.319426258587104),
(0.957807698698665, 0.312913179773458),
(0.956605438149408, 0.306556377051107),
(0.955404451612776, 0.300287818697188),
(0.954194718585367, 0.29404782746237),
(0.952989233017565, 0.287896269816159),
(0.951778352488454, 0.281776901969062),
(0.950574437220297, 0.275745429410847),
(0.949368212787461, 0.269748820334489),
(0.948161368969195, 0.263789713483043),
(0.946965275751128, 0.257918189085454),
(0.945752195005795, 0.251992953632337),
(0.9445528451823, 0.246159054011439),
(0.943340858876901, 0.240283202722378),
(0.942136498435854, 0.234458953551446),
(0.940932458185028, 0.228646177461935),
(0.939722349385998, 0.222809528908169),
(0.938524585132052, 0.217033357984317),
(0.937316865437844, 0.211205733205298),
(0.936109641452604, 0.205372691403391),
(0.934905010658402, 0.199540078052735),
(0, 0) });
public static IPPPCurve ParseToCurve(CurveInfo curveInfo)
{
switch (curveInfo.CurveType)
Expand All @@ -56,6 +114,8 @@ public static IPPPCurve ParseToCurve(CurveInfo curveInfo)
return new CustomPPPCurve(curveInfo.ArrPPCurve, Utilities.CurveType.Linear, curveInfo.BasePPMultiplier.GetValueOrDefault());
case Utilities.CurveType.Basic:
return CustomPPPCurve.CreateBasicPPPCurve(curveInfo.BasePPMultiplier.GetValueOrDefault(), curveInfo.Baseline, curveInfo.Exponential, curveInfo.Cutoff);
case Utilities.CurveType.AccSaber:
return new CustomPPPCurve(arrPPCurveAccSaber, Utilities.CurveType.AccSaber, 61, starOffest: 18);
default:
return CustomPPPCurve.CreateDummyPPPCurve();
}
Expand Down
12 changes: 9 additions & 3 deletions PPPredictor/Data/Curve/CustomPPPCurve.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using PPPredictor.Interfaces;
using PPPredictor.OpenAPIs;
using PPPredictor.Utilities;
using System;
using System.Linq;
Expand All @@ -13,18 +12,20 @@ class CustomPPPCurve : IPPPCurve
private readonly List<(double, double)> arrPPCurve;
private readonly CurveType curveType;
private readonly double basePPMultiplier;
private readonly double starOffest = 0;
private readonly double? baseline;
private readonly double? exponential;
private readonly double? cutoff;
private readonly bool _isDummy;
public bool IsDummy { get => _isDummy; }

public CustomPPPCurve(List<(double, double)> arrPPCurve, CurveType curveType, double basePPMultiplier, bool isDummy = false)
public CustomPPPCurve(List<(double, double)> arrPPCurve, CurveType curveType, double basePPMultiplier, bool isDummy = false, double starOffest = 0)
{
this.arrPPCurve = arrPPCurve;
this.curveType = curveType;
this.basePPMultiplier = basePPMultiplier;
_isDummy = isDummy;
this.starOffest = starOffest;
}

private CustomPPPCurve(List<(double, double)> arrPPCurve, double basePPMultiplier, double? baseline, double? exponential, double? cutoff, bool isDummy = false) : this(arrPPCurve, CurveType.Basic, basePPMultiplier, isDummy)
Expand Down Expand Up @@ -68,6 +69,8 @@ public double CalculatePPatPercentage(PPPBeatMapInfo beatMapInfo, double percent
return BasicCurveCalculatePPatPercentage(beatMapInfo, percentage);
case CurveType.ScoreSaber:
return LinearCalculatePPatPercentage(beatMapInfo, failed ? percentage / 2.0f : percentage);
case CurveType.AccSaber:
return LinearCalculatePPatPercentage(beatMapInfo, failed ? percentage / 2.0f : percentage);
default:
return 0;
}
Expand All @@ -88,9 +91,10 @@ private double LinearCalculatePPatPercentage(PPPBeatMapInfo beatMapInfo, double
{
try
{
if (!beatMapInfo.ModifiedStarRating.IsRanked()) return 0; //Needed because of starOffset in AccSaber
percentage /= 100.0;
double multiplier = CalculateMultiplierAtPercentage(percentage);
return multiplier * beatMapInfo.ModifiedStarRating.Stars * basePPMultiplier;
return multiplier * (beatMapInfo.ModifiedStarRating.Stars + starOffest) * basePPMultiplier;
}
catch (Exception ex)
{
Expand Down Expand Up @@ -167,6 +171,8 @@ public CurveInfo ToCurveInfo()
return new CurveInfo(CurveType.ScoreSaber);
case CurveType.Basic:
return new CurveInfo(CurveType.Basic, this.arrPPCurve, this.basePPMultiplier, this.baseline, this.exponential, this.cutoff);
case CurveType.AccSaber:
return new CurveInfo(CurveType.AccSaber);
default:
return new CurveInfo(CurveType.Linear, this.arrPPCurve, this.basePPMultiplier);
}
Expand Down
36 changes: 36 additions & 0 deletions PPPredictor/Data/LeaderBoardDataTypes/AccSaberDataTypes.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System;

namespace PPPredictor.Data.LeaderBoardDataTypes
{
internal class AccSaberDataTypes
{
internal class AccSaberScores
{
public double ap { get; set; }
public double weightedAp { get; set; }
public string songHash { get; set; }
public string difficulty { get; set; }
public DateTime timeSet { get; set; }
public string categoryDisplayName { get; set; }
}

internal class AccSaberPlayer
{
public int rank { get; set; }
public double ap { get; set; }
}

internal class AccSaberMapPool
{
public string categoryName { get; set; }
public string categoryDisplayName { get; set; }
}

internal class AccSaberRankedMap
{
public string difficulty { get; set; }
public string songHash { get; set; }
public double complexity { get; set; }
}
}
}
3 changes: 0 additions & 3 deletions PPPredictor/Data/LeaderBoardDataTypes/BeatLeaderDataTypes.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
using PPPredictor.Utilities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace PPPredictor.Data.LeaderBoardDataTypes
{
Expand Down
4 changes: 2 additions & 2 deletions PPPredictor/Data/PPGainResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ class PPGainResult

public PPGainResult() : this(0,0,0) { }

public PPGainResult(double ppTotal, double ppGain, double ppGainRaw)
public PPGainResult(double ppTotal, double ppGainWeighted, double ppGainRaw)
{
_ppTotal = ppTotal;
_ppGainWeighted = ppGain;
_ppGainWeighted = ppGainWeighted;
_ppGainRaw = ppGainRaw;
}

Expand Down
Loading

0 comments on commit 9715add

Please sign in to comment.