Skip to content

Commit

Permalink
Upd + Fix Merge
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryddag1 committed Aug 9, 2016
2 parents 9432488 + fa31790 commit be0b1e0
Show file tree
Hide file tree
Showing 11 changed files with 50 additions and 46 deletions.
2 changes: 1 addition & 1 deletion FeroxRev
3 changes: 2 additions & 1 deletion PoGo.NecroBot.CLI/ConsoleEventListener.cs
Expand Up @@ -126,7 +126,8 @@ private static void HandleEvent(FortFailedEvent fortFailedEvent, ISession sessio

private static void HandleEvent(FortTargetEvent fortTargetEvent, ISession session)
{
int intTimeForArrival = (int) ( fortTargetEvent.Distance / ( session.LogicSettings.WalkingSpeedInKilometerPerHour * 0.2 ) );

int intTimeForArrival = (int) ( fortTargetEvent.Distance / ( session.LogicSettings.WalkingSpeedInKilometerPerHour * 0.8 ) );

Logger.Write(
session.Translation.GetTranslation(TranslationString.EventFortTargeted, fortTargetEvent.Name,
Expand Down
2 changes: 1 addition & 1 deletion PoGo.NecroBot.CLI/ConsoleLogger.cs
Expand Up @@ -98,7 +98,7 @@ public void Write(string message, LogLevel level = LogLevel.Info, ConsoleColor c
Console.WriteLine($"[{DateTime.Now.ToString("HH:mm:ss")}] ({LoggingStrings.Transferred}) {message}");
break;
case LogLevel.Evolve:
Console.ForegroundColor = color == ConsoleColor.Black ? ConsoleColor.Yellow : color;
Console.ForegroundColor = color == ConsoleColor.Black ? ConsoleColor.DarkGreen : color;
Console.WriteLine($"[{DateTime.Now.ToString("HH:mm:ss")}] ({LoggingStrings.Evolved}) {message}");
break;
case LogLevel.Berry:
Expand Down
25 changes: 17 additions & 8 deletions PoGo.NecroBot.CLI/Program.cs
Expand Up @@ -30,7 +30,7 @@ internal class Program
private static void Main(string[] args)
{
string strCulture = Thread.CurrentThread.CurrentCulture.TwoLetterISOLanguageName;
var culture = CultureInfo.CreateSpecificCulture( "en-US" );
var culture = CultureInfo.CreateSpecificCulture(strCulture);

CultureInfo.DefaultThreadCurrentCulture = culture;
Thread.CurrentThread.CurrentCulture = culture;
Expand Down Expand Up @@ -91,17 +91,26 @@ private static void Main(string[] args)


var session = new Session(new ClientSettings(settings), new LogicSettings(settings));
if( boolNeedsSetup )

if (boolNeedsSetup)
{
if( GlobalSettings.PromptForSetup( session.Translation ) && !settings.isGui )
session = GlobalSettings.SetupSettings( session, settings, configFile );
if (GlobalSettings.PromptForSetup(session.Translation) && !settings.isGui)
{
session = GlobalSettings.SetupSettings(session, settings, configFile);

if (!settings.isGui)
{
var fileName = Assembly.GetExecutingAssembly().Location;
System.Diagnostics.Process.Start(fileName);
Environment.Exit(0);
}
}
else
{
GlobalSettings.Load( subPath );
GlobalSettings.Load(subPath);

Logger.Write( "Press a Key to continue...",
LogLevel.Warning );
Logger.Write("Press a Key to continue...",
LogLevel.Warning);
Console.ReadKey();
return;
}
Expand Down
2 changes: 1 addition & 1 deletion PoGo.NecroBot.CLI/Properties/AssemblyInfo.cs
Expand Up @@ -39,5 +39,5 @@
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]

[assembly: AssemblyVersion("0.8.0")]
[assembly: AssemblyVersion("0.8.1")]
[assembly: AssemblyFileVersion("1.0.0.0")]
2 changes: 1 addition & 1 deletion PoGo.NecroBot.Logic/Common/Translations.cs
Expand Up @@ -421,7 +421,7 @@ public class Translation : ITranslation
new KeyValuePair<TranslationString, string>(TranslationString.AmountPkmSeenCaught,
"Amount of Pokemon Seen: {0}/151, Amount of Pokemon Caught: {1}/151"),
new KeyValuePair<TranslationString, string>(TranslationString.PkmPotentialEvolveCount,
"[Evolves] Potential Evolves: {0}"),
"Potential Evolutions: {0}"),
new KeyValuePair<TranslationString, string>(TranslationString.PkmNotEnoughRessources,
"Pokemon Upgrade Failed Not Enough Resources"),
new KeyValuePair<TranslationString, string>(TranslationString.SnipeServerOffline, "Sniping server is offline. Skipping..."),
Expand Down
13 changes: 9 additions & 4 deletions PoGo.NecroBot.Logic/Inventory.cs
Expand Up @@ -28,6 +28,8 @@ public class Inventory
private readonly ILogicSettings _logicSettings;
private GetPlayerResponse _player = null;
private int _level = 0;
private DownloadItemTemplatesResponse _templates;
private IEnumerable<PokemonSettings> _pokemonSettings;

private readonly List<ItemId> _revives = new List<ItemId> { ItemId.ItemRevive, ItemId.ItemMaxRevive };
private GetInventoryResponse _cachedInventory;
Expand Down Expand Up @@ -380,10 +382,13 @@ public async Task<IEnumerable<PokemonData>> GetPokemons()

public async Task<IEnumerable<PokemonSettings>> GetPokemonSettings()
{
var templates = await _client.Download.GetItemTemplates();
return
templates.ItemTemplates.Select(i => i.PokemonSettings)
.Where(p => p != null && p.FamilyId != PokemonFamilyId.FamilyUnset);
if (_templates == null || _pokemonSettings == null)
{
_templates = await _client.Download.GetItemTemplates();
_pokemonSettings = _templates.ItemTemplates.Select(i => i.PokemonSettings).Where(p => p != null && p.FamilyId != PokemonFamilyId.FamilyUnset);
}

return _pokemonSettings;
}

public async Task<IEnumerable<PokemonData>> GetPokemonToEvolve(IEnumerable<PokemonId> filter = null)
Expand Down
2 changes: 1 addition & 1 deletion PoGo.NecroBot.Logic/Properties/AssemblyInfo.cs
Expand Up @@ -39,5 +39,5 @@
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]

[assembly: AssemblyVersion("0.8.0")]
[assembly: AssemblyVersion("0.8.1")]
[assembly: AssemblyFileVersion("1.0.0.0")]
19 changes: 1 addition & 18 deletions PoGo.NecroBot.Logic/Settings.cs
Expand Up @@ -297,7 +297,7 @@ public class GlobalSettings
public double DefaultLatitude;
[DefaultValue(-73.962277)]
public double DefaultLongitude;
[DefaultValue(31.0)]
[DefaultValue(19.0)]
public double WalkingSpeedInKilometerPerHour;
[DefaultValue(10)]
public int MaxSpawnLocationOffset;
Expand Down Expand Up @@ -773,7 +773,6 @@ public static GlobalSettings Load(string path, bool boolSkipSave = false)
settings.ProfileConfigPath = profileConfigPath;
settings.GeneralConfigPath = Path.Combine(Directory.GetCurrentDirectory(), "config");
settings.isGui = isGui;
settings.migratePercentages();

if (!boolSkipSave || !settings.AutoUpdate)
{
Expand Down Expand Up @@ -973,22 +972,6 @@ private static void SaveFiles(GlobalSettings settings, String configFile)
settings.Auth.Load(Path.Combine(settings.ProfileConfigPath, "auth.json"));
}


/// <summary>
/// Method for issue #1966
/// </summary>
private void migratePercentages()
{
if (EvolveKeptPokemonsAtStorageUsagePercentage <= 1.0)
{
EvolveKeptPokemonsAtStorageUsagePercentage *= 100.0f;
}
if (RecycleInventoryAtUsagePercentage <= 1.0)
{
RecycleInventoryAtUsagePercentage *= 100.0f;
}
}

public void Save(string fullPath)
{
var jsonSerializeSettings = new JsonSerializerSettings
Expand Down
3 changes: 2 additions & 1 deletion PoGo.NecroBot.Logic/Tasks/LevelUpPokemonTask.cs
Expand Up @@ -36,7 +36,8 @@ public static async Task Execute(ISession session, CancellationToken cancellatio

foreach (var pokemon in upgradablePokemon)
{
if (session.LogicSettings.UseLevelUpList)

if (session.LogicSettings.UseLevelUpList && PokemonToLevel!=null)
{
for (int i = 0; i < PokemonToLevel.Count - 1; i++)
{
Expand Down
23 changes: 14 additions & 9 deletions PoGo.NecroBot.Logic/Tasks/SnipePokemonTask.cs
Expand Up @@ -191,7 +191,9 @@ public static async Task Execute(ISession session, CancellationToken cancellatio
pokemonIds = pokemonOnlyList.Union(pokemonToCapture).ToList();
}
else
{
pokemonIds = session.LogicSettings.PokemonToSnipe.Pokemon;
}

if (session.LogicSettings.UseSnipeLocationServer)
{
Expand Down Expand Up @@ -359,7 +361,7 @@ public static async Task Execute(ISession session, CancellationToken cancellatio
var CurrentLongitude = session.Client.CurrentLongitude;
var catchedPokemon = false;

session.EventDispatcher.Send(new SnipeModeEvent {Active = true});
session.EventDispatcher.Send(new SnipeModeEvent { Active = true });

List<MapPokemon> catchablePokemon;
try
Expand Down Expand Up @@ -400,6 +402,7 @@ public static async Task Execute(ISession session, CancellationToken cancellatio

if (encounter.Status == EncounterResponse.Types.Status.EncounterSuccess)
{

if (!LocsVisited.Contains(new PokemonLocation(latitude, longitude)))
LocsVisited.Add(new PokemonLocation(latitude, longitude));
//Also add exact pokemon location to LocsVisited, some times the server one differ a little.
Expand Down Expand Up @@ -458,14 +461,16 @@ public static async Task Execute(ISession session, CancellationToken cancellatio
});
}

session.EventDispatcher.Send(new SnipeModeEvent {Active = false});
session.EventDispatcher.Send(new SnipeModeEvent { Active = false });
await Task.Delay(session.LogicSettings.DelayBetweenPlayerActions, cancellationToken);

}

}

private static ScanResult SnipeScanForPokemon(ISession session, Location location)
{
var formatter = new NumberFormatInfo {NumberDecimalSeparator = "."};
var formatter = new NumberFormatInfo { NumberDecimalSeparator = "." };

var offset = session.LogicSettings.SnipingScanOffset;
// 0.003 = half a mile; maximum 0.06 is 10 miles
Expand Down Expand Up @@ -500,7 +505,7 @@ private static ScanResult SnipeScanForPokemon(ISession session, Location locatio
catch (Exception ex)
{
// most likely System.IO.IOException
session.EventDispatcher.Send(new ErrorEvent {Message = ex.Message});
session.EventDispatcher.Send(new ErrorEvent { Message = ex.Message });
scanResult = new ScanResult
{
Status = "fail",
Expand All @@ -523,7 +528,7 @@ private static List<SniperInfo> GetSniperInfoFrom_pokezz(ISession session, List<

List<PokemonLocation_pokezz> pokemons = new List<PokemonLocation_pokezz>();

socket.On("pokemons", (msg) =>
socket.On("pokemons", (msg) =>
{
JArray data = JArray.FromObject(msg);
Expand All @@ -536,14 +541,13 @@ private static List<SniperInfo> GetSniperInfoFrom_pokezz(ISession session, List<
waitforbroadcast.Set();
});

socket.On(Quobject.SocketIoClientDotNet.Client.Socket.EVENT_ERROR, () =>
socket.On(Quobject.SocketIoClientDotNet.Client.Socket.EVENT_ERROR, () =>
{
hasError = true;
waitforbroadcast.Set();
});


socket.On(Quobject.SocketIoClientDotNet.Client.Socket.EVENT_CONNECT_ERROR, () =>
socket.On(Quobject.SocketIoClientDotNet.Client.Socket.EVENT_CONNECT_ERROR, () =>
{
hasError = true;
waitforbroadcast.Set();
Expand All @@ -564,6 +568,7 @@ private static List<SniperInfo> GetSniperInfoFrom_pokezz(ISession session, List<
if (pokemon.verified || !session.LogicSettings.GetOnlyVerifiedSniperInfoFromPokezz)
SnipeLocations.Add(SnipInfo);
}

var locationsToSnipe = SnipeLocations?.Where(q =>
(!session.LogicSettings.UseTransferIvForSnipe ||
(q.IV == 0 && !session.LogicSettings.SnipeIgnoreUnknownIv) ||
Expand Down Expand Up @@ -694,7 +699,7 @@ public static async Task Start(Session session, CancellationToken cancellationTo
catch (Exception ex)
{
// most likely System.IO.IOException
session.EventDispatcher.Send(new ErrorEvent {Message = ex.ToString()});
session.EventDispatcher.Send(new ErrorEvent { Message = ex.ToString() });
}
await Task.Delay(100, cancellationToken);
}
Expand Down

0 comments on commit be0b1e0

Please sign in to comment.