private async Task UseBerry(ulong encounterId, string spawnId, ItemId berry)
        {
            ItemData berryData = Items.FirstOrDefault(x => x.ItemId == berry);

            if (berryData == null || berryData.Count <= 0)
            {
                return;
            }

            var response = await _client.ClientSession.RpcClient.SendRemoteProcedureCallAsync(new Request
            {
                RequestType    = RequestType.UseItemEncounter,
                RequestMessage = new UseItemEncounterMessage
                {
                    EncounterId    = encounterId,
                    Item           = berryData.ItemId,
                    SpawnPointGuid = spawnId
                }.ToByteString()
            });

            if (response == null)
            {
                return;
            }

            UseItemEncounterResponse useItemEncounterResponse = UseItemEncounterResponse.Parser.ParseFrom(response);

            switch (useItemEncounterResponse.Status)
            {
            case UseItemEncounterResponse.Types.Status.ActiveItemExists:
                LogCaller(new LoggerEventArgs("Faill: " + useItemEncounterResponse.Status, LoggerTypes.Debug));
                break;

            case UseItemEncounterResponse.Types.Status.AlreadyCompleted:
                LogCaller(new LoggerEventArgs("Faill: " + useItemEncounterResponse.Status, LoggerTypes.Debug));
                break;

            case UseItemEncounterResponse.Types.Status.InvalidItemCategory:
                LogCaller(new LoggerEventArgs("Faill: " + useItemEncounterResponse.Status, LoggerTypes.Debug));
                break;

            case UseItemEncounterResponse.Types.Status.NoItemInInventory:
                LogCaller(new LoggerEventArgs("Faill: " + useItemEncounterResponse.Status, LoggerTypes.Debug));
                break;

            case UseItemEncounterResponse.Types.Status.Success:
                int remaining = berryData.Count - 1;
                berryData.Count = remaining;
                LogCaller(new LoggerEventArgs(String.Format("Successfully used {0}. Remaining: {1}", berryData.ItemId.ToString().Replace("Item", ""), remaining), LoggerTypes.Success));

                await Task.Delay(CalculateDelay(UserSettings.DelayBetweenPlayerActions, UserSettings.PlayerActionDelayRandom));

                break;
            }
        }
Ejemplo n.º 2
0
        private async Task UseBerry(ulong encounterId, string spawnId, ItemId berry)
        {
            ItemData berryData = Items.FirstOrDefault(x => x.ItemId == berry);

            if (berryData == null || berryData.Count <= 0)
            {
                return;
            }

            try
            {
                var response = await _client.ClientSession.RpcClient.SendRemoteProcedureCallAsync(new Request
                {
                    RequestType    = RequestType.UseItemEncounter,
                    RequestMessage = new UseItemEncounterMessage
                    {
                        EncounterId    = encounterId,
                        Item           = berryData.ItemId,
                        SpawnPointGuid = spawnId
                    }.ToByteString()
                });

                UseItemEncounterResponse useItemEncounterResponse = null;

                useItemEncounterResponse = UseItemEncounterResponse.Parser.ParseFrom(response);
                LogCaller(new LoggerEventArgs("Success: " + useItemEncounterResponse.Status, LoggerTypes.Debug));
                int remaining = berryData.Count - 1;
                berryData.Count = remaining;
                LogCaller(new LoggerEventArgs(String.Format("Successfully used berry. Remaining: {0}", remaining), LoggerTypes.Info));

                await Task.Delay(CalculateDelay(UserSettings.DelayBetweenPlayerActions, UserSettings.PlayerActionDelayRandom));
            }
            catch (Exception ex1)
            {
                LogCaller(new LoggerEventArgs(String.Format("Failed using berry {0}. Remaining: {1}", berryData.ItemId, berryData.Count), LoggerTypes.Warning));
                LogCaller(new LoggerEventArgs(String.Format("Exception Message:" + ex1.Message), LoggerTypes.Debug));
            }
        }