Skip to content

Commit

Permalink
Revert a false merge
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryuichiro committed Jul 30, 2016
1 parent 23081bf commit 89b0a51
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 25 deletions.
2 changes: 0 additions & 2 deletions PoGo.NecroBot.Logic/Common/Translations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ public enum TranslationString
MissingCredentialsPtc,
SnipeScan,
NoPokemonToSnipe,
NotEnoughPokeballsToSnipe,
}

public class Translation : ITranslation
Expand Down Expand Up @@ -225,7 +224,6 @@ public class Translation : ITranslation
new KeyValuePair<TranslationString, string>(Common.TranslationString.MissingCredentialsPtc, "You need to fill out PtcUsername and PtcPassword in auth.json!"),
new KeyValuePair<TranslationString, string>(Common.TranslationString.SnipeScan, "[Sniper] Scanning for Snipeable Pokemon at {0}..."),
new KeyValuePair<TranslationString, string>(Common.TranslationString.NoPokemonToSnipe, "[Sniper] No Pokemon found to snipe!"),
new KeyValuePair<TranslationString, string>(Common.TranslationString.NotEnoughPokeballsToSnipe, "Not enough Pokeballs to start sniping! ({0}/{1})"),
};

public string GetTranslation(TranslationString translationString, params object[] data)
Expand Down
2 changes: 0 additions & 2 deletions PoGo.NecroBot.Logic/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@ public class GlobalSettings
public bool StartupWelcomeDelay = true;
public bool SnipeAtPokestops = false;
public int MinPokeballsToSnipe = 20;
public int MinPokeballsWhileSnipe = 0;
public string SnipeLocationServer = "localhost";
public int SnipeLocationServerPort = 16969;
public bool UseSnipeLocationServer = false;
Expand Down Expand Up @@ -598,7 +597,6 @@ public LogicSettings(GlobalSettings settings)
public bool StartupWelcomeDelay => _settings.StartupWelcomeDelay;
public bool SnipeAtPokestops => _settings.SnipeAtPokestops;
public int MinPokeballsToSnipe => _settings.MinPokeballsToSnipe;
public int MinPokeballsWhileSnipe => _settings.MinPokeballsWhileSnipe;
public SnipeSettings PokemonToSnipe => _settings.PokemonToSnipe;
public string SnipeLocationServer => _settings.SnipeLocationServer;
public int SnipeLocationServerPort => _settings.SnipeLocationServerPort;
Expand Down
28 changes: 7 additions & 21 deletions PoGo.NecroBot.Logic/Tasks/SnipePokemonTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ public static async Task Execute(ISession session, CancellationToken cancellatio
}
}
}
else if (await CheckPokeballsToSnipe(session.LogicSettings.MinPokeballsToSnipe, session, cancellationToken))
else

foreach (var location in session.LogicSettings.PokemonToSnipe.Locations)
{
Expand All @@ -264,7 +264,12 @@ public static async Task Execute(ISession session, CancellationToken cancellatio
lastSnipe = DateTime.Now;
foreach (var pokemonLocation in locationsToSnipe)
{
if (!await CheckPokeballsToSnipe(session.LogicSettings.MinPokeballsWhileSnipe + 1, session, cancellationToken))
var pokeBallsCount = await session.Inventory.GetItemAmountByType(POGOProtos.Inventory.Item.ItemId.ItemPokeBall);
var greatBallsCount = await session.Inventory.GetItemAmountByType(POGOProtos.Inventory.Item.ItemId.ItemGreatBall);
var ultraBallsCount = await session.Inventory.GetItemAmountByType(POGOProtos.Inventory.Item.ItemId.ItemUltraBall);
var masterBallsCount = await session.Inventory.GetItemAmountByType(POGOProtos.Inventory.Item.ItemId.ItemMasterBall);

if (pokeBallsCount + greatBallsCount + ultraBallsCount + masterBallsCount < session.LogicSettings.MinPokeballsToSnipe)
return;

locsVisited.Add(pokemonLocation);
Expand Down Expand Up @@ -312,24 +317,5 @@ private static ScanResult SnipeScanForPokemon(Location location)
}
return scanResult;
}

public static async Task<bool> CheckPokeballsToSnipe(int minPokeballs, ISession session, CancellationToken cancellationToken)
{
var pokeBallsCount = await session.Inventory.GetItemAmountByType(POGOProtos.Inventory.Item.ItemId.ItemPokeBall);
pokeBallsCount += await session.Inventory.GetItemAmountByType(POGOProtos.Inventory.Item.ItemId.ItemGreatBall);
pokeBallsCount += await session.Inventory.GetItemAmountByType(POGOProtos.Inventory.Item.ItemId.ItemUltraBall);
pokeBallsCount += await session.Inventory.GetItemAmountByType(POGOProtos.Inventory.Item.ItemId.ItemMasterBall);

if (pokeBallsCount < minPokeballs)
{
session.EventDispatcher.Send(new NoticeEvent()
{
Message = session.Translation.GetTranslation(Common.TranslationString.NotEnoughPokeballsToSnipe, pokeBallsCount, minPokeballs)
});
return false;
}

return true;
}
}
}

0 comments on commit 89b0a51

Please sign in to comment.