Skip to content

Commit

Permalink
Merge pull request #1584 from RoseFlunder/FixListenBerryEvent
Browse files Browse the repository at this point in the history
Fixed the berry event handlig in the CLI and added the berry type
  • Loading branch information
NecronomiconCoding authored Jul 31, 2016
2 parents 15d48b2 + b016e76 commit 4b6fb20
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 3 deletions.
8 changes: 8 additions & 0 deletions PoGo.NecroBot.CLI/Config/Translations/translation.de.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,14 @@
"Key": "eventNoPokeballs",
"Value": "Keine Pokébälle mehr! - Wir haben ein {0} mit {1} WP verpasst!"
},
{
"Key": "eventUseBerry",
"Value": "{0} benutzt, {1} verbleibend"
},
{
"Key": "itemRazzBerry",
"Value": "Himmihbeere"
},
{
"Key": "catchStatusAttempt",
"Value": "{0} Versuch #{1}"
Expand Down
13 changes: 12 additions & 1 deletion PoGo.NecroBot.CLI/ConsoleEventListener.cs
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,18 @@ public void HandleEvent(NoPokeballEvent evt, ISession session)

public void HandleEvent(UseBerryEvent evt, ISession session)
{
Logger.Write(session.Translation.GetTranslation(TranslationString.EventNoPokeballs, evt.Count),
string strBerry;
switch (evt.BerryType)
{
case ItemId.ItemRazzBerry:
strBerry = session.Translation.GetTranslation(TranslationString.ItemRazzBerry);
break;
default:
strBerry = evt.BerryType.ToString();
break;
}

Logger.Write(session.Translation.GetTranslation(TranslationString.EventUseBerry, strBerry, evt.Count),
LogLevel.Berry);
}

Expand Down
4 changes: 4 additions & 0 deletions PoGo.NecroBot.Logic/Common/Translations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ public enum TranslationString
EventItemRecycled,
EventPokemonCapture,
EventNoPokeballs,
EventUseBerry,
ItemRazzBerry,
CatchStatusAttempt,
CatchStatus,
Candies,
Expand Down Expand Up @@ -175,6 +177,8 @@ public class Translation : ITranslation
"({0}) | ({1}) {2} Lvl: {3} CP: ({4}/{5}) IV: {6}% | Chance: {7}% | {8}m dist | with a {9} ({10} left). | {11}"),
new KeyValuePair<TranslationString, string>(TranslationString.EventNoPokeballs,
"No Pokeballs - We missed a {0} with CP {1}"),
new KeyValuePair<TranslationString, string>(TranslationString.EventUseBerry, "Used {0} | {1} remaining"),
new KeyValuePair<TranslationString, string>(TranslationString.ItemRazzBerry, "Razz Berry"),
new KeyValuePair<TranslationString, string>(TranslationString.CatchStatusAttempt, "{0} Attempt #{1}"),
new KeyValuePair<TranslationString, string>(TranslationString.CatchStatus, "{0}"),
new KeyValuePair<TranslationString, string>(TranslationString.Candies, "Candies: {0}"),
Expand Down
5 changes: 4 additions & 1 deletion PoGo.NecroBot.Logic/Event/UseBerryEvent.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
namespace PoGo.NecroBot.Logic.Event
using POGOProtos.Inventory.Item;

namespace PoGo.NecroBot.Logic.Event
{
public class UseBerryEvent : IEvent
{
public ItemId BerryType;
public int Count;
}
}
2 changes: 1 addition & 1 deletion PoGo.NecroBot.Logic/Tasks/CatchPokemonTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ private static async Task UseBerry(ISession session, ulong encounterId, string s

await session.Client.Encounter.UseCaptureItem(encounterId, ItemId.ItemRazzBerry, spawnPointId);
berry.Count -= 1;
session.EventDispatcher.Send(new UseBerryEvent {Count = berry.Count});
session.EventDispatcher.Send(new UseBerryEvent {BerryType = ItemId.ItemRazzBerry, Count = berry.Count});
}
}
}

0 comments on commit 4b6fb20

Please sign in to comment.