public void Save(PokeRoadieInventory inventory, PokemonData pokemon, GeoCoordinate geo, string playerName, int playerLevel, string playerTeam, ulong encounterId, EncounterSourceTypes encounterType, string filePath) { try { var data = new Xml.PokemonEncounter() { EncounterId = encounterId, EncounterType = Convert.ToInt32(encounterType), Latitude = geo.Latitude, Longitude = geo.Longitude, Altitude = geo.Altitude, Player = playerName, PlayerLevel = playerLevel, PlayerTeam = playerTeam, Cp = pokemon.Cp, IV = pokemon.GetPerfection(), V = CalculatePokemonValue(pokemon), NumberOfUpgrades = System.Convert.ToInt32(pokemon.GetLevel()), Type = pokemon.PokemonId.ToString() }; Xml.Serializer.SerializeToFile(data, filePath); } catch// (Exception e) { //Logger.Write($"Could not save the encounter information file for {encounterId} - {e.ToString()}", LogLevel.Error); } }
public async Task <string> _getcurrentLevelInfos(PokeRoadieInventory _inventory) { var stats = await _inventory.GetPlayerStats(); var output = string.Empty; var stat = stats.FirstOrDefault(); if (stat != null) { Currentlevel = stat.Level; var ep = (stat.NextLevelXp - stat.PrevLevelXp) - (stat.Experience - stat.PrevLevelXp); var time = Math.Round(ep / (TotalExperience / _getSessionRuntime()), 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"), System.Globalization.CultureInfo.InvariantCulture); hours = Math.Truncate(time); minutes = Math.Round((time - hours) * 100); } bool didLevelUp = false; if (LevelForRewards == -1 || stat.Level >= LevelForRewards) { LevelUpRewardsResponse Result = await _inventory.GetLevelUpRewards(stat.Level); if (Result.Result == LevelUpRewardsResponse.Types.Result.AwardedAlready) { LevelForRewards = stat.Level + 1; } if (Result.Result == LevelUpRewardsResponse.Types.Result.Success) { didLevelUp = true; Logger.Write($"(LEVEL) Reached level {stat.Level}!", LogLevel.None, ConsoleColor.Green); RepeatedField <ItemAward> items = Result.ItemsAwarded; if (items.Any <ItemAward>()) { Logger.Write("Received Bonus Items:", LogLevel.None, ConsoleColor.Green); foreach (ItemAward item in items) { Logger.Write($"{item.ItemId} x {item.ItemCount} ", LogLevel.None, ConsoleColor.Green); } } } } if (!didLevelUp) { output = $"{stat.Level} (Level in {hours}h {minutes}m | {stat.Experience - stat.PrevLevelXp - GetXpDiff(stat.Level)}/{stat.NextLevelXp - stat.PrevLevelXp - GetXpDiff(stat.Level)} XP)"; } } return(output); }
public Context(PokeRoadieSettings settings) { Settings = settings; Directories = new Directories(); Utility = new Utility(this); Session = new Session(this); ApiFailureStrategy = new ApiFailureStrategy(this); Client = new PokeRoadieClient(this); Inventory = new PokeRoadieInventory(this); Statistics = new Statistics(this); Navigation = new Navigation(this); Logic = new PokeRoadieLogic(this); }
public async void UpdateConsoleTitle(PokeRoadieClient _client, PokeRoadieInventory _inventory) { if (nextTitleUpdate > DateTime.Now) { return; } nextTitleUpdate.AddSeconds(1); //appears to give incorrect info? var pokes = await _inventory.GetPokemons(); TotalPokesInBag = pokes.Count(); var inventory = await PokeRoadieInventory.GetCachedInventory(_client); if (inventory.InventoryDelta != null) { TotalPokesInPokedex = inventory.InventoryDelta.InventoryItems.Select(i => i.InventoryItemData?.PokedexEntry).Where(x => x != null && x.TimesCaptured >= 1).OrderBy(k => k.PokemonId).ToArray().Length; CurrentLevelInfos = await _getcurrentLevelInfos(); } Console.Title = ToString(); }
public Statistics(PokeRoadieInventory inventory) { _inventory = inventory; InitSessionDateTime = DateTime.Now; Duration = DateTime.Now - InitSessionDateTime; }