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

#494: Implemented Family Candies display when transferring and catchi… #503

Merged
merged 1 commit into from
Jul 26, 2016
Merged
Show file tree
Hide file tree
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
8 changes: 6 additions & 2 deletions PoGo.NecroBot.CLI/ConsoleEventListener.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public void HandleEvent(PokemonEvolveEvent evt, Context ctx)
public void HandleEvent(TransferPokemonEvent evt, Context ctx)
{
Logger.Write(
$"{evt.Id} with {evt.Cp} ({evt.Perfection.ToString("0.00")} % perfect) CP (Best: {evt.BestCp} | ({evt.BestPerfection.ToString("0.00")} % perfect))",
$"{evt.Id} with {evt.Cp} ({evt.Perfection.ToString("0.00")} % perfect) CP (Best: {evt.BestCp} | ({evt.BestPerfection.ToString("0.00")} % perfect)) | Family Candies: {evt.FamilyCandies}",
LogLevel.Transfer);
}

Expand Down Expand Up @@ -91,8 +91,12 @@ public void HandleEvent(PokemonCaptureEvent evt, Context ctx)
? $"{evt.Status} Attempt #{evt.Attempt}"
: $"{evt.Status}";

var familyCandies = evt.FamilyCandies > 0
? $" | Family Candies: {evt.FamilyCandies}"
: "";

Logger.Write(
$"({catchStatus}) | {evt.Id} Lvl {evt.Level} ({evt.Cp}/{evt.MaxCp} CP) ({evt.Perfection.ToString("0.00")}% perfect) | Chance: {evt.Probability}% | {Math.Round(evt.Distance)}m dist | with a {returnRealBallName(evt.Pokeball)}Ball.",
$"({catchStatus}) | {evt.Id} Lvl {evt.Level} ({evt.Cp}/{evt.MaxCp} CP) ({evt.Perfection.ToString("0.00")}% perfect) | Chance: {evt.Probability}% | {Math.Round(evt.Distance)}m dist | with a {returnRealBallName(evt.Pokeball)}Ball.{familyCandies}",
LogLevel.Caught);
}

Expand Down
1 change: 1 addition & 0 deletions PoGo.NecroBot.Logic/Event/PokemonCaptureEvent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,6 @@ public class PokemonCaptureEvent : IEvent
public double Probability;
public int Stardust;
public CatchPokemonResponse.Types.CatchStatus Status;
public int FamilyCandies;
}
}
1 change: 1 addition & 0 deletions PoGo.NecroBot.Logic/Event/TransferPokemonEvent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ public class TransferPokemonEvent : IEvent
public int Cp;
public PokemonId Id;
public double Perfection;
public int FamilyCandies;
}
}
10 changes: 10 additions & 0 deletions PoGo.NecroBot.Logic/Tasks/CatchPokemonTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,16 @@ public static void Execute(Context ctx, StateMachine machine, EncounterResponse

evt.Exp = totalExp;
evt.Stardust = profile.PlayerData.Currencies.ToArray()[1].Amount;

var pokemonSettings = ctx.Inventory.GetPokemonSettings().Result;
var pokemonFamilies = ctx.Inventory.GetPokemonFamilies().Result;

var setting = pokemonSettings.Single(q => q.PokemonId == pokemon.PokemonId);
var family = pokemonFamilies.Single(q => q.FamilyId == setting.FamilyId);

family.Candy += 3;

evt.FamilyCandies = family.Candy;
}


Expand Down
12 changes: 11 additions & 1 deletion PoGo.NecroBot.Logic/Tasks/TransferDuplicatePokemonTask.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#region using directives

using System.Linq;
using PoGo.NecroBot.Logic.Event;
using PoGo.NecroBot.Logic.PoGoUtils;
using PoGo.NecroBot.Logic.State;
Expand All @@ -16,6 +17,9 @@ public static void Execute(Context ctx, StateMachine machine)
ctx.Inventory.GetDuplicatePokemonToTransfer(ctx.LogicSettings.KeepPokemonsThatCanEvolve, ctx.LogicSettings.PrioritizeIvOverCp,
ctx.LogicSettings.PokemonsNotToTransfer).Result;

var pokemonSettings = ctx.Inventory.GetPokemonSettings().Result;
var pokemonFamilies = ctx.Inventory.GetPokemonFamilies().Result;

foreach (var duplicatePokemon in duplicatePokemons)
{
if (duplicatePokemon.Cp >= ctx.LogicSettings.KeepMinCp ||
Expand All @@ -34,13 +38,19 @@ public static void Execute(Context ctx, StateMachine machine)
if (bestPokemonOfType == null)
bestPokemonOfType = duplicatePokemon;

var setting = pokemonSettings.Single(q => q.PokemonId == duplicatePokemon.PokemonId);
var family = pokemonFamilies.Single(q => q.FamilyId == setting.FamilyId);

family.Candy++;

machine.Fire(new TransferPokemonEvent
{
Id = duplicatePokemon.PokemonId,
Perfection = PokemonInfo.CalculatePokemonPerfection(duplicatePokemon),
Cp = duplicatePokemon.Cp,
BestCp = bestPokemonOfType.Cp,
BestPerfection = PokemonInfo.CalculatePokemonPerfection(bestPokemonOfType)
BestPerfection = PokemonInfo.CalculatePokemonPerfection(bestPokemonOfType),
FamilyCandies = family.Candy
});
}
}
Expand Down