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); }
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; }
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; }
public void Dirty(Inventory inventory) { if (_exportStats != null) { _currentStats = _exportStats; } _exportStats = GetCurrentInfo(inventory); DirtyEvent?.Invoke(); }
public async void Dirty(Inventory inventory) { if (ExportStats != null) { _currentStats = ExportStats; } ExportStats = await GetCurrentInfo(inventory); DirtyEvent?.Invoke(); }
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; }
public void Dirty(Inventory inventory) { ExportStats = GetCurrentInfo(inventory); DirtyEvent?.Invoke(); }