Пример #1
0
        public ProgressionAchievements ProgessionSource(Guid GameSourceId)
        {
            ProgressionAchievements Result = new ProgressionAchievements();
            int Total    = 0;
            int Locked   = 0;
            int Unlocked = 0;

            try
            {
                foreach (var item in Database.Items)
                {
                    Guid Id               = item.Key;
                    Game Game             = _PlayniteApi.Database.Games.Get(Id);
                    var  GameAchievements = item.Value;

                    if (GameAchievements.HaveAchivements && Game.SourceId == GameSourceId)
                    {
                        Total    += GameAchievements.Total;
                        Locked   += GameAchievements.Locked;
                        Unlocked += GameAchievements.Unlocked;
                    }
                }
            }
            catch (Exception ex)
            {
                Common.LogError(ex, "SuccessStroy", $"Error on ProgessionSource()");
            }

            Result.Total       = Total;
            Result.Locked      = Locked;
            Result.Unlocked    = Unlocked;
            Result.Progression = (Total != 0) ? (int)Math.Ceiling((double)(Unlocked * 100 / Total)) : 0;

            return(Result);
        }
Пример #2
0
        public ProgressionAchievements ProgessionLaunched()
        {
            ProgressionAchievements Result = new ProgressionAchievements();
            int Total    = 0;
            int Locked   = 0;
            int Unlocked = 0;

            try
            {
                foreach (var item in Database.Items)
                {
                    var GameAchievements = item.Value;

                    if (GameAchievements.HaveAchivements && _PlayniteApi.Database.Games.Get(item.Key).Playtime > 0)
                    {
                        Total    += GameAchievements.Total;
                        Locked   += GameAchievements.Locked;
                        Unlocked += GameAchievements.Unlocked;
                    }
                }
            }
            catch (Exception ex)
            {
                Common.LogError(ex, "SuccessStroy", $"Error on ProgessionLaunched()");
            }

            Result.Total       = Total;
            Result.Locked      = Locked;
            Result.Unlocked    = Unlocked;
            Result.Progression = (Total != 0) ? (int)Math.Round((double)(Unlocked * 100 / Total)) : 0;

            return(Result);
        }