コード例 #1
0
        public async Task <StatsExport> GetCurrentInfo(Inventory inventory)
        {
            var stats = await inventory.GetPlayerStats();

            var stat = stats?.FirstOrDefault();

            if (stat == null)
            {
                return(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;
            }

            var 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);
        }
コード例 #2
0
ファイル: Statistics.cs プロジェクト: Andreinod1/Catchem
        public StatsExport GetCurrentInfo(Inventory inventory)
        {
            var pokemons = inventory.GetPokemons().Result.Count();
            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;
        }
コード例 #3
0
        public void CheckLevelUp(ISession session)
        {
            if (_currentStats == null)
            {
                return;
            }
            if (_currentStats.Level < ExportStats.Level)
            {
                var response = session.Inventory.GetLevelUpRewards(ExportStats);
                session.Runtime.CurrentLevel = ExportStats.Level;
                if (response.Result.ItemsAwarded.Any())
                {
                    session.EventDispatcher.Send(new PlayerLevelUpEvent
                    {
                        Items = StringUtils.GetSummedFriendlyNameOfItemAwardList(response.Result.ItemsAwarded)
                    });
                    session.EventDispatcher.Send(new InventoryNewItemsEvent()
                    {
                        Items = response.Result.ItemsAwarded.ToItemList()
                    });
                }
            }
            else if (session.Runtime.CurrentLevel == 0)
            {
                session.Runtime.CurrentLevel = ExportStats.Level;
            }

            _currentStats = null;
        }
コード例 #4
0
        public void Dirty(Inventory inventory)
        {
            if (_exportStats != null)
            {
                _currentStats = _exportStats;
            }

            _exportStats = GetCurrentInfo(inventory);
            DirtyEvent?.Invoke();
        }
コード例 #5
0
        public async void Dirty(Inventory inventory)
        {
            if (ExportStats != null)
            {
                _currentStats = ExportStats;
            }

            ExportStats = await GetCurrentInfo(inventory);

            DirtyEvent?.Invoke();
        }
コード例 #6
0
        public async Task CheckLevelUp(ISession session)
        {
            if (_currentStats == null)
            {
                if (ExportStats != null)
                {
                    await GetLevelUpRewards(session, ExportStats.Level);
                }
                return;
            }
            if (_currentStats.Level < ExportStats.Level)
            {
                await GetLevelUpRewards(session, ExportStats.Level);
            }
            else if (session.Runtime.CurrentLevel == 0)
            {
                session.Runtime.CurrentLevel = ExportStats.Level;
            }

            _currentStats = null;
        }
コード例 #7
0
ファイル: Statistics.cs プロジェクト: Andreinod1/Catchem
 public void Dirty(Inventory inventory)
 {
     ExportStats = GetCurrentInfo(inventory);
     DirtyEvent?.Invoke();
 }