Skip to content

Commit

Permalink
Fix for zero out coords, complete removal of singleton settings
Browse files Browse the repository at this point in the history
  • Loading branch information
disdain13 committed Sep 6, 2016
1 parent e0c7a9d commit 4417694
Show file tree
Hide file tree
Showing 9 changed files with 524 additions and 317 deletions.
30 changes: 3 additions & 27 deletions PokeRoadie/Context.cs
Original file line number Diff line number Diff line change
@@ -1,33 +1,6 @@
#region " Imports "

using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Net;

using PokemonGo.RocketAPI;
using PokemonGo.RocketAPI.Enums;
using PokemonGo.RocketAPI.Extensions;
using PokemonGo.RocketAPI.Helpers;
using PokemonGo.RocketAPI.Logging;
using PokemonGo.RocketAPI.Exceptions;
using PokemonGo.RocketAPI.Rpc;

using POGOProtos.Inventory;
using POGOProtos.Inventory.Item;
using POGOProtos.Networking.Responses;
using POGOProtos.Data;
using POGOProtos.Enums;
using POGOProtos.Map.Fort;
using POGOProtos.Data.Player;
using POGOProtos.Map.Pokemon;
using POGOProtos.Data.Capture;

using PokeRoadie.Extensions;
using PokeRoadie.Utils;
//using PokeRoadie.Logging;
using System.ComponentModel;

#endregion
Expand All @@ -47,11 +20,13 @@ public class Context
public Player PlayerState { get; set; }
public Directories Directories { get; set; }
public ISynchronizeInvoke Invoker { get; set; }
public Utility Utility { get; set; }

public Context(PokeRoadieSettings settings)
{
Settings = settings;
Directories = new Directories();
Utility = new Utility(this);
ApiFailureStrategy = new ApiFailureStrategy(this);
Client = new PokeRoadieClient(this);
ApiFailureStrategy.Client = Client;
Expand All @@ -65,5 +40,6 @@ public Context(PokeRoadieSettings settings, ISynchronizeInvoke form) : this(sett
{
Invoker = form;
}

}
}
1 change: 1 addition & 0 deletions PokeRoadie/PokeRoadie.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@
<DesignTimeSharedInput>True</DesignTimeSharedInput>
<DependentUpon>UserSettings.settings</DependentUpon>
</Compile>
<Compile Include="Utility.cs" />
<Compile Include="Utils\ApiFailureStrategy.cs" />
<Compile Include="Utils\GPXReader.cs" />
<Compile Include="Utils\RouteUtils.cs" />
Expand Down
373 changes: 188 additions & 185 deletions PokeRoadie/PokeRoadieExtensions.cs

Large diffs are not rendered by default.

32 changes: 16 additions & 16 deletions PokeRoadie/PokeRoadieInventory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public async Task<IEnumerable<PokemonData>> GetPokemonToTransfer()
((Context.Settings.AlwaysTransferBelowCp > 0 && x.Cp < Context.Settings.AlwaysTransferBelowCp) ||
(Context.Settings.AlwaysTransferBelowIV > 0 && x.GetPerfection() < Context.Settings.AlwaysTransferBelowIV) ||
(Context.Settings.AlwaysTransferBelowLV > 0 && x.GetLevel() < Context.Settings.AlwaysTransferBelowLV) ||
(Context.Settings.AlwaysTransferBelowV > 0 && x.CalculatePokemonValue() < Context.Settings.AlwaysTransferBelowV))
(Context.Settings.AlwaysTransferBelowV > 0 && Context.Utility.CalculatePokemonValue(x) < Context.Settings.AlwaysTransferBelowV))
);


Expand All @@ -92,7 +92,7 @@ public async Task<IEnumerable<PokemonData>> GetPokemonToTransfer()

//Keep By V filter
if (Context.Settings.KeepAboveV > 0)
query = query.Where(p => p.CalculatePokemonValue() < Context.Settings.KeepAboveV);
query = query.Where(p => Context.Utility.CalculatePokemonValue(p) < Context.Settings.KeepAboveV);

