Skip to content

Commit

Permalink
Merge pull request NecronomiconCoding#1638 from simplyphp/master
Browse files Browse the repository at this point in the history
Maximum storage settings checking
  • Loading branch information
NecronomiconCoding authored Aug 1, 2016
2 parents 486a456 + 5619c76 commit c428fc1
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 1 deletion.
1 change: 0 additions & 1 deletion PoGo.NecroBot.CLI/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ private static void Main(string[] args)
var session = new Session(new ClientSettings(settings), new LogicSettings(settings));
session.Client.ApiFailure = new ApiFailureStrategy(session);


/*SimpleSession session = new SimpleSession
{
_client = new PokemonGo.RocketAPI.Client(new ClientSettings(settings)),
Expand Down
3 changes: 3 additions & 0 deletions PoGo.NecroBot.Logic/Common/Translations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ public enum TranslationString
PokemonSkipped,
ZeroPokeballInv,
CurrentPokeballInv,
MaxItemsCombinedOverMaxItemStorage,
RecyclingQuietly,
CheckingForBallsToRecycle,
CheckingForPotionsToRecycle,
Expand Down Expand Up @@ -265,6 +266,8 @@ public class Translation : ITranslation
"You have no pokeballs in your inventory, no more Pokemon can be caught!"),
new KeyValuePair<TranslationString, string>(TranslationString.CurrentPokeballInv,
"[Current Inventory] Pokeballs: {0} | Greatballs: {1} | Ultraballs: {2} | Masterballs: {3}"),
new KeyValuePair<TranslationString, string>(TranslationString.MaxItemsCombinedOverMaxItemStorage,
"[Configuration Invalid] Your maximum items combined (balls+potions+revives={0}) is over your max item storage ({1})"),
new KeyValuePair<TranslationString, string>(TranslationString.RecyclingQuietly, "Recycling Quietly..."),
new KeyValuePair<TranslationString, string>(TranslationString.CheckingForBallsToRecycle,
"Checking for balls to recycle, keeping {0}"),
Expand Down
4 changes: 4 additions & 0 deletions PoGo.NecroBot.Logic/State/FarmState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
using System.Threading;
using System.Threading.Tasks;
using PoGo.NecroBot.Logic.Tasks;
using PoGo.NecroBot.Logic.Common;
using PoGo.NecroBot.Logic.Logging;
using System;

#endregion

Expand All @@ -12,6 +15,7 @@ public class FarmState : IState
{
public async Task<IState> Execute(ISession session, CancellationToken cancellationToken)
{

if (session.LogicSettings.EvolveAllPokemonAboveIv || session.LogicSettings.EvolveAllPokemonWithEnoughCandy)
{
await EvolvePokemonTask.Execute(session, cancellationToken);
Expand Down
13 changes: 13 additions & 0 deletions PoGo.NecroBot.Logic/State/LoginState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using PoGo.NecroBot.Logic.Event;
using PokemonGo.RocketAPI.Enums;
using PokemonGo.RocketAPI.Exceptions;
using PoGo.NecroBot.Logic.Logging;

#endregion

Expand Down Expand Up @@ -128,6 +129,18 @@ public async Task<IState> Execute(ISession session, CancellationToken cancellati

await DownloadProfile(session);

int maxTheoreticalItems = session.LogicSettings.TotalAmountOfPokeballsToKeep +
session.LogicSettings.TotalAmountOfPotionsToKeep +
session.LogicSettings.TotalAmountOfRevivesToKeep;

if (maxTheoreticalItems > session.Profile.PlayerData.MaxItemStorage)
{
Logger.Write(session.Translation.GetTranslation(TranslationString.MaxItemsCombinedOverMaxItemStorage, maxTheoreticalItems, session.Profile.PlayerData.MaxItemStorage), LogLevel.Error);
Logger.Write("Press any key to exit, then fix your configuration and run the bot again.", LogLevel.Warning);
Console.ReadKey();
System.Environment.Exit(1);
}

return new PositionCheckState();
}

Expand Down

0 comments on commit c428fc1

Please sign in to comment.