Skip to content

Commit

Permalink
Merge pull request #1489 from SindreKjetsa/master
Browse files Browse the repository at this point in the history
Adding Candy amount in output to console and text dump
  • Loading branch information
NecronomiconCoding authored Jul 31, 2016
2 parents 4c4eac9 + e766bea commit 9bec54e
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 9 deletions.
7 changes: 5 additions & 2 deletions PoGo.NecroBot.CLI/ConsoleEventListener.cs
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ public void HandleEvent(SnipeScanEvent evt, ISession session)
public void HandleEvent(DisplayHighestsPokemonEvent evt, ISession session)
{
string strHeader;
//PokemonData | CP | IV | Level | MOVE1 | MOVE2
//PokemonData | CP | IV | Level | MOVE1 | MOVE2 | Candy
switch (evt.SortedBy)
{
case "Level":
Expand All @@ -215,6 +215,9 @@ public void HandleEvent(DisplayHighestsPokemonEvent evt, ISession session)
case "MOVE2":
strHeader = session.Translation.GetTranslation(TranslationString.DisplayHighestMove2Header);
break;
case "Candy":
strHeader = session.Translation.GetTranslation(TranslationString.DisplayHighestCandy);
break;
default:
strHeader = session.Translation.GetTranslation(TranslationString.DisplayHighestsHeader);
break;
Expand All @@ -225,7 +228,7 @@ public void HandleEvent(DisplayHighestsPokemonEvent evt, ISession session)
Logger.Write($"====== {strHeader} ======", LogLevel.Info, ConsoleColor.Yellow);
foreach (var pokemon in evt.PokemonList)
Logger.Write(
$"# CP {pokemon.Item1.Cp.ToString().PadLeft(4, ' ')}/{pokemon.Item2.ToString().PadLeft(4, ' ')} | ({pokemon.Item3.ToString("0.00")}% {strPerfect})\t| Lvl {pokemon.Item4.ToString("00")}\t {strName}: {pokemon.Item1.PokemonId.ToString().PadRight(10, ' ')}\t MOVE1: {pokemon.Item5.ToString().PadRight(20, ' ')} MOVE2: {pokemon.Item6}",
$"# CP {pokemon.Item1.Cp.ToString().PadLeft(4, ' ')}/{pokemon.Item2.ToString().PadLeft(4, ' ')} | ({pokemon.Item3.ToString("0.00")}% {strPerfect})\t| Lvl {pokemon.Item4.ToString("00")}\t {strName}: {pokemon.Item1.PokemonId.ToString().PadRight(10, ' ')}\t MOVE1: {pokemon.Item5.ToString().PadRight(20, ' ')} MOVE2: {pokemon.Item6.ToString().PadRight(20, ' ')} Candy: {pokemon.Item7}",
LogLevel.Info, ConsoleColor.Yellow);
}

Expand Down
6 changes: 4 additions & 2 deletions PoGo.NecroBot.Logic/Common/Translations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,8 @@ public enum TranslationString
NoPokemonToSnipe,
NotEnoughPokeballsToSnipe,
DisplayHighestMove1Header,
DisplayHighestMove2Header
DisplayHighestMove2Header,
DisplayHighestCandy
}

public class Translation : ITranslation
Expand Down Expand Up @@ -318,7 +319,8 @@ public class Translation : ITranslation
new KeyValuePair<TranslationString, string>(TranslationString.NotEnoughPokeballsToSnipe,
"Not enough Pokeballs to start sniping! ({0}/{1})"),
new KeyValuePair<TranslationString, string>(TranslationString.DisplayHighestMove1Header, "MOVE1"),
new KeyValuePair<TranslationString, string>(TranslationString.DisplayHighestMove2Header, "MOVE2")
new KeyValuePair<TranslationString, string>(TranslationString.DisplayHighestMove2Header, "MOVE2"),
new KeyValuePair<TranslationString, string>(TranslationString.DisplayHighestCandy, "Candy")
};

public string GetTranslation(TranslationString translationString, params object[] data)
Expand Down
4 changes: 2 additions & 2 deletions PoGo.NecroBot.Logic/Event/DisplayHighestsPokemonEvent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ namespace PoGo.NecroBot.Logic.Event
{
public class DisplayHighestsPokemonEvent : IEvent
{
//PokemonData | CP | IV | Level | MOVE1 | MOVE2
public List<Tuple<PokemonData, int, double, double, PokemonMove, PokemonMove>> PokemonList;
//PokemonData | CP | IV | Level | MOVE1 | MOVE2 | Candy
public List<Tuple<PokemonData, int, double, double, PokemonMove, PokemonMove, int>> PokemonList;
public string SortedBy;
}
}
12 changes: 12 additions & 0 deletions PoGo.NecroBot.Logic/PoGoUtils/PokemonInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
using System;
using POGOProtos.Data;
using POGOProtos.Enums;
using POGOProtos.Inventory;
using System.Collections.Generic;
using POGOProtos.Settings.Master;
using System.Linq;