//Keep By LV filter
if (Context.Settings.KeepAboveLV > 0)
Expand All @@ -117,7 +117,7 @@ public async Task<IEnumerable<PokemonData>> GetPokemonToTransfer()
orderBy = new Func<PokemonData, double>(x => x.GetLevel());
break;
case PriorityTypes.V:
orderBy = new Func<PokemonData, double>(x => x.CalculatePokemonValue());
orderBy = new Func<PokemonData, double>(x => Context.Utility.CalculatePokemonValue(x));
break;
default:
break;
Expand All @@ -133,7 +133,7 @@ public async Task<IEnumerable<PokemonData>> GetPokemonToTransfer()
thenBy = new Func<PokemonData, double>(x => x.GetPerfection());
break;
case PriorityTypes.V:
thenBy = new Func<PokemonData, double>(x => x.CalculatePokemonValue());
thenBy = new Func<PokemonData, double>(x => Context.Utility.CalculatePokemonValue(x));
break;
case PriorityTypes.LV:
thenBy = new Func<PokemonData, double>(x => x.GetLevel());
Expand Down Expand Up @@ -208,26 +208,26 @@ public async Task<IEnumerable<PokemonData>> GetHighestsV(int limit)
{
var myPokemon = await GetPokemons();
var pokemons = myPokemon.ToList();
return pokemons.OrderByDescending(x => x.CalculatePokemonValue()).ThenBy(n => n.StaminaMax).Take(limit);
return pokemons.OrderByDescending(x => Context.Utility.CalculatePokemonValue(x)).ThenBy(n => n.StaminaMax).Take(limit);
}

public async Task<IEnumerable<PokemonData>> GetPokemonToHeal()
{
var myPokemon = await GetPokemons();
var pokemons = myPokemon.ToList();
return pokemons.Where(x => string.IsNullOrWhiteSpace(x.DeployedFortId) && x.Stamina > 0 && x.Stamina < x.StaminaMax).OrderByDescending(n => n.CalculatePokemonValue()).ThenBy(n => n.Stamina);
return pokemons.Where(x => string.IsNullOrWhiteSpace(x.DeployedFortId) && x.Stamina > 0 && x.Stamina < x.StaminaMax).OrderByDescending(n => Context.Utility.CalculatePokemonValue(n)).ThenBy(n => n.Stamina);
}

public async Task<IEnumerable<PokemonData>> GetPokemonToRevive()
{
return (await GetPokemons()).Where(x => string.IsNullOrWhiteSpace(x.DeployedFortId) && x.Stamina == 0).OrderByDescending(n => n.CalculatePokemonValue());
return (await GetPokemons()).Where(x => string.IsNullOrWhiteSpace(x.DeployedFortId) && x.Stamina == 0).OrderByDescending(n => Context.Utility.CalculatePokemonValue(n));
}

public async Task<IEnumerable<PokemonData>> GetHighestsVNotDeployed(int limit)
{
var myPokemon = await GetPokemons();
var pokemons = myPokemon.ToList();
return pokemons.Where(x => string.IsNullOrWhiteSpace(x.DeployedFortId) && x.Stamina == x.StaminaMax).OrderByDescending(x => x.CalculatePokemonValue()).ThenBy(n => n.StaminaMax).Take(limit);
return pokemons.Where(x => string.IsNullOrWhiteSpace(x.DeployedFortId) && x.Stamina == x.StaminaMax).OrderByDescending(x => Context.Utility.CalculatePokemonValue(x)).ThenBy(n => n.StaminaMax).Take(limit);
}

public async Task<IEnumerable<PokemonData>> GetHighestsCP(int limit)
Expand Down Expand Up @@ -276,7 +276,7 @@ public async Task<PokemonData> GetHighestPokemonOfTypeByV(PokemonData pokemon)
var myPokemon = await GetPokemons();
var pokemons = myPokemon.ToList();
return pokemons.Where(x => x.PokemonId == pokemon.PokemonId)
.OrderByDescending(x => x.CalculatePokemonValue())
.OrderByDescending(x => Context.Utility.CalculatePokemonValue(x))
.FirstOrDefault();
}

