Skip to content
Open
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
4 changes: 2 additions & 2 deletions PoGo.PokeMobBot.CLI/Config/Translations/translation.de.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
},
{
"Key": "eventUseLuckyEggMinPokemonCheck",
"Value": "Not enough Pokemon to trigger a lucky egg. Waiting for {0} more. ({1}/{2})"
"Value": "Nicht genug Pokemon vorhanden um Glücks-Ei zu benutzen. Warte auf {0} mehr. ({1}/{2})"
},
{
"Key": "eventPokemonEvolvedSuccess",
Expand Down Expand Up @@ -325,7 +325,7 @@
},
{
"Key": "UseBerry",
"Value": "Benutze Himbeere. Verbleibend: {0}"
"Value": "Benutze Himmihbeere. Verbleibend: {0}"
}
],
"pokemon": [
Expand Down
2 changes: 1 addition & 1 deletion PoGo.PokeMobBot.Logic/DataDumper/Dumper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public static void Dump(ISession session, string data, string filename, string e
private static void DumpToFile(ISession session, string data, string filename, string extension = "txt")
{
var path = Path.Combine(session.LogicSettings.ProfilePath, "Dumps",
$"PokeMobBot-{filename}-{DateTime.Today.ToString("yyyy-MM-dd")}-{DateTime.Now.ToString("HH")}.{extension}");
$"PokeMobBot-{filename}-{DateTime.Today.ToString("yyyy-MM-dd")}-{DateTime.Now.ToString("HH:mm:ss")}.{extension}");

try
{
Expand Down
20 changes: 20 additions & 0 deletions PoGo.PokeMobBot.Logic/Tasks/CatchLurePokemonsTask.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
#region using directives

using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using PoGo.PokeMobBot.Logic.Common;
using PoGo.PokeMobBot.Logic.Event;
using PoGo.PokeMobBot.Logic.Logging;
using PoGo.PokeMobBot.Logic.PoGoUtils;
using PoGo.PokeMobBot.Logic.State;
using POGOProtos.Map.Fort;
using POGOProtos.Networking.Responses;
Expand All @@ -15,6 +18,8 @@ namespace PoGo.PokeMobBot.Logic.Tasks
{
public static class CatchLurePokemonsTask
{
private static HashSet<int> cache;

public static async Task Execute(ISession session, FortData currentFortData, CancellationToken cancellationToken)
{
cancellationToken.ThrowIfCancellationRequested();
Expand All @@ -41,6 +46,21 @@ public static async Task Execute(ISession session, FortData currentFortData, Can
var encounterId = currentFortData.LureInfo.EncounterId;
var encounter = await session.Client.Encounter.EncounterLurePokemon(encounterId, fortId);

// Feed this encounter back to the snipe server
if (session.LogicSettings.UseSnipeLocationServer)
{
var payload = new SniperInfo
{
Latitude = currentFortData.Latitude,
Longitude = currentFortData.Longitude,
Iv = PokemonInfo.CalculatePokemonPerfection(encounter.PokemonData),
Id = encounter.PokemonData.PokemonId,
Move1 = encounter.PokemonData.Move1,
Move2 = encounter.PokemonData.Move2,
};
SnipePokemonTask.Feedback(payload);
}

if (encounter.Result == DiskEncounterResponse.Types.Result.Success)
{
await CatchPokemonTask.Execute(session, encounter, null, currentFortData, encounterId);
Expand Down
18 changes: 18 additions & 0 deletions PoGo.PokeMobBot.Logic/Tasks/CatchNearbyPokemonsTask.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
#region using directives

using System;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Newtonsoft.Json;
using PoGo.PokeMobBot.Logic.Common;
using PoGo.PokeMobBot.Logic.Event;
using PoGo.PokeMobBot.Logic.Logging;
using PoGo.PokeMobBot.Logic.PoGoUtils;
using PoGo.PokeMobBot.Logic.State;
using PoGo.PokeMobBot.Logic.Utils;
using POGOProtos.Inventory.Item;
Expand Down Expand Up @@ -57,6 +60,21 @@ public static async Task Execute(ISession session, CancellationToken cancellatio
var encounter =
await session.Client.Encounter.EncounterPokemon(pokemon.EncounterId, pokemon.SpawnPointId);

// Feed this encounter back to the snipe server
if (session.LogicSettings.UseSnipeLocationServer)
{
var payload = new SniperInfo
{
Latitude = encounter.WildPokemon.Latitude,
Longitude = encounter.WildPokemon.Longitude,
Iv = PokemonInfo.CalculatePokemonPerfection(encounter.WildPokemon.PokemonData),
Id = encounter.WildPokemon.PokemonData.PokemonId,
Move1 = encounter.WildPokemon.PokemonData.Move1,
Move2 = encounter.WildPokemon.PokemonData.Move2,
};
SnipePokemonTask.Feedback(payload);
}

if (encounter.Status == EncounterResponse.Types.Status.EncounterSuccess)
{
await CatchPokemonTask.Execute(session, encounter, pokemon);
Expand Down
22 changes: 0 additions & 22 deletions PoGo.PokeMobBot.Logic/Tasks/RecycleItemsTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -263,28 +263,6 @@ private static async Task OptimizedRecycleRevives(ISession session, Cancellation
await DelayingUtils.Delay(session.LogicSettings.DelayBetweenPlayerActions, 500);
}
}

if (diff > 0)
{
int maxRevivesToKeep = maxReviveCount - diff;
if (maxRevivesToKeep < 0)
{
maxRevivesToKeep = 0;
}
maxRevivesToRecycle = maxReviveCount - maxRevivesToKeep;

if (maxRevivesToRecycle != 0)
{
diff -= maxRevivesToRecycle;
cancellationToken.ThrowIfCancellationRequested();
await session.Client.Inventory.RecycleItem(ItemId.ItemMaxRevive, maxRevivesToRecycle);
session.EventDispatcher.Send(new ItemRecycledEvent { Id = ItemId.ItemMaxRevive, Count = maxRevivesToRecycle });
if (session.LogicSettings.Teleport)
await Task.Delay(session.LogicSettings.DelayRecyleItem);
else
await DelayingUtils.Delay(session.LogicSettings.DelayBetweenPlayerActions, 500);
}
}
}
}
}
Expand Down
35 changes: 30 additions & 5 deletions PoGo.PokeMobBot.Logic/Tasks/SnipePokemonTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
using Newtonsoft.Json;
using PoGo.PokeMobBot.Logic.Common;
using PoGo.PokeMobBot.Logic.Event;
using PoGo.PokeMobBot.Logic.Logging;
using PoGo.PokeMobBot.Logic.State;
using PoGo.PokeMobBot.Logic.PoGoUtils;
using POGOProtos.Enums;
Expand All @@ -30,6 +31,8 @@ public class SniperInfo
public double Iv { get; set; }
public DateTime TimeStamp { get; set; }
public PokemonId Id { get; set; }
public PokemonMove Move1 { get; set; }
public PokemonMove Move2 { get; set; }

[JsonIgnore]
public DateTime TimeStampAdded { get; set; } = DateTime.Now;
Expand Down Expand Up @@ -88,6 +91,8 @@ public static class SnipePokemonTask
public static List<PokemonLocation> LocsVisited = new List<PokemonLocation>();
private static readonly List<SniperInfo> SnipeLocations = new List<SniperInfo>();
private static DateTime _lastSnipe = DateTime.MinValue;
private static StreamReader Reader;
private static StreamWriter Writer;

public static Task AsyncStart(Session session, CancellationToken cancellationToken = default(CancellationToken))
{
Expand Down Expand Up @@ -516,7 +521,7 @@ public static async Task Start(Session session, CancellationToken cancellationTo
var currentTimestamp = t.TotalMilliseconds;
var pokemonIds = session.LogicSettings.PokemonToSnipe.Pokemon;

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 @@ -636,11 +641,13 @@ public static async Task Start(Session session, CancellationToken cancellationTo
lClient.Connect(session.LogicSettings.SnipeLocationServer,
session.LogicSettings.SnipeLocationServerPort);

var sr = new StreamReader(lClient.GetStream());
NetworkStream stream = lClient.GetStream();
Reader = new StreamReader(stream);
Writer = new StreamWriter(stream);

while (lClient.Connected)
{
var line = sr.ReadLine();
var line = Reader.ReadLine();
if (line == null)
throw new Exception("Unable to ReadLine from sniper socket");

Expand All @@ -655,6 +662,12 @@ public static async Task Start(Session session, CancellationToken cancellationTo
SnipeLocations.RemoveAll(x => DateTime.Now > x.TimeStampAdded.AddMinutes(15));
SnipeLocations.Add(info);
}

Reader.Close();
Writer.Close();
stream.Close();
Reader = null;
Writer = null;
}
catch (SocketException)
{
Expand All @@ -663,11 +676,23 @@ 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(5000, cancellationToken);
}
await Task.Delay(5000, cancellationToken);
}
}

/// <summary>
/// Sends a communication back to the feeder server.
/// </summary>
/// <param name="message">Message to send.</param>
public static void Feedback(SniperInfo info)
{
if (Writer == null)
return;
Writer.WriteLine(JsonConvert.SerializeObject(info));
Writer.Flush();
}
}
}
1 change: 0 additions & 1 deletion Pokemon-Go-Rocket-API
Submodule Pokemon-Go-Rocket-API deleted from 150516