Skip to content

Commit

Permalink
Merge pull request #8 from no-1-noob/TriangleOfDoom
Browse files Browse the repository at this point in the history
BL: Triangle PP Calculation
  • Loading branch information
no-1-noob authored Apr 11, 2023
2 parents 890fc68 + ab4455e commit a16eae4
Show file tree
Hide file tree
Showing 16 changed files with 223 additions and 92 deletions.
6 changes: 2 additions & 4 deletions PPPredictor/Counter/CounterInfoHolder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ class CounterInfoHolder
private readonly CustomConfigModel settings;
private readonly CanvasUtility canvasUtility;
private GameplayModifiers gameplayModifiers;
private double modifiedStars;
private float positionScale;
private double maxPP = -1;

Expand Down Expand Up @@ -65,7 +64,6 @@ public CounterInfoHolder(Leaderboard leaderboard, CustomConfigModel settings, st
icon = CreateIcon(canvas, iconPath, new Vector3((-1f + centerOffset) * positionScaleFactor, lineOffset, 0), Math.Abs(lineOffset));
}
this.gameplayModifiers = gameplayModifiers;
modifiedStars = Plugin.pppViewController.ppPredictorMgr.GetModifiedStarsForCalculator(leaderboard, gameplayModifiers);
}

private float getCenterOffset()
Expand Down Expand Up @@ -105,10 +103,10 @@ public void UpdateCounterText(double percentage, bool levelFailed)
if (showInfo)
{
if (Plugin.ProfileInfo.CounterUseIcons) icon.enabled = true;
double pp = Plugin.pppViewController.ppPredictorMgr.GetPPAtPercentageForCalculator(leaderboard, percentage, levelFailed, modifiedStars, gameplayModifiers);
double pp = Plugin.pppViewController.ppPredictorMgr.GetPPAtPercentageForCalculator(leaderboard, percentage, levelFailed, gameplayModifiers);
double ppGain = Math.Round(Plugin.pppViewController.ppPredictorMgr.GetPPGainForCalculator(leaderboard, pp), 2);

if (maxPP == -1) maxPP = Plugin.pppViewController.ppPredictorMgr.GetMaxPPForCalculator(leaderboard, modifiedStars, gameplayModifiers);
if (maxPP == -1) maxPP = Plugin.pppViewController.ppPredictorMgr.GetMaxPPForCalculator(leaderboard, gameplayModifiers);

string maxPPReachedPrefix = string.Empty;
string maxPPReachedSuffix = string.Empty;
Expand Down
8 changes: 4 additions & 4 deletions PPPredictor/Data/PPPBeatMapInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@
{
public class PPPBeatMapInfo
{
double _baseStars = 0;
PPPStarRating _baseStarRating = new PPPStarRating();
int _modifierValueId = 0;

public double BaseStars { get => _baseStars; set => _baseStars = value; }
public PPPStarRating BaseStarRating { get => _baseStarRating; set => _baseStarRating = value; }
public int ModifierValueId { get => _modifierValueId; set => _modifierValueId = value; }

public PPPBeatMapInfo()
{
}

public PPPBeatMapInfo(double baseStars, int modifierValueId)
public PPPBeatMapInfo(PPPStarRating baseStars, int modifierValueId)
{
_baseStars = baseStars;
_baseStarRating = baseStars;
_modifierValueId = modifierValueId;
}
}
Expand Down
56 changes: 56 additions & 0 deletions PPPredictor/Data/PPPStarRating.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
using beatleaderapi;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace PPPredictor.Data
{
public class PPPStarRating
{
private double _stars = 0;
private double _predictedAcc = 0;
private double _passRating = 0;
private double _accRating = 0;
private double _techRating = 0;
private Dictionary<string, double> _modifiersRating = new Dictionary<string, double>();

[DefaultValue(0)]
public double Stars { get => _stars; set => _stars = value; }
[DefaultValue(0)]
public double PredictedAcc { get => _predictedAcc; set => _predictedAcc = value; }
[DefaultValue(0)]
public double PassRating { get => _passRating; set => _passRating = value; }
[DefaultValue(0)]
public double AccRating { get => _accRating; set => _accRating = value; }
[DefaultValue(0)]
public double TechRating { get => _techRating; set => _techRating = value; }
[DefaultValue(null)]
public Dictionary<string, double> ModifiersRating { get => _modifiersRating; set => _modifiersRating = value; }

public PPPStarRating()
{
}

public PPPStarRating(double starRating)
{
_stars = _predictedAcc = _passRating = _accRating = _techRating = starRating;
}

public PPPStarRating(DifficultyDescription beatLeaderDifficulty)
{
_predictedAcc = beatLeaderDifficulty.PredictedAcc.GetValueOrDefault();
_passRating = beatLeaderDifficulty.PassRating.GetValueOrDefault();
_accRating = beatLeaderDifficulty.AccRating.GetValueOrDefault();
_techRating = beatLeaderDifficulty.TechRating.GetValueOrDefault();
_modifiersRating = beatLeaderDifficulty.ModifiersRating ?? null;
}

public bool IsRanked()
{
return _predictedAcc > 0 || _passRating > 0 || _accRating > 0 || _techRating > 0 || _stars > 0;
}
}
}
12 changes: 6 additions & 6 deletions PPPredictor/Data/ShortScore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ public class ShortScore
{
private readonly string _searchstring;
private double _pp;
private double _stars;
private PPPStarRating _starRating;
private DateTime _fetchTime;
private int _modifierValuesId;

public string Searchstring { get => _searchstring; }
public double Pp { get => _pp; set => _pp = value; }
public double Stars { get => _stars; set => _stars = value; }
public PPPStarRating StarRating { get => _starRating; set => _starRating = value; }
public DateTime FetchTime { get => _fetchTime; set => _fetchTime = value; }
public int ModifierValuesId { get => _modifierValuesId; set => _modifierValuesId = value; }

Expand All @@ -23,20 +23,20 @@ public ShortScore(string searchstring, double pp)
this._pp = pp;
}

public ShortScore(string searchstring, double stars, DateTime fetchTime, int modifierValuesId)
public ShortScore(string searchstring, PPPStarRating starRating, DateTime fetchTime, int modifierValuesId)
{
this._searchstring = searchstring.ToUpper();
this._fetchTime = fetchTime;
this._stars = stars;
this._starRating = starRating;
this._modifierValuesId = modifierValuesId;
}
[JsonConstructor]
public ShortScore(string searchstring, double pp, double stars, DateTime fetchTime, int modifierValuesId)
public ShortScore(string searchstring, double pp, PPPStarRating starRating, DateTime fetchTime, int modifierValuesId)
{
this._searchstring = searchstring.ToUpper();
this._pp = pp;
this._fetchTime = fetchTime;
this._stars = stars;
this._starRating = starRating;
this._modifierValuesId = modifierValuesId;
}
}
Expand Down
8 changes: 4 additions & 4 deletions PPPredictor/Interfaces/IPPPredictor.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.ComponentModel;
using PPPredictor.Data;
using System.ComponentModel;
using System.Threading.Tasks;

namespace PPPredictor.Interfaces
Expand All @@ -12,9 +13,8 @@ interface IPPPredictor
Task UpdateCurrentAndCheckResetSession(bool doResetSession);
void RefreshCurrentData(int fetchLength);
void ResetDisplay(bool resetAll);
double CalculatePPatPercentage(double stars, double percentage, GameplayModifiers gameplayModifiers, bool levelFailed = false);
double CalculateMaxPP(double stars, GameplayModifiers gameplayModifiers);
double GetModifiedStars(GameplayModifiers gameplayModifiers);
double CalculatePPatPercentage(double percentage, GameplayModifiers gameplayModifiers, bool levelFailed = false);
double CalculateMaxPP(GameplayModifiers gameplayModifiers);
double CalculatePPGain(double pp);
bool IsRanked();
void DisplayPP();
Expand Down
18 changes: 16 additions & 2 deletions PPPredictor/OpenAPIs/beatleader-v1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -665,10 +665,22 @@ public partial class DifficultyDescription

[Newtonsoft.Json.JsonProperty("rankedTime", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
public int RankedTime { get; set; }

[Newtonsoft.Json.JsonProperty("stars", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
public float? Stars { get; set; }


[Newtonsoft.Json.JsonProperty("predictedAcc", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
public float? PredictedAcc { get; set; }

[Newtonsoft.Json.JsonProperty("passRating", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
public float? PassRating { get; set; }

[Newtonsoft.Json.JsonProperty("accRating", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
public float? AccRating { get; set; }

[Newtonsoft.Json.JsonProperty("techRating", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
public float? TechRating { get; set; }

[Newtonsoft.Json.JsonProperty("type", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
public int Type { get; set; }

Expand All @@ -692,6 +704,8 @@ public partial class DifficultyDescription

[Newtonsoft.Json.JsonProperty("modifierValues", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
public Dictionary<string, float> ModifierValues { get; set; }
[Newtonsoft.Json.JsonProperty("modifiersRating", Required = Newtonsoft.Json.Required.AllowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
public Dictionary<string, double> ModifiersRating { get; set; }


}
Expand Down
1 change: 1 addition & 0 deletions PPPredictor/PPPredictor.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@
<Compile Include="Data\PPPPlayer.cs" />
<Compile Include="Data\PPPScore.cs" />
<Compile Include="Data\PPPScoreCollection.cs" />
<Compile Include="Data\PPPStarRating.cs" />
<Compile Include="Installers\PPPPredictorDisplayInstaller.cs" />
<Compile Include="Events\PPPredictorEventsMgr.cs" />
<Compile Include="Data\ProfileInfo.cs" />
Expand Down
4 changes: 2 additions & 2 deletions PPPredictor/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.6.2")]
[assembly: AssemblyFileVersion("0.6.2")]
[assembly: AssemblyVersion("0.6.3")]
[assembly: AssemblyFileVersion("0.6.3")]
7 changes: 3 additions & 4 deletions PPPredictor/Utilities/PPCalculator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public abstract class PPCalculator
{
private List<PPPPlayer> _lsPlayerRankings;
internal PPPLeaderboardInfo _leaderboardInfo;
internal double accConstant = 0.965;

public PPCalculator()
{
Expand Down Expand Up @@ -200,7 +201,7 @@ public async Task<RankGainResult> GetPlayerRankGain(double pp)

public double WeightPP(double rawPP, int index)
{
return rawPP * Math.Pow(0.965, (index - 1));
return rawPP * Math.Pow(accConstant, (index - 1));
}

public string CreateSeachString(string hash, string gameMode, int difficulty)
Expand All @@ -222,11 +223,9 @@ public double Zeroizer(double pp)

protected abstract Task<List<PPPPlayer>> GetPlayers(double fetchIndexPage);

public abstract double CalculatePPatPercentage(double star, double percentage, bool levelFailed);
public abstract double CalculatePPatPercentage(PPPBeatMapInfo currentBeatMapInfo, double percentage, bool levelFailed, GameplayModifiers gameplayModifiers);

public abstract Task<PPPBeatMapInfo> GetBeatMapInfoAsync(LevelSelectionNavigationController lvlSelectionNavigationCtrl, IDifficultyBeatmap beatmap);

public abstract double ApplyModifierMultiplierToStars(PPPBeatMapInfo beatMapInfo, GameplayModifiers gameplayModifiers, bool levelFailed = false);

}
}
Loading

0 comments on commit a16eae4

Please sign in to comment.