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

Add Moves to TransferFilter #1896

Merged
merged 3 commits into from
Aug 1, 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
6 changes: 5 additions & 1 deletion PoGo.NecroBot.Logic/ILogicSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Collections.Generic;
using POGOProtos.Enums;
using POGOProtos.Inventory.Item;
using POGOProtos.Settings.Master.Item;

#endregion

Expand Down Expand Up @@ -46,16 +47,19 @@ public TransferFilter()
{
}

public TransferFilter(int keepMinCp, float keepMinIvPercentage, int keepMinDuplicatePokemon)
public TransferFilter(int keepMinCp, float keepMinIvPercentage, int keepMinDuplicatePokemon,
List<PokemonMove> moves = null)
{
KeepMinCp = keepMinCp;
KeepMinIvPercentage = keepMinIvPercentage;
KeepMinDuplicatePokemon = keepMinDuplicatePokemon;
Moves = moves ?? new List<PokemonMove>();
}

public int KeepMinCp { get; set; }
public float KeepMinIvPercentage { get; set; }
public int KeepMinDuplicatePokemon { get; set; }
public List<PokemonMove> Moves { get; set; }
}

public interface ILogicSettings
Expand Down
7 changes: 7 additions & 0 deletions PoGo.NecroBot.Logic/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
using System.ComponentModel;
using System.Reflection;
using System.Collections;
using System.Linq;

#endregion

Expand Down Expand Up @@ -445,6 +446,12 @@ public static GlobalSettings Load(string path)
jsonSettings.DefaultValueHandling = DefaultValueHandling.Populate;

settings = JsonConvert.DeserializeObject<GlobalSettings>(input, jsonSettings);

//This makes sure that existing config files dont get null values which lead to an exception
foreach (var filter in settings.PokemonsTransferFilter.Where(x => x.Value.Moves == null))
{
filter.Value.Moves = new List<PokemonMove>();
}

// One day we might be able to better do this so its automatic
/*
Expand Down
7 changes: 5 additions & 2 deletions PoGo.NecroBot.Logic/Tasks/TransferDuplicatePokemonTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,14 @@ public static async Task Execute(ISession session, CancellationToken cancellatio
foreach (var duplicatePokemon in duplicatePokemons)
{
cancellationToken.ThrowIfCancellationRequested();
var pokemonTransferFilter = session.Inventory.GetPokemonTransferFilter(duplicatePokemon.PokemonId);

if (duplicatePokemon.Cp >=
session.Inventory.GetPokemonTransferFilter(duplicatePokemon.PokemonId).KeepMinCp ||
pokemonTransferFilter.KeepMinCp ||
PokemonInfo.CalculatePokemonPerfection(duplicatePokemon) >
session.Inventory.GetPokemonTransferFilter(duplicatePokemon.PokemonId).KeepMinIvPercentage)
pokemonTransferFilter.KeepMinIvPercentage ||
pokemonTransferFilter.Moves.Contains(duplicatePokemon.Move1) ||
pokemonTransferFilter.Moves.Contains(duplicatePokemon.Move2))
{
continue;
}
Expand Down