Exemplo n.º 1
0
        public float GetAcc(SongID songID)
        {
            // First check for song specific accuracy
            if (_songSpecificAcc.ContainsKey(songID))
            {
                return(RoundedAcc(_songSpecificAcc[songID]));
            }

            double bestAcc = 0;

            // Next check for max of current best acc and star acc
            if (ProfileDataLoader.instance.songDataInfo.ContainsKey(songID))
            {
                bestAcc = ProfileDataLoader.instance.songDataInfo[songID].acc;
            }

            // Next check for star acc
            var star = SongDataUtils.GetRoundedStars(songID);

            if (_starAcc.ContainsKey(star))
            {
                bestAcc = Math.Max(bestAcc, _starAcc[star]);
            }

            if (bestAcc > 0)
            {
                return(RoundedAcc(bestAcc));
            }

            // Finally resort to default
            return(Config.defaultAcc);
        }
Exemplo n.º 2
0
        public static float GetRawPP(SongID songID)
        {
            if (!init)
            {
                Logger.log.Error("Tried to use RawPPLoader when it wasn't initialized!");
                throw new Exception("Tried to use RawPPLoader when it wasn't initialized");
            }

            switch (songID.difficulty)
            {
            case BeatmapDifficulty.Easy:
                return(_songData[songID.id]._Easy_SoloStandard);

            case BeatmapDifficulty.Normal:
                return(_songData[songID.id]._Normal_SoloStandard);

            case BeatmapDifficulty.Hard:
                return(_songData[songID.id]._Hard_SoloStandard);

            case BeatmapDifficulty.Expert:
                return(_songData[songID.id]._Expert_SoloStandard);

            case BeatmapDifficulty.ExpertPlus:
                return(_songData[songID.id]._ExpertPlus_SoloStandard);

            default:
                Logger.log.Error("Unknown beatmap difficulty: " + songID.difficulty.ToString());
                throw new Exception("Unknown difficultry");
            }
        }
Exemplo n.º 3
0
        // Purposefully ignore modifiers here - only 2 maps have them enabled and it doesn't make much sense to just filter to those two
        private static float GetHighestPP(IPreviewBeatmapLevel previewBeatmapLevel, bool ppGain)
        {
            float maxPP = 0;
            var   id    = SongDataUtils.GetHash(previewBeatmapLevel.levelID);

            // Check if in SDC
            if (SongDataCore.Plugin.Songs.Data.Songs.ContainsKey(id))
            {
                // Loop through each diff
                foreach (var diff in SongDataCore.Plugin.Songs.Data.Songs[id].diffs)
                {
                    var difficulty = SongDataUtils.GetBeatmapDifficulty(diff.diff);
                    var songID     = new SongID(id, difficulty);
                    // Only go through ranked songs
                    if (SongDataUtils.IsRankedSong(songID))
                    {
                        float pp = PPUtils.CalculatePP(songID, AccLoader.instance.GetAcc(songID));
                        if (ppGain)
                        {
                            pp = PPUtils.GetPPGain(pp, songID);
                        }
                        maxPP = pp > maxPP ? pp : maxPP;
                    }
                }
                return(maxPP);
            }
            return(0);
        }
Exemplo n.º 4
0
        IEnumerator FindDifficultyBeatmap()
        {
            yield return(new WaitUntil(() => BS_Utils.Plugin.LevelData.IsSet));

            _difficultyBeatmap = BS_Utils.Plugin.LevelData.GameplayCoreSceneSetupData.difficultyBeatmap;
            _songID            = new SongID(SongDataUtils.GetHash(_difficultyBeatmap.level.levelID), _difficultyBeatmap.difficulty);
            _rawPP             = SongDataUtils.GetRawPP(_songID);

            // modifiers
            var gameplayModifiersModelSO = Resources.FindObjectsOfTypeAll <GameplayModifiersModelSO>().FirstOrDefault();
            var gameplayModifiers        = BS_Utils.Plugin.LevelData.GameplayCoreSceneSetupData.gameplayModifiers;

            _multiplier = gameplayModifiersModelSO.GetTotalMultiplier(gameplayModifiers);
            _multiplier = (Config.ignoreNoFail && gameplayModifiers.noFail) ? _multiplier + 0.5 : _multiplier;

            // Only update for ranked songs
            if (SongDataUtils.IsRankedSong(_songID))
            {
                yield return(new WaitUntil(() => _beatmapObjectManager != null));

                _beatmapObjectManager.noteWasCutEvent    += OnNoteCut;
                _beatmapObjectManager.noteWasMissedEvent += OnNoteMissed;

                yield return(new WaitUntil(() => _scoreController != null));

                _scoreController.scoreDidChangeEvent += OnScoreChange;
                if (!Config.hideOnStart)
                {
                    UpdateCounter();
                }
            }
        }
Exemplo n.º 5
0
 public static float GetRawPP(SongID songID)
 {
     if (RawPPLoader.InDict(songID.id))
     {
         return(RawPPLoader.GetRawPP(songID));
     }
     return(0);
 }
Exemplo n.º 6
0
 public static bool IsRankedSong(SongID songID)
 {
     if (RawPPLoader.InDict(songID.id))
     {
         return(RawPPLoader.GetRawPP(songID) > 0);
     }
     return(false);
 }
Exemplo n.º 7
0
 public static void UpdatePlayHistory(SongID songID, double acc)
 {
     Logger.log.Debug($"Updating play history w/ {acc} on {songID}");
     if (!playHistory.ContainsKey(songID) || acc > playHistory[songID])
     {
         playHistory[songID] = acc;
         WriteToPlayHistory();
     }
 }
Exemplo n.º 8
0
        public override TrackLink ToLink()
        {
            TrackLink link = new TrackLink("gs");

            link["S"]  = SongID.ToString(CultureInfo.InvariantCulture);
            link["A"]  = ArtistID.ToString(CultureInfo.InvariantCulture);
            link["N"]  = Name;
            link["AR"] = Artist;
            return(link);
        }
Exemplo n.º 9
0
        public void SubmitPlay(SongID songID, double acc)
        {
            // Unplayed or better than previous acc
            if (!songDataInfo.ContainsKey(songID) || acc > songDataInfo[songID].acc)
            {
                Logger.log.Debug("Unplayed or better score");
                double pp       = PPUtils.CalculatePP(songID, (float)(acc * 100));
                int    oldIndex = songDataInfo.ContainsKey(songID) ? songIndex[songID] : songIndex.Count;
                double weight   = Double.NegativeInfinity;
                // Find first song that it's worth more than
                var i = 0;
                foreach (var song in songOrder)
                {
                    var songWorth = songDataInfo[song].pp;
                    if (songWorth < pp)
                    {
                        weight = songDataInfo[song].weight;
                        break;
                    }
                    i++;
                }

                // found a song it's worth more than, decrease weight of songs below it that are above original
                if (weight != Double.NegativeInfinity)
                {
                    for (; i < oldIndex; i++)
                    {
                        var song = songOrder[i];
                        songDataInfo[song].weight *= PPUtils.FALLOFF_RATE;
                    }
                }
                // Lowest value song
                else
                {
                    Logger.log.Debug("Lowest value song");
                    weight = songDataInfo[songOrder.Last()].weight * PPUtils.FALLOFF_RATE;
                }

                // Add/update this song
                songDataInfo[songID] = new SongData(acc, pp, weight);
                // recalculate and save data
                CalculateSums();
                SaveSongData();
            }
        }
Exemplo n.º 10
0
        public void LevelCleared(StandardLevelScenesTransitionSetupDataSO standardLevelScenesTransitionSetupDataSO, LevelCompletionResults levelCompletionResults)
        {
            Logger.log.Debug("Level cleared");
            // Score submission disabled or using practice mode
            if (BS_Utils.Gameplay.ScoreSubmission.WasDisabled || BS_Utils.Gameplay.ScoreSubmission.ProlongedDisabled ||
                ((GameplayCoreSceneSetupData)standardLevelScenesTransitionSetupDataSO.sceneSetupDataArray.First(x => x.GetType().Equals(typeof(GameplayCoreSceneSetupData)))).practiceSettings != null)
            {
                Logger.log.Debug("Practice mode or score disabled");
                return;
            }

            var gameplayCoreSceneSetupData = ((GameplayCoreSceneSetupData)standardLevelScenesTransitionSetupDataSO.sceneSetupDataArray[1]);
            var difficultyBeatmap          = gameplayCoreSceneSetupData.difficultyBeatmap;

            SongID songID = SongDataUtils.GetSongID(difficultyBeatmap);

            // I don't like putting play history here but until I do a refactor I'm gonna keep it here
            if (SongDataUtils.IsRankedSong(songID) || Config.playHistory)
            {
                Logger.log.Debug("Beat song");
                GameplayModifiers modifiers = new GameplayModifiers(levelCompletionResults.gameplayModifiers);
                // Remove positive modifiers if not allowed
                if (!PPUtils.AllowedModifiers(songID.id, modifiers))
                {
                    Logger.log.Debug("Using invalid modifiers, removing from score");
                    modifiers = BeatSaberUtils.RemovePositiveModifiers(modifiers);
                }

                var    multiplier = levelCompletionResults.gameplayModifiersModel.GetTotalMultiplier(modifiers);
                var    score      = levelCompletionResults.rawScore * multiplier;
                var    maxScore   = ScoreModel.MaxRawScoreForNumberOfNotes(difficultyBeatmap.beatmapData.notesCount);
                double acc        = (double)score / (double)maxScore;
                Logger.log.Debug($"acc: {acc}");

                if (SongDataUtils.IsRankedSong(songID))
                {
                    SubmitPlay(songID, acc);
                }
                else
                {
                    PlayHistoryTracker.UpdatePlayHistory(songID, acc);
                }
            }
        }
Exemplo n.º 11
0
        public override void CounterInit()
        {
            var id = SongDataUtils.GetHash(difficultyBeatmap.level.levelID);

            songID = new SongID(id, difficultyBeatmap.difficulty);

            // Don't show anything for unranked songs or if data not initialized
            if (!ppUtils.DataInitialized() || !ppUtils.IsRanked(songID))
            {
                return;
            }

            var gameplayModifiersModelSO = IPA.Utilities.FieldAccessor <RelativeScoreAndImmediateRankCounter, GameplayModifiersModelSO> .Get(relativeScoreAndImmediateRank, "_gameplayModifiersModel");

            GameplayModifiers updatedModifiers = ppUtils.AllowedPositiveModifiers(songID) ?
                                                 gameplayModifiers : GameplayModifierUtils.RemovePositiveModifiers(gameplayModifiers);

            _multiplier = GameplayModifierUtils.CalculateMultiplier(gameplayModifiersModelSO, updatedModifiers);

            counter          = CanvasUtility.CreateTextFromSettings(Settings);
            counter.fontSize = 3;

            relativeScoreAndImmediateRank.relativeScoreOrImmediateRankDidChangeEvent += ScoreUpdated;
            UpdateCounterText(ppUtils.CalculatePP(songID, _multiplier, ppUtils.AllowedPositiveModifiers(songID)));

            if (PluginSettings.Instance.relativeGain)
            {
                var highScore = playerDataModel.playerData.GetPlayerLevelStatsData(difficultyBeatmap).highScore;
                if (highScore == 0)
                {
                    _pbPP = 0;
                    return;
                }

                var maxScore = ScoreModel.ComputeMaxMultipliedScoreForBeatmap(beatmapData);
                var acc      = (float)highScore / maxScore;
                _pbPP = ppUtils.CalculatePP(songID, acc, ppUtils.AllowedPositiveModifiers(songID));
            }
        }
Exemplo n.º 12
0
 public override string ToString()
 {
     return(string.Format("{0:20} | {1:15} | {2:15} | {3:15} | {4:2} | {5:15} ", Score.ToString(), SongID.ToString(), GameType.ToString(), Name.ToString(), Grade.ToString(), Difficulty.ToString()));
 }
Exemplo n.º 13
0
 internal void ClearAcc(SongID id)
 {
     _songSpecificAcc.Remove(id);
     WriteSongSpecificAccuracy();
 }
Exemplo n.º 14
0
 internal void SaveAcc(SongID id, float accuracy)
 {
     _songSpecificAcc[id] = accuracy / 100f;
     WriteSongSpecificAccuracy();
 }
Exemplo n.º 15
0
        private static SongDataCore.BeatStar.BeatStarSongDifficultyStats GetDifficultyStat(SongID songID)
        {
            var difficultyStats = SongDataCore.Plugin.Songs.Data.Songs[songID.id].diffs;

            foreach (var difficultyStat in difficultyStats)
            {
                if (difficultyStat.diff.Equals(SongDataUtils.GetDifficultyAsString(songID.difficulty)))
                {
                    return(difficultyStat);
                }
            }

            throw new ArgumentException();
        }
Exemplo n.º 16
0
        public static double GetRoundedStars(SongID songID)
        {
            var star = GetStars(songID);

            return(GetRoundedStars(star));
        }
Exemplo n.º 17
0
        public static double GetStars(SongID songID)
        {
            var difficultyStat = GetDifficultyStat(songID);

            return(difficultyStat.star);
        }
Exemplo n.º 18
0
        protected virtual UriQuery GetUriQuery()
        {
            UriQuery query = new UriQuery(BaseUrl);

            query.Add("api_key", ApiKey);
            query.Add("format", "json");

            if (!string.IsNullOrEmpty(Type))
            {
                query.Add("type", Type);
            }

            if (ArtistID.Count() > 0)
            {
                foreach (Term artistId in ArtistID)
                {
                    query.Add("artist_id", artistId);
                }
            }

            if (Artist.Count() > 0)
            {
                foreach (Term artist in Artist)
                {
                    query.Add("artist", artist);
                }
            }

            if (SongID.Count() > 0)
            {
                foreach (Term songId in SongID)
                {
                    query.Add("song_id", songId);
                }
            }

            if (TrackID.Count() > 0)
            {
                foreach (Term trackId in TrackID)
                {
                    query.Add("track_id", trackId);
                }
            }

            if (Results.HasValue)
            {
                query.Add("results", Results.Value);
            }

            if (Bucket.HasValue)
            {
                foreach (string bucket in Bucket.Value.GetBucketDescriptions())
                {
                    query.Add("bucket", bucket);
                }
            }

            if (Limit.HasValue)
            {
                query.Add("limit", Limit.Value.ToString().ToLower());
            }

            if (Dmca.HasValue)
            {
                query.Add("dmca", Dmca.Value.ToString().ToLower());
            }

            return(query);
        }