Expand Down Expand Up @@ -330,7 +330,7 @@ public async Task<IEnumerable<PokemonData>> GetPokemonToEvolve()

//Evolve By V filter
if (Context.Settings.EvolveAboveV > 0)
query = query.Where(p => p.CalculatePokemonValue() > Context.Settings.EvolveAboveV);
query = query.Where(p => Context.Utility.CalculatePokemonValue(p) > Context.Settings.EvolveAboveV);
if (query.Count() == 0) return new List<PokemonData>();

//Evolve By LV filter
Expand All @@ -349,7 +349,7 @@ public async Task<IEnumerable<PokemonData>> GetPokemonToEvolve()
orderBy = new Func<PokemonData, double>(x => x.GetPerfection());
break;
case PriorityTypes.V:
orderBy = new Func<PokemonData, double>(x => x.CalculatePokemonValue());
orderBy = new Func<PokemonData, double>(x => Context.Utility.CalculatePokemonValue(x));
break;
case PriorityTypes.LV:
orderBy = new Func<PokemonData, double>(x => x.GetLevel());
Expand All @@ -368,7 +368,7 @@ public async Task<IEnumerable<PokemonData>> GetPokemonToEvolve()
thenBy = new Func<PokemonData, double>(x => x.GetPerfection());
break;
case PriorityTypes.V:
thenBy = new Func<PokemonData, double>(x => x.CalculatePokemonValue());
thenBy = new Func<PokemonData, double>(x => Context.Utility.CalculatePokemonValue(x));
break;
case PriorityTypes.LV:
thenBy = new Func<PokemonData, double>(x => x.GetLevel());
Expand Down Expand Up @@ -435,7 +435,7 @@ public async Task<List<PokemonData>> GetPokemonToPowerUp()

//PowerUp By V filter
if (Context.Settings.PowerUpAboveV > 0)
query = query.Where(p => p.CalculatePokemonValue() > Context.Settings.PowerUpAboveV);
query = query.Where(p => Context.Utility.CalculatePokemonValue(p) > Context.Settings.PowerUpAboveV);
if (query.Count() == 0) return new List<PokemonData>();

//PowerUp By LV filter
Expand All @@ -455,7 +455,7 @@ public async Task<List<PokemonData>> GetPokemonToPowerUp()
orderBy = new Func<PokemonData, double>(x => x.GetPerfection());
break;
case PriorityTypes.V:
orderBy = new Func<PokemonData, double>(x => x.CalculatePokemonValue());
orderBy = new Func<PokemonData, double>(x => Context.Utility.CalculatePokemonValue(x));
break;
case PriorityTypes.LV:
orderBy = new Func<PokemonData, double>(x => x.GetLevel());
Expand All @@ -474,7 +474,7 @@ public async Task<List<PokemonData>> GetPokemonToPowerUp()
thenBy = new Func<PokemonData, double>(x => x.GetPerfection());
break;
case PriorityTypes.V:
thenBy = new Func<PokemonData, double>(x => x.CalculatePokemonValue());
thenBy = new Func<PokemonData, double>(x => Context.Utility.CalculatePokemonValue(x));
break;
case PriorityTypes.LV:
thenBy = new Func<PokemonData, double>(x => x.GetLevel());
Expand Down Expand Up @@ -506,7 +506,7 @@ public async Task<List<PokemonData>> GetPokemonToFavorite()

//Favorite By V filter
if (Context.Settings.FavoriteAboveV > 0)
query = query.Where(p => p.CalculatePokemonValue() > Context.Settings.FavoriteAboveV);
query = query.Where(p => Context.Utility.CalculatePokemonValue(p) > Context.Settings.FavoriteAboveV);
if (query.Count() == 0) return new List<PokemonData>();

//Favorite By LV filter
Expand Down
Loading

0 comments on commit 4417694

Please sign in to comment.