Skip to content

Commit

Permalink
Merge branch 'pr/4'
Browse files Browse the repository at this point in the history
  • Loading branch information
MineMalox committed Aug 9, 2016
2 parents 2dcb691 + 478ca0d commit 8b3fca9
Show file tree
Hide file tree
Showing 10 changed files with 53 additions and 36 deletions.
28 changes: 14 additions & 14 deletions PoGo.NecroBot.CLI/Config/Translations/translation.tr.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@
"TranslationStrings": [
{
"Key": "pokeball",
"Value": "Poké Ball"
"Value": "Pokéball"
},
{
"Key": "greatPokeball",
"Value": "Great Ball"
"Value": "Greatball"
},
{
"Key": "ultraPokeball",
"Value": "Ultra Ball"
"Value": "Ultraball"
},
{
"Key": "masterPokeball",
"Value": "Master Ball"
"Value": "Masterball"
},
{
"Key": "wrongAuthType",
Expand All @@ -30,7 +30,7 @@
},
{
"Key": "farmPokestopsNoUsableFound",
"Value": "Bu alanda uygun PokéStop bulunamadı. \"MaxTravelDistanceInMeters\" değeri çok küçük olabilir."
"Value": "Bu alanda uygun Pokéstop bulunamadı. \"MaxTravelDistanceInMeters\" değeri çok küçük olabilir."
},
{
"Key": "eventFortUsed",
Expand All @@ -42,7 +42,7 @@
},
{
"Key": "eventFortTargeted",
"Value": "{1}m mesafedeki \"{0}\" PokéStopuna {2} saniye sonra varılacak."
"Value": "{1}m mesafedeki \"{0}\" Pokéstopuna {2} saniye sonra varılacak."
},
{
"Key": "eventProfileLogin",
Expand Down Expand Up @@ -82,7 +82,7 @@
},
{
"Key": "eventNoPokeballs",
"Value": "Poké topu kalmadı. - Kaçırılan Pokémon: {0} (CP: {1})"
"Value": "Pokéball kalmadı. - Kaçırılan Pokémon: {0} (CP: {1})"
},
{
"Key": "waitingForMorePokemonToEvolve",
Expand Down Expand Up @@ -306,27 +306,27 @@
},
{
"Key": "lookingForIncensePokemon",
"Value": "Tütsü(Incense) Pokémonu aranıyor..."
"Value": "Tütsü(Incense) Pokémon'u aranıyor..."
},
{
"Key": "lookingForPokemon",
"Value": "Pokémon aranıyor..."
},
{
"Key": "lookingForLurePokemon",
"Value": "Yem(Lure) Pokémonu aranıyor..."
"Value": "Yem(Lure) Pokémon'u aranıyor..."
},
{
"Key": "pokemonSkipped",
"Value": "{0} atlandı."
},
{
"Key": "zeroPokeballInv",
"Value": "Poké topu kalmadı. Daha fazla Pokémon yakalanamaz!"
"Value": "Pokéball kalmadı. Daha fazla Pokémon yakalanamaz!"
},
{
"Key": "currentPokeballInv",
"Value": "Poké Ball: {0} | Great Ball: {1} | Ultra Ball: {2} | Master Ball: {3}"
"Value": "Pokéball: {0} | Greatball: {1} | Ultraball: {2} | Masterball: {3}"
},
{
"Key": "currentPotionInv",
Expand Down Expand Up @@ -366,15 +366,15 @@
},
{
"Key": "encounterProblemLurePokemon",
"Value": "Yem(Lure) Pokémonu yakalarken bir sorunla karşılaşıldı: {0}"
"Value": "Yem(Lure) Pokémon'u yakalarken bir sorunla karşılaşıldı: {0}"
},
{
"Key": "desiredDestTooFar",
"Value": "Hedeflenen konum ({0}, {1}) geçerli konuma ({2}, {3}) çok uzak."
},
{
"Key": "pokemonRename",
"Value": "{0} ({1}) | Pokémonun ismi değiştirildi. (\"{2}\" -> \"{3}\")"
"Value": "{0} ({1}) | Pokémon'un ismi değiştirildi. (\"{2}\" -> \"{3}\")"
},
{
"Key": "pokemonFavorite",
Expand Down Expand Up @@ -486,7 +486,7 @@
},
{
"Key": "notEnoughPokeballsToSnipe",
"Value": "Keskin nişancılık için yeterli Poké topu yok! ({0}/{1})"
"Value": "Keskin nişancılık için yeterli Pokéball yok! ({0}/{1})"
},
{
"Key": "displayHighestMOVE1Header",
Expand Down
4 changes: 2 additions & 2 deletions PoGo.NecroBot.CLI/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ internal class Program
private static void Main(string[] args)
{
string strCulture = Thread.CurrentThread.CurrentCulture.TwoLetterISOLanguageName;
var culture = CultureInfo.CreateSpecificCulture(strCulture);

var culture = CultureInfo.CreateSpecificCulture( "en" );
CultureInfo.DefaultThreadCurrentCulture = culture;
Thread.CurrentThread.CurrentCulture = culture;

Expand Down Expand Up @@ -87,7 +87,7 @@ private static void Main(string[] args)
settings.DefaultLatitude = lat;
settings.DefaultLongitude = lng;
}
catch (Exception e) { }
catch (Exception) { }
}


Expand Down
2 changes: 1 addition & 1 deletion PoGo.NecroBot.Logic/Common/Translations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ public class Translation : ITranslation
new KeyValuePair<TranslationString, string>(TranslationString.SnipeScanEx,
"Sniping a {0} with {1} IV at {2}..."),
new KeyValuePair<TranslationString, string>(TranslationString.NoPokemonToSnipe,
"Did not find a Pokemon within the SnipingScanOffset!"),
"Did not find a Pokemon within the Location, pokemon despawned?"),
new KeyValuePair<TranslationString, string>(TranslationString.NotEnoughPokeballsToSnipe,
"Not enough Pokeballs to start sniping! ({0}/{1})"),
new KeyValuePair<TranslationString, string>(TranslationString.DisplayHighestMove1Header, "MOVE1"),
Expand Down
2 changes: 1 addition & 1 deletion PoGo.NecroBot.Logic/Inventory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ public async Task<PokemonData> GetHighestPokemonOfTypeByCp(PokemonData pokemon)
.FirstOrDefault();
}

