Skip to content

Commit

Permalink
Fixed lucky egg and incense functionalities
Browse files Browse the repository at this point in the history
  • Loading branch information
BornSupercharged committed Jul 31, 2016
1 parent e20532b commit a42e271
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 13 deletions.
4 changes: 4 additions & 0 deletions PoGo.NecroBot.Logic/State/FarmState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,19 @@ public async Task<IState> Execute(ISession session, CancellationToken cancellati
{
await LevelUpPokemonTask.Execute(session, cancellationToken);
}

if (session.LogicSettings.UseLuckyEggConstantly)
{
await UseLuckyEggConstantlyTask.Execute(session, cancellationToken);
}

if (session.LogicSettings.UseIncenseConstantly)
{
await UseIncenseConstantlyTask.Execute(session, cancellationToken);
}

await GetPokeDexCount.Execute(session, cancellationToken);

if (session.LogicSettings.RenamePokemon)
{
await RenamePokemonTask.Execute(session, cancellationToken);
Expand Down
23 changes: 17 additions & 6 deletions PoGo.NecroBot.Logic/Tasks/UseIncenseConstantlyTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,38 @@
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using POGOProtos.Inventory.Item;

namespace PoGo.NecroBot.Logic.Tasks
{
class UseIncenseConstantlyTask
{
public static async Task Execute(ISession session, CancellationToken cancellationToken)
{
var UseEgg = await session.Inventory.UseIncenseConstantly();
if (!session.LogicSettings.UseIncenseConstantly)
return;

if (UseEgg.Result.ToString().ToLower().Contains("noneininventory"))
var currentAmountOfIncense = await session.Inventory.GetItemAmountByType(ItemId.ItemIncenseOrdinary);
if (currentAmountOfIncense == 0)
{
Logging.Logger.Write("No Incense Available");
return;
}

var UseIncense = await session.Inventory.UseIncenseConstantly();

if (UseIncense.Result.ToString().Contains("Success"))
{
Logging.Logger.Write("Used an Incense");
}
else if (UseEgg.Result.ToString().Contains("IncenseAlreadyActive"))
else if (UseIncense.Result.ToString().ToLower().Contains("errornoitemsremaining") ||
UseIncense.Result.ToString().ToLower().Contains("noneininventory"))
{
Logging.Logger.Write("Incense Already Active");
Logging.Logger.Write("No Incense Available");
}
else
else if (UseIncense.Result.ToString().Contains("AlreadyActive") || (UseIncense.AppliedIncense == null))
{
Logging.Logger.Write("Used an Incense");
Logging.Logger.Write("Incense Already Active");
}
}
}
Expand Down
24 changes: 17 additions & 7 deletions PoGo.NecroBot.Logic/Tasks/UseLuckyEggConstantlyTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,38 @@
using System.Threading;
using System.Threading.Tasks;
using PoGo.NecroBot.Logic.State;
using POGOProtos.Inventory.Item;

namespace PoGo.NecroBot.Logic.Tasks
{
class UseLuckyEggConstantlyTask
{
public static async Task Execute(ISession session, CancellationToken cancellationToken)
{
var UseEgg =await session.Inventory.UseLuckyEggConstantly();
if (UseEgg.Result.ToString().ToLower().Contains("errornoitemsremaining"))
if (!session.LogicSettings.UseLuckyEggConstantly)
return;

var currentAmountOfLuckyEggs = await session.Inventory.GetItemAmountByType(ItemId.ItemLuckyEgg);
if (currentAmountOfLuckyEggs == 0)
{
Logging.Logger.Write("No Eggs Available");
return;
}

var UseEgg = await session.Inventory.UseLuckyEggConstantly();

if (UseEgg.Result.ToString().Contains("Success"))
{
Logging.Logger.Write("Used a Lucky Egg");
}
else if (UseEgg.Result.ToString().Contains("AlreadyActive"))
else if (UseEgg.Result.ToString().ToLower().Contains("errornoitemsremaining"))
{
Logging.Logger.Write("Lucky Egg Already Active");
Logging.Logger.Write("No Eggs Available");
}
else
else if (UseEgg.Result.ToString().Contains("AlreadyActive") || (UseEgg.AppliedItems == null))
{
Logging.Logger.Write("Used a Lucky Egg");
Logging.Logger.Write("Lucky Egg Already Active");
}

}

}
Expand Down

0 comments on commit a42e271

Please sign in to comment.