Esempio n. 1
0
 public void Dirty(Inventory inventory, ISession session)
 {
     _exportStats  = GetCurrentInfo(inventory);
     TotalStardust = inventory.GetStarDust();
     DirtyEvent?.Invoke();
     OnStatisticChanged(session);
 }
        public StatsExport GetCurrentInfo(Inventory inventory)
        {
            var         stats  = inventory.GetPlayerStats().Result;
            StatsExport output = null;
            var         stat   = stats.FirstOrDefault();

            if (stat != null)
            {
                var ep      = stat.NextLevelXp - stat.PrevLevelXp - (stat.Experience - stat.PrevLevelXp);
                var time    = Math.Round(ep / (TotalExperience / GetRuntime()), 2);
                var hours   = 0.00;
                var minutes = 0.00;
                if (double.IsInfinity(time) == false && time > 0)
                {
                    hours   = Math.Truncate(TimeSpan.FromHours(time).TotalHours);
                    minutes = TimeSpan.FromHours(time).Minutes;
                }

                output = new StatsExport
                {
                    Level             = stat.Level,
                    HoursUntilLvl     = hours,
                    MinutesUntilLevel = minutes,
                    CurrentXp         = stat.Experience - stat.PrevLevelXp - GetXpDiff(stat.Level),
                    LevelupXp         = stat.NextLevelXp - stat.PrevLevelXp - GetXpDiff(stat.Level)
                };
            }
            return(output);
        }
Esempio n. 3
0
        public StatsExport GetCurrentInfo(Inventory inventory)
        {
            var stats = inventory.GetPlayerStats().Result;
            StatsExport output = null;
            var stat = stats.FirstOrDefault();
            if (stat != null)
            {
                var ep = stat.NextLevelXp - stat.PrevLevelXp - (stat.Experience - stat.PrevLevelXp);
                var time = Math.Round(ep/(TotalExperience/GetRuntime()), 2);
                var hours = 0.00;
                var minutes = 0.00;
                if (double.IsInfinity(time) == false && time > 0)
                {
                    time = Convert.ToDouble(TimeSpan.FromHours(time).ToString("h\\.mm"), CultureInfo.InvariantCulture);
                    hours = Math.Truncate(time);
                    minutes = Math.Round((time - hours)*100);
                }

                output = new StatsExport
                {
                    Level = stat.Level,
                    HoursUntilLvl = hours,
                    MinutesUntilLevel = minutes,
                    CurrentXp = stat.Experience - stat.PrevLevelXp - GetXpDiff(stat.Level),
                    LevelupXp = stat.NextLevelXp - stat.PrevLevelXp - GetXpDiff(stat.Level)
                };
            }
            return output;
        }
Esempio n. 4
0
 public void Dirty(Inventory inventory, ISession session)
 {
     _exportStats  = GetCurrentInfo(session, inventory).Result;
     TotalStardust = inventory.GetStarDust();
     TinyIoCContainer.Current.Resolve <MultiAccountManager>().DirtyEventHandle(this);
     DirtyEvent?.Invoke();
     OnStatisticChanged(session);
 }
Esempio n. 5
0
        public StatsExport GetCurrentInfo(Inventory inventory)
        {
            var         stats  = inventory.GetPlayerStats().Result;
            StatsExport output = null;
            var         stat   = stats.FirstOrDefault();

            if (stat != null)
            {
                var ep      = stat.NextLevelXp - stat.PrevLevelXp - (stat.Experience - stat.PrevLevelXp);
                var time    = Math.Round(ep / (TotalExperience / GetRuntime()), 2);
                var hours   = 0.00;
                var minutes = 0.00;
                if (double.IsInfinity(time) == false && time > 0)
                {
                    hours   = Math.Truncate(TimeSpan.FromHours(time).TotalHours);
                    minutes = TimeSpan.FromHours(time).Minutes;
                }

                if (LevelForRewards == -1 || stat.Level >= LevelForRewards)
                {
                    LevelUpRewardsResponse Result = Execute(inventory).Result;

                    if (Result.ToString().ToLower().Contains("awarded_already"))
                    {
                        LevelForRewards = stat.Level + 1;
                    }

                    if (Result.ToString().ToLower().Contains("success"))
                    {
                        Logger.Write("Leveled up: " + stat.Level, LogLevel.Info);

                        RepeatedField <ItemAward> items = Result.ItemsAwarded;

                        if (items.Any <ItemAward>())
                        {
                            Logger.Write("- Received Items -", LogLevel.Info);
                            foreach (ItemAward item in items)
                            {
                                Logger.Write($"[ITEM] {item.ItemId} x {item.ItemCount} ", LogLevel.Info);
                            }
                        }
                    }
                }

                output = new StatsExport
                {
                    Level             = stat.Level,
                    HoursUntilLvl     = hours,
                    MinutesUntilLevel = minutes,
                    CurrentXp         = stat.Experience - stat.PrevLevelXp - GetXpDiff(stat.Level),
                    LevelupXp         = stat.NextLevelXp - stat.PrevLevelXp - GetXpDiff(stat.Level)
                };
            }
            return(output);
        }
Esempio n. 6
0
 internal void Reset()
 {
     this.TotalExperience         = 0;
     this.TotalItemsRemoved       = 0;
     this.TotalPokemons           = 0;
     this.TotalPokemonEvolved     = 0;
     this.TotalPokestops          = 0;
     this.TotalStardust           = 0;
     this.TotalPokemonTransferred = 0;
     this._initSessionDateTime    = DateTime.Now;
     this._exportStats            = new StatsExport();
 }
Esempio n. 7
0
 public void Dirty(Inventory inventory)
 {
     _exportStats = GetCurrentInfo(inventory);
     DirtyEvent?.Invoke();
 }
Esempio n. 8
0
        public async Task <StatsExport> GetCurrentInfo(ISession session, Inventory inventory)
        {
            var stats = await inventory.GetPlayerStats().ConfigureAwait(false);

            StatsExport output = null;
            var         stat   = stats.FirstOrDefault();

            if (stat != null)
            {
                var ep      = stat.NextLevelXp - stat.Experience;
                var time    = Math.Round(ep / (TotalExperience / GetRuntime()), 2);
                var hours   = 0.00;
                var minutes = 0.00;

                var TotXP = 0;

                for (int i = 0; i < stat.Level + 1; i++)
                {
                    TotXP = TotXP + Statistics.GetXpDiff(i);
                }

                if (double.IsInfinity(time) == false && time > 0)
                {
                    hours   = Math.Truncate(TimeSpan.FromHours(time).TotalHours);
                    minutes = TimeSpan.FromHours(time).Minutes;
                }

                if (LevelForRewards == -1 || stat.Level >= LevelForRewards)
                {
                    if (session.LogicSettings.SkipCollectingLevelUpRewards)
                    {
                        Logger.Write("Current Lvl: " + stat.Level + ". Skipped collecting level up rewards.", LogLevel.Info);
                    }
                    else
                    {
                        LevelUpRewardsResponse Result = await inventory.GetLevelUpRewards(stat.Level).ConfigureAwait(false);

                        if (Result.ToString().ToLower().Contains("awarded_already"))
                        {
                            LevelForRewards = stat.Level + 1;
                        }

                        if (Result.ToString().ToLower().Contains("success"))
                        {
                            Logger.Write($"{session.Profile.PlayerData.Username} has leveled up: " + stat.Level, LogLevel.Info);
                            LevelForRewards = stat.Level + 1;

                            RepeatedField <ItemAward> items = Result.ItemsAwarded;
                            string Rewards = "";

                            if (items.Any <ItemAward>())
                            {
                                Logger.Write("- Received Items -", LogLevel.Info);
                                Rewards = "\nItems Recieved:";
                                foreach (ItemAward item in items)
                                {
                                    Logger.Write($"{item.ItemCount,2:#0}x {item.ItemId}'s", LogLevel.Info);
                                    Rewards += $"\n{item.ItemCount,2:#0}x {item.ItemId}'s";
                                }
                            }

                            if (session.LogicSettings.NotificationConfig.EnablePushBulletNotification)
                            {
                                await PushNotificationClient.SendNotification(session, $"{session.Profile.PlayerData.Username} has leveled up.", $"Trainer just reached level {stat.Level}{Rewards}", true).ConfigureAwait(false);
                            }
                        }
                    }
                }

                output = new StatsExport
                {
                    Level             = stat.Level,
                    HoursUntilLvl     = hours,
                    MinutesUntilLevel = minutes,
                    LevelXp           = TotXP,
                    CurrentXp         = stat.Experience,
                    PreviousXp        = stat.PrevLevelXp,
                    LevelupXp         = stat.NextLevelXp
                };
            }
            return(output);
        }
Esempio n. 9
0
        public async Task <StatsExport> GetCurrentInfo(ISession session, Inventory inventory)
        {
            var stats = await inventory.GetPlayerStats().ConfigureAwait(false);

            StatsExport output = null;
            var         stat   = stats.FirstOrDefault();

            if (stat != null)
            {
                var ep      = stat.NextLevelXp - stat.Experience;
                var time    = Math.Round(ep / (TotalExperience / GetRuntime()), 2);
                var hours   = 0.00;
                var minutes = 0.00;
                if (double.IsInfinity(time) == false && time > 0)
                {
                    hours   = Math.Truncate(TimeSpan.FromHours(time).TotalHours);
                    minutes = TimeSpan.FromHours(time).Minutes;
                }

                if (LevelForRewards == -1 || stat.Level >= LevelForRewards)
                {
                    if (session.LogicSettings.SkipCollectingLevelUpRewards)
                    {
                        Logger.Write("Current level: " + stat.Level + ". Skipped collecting level up rewards.", LogLevel.Info);
                    }
                    else
                    {
                        LevelUpRewardsResponse Result = await GetLevelUpRewards(session).ConfigureAwait(false);

                        if (Result.ToString().ToLower().Contains("awarded_already"))
                        {
                            LevelForRewards = stat.Level + 1;
                        }

                        if (Result.ToString().ToLower().Contains("success"))
                        {
                            Logger.Write("Leveled up: " + stat.Level, LogLevel.Info);

                            RepeatedField <ItemAward> items = Result.ItemsAwarded;

                            if (items.Any <ItemAward>())
                            {
                                Logger.Write("- Received Items -", LogLevel.Info);
                                foreach (ItemAward item in items)
                                {
                                    Logger.Write($"[ITEM] {item.ItemId} x {item.ItemCount} ", LogLevel.Info);
                                }
                            }
                        }
                    }
                }

                output = new StatsExport
                {
                    Level             = stat.Level,
                    HoursUntilLvl     = hours,
                    MinutesUntilLevel = minutes,
                    CurrentXp         = stat.Experience,
                    PreviousXp        = stat.PrevLevelXp,
                    LevelupXp         = stat.NextLevelXp
                };
            }
            return(output);
        }
Esempio n. 10
0
 public void Dirty(Inventory inventory)
 {
     _exportStats = GetCurrentInfo(inventory);
     DirtyEvent?.Invoke();
 }
Esempio n. 11
0
        public StatsExport GetCurrentInfo(Inventory inventory)
        {
            PlayerStats playerStats = inventory.GetPlayerStats().Result;

            if (playerStats == null)
            {
                return(null);
            }

            var ep      = playerStats.NextLevelXp - playerStats.PrevLevelXp - (playerStats.Experience - playerStats.PrevLevelXp);
            var time    = Math.Round(ep / (TotalExperience / GetRuntime()), 2);
            var hours   = 0.00;
            var minutes = 0.00;

            if (double.IsInfinity(time) == false && time > 0)
            {
                hours   = Math.Truncate(TimeSpan.FromHours(time).TotalHours);
                minutes = TimeSpan.FromHours(time).Minutes;
            }

            if (LevelForRewards == -1 || playerStats.Level >= LevelForRewards)
            {
                LevelUpRewardsResponse result = Execute(inventory).Result;

                if (result.ToString().ToLower().Contains("awarded_already"))
                {
                    LevelForRewards = playerStats.Level + 1;
                }

                if (result.ToString().ToLower().Contains("success"))
                {
                    Logger.Write("Leveled up: " + playerStats.Level, LogLevel.Info);

                    RepeatedField <ItemAward> items = result.ItemsAwarded;

                    if (items.Any <ItemAward>())
                    {
                        Logger.Write("- Received Items -", LogLevel.Info);
                        foreach (ItemAward item in items)
                        {
                            Logger.Write($"[ITEM] {item.ItemId} x {item.ItemCount} ", LogLevel.Info);
                        }
                    }
                }
            }

            LevelUpRewardsResponse result2 = Execute(inventory).Result;

            LevelForRewards = playerStats.Level;
            if (result2.ToString().ToLower().Contains("success"))
            {
                //string[] tokens = result2.Result.ToString().Split(new[] { "itemId" }, StringSplitOptions.None);
                Logger.Write("Items Awarded:" + result2.ItemsAwarded);
            }

            StatsExport output = new StatsExport
            {
                Level             = playerStats.Level,
                HoursUntilLvl     = hours,
                MinutesUntilLevel = minutes,
                CurrentXp         = playerStats.Experience - playerStats.PrevLevelXp - GetXpDiff(playerStats.Level),
                LevelupXp         = playerStats.NextLevelXp - playerStats.PrevLevelXp - GetXpDiff(playerStats.Level)
            };

            return(output);
        }
Esempio n. 12
0
        public StatsExport GetCurrentInfo(Inventory inventory)
        {
            var stats = inventory.GetPlayerStats().Result;
            StatsExport output = null;
            var stat = stats.FirstOrDefault();
            if (stat != null)
            {
                var ep = stat.NextLevelXp - stat.PrevLevelXp - (stat.Experience - stat.PrevLevelXp);
                var time = Math.Round(ep/(TotalExperience/GetRuntime()), 2);
                var hours = 0.00;
                var minutes = 0.00;
                if (double.IsInfinity(time) == false && time > 0)
                {
                    hours = Math.Truncate(TimeSpan.FromHours(time).TotalHours);
                    minutes = TimeSpan.FromHours(time).Minutes;
                }
                
                if( LevelForRewards == -1 || stat.Level >= LevelForRewards )
                {
                    LevelUpRewardsResponse Result = Execute( inventory ).Result;

                    if( Result.ToString().ToLower().Contains( "awarded_already" ) )
                        LevelForRewards = stat.Level + 1;

                    if( Result.ToString().ToLower().Contains( "success" ) )
                    {
                        Logger.Write( "Leveled up: " + stat.Level, LogLevel.Info );

                        RepeatedField<ItemAward> items = Result.ItemsAwarded;

                        if( items.Any<ItemAward>() )
                        {
                            Logger.Write( "- Received Items -", LogLevel.Info );
                            foreach( ItemAward item in items )
                            {
                                Logger.Write( $"[ITEM] {item.ItemId} x {item.ItemCount} ", LogLevel.Info );
                            }
                        }
                    }
                }

                output = new StatsExport
                {
                    Level = stat.Level,
                    HoursUntilLvl = hours,
                    MinutesUntilLevel = minutes,
                    CurrentXp = stat.Experience - stat.PrevLevelXp - GetXpDiff(stat.Level),
                    LevelupXp = stat.NextLevelXp - stat.PrevLevelXp - GetXpDiff(stat.Level)
                };
            }
            return output;
        }