public async Task<int> GetStarDust()
public int GetStarDust()
{
GetPlayerData();
return _player.PlayerData.Currencies[1].Amount;
Expand Down
9 changes: 8 additions & 1 deletion PoGo.NecroBot.Logic/Service/TelegramService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using PoGo.NecroBot.Logic.Common;
using PoGo.NecroBot.Logic.Event;
using PoGo.NecroBot.Logic.PoGoUtils;
using POGOProtos.Data;
using POGOProtos.Enums;
Expand All @@ -34,7 +36,7 @@ public TelegramService(string apiKey, ISession session)
bot.OnMessage += OnTelegramMessageReceived;
bot.StartReceiving();

Logger.Write("Using TelegramAPI with " + me.Username);
this.session.EventDispatcher.Send(new NoticeEvent {Message = "Using TelegramAPI with " + me.Username});
}

private async void OnTelegramMessageReceived(object sender, MessageEventArgs messageEventArgs)
Expand Down Expand Up @@ -224,6 +226,11 @@ await session.Inventory.GetItemAmountByType(ItemId.ItemTroyDisk)
case "/status":
SendMessage(message.Chat.Id, Console.Title);
break;
case "/restart":
Process.Start(Assembly.GetEntryAssembly().Location);
SendMessage(message.Chat.Id, "Restarted Bot. Closing old Instance... BYE!");
Environment.Exit(-1);
break;
default:
answerTextmessage += session.Translation.GetTranslation(TranslationString.HelpTemplate);
SendMessage(message.Chat.Id, answerTextmessage);
Expand Down
4 changes: 3 additions & 1 deletion PoGo.NecroBot.Logic/State/StateMachine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ public void SetFailureState(IState state)
}
catch (Exception ex)
{
session.EventDispatcher.Send(new ErrorEvent {Message = ex.ToString()});
session.EventDispatcher.Send(new ErrorEvent {Message = "Pokemon Servers might be offline / unstable. Trying again..."});
Thread.Sleep(1000);
session.EventDispatcher.Send(new ErrorEvent { Message = "Error: " + ex });
state = _initialState;
}
} while (state != null);
Expand Down
2 changes: 1 addition & 1 deletion PoGo.NecroBot.Logic/Tasks/CatchIncensePokemonsTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public static async Task Execute(ISession session, CancellationToken cancellatio
{
Message = session.Translation.GetTranslation(TranslationString.InvFullTransferring)
});
TransferDuplicatePokemonTask.Execute(session, cancellationToken);
await TransferDuplicatePokemonTask.Execute(session, cancellationToken);
}
else
session.EventDispatcher.Send(new WarnEvent
Expand Down
2 changes: 1 addition & 1 deletion PoGo.NecroBot.Logic/Tasks/CatchLurePokemonsTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public static async Task Execute(ISession session, FortData currentFortData, Can
{
Message = session.Translation.GetTranslation(TranslationString.InvFullTransferring)
});
TransferDuplicatePokemonTask.Execute(session, cancellationToken);
await TransferDuplicatePokemonTask.Execute(session, cancellationToken);
}
else
session.EventDispatcher.Send(new WarnEvent
Expand Down
2 changes: 1 addition & 1 deletion PoGo.NecroBot.Logic/Tasks/LevelUpPokemonTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ internal class LevelUpPokemonTask
public static List<PokemonData> Upgrade = new List<PokemonData>();
public static async Task Execute(ISession session, CancellationToken cancellationToken)
{
if (await session.Inventory.GetStarDust() <= session.LogicSettings.GetMinStarDustForLevelUp)
if (session.Inventory.GetStarDust() <= session.LogicSettings.GetMinStarDustForLevelUp)
return;

var upgradablePokemon = await session.Inventory.GetPokemonToUpgrade();
Expand Down
34 changes: 21 additions & 13 deletions PoGo.NecroBot.Logic/Tasks/SnipePokemonTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,6 @@ public static async Task Execute(ISession session, CancellationToken cancellatio

if (_locationsToSnipe.Any())
{
_lastSnipe = DateTime.Now;
foreach (var location in _locationsToSnipe)
{
if ((location.ExpirationTimestamp > DateTime.Now.AddSeconds(10)) && (!LocsVisited.Contains(new PokemonLocation(location.Latitude, location.Longitude))))
Expand All @@ -243,9 +242,9 @@ public static async Task Execute(ISession session, CancellationToken cancellatio
return;

await Snipe(session, pokemonIds, location.Latitude, location.Longitude, cancellationToken);

_lastSnipe = DateTime.Now;
//if (!LocsVisited.Contains(new PokemonLocation(location.Latitude, location.Longitude)))
//LocsVisited.Add(new PokemonLocation(location.Latitude, location.Longitude));
//LocsVisited.Add(new PokemonLocation(location.Latitude, location.Longitude));

}
}
Expand All @@ -254,7 +253,6 @@ public static async Task Execute(ISession session, CancellationToken cancellatio

if (session.LogicSettings.GetSniperInfoFromPokezz)
{
_lastSnipe = DateTime.Now;
var _locationsToSnipe = GetSniperInfoFrom_pokezz(session, pokemonIds);
if (_locationsToSnipe.Any())
{
Expand All @@ -274,17 +272,16 @@ public static async Task Execute(ISession session, CancellationToken cancellatio
return;

await Snipe(session, pokemonIds, location.Latitude, location.Longitude, cancellationToken);

_lastSnipe = DateTime.Now;
// if (!LocsVisited.Contains(new PokemonLocation(location.Latitude, location.Longitude)))
//LocsVisited.Add(new PokemonLocation(location.Latitude, location.Longitude));
//LocsVisited.Add(new PokemonLocation(location.Latitude, location.Longitude));
}
}
}
}

if (session.LogicSettings.GetSniperInfoFromPokeSnipers)
{
_lastSnipe = DateTime.Now;
var _locationsToSnipe = GetSniperInfoFrom_pokesnipers(session, pokemonIds);
if (_locationsToSnipe.Any())
{
Expand All @@ -304,9 +301,9 @@ public static async Task Execute(ISession session, CancellationToken cancellatio
return;

await Snipe(session, pokemonIds, location.Latitude, location.Longitude, cancellationToken);

_lastSnipe = DateTime.Now;
//if (!LocsVisited.Contains(new PokemonLocation(location.Latitude, location.Longitude)))
//LocsVisited.Add(new PokemonLocation(location.Latitude, location.Longitude));
//LocsVisited.Add(new PokemonLocation(location.Latitude, location.Longitude));
}
}
}
Expand Down Expand Up @@ -344,7 +341,6 @@ public static async Task Execute(ISession session, CancellationToken cancellatio

if (session.LogicSettings.SnipeWithSkiplagged)
{
_lastSnipe = DateTime.Now;
foreach (var location in session.LogicSettings.PokemonToSnipe.Locations)
{
session.EventDispatcher.Send(new SnipeScanEvent
Expand All @@ -363,7 +359,7 @@ public static async Task Execute(ISession session, CancellationToken cancellatio
var notVisitedPokemon = filteredPokemon.Where(q => !LocsVisited.Contains(q));
var notExpiredPokemon = notVisitedPokemon.Where(q => q.expires < (DateTime.Now.ToUniversalTime() - (new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc))).TotalMilliseconds);

if (notExpiredPokemon.Count() > 0)
if (notExpiredPokemon.Any())
locationsToSnipe.AddRange(notExpiredPokemon);
}

Expand All @@ -379,7 +375,7 @@ public static async Task Execute(ISession session, CancellationToken cancellatio
return;

await Snipe(session, pokemonIds, pokemonLocation.latitude, pokemonLocation.longitude, cancellationToken);

_lastSnipe = DateTime.Now;
//if (!LocsVisited.Contains(new PokemonLocation(location.Latitude, location.Longitude)))
// LocsVisited.Add(new PokemonLocation(location.Latitude, location.Longitude));
}
Expand All @@ -399,6 +395,9 @@ public static async Task Execute(ISession session, CancellationToken cancellatio
private static async Task Snipe(ISession session, IEnumerable<PokemonId> pokemonIds, double latitude,
double longitude, CancellationToken cancellationToken)
{
if (_lastSnipe.AddMilliseconds(session.LogicSettings.MinDelayBetweenSnipes) > DateTime.Now)
return;

var CurrentLatitude = session.Client.CurrentLatitude;
var CurrentLongitude = session.Client.CurrentLongitude;
var catchedPokemon = false;
Expand Down Expand Up @@ -428,6 +427,14 @@ public static async Task Execute(ISession session, CancellationToken cancellatio
await session.Client.Player.UpdatePlayerLocation(CurrentLatitude, CurrentLongitude, session.Client.CurrentAltitude);
}

if (catchablePokemon.Count == 0)
{
// Pokemon not found but we still add to the locations visited, so we don't keep sniping
// locations with no pokemon.
if (!LocsVisited.Contains(new PokemonLocation(latitude, longitude)))
LocsVisited.Add(new PokemonLocation(latitude, longitude));
}

foreach (var pokemon in catchablePokemon)
{
EncounterResponse encounter;
Expand Down Expand Up @@ -674,8 +681,9 @@ private static List<SniperInfo> GetSniperInfoFrom_pokesnipers(ISession session,
SnipInfo.IV = pokemon.iv;
SnipeLocations.Add(SnipInfo);
}
catch (Exception ex)
catch (Exception)
{
// ignored
}
}
var locationsToSnipe = SnipeLocations?.Where(q =>
Expand Down

0 comments on commit 8b3fca9

Please sign in to comment.