#endregion

Expand Down Expand Up @@ -579,6 +583,14 @@ public static PokemonMove GetPokemonMove2(PokemonData poke)
return move2;
}

public static int GetCandy(PokemonData pokemon, List<Candy> PokemonFamilies, IEnumerable<PokemonSettings> PokemonSettings)
{
var setting = PokemonSettings.FirstOrDefault(q => pokemon != null && q.PokemonId.Equals(pokemon.PokemonId));
var family = PokemonFamilies.FirstOrDefault(q => setting != null && q.FamilyId.Equals(setting.FamilyId));

return family.Candy_;
}

public static int GetPowerUpLevel(PokemonData poke)
{
return (int) (GetLevel(poke)*2.0);
Expand Down
12 changes: 9 additions & 3 deletions PoGo.NecroBot.Logic/Tasks/DisplayPokemonStatsTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ public class DisplayPokemonStatsTask

public static async Task Execute(ISession session)
{
var myPokemonFamilies = await session.Inventory.GetPokemonFamilies();
var myPokeSettings = await session.Inventory.GetPokemonSettings();

var highestsPokemonCp =
await session.Inventory.GetHighestsCp(session.LogicSettings.AmountOfPokemonToDisplayOnStart);
var highestsPokemonCpForUpgrade = await session.Inventory.GetHighestsCp(50);
Expand All @@ -31,7 +34,8 @@ public static async Task Execute(ISession session)
pokemon =>
Tuple.Create(pokemon, PokemonInfo.CalculateMaxCp(pokemon),
PokemonInfo.CalculatePokemonPerfection(pokemon), PokemonInfo.GetLevel(pokemon),
PokemonInfo.GetPokemonMove1(pokemon), PokemonInfo.GetPokemonMove2(pokemon))).ToList();
PokemonInfo.GetPokemonMove1(pokemon), PokemonInfo.GetPokemonMove2(pokemon),
PokemonInfo.GetCandy(pokemon, myPokemonFamilies, myPokeSettings))).ToList();
var pokemonPairedWithStatsCpForUpgrade =
highestsPokemonCpForUpgrade.Select(
pokemon =>
Expand All @@ -46,7 +50,8 @@ public static async Task Execute(ISession session)
pokemon =>
Tuple.Create(pokemon, PokemonInfo.CalculateMaxCp(pokemon),
PokemonInfo.CalculatePokemonPerfection(pokemon), PokemonInfo.GetLevel(pokemon),
PokemonInfo.GetPokemonMove1(pokemon), PokemonInfo.GetPokemonMove2(pokemon))).ToList();
PokemonInfo.GetPokemonMove1(pokemon), PokemonInfo.GetPokemonMove2(pokemon),
PokemonInfo.GetCandy(pokemon, myPokemonFamilies, myPokeSettings))).ToList();
var pokemonPairedWithStatsIvForUpgrade =
highestsPokemonIvForUpgrade.Select(
pokemon =>
Expand Down Expand Up @@ -104,8 +109,9 @@ public static async Task Execute(ISession session)
Dumper.ClearDumpFile(session, dumpFileName);
foreach (var pokemon in allPokemonInBag)
{
int candy = PokemonInfo.GetCandy(pokemon, myPokemonFamilies, myPokeSettings);
Dumper.Dump(session,
$"NAME: {pokemon.PokemonId.ToString().PadRight(16, ' ')}Lvl: {PokemonInfo.GetLevel(pokemon).ToString("00")}\t\tCP: {pokemon.Cp.ToString().PadRight(8, ' ')}\t\t IV: {PokemonInfo.CalculatePokemonPerfection(pokemon).ToString("0.00")}%\t\t\tMOVE1: {pokemon.Move1}\t\t\tMOVE2: {pokemon.Move2}",
$"NAME: {pokemon.PokemonId.ToString().PadRight(16, ' ')}Lvl: {PokemonInfo.GetLevel(pokemon).ToString("00")}\t\tCP: {pokemon.Cp.ToString().PadRight(8, ' ')}\t\t IV: {PokemonInfo.CalculatePokemonPerfection(pokemon).ToString("0.00")}%\t\t\tMOVE1: {pokemon.Move1}\t\t\tMOVE2: {pokemon.Move2} \t\tCandy: {candy}",
dumpFileName);
}
}
Expand Down

0 comments on commit 9bec54e

Please sign in to comment.