Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update title bar with latest exp in real-time #64

Merged
merged 1 commit into from
Jul 22, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions PokemonGo.RocketAPI.Logic/Logic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,13 @@ private async Task CatchEncounter(EncounterResponse encounter, MapPokemon pokemo
? $"{pokemon.PokemonId} ({encounter?.WildPokemon?.PokemonData?.Cp} CP) ({Math.Round(CalculatePokemonPerfection(encounter?.WildPokemon?.PokemonData)).ToString("0.00")}% perfection) | Chance: {encounter?.CaptureProbability.CaptureProbability_.First()} | {Math.Round(distance)}m distance | with {pokeball} "
: $"{pokemon.PokemonId} ({encounter?.WildPokemon?.PokemonData?.Cp} CP) Chance: {Math.Round(Convert.ToDouble(encounter?.CaptureProbability?.CaptureProbability_.First()))} | {Math.Round(distance)}m distance {caughtPokemonResponse.Status} | with {pokeball}",
LogLevel.Caught);
await DisplayPlayerLevelInTitle(true);
await Task.Delay(2000);
} while (caughtPokemonResponse.Status == CatchPokemonResponse.Types.CatchStatus.CatchMissed ||
caughtPokemonResponse.Status == CatchPokemonResponse.Types.CatchStatus.CatchEscape);
}

private async Task DisplayPlayerLevelInTitle()
private async Task DisplayPlayerLevelInTitle(bool updateOnly = false)
{
_playerProfile = _playerProfile.Profile != null ? _playerProfile : await _client.GetProfile();
var playerName = _playerProfile.Profile.Username != null ? _playerProfile.Profile.Username : "";
Expand All @@ -85,9 +86,11 @@ private async Task DisplayPlayerLevelInTitle()
var message =
$"Character Level {playerName} {playerStat.Level:0} - ({playerStat.Experience - playerStat.PrevLevelXp:0} / {playerStat.NextLevelXp - playerStat.PrevLevelXp:0} XP)";
Console.Title = message;
Logger.Write(message);
if (updateOnly == false)
Logger.Write(message);
}
await Task.Delay(5000);
if (updateOnly == false)
await Task.Delay(5000);
}

public static int GetXpDiff(int Level)
Expand Down Expand Up @@ -186,8 +189,11 @@ private async Task EvolveAllPokemonWithEnoughCandy(IEnumerable<PokemonId> filter
var evolvePokemonOutProto = await _client.EvolvePokemon(pokemon.Id);

if (evolvePokemonOutProto.Result == EvolvePokemonOut.Types.EvolvePokemonStatus.PokemonEvolvedSuccess)
{
Logger.Write($"{pokemon.PokemonId} successfully for {evolvePokemonOutProto.ExpAwarded}xp",
LogLevel.Evolve);
await DisplayPlayerLevelInTitle(true);
}
else
Logger.Write(
$"Failed {pokemon.PokemonId}. EvolvePokemonOutProto.Result was {evolvePokemonOutProto.Result}, stopping evolving {pokemon.PokemonId}",
Expand Down Expand Up @@ -322,9 +328,12 @@ private async Task ExecuteFarmingPokestopsAndPokemons()
var fortSearch = await _client.SearchFort(pokeStop.Id, pokeStop.Latitude, pokeStop.Longitude);
Logger.Write($"{fortInfo.Name} in ({Math.Round(distance)}m)", LogLevel.Info, ConsoleColor.DarkRed);
if (fortSearch.ExperienceAwarded > 0)
{
Logger.Write(
$"XP: {fortSearch.ExperienceAwarded}, Gems: {fortSearch.GemsAwarded}, Eggs: {fortSearch.PokemonDataEgg} Items: {StringUtils.GetSummedFriendlyNameOfItemAwardList(fortSearch.ItemsAwarded)}",
LogLevel.Pokestop);
await DisplayPlayerLevelInTitle(true);
}

await Task.Delay(1000);
await RecycleItems();
Expand Down