Ejemplo n.º 1
0
        private async Task <bool> HandleCollectable()
        {
            var required = CollectabilityValue;
            var itemName = string.Empty;

            if (!string.IsNullOrWhiteSpace(Collectables.First().Name))
            {
                var item = SelectYesNoItem.Item;
                if (item == null ||
                    !Collectables.Any(c => string.Equals(c.Name, item.EnglishName, StringComparison.InvariantCultureIgnoreCase)))
                {
                    var ticks = 0;
                    while ((item == null
                            ||
                            !Collectables.Any(c => string.Equals(c.Name, item.EnglishName, StringComparison.InvariantCultureIgnoreCase))) &&
                           ticks++ < 60 && Behaviors.ShouldContinue)
                    {
                        item = SelectYesNoItem.Item;
                        await Coroutine.Yield();
                    }

                    if (ticks > 60)
                    {
                        required = (uint)Collectables.Select(c => c.Value).Max();
                    }
                }

                if (item != null)
                {
                    itemName = item.EnglishName;
                    var collectable = Collectables.FirstOrDefault(c => string.Equals(c.Name, item.EnglishName));

                    if (collectable != null)
                    {
                        required = (uint)collectable.Value;
                    }
                }
            }

            var value = SelectYesNoItem.CollectabilityValue;

            if (value >= required)
            {
                Logger.Info(Localization.ExFish_Collecting, itemName, value, required);
                SelectYesNoItem.Yes();
            }
            else
            {
                Logger.Info(Localization.ExFish_Declining, itemName, value, required);
                SelectYesNoItem.No();
            }

            await Coroutine.Wait(3000, () => !SelectYesNoItem.IsOpen);

            return(true);
        }
Ejemplo n.º 2
0
        private async Task <bool> HandleCollectable()
        {
            if (Collectables == null)
            {
                //we are not collecting
                return(false);
            }

            if (FishingManager.State != FishingState.Waitin)
            {
                // we are not waitin yet!
                return(false);
            }

            if (!SelectYesNoItem.IsOpen)
            {
                //Wait a few seconds
                var opened = await Coroutine.Wait(5000, () => SelectYesNoItem.IsOpen);

                if (!opened)
                {
                    Logger.Info("SelectYesNoItem never appeared");
                    return(false);
                }
            }

            var required = CollectabilityValue;
            var itemName = string.Empty;

            if (!string.IsNullOrWhiteSpace(Collectables.First().Name))
            {
                var item = SelectYesNoItem.Item;
                if (item == null ||
                    !Collectables.Any(c => string.Equals(c.Name, item.EnglishName, StringComparison.InvariantCultureIgnoreCase)))
                {
                    var ticks = 0;
                    while ((item == null
                            ||
                            !Collectables.Any(c => string.Equals(c.Name, item.EnglishName, StringComparison.InvariantCultureIgnoreCase))) &&
                           ticks++ < 60 && Behaviors.ShouldContinue)
                    {
                        item = SelectYesNoItem.Item;
                        await Coroutine.Yield();
                    }

                    // handle timeout
                    if (ticks > 60)
                    {
                        required = (uint)Collectables.Select(c => c.Value).Max();
                    }
                }

                if (item != null)
                {
                    // handle normal
                    itemName = item.EnglishName;
                    var collectable = Collectables.FirstOrDefault(c => string.Equals(c.Name, item.EnglishName));

                    if (collectable != null)
                    {
                        required = (uint)collectable.Value;
                    }
                }
            }

            // handle

            var value = SelectYesNoItem.CollectabilityValue;

            if (value >= required)
            {
                Logger.Info(Localization.Localization.ExFish_Collecting, itemName, value, required);
                SelectYesNoItem.Yes();
            }
            else
            {
                Logger.Info(Localization.Localization.ExFish_Declining, itemName, value, required);
                SelectYesNoItem.No();
            }

            await Coroutine.Wait(3000, () => !SelectYesNoItem.IsOpen && FishingManager.State != FishingState.Waitin);

            return(true);
        }