Exemple #1
0
        internal static async Task <bool> DeSelectRetainer()
        {
            if (!RetainerTasks.IsOpen)
            {
                return(true);
            }
            RetainerTasks.CloseTasks();

            await Coroutine.Wait(1500, () => DialogOpen || SelectYesno.IsOpen);

            if (SelectYesno.IsOpen)
            {
                SelectYesno.Yes();
                await Coroutine.Wait(1500, () => DialogOpen || RetainerList.Instance.IsOpen);
            }

            await Coroutine.Sleep(200);

            if (DialogOpen)
            {
                Next();
            }
            //await Coroutine.Sleep(200);
            return(await Coroutine.Wait(3000, () => RetainerList.Instance.IsOpen));
        }
Exemple #2
0
        internal static async Task <bool> SelectRetainer(int retainerIndex)
        {
            if (RetainerList.Instance.IsOpen)
            {
                return(await RetainerList.Instance.SelectRetainer(retainerIndex));
            }

            if (RetainerTasks.IsOpen)
            {
                RetainerTasks.CloseTasks();
                await Coroutine.Wait(1500, () => DialogOpen || RetainerList.Instance.IsOpen);

                await Coroutine.Sleep(200);

                if (DialogOpen)
                {
                    Next();
                }
                //await Coroutine.Sleep(200);
                await Coroutine.Wait(3000, () => RetainerList.Instance.IsOpen);

                return(await RetainerList.Instance.SelectRetainer(retainerIndex));
            }

            if (!RetainerList.Instance.IsOpen && FindSummoningBell() != null)
            {
                await UseSummoningBell();

                await Coroutine.Wait(5000, () => RetainerList.Instance.IsOpen);

                return(await RetainerList.Instance.SelectRetainer(retainerIndex));
            }

            return(false);
        }
Exemple #3
0
        public static async Task <bool> DeSelectRetainer()
        {
            if (!RetainerTasks.IsOpen)
            {
                return(true);
            }
            RetainerTasks.CloseTasks();

            await Coroutine.Wait(3000, () => DialogOpen || SelectYesno.IsOpen);

            if (SelectYesno.IsOpen)
            {
                SelectYesno.Yes();
                await Coroutine.Wait(3000, () => DialogOpen || RetainerList.Instance.IsOpen);
            }

            while (!RetainerList.Instance.IsOpen)
            {
                if (DialogOpen)
                {
                    Next();
                    await Coroutine.Sleep(100);
                }
                await Coroutine.Wait(3000, () => DialogOpen || RetainerList.Instance.IsOpen);
            }

            return(RetainerList.Instance.IsOpen);
        }
        public static async Task <bool> ExitRetainer(bool exitList = false)
        {
            if (RetainerTasks.IsInventoryOpen())
            {
                RetainerTasks.CloseInventory();

                await Coroutine.Wait(3000, () => RetainerTasks.IsOpen);
            }
            if (RetainerTasks.IsOpen)
            {
                RetainerTasks.CloseTasks();

                await Coroutine.Wait(3000, () => Talk.DialogOpen);
            }
            if (Talk.DialogOpen)
            {
                Talk.Next();
                await Coroutine.Wait(3000, () => RetainerList.Instance.IsOpen);
            }

            if (!exitList)
            {
                return(RetainerList.Instance.IsOpen);
            }

            if (!RetainerList.Instance.IsOpen)
            {
                return(true);
            }

            await RetainerRoutine.CloseRetainers();

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

            return(!RetainerList.Instance.IsOpen);
        }
Exemple #5
0
        public static async Task RetainerSellItems(IEnumerable <BagSlot> items)
        {
            if (await HelperFunctions.GetNumberOfRetainers() == 0)
            {
                Log("No retainers found to sell items to.");

                return;
            }

            List <BagSlot> bagSlots = items.ToList();

            if (!bagSlots.Any())
            {
                Log("No items found to sell.");
                return;
            }

            await StopBusy();

            if (!await HelperFunctions.UseSummoningBell())
            {
                Log("Couldn't get to summoning bell.");
                return;
            }

            await RetainerRoutine.SelectRetainer(0);

            RetainerTasks.OpenInventory();
            if (!await Coroutine.Wait(3000, RetainerTasks.IsInventoryOpen))
            {
                Log("Couldn't get Retainer inventory open.");
                RetainerTasks.CloseInventory();
                await Coroutine.Wait(3000, () => RetainerTasks.IsOpen);

                RetainerTasks.CloseTasks();
                await Coroutine.Wait(3000, () => Talk.DialogOpen);

                if (Talk.DialogOpen)
                {
                    Talk.Next();
                }
                await Coroutine.Wait(3000, () => RetainerList.Instance.IsOpen);

                await RetainerRoutine.CloseRetainers();

                return;
            }

            int itemCount = bagSlots.Count;
            int i         = 1;

            foreach (var bagSlot in bagSlots)
            {
                if (!bagSlot.IsValid || !bagSlot.IsFilled)
                {
                    Log("BagSlot isn't valid or filled.");
                    i++;
                    continue;
                }

                string name = bagSlot.Name;
                Log($"Attempting to sell #{i++} of {itemCount}: {name}");
                int waitTime = 600;

                bagSlot.RetainerSellItem();

                if (await Coroutine.Wait(500, () => SelectYesno.IsOpen))
                {
                    SelectYesno.ClickYes();
                }
                else
                {
                    waitTime -= 500;
                }

                if (!await Coroutine.Wait(5000, () => !bagSlot.IsValid || !bagSlot.IsFilled))
                {
                    Log($"We couldn't sell {name}.");
                }
                else
                {
                    Log($"Sold {name}.");
                }

                await Coroutine.Sleep(waitTime);
            }

            RetainerTasks.CloseInventory();
            await Coroutine.Wait(3000, () => RetainerTasks.IsOpen);

            RetainerTasks.CloseTasks();
            await Coroutine.Wait(3000, () => SelectYesno.IsOpen);

            SelectYesno.ClickYes();
            await Coroutine.Wait(3000, () => Talk.DialogOpen);

            if (Talk.DialogOpen)
            {
                Talk.Next();
            }
            await Coroutine.Wait(3000, () => RetainerList.Instance.IsOpen);

            await RetainerRoutine.CloseRetainers();
        }
Exemple #6
0
        private static async Task SortLoop(int index)
        {
            LogDebug($"We're gonna go try to sort {ItemSortStatus.GetByIndex(index).Name}!");

            if (index < ItemSortStatus.PlayerInventoryIndex)
            {
                LogCritical($"Tried to sort index of #{index.ToString()} but that's out of range...");
                return;
            }

            if (index < ItemSortStatus.SaddlebagInventoryIndex)
            {
                LogCritical($"Tried to sort the player's inventory, but we can't do anything with that alone...");
                return;
            }

            if (InventoryManager.FreeSlots == 0 && ItemSortStatus.GetByIndex(index).FreeSlots == 0)
            {
                LogCritical($"Both our player inventory and {ItemSortStatus.GetByIndex(index).Name} are completely full! Can't move anything around like this.");
                return;
            }

            bool openingSaddlebag = index == ItemSortStatus.SaddlebagInventoryIndex;
            await GeneralFunctions.ExitRetainer(openingSaddlebag);

            if (openingSaddlebag)
            {
                await InventoryBuddy.Instance.Open();

                if (!InventoryBuddy.Instance.IsOpen)
                {
                    LogCritical($"We were unable to open the saddlebag!");
                    return;
                }
            }
            else
            {
                await RetainerRoutine.SelectRetainer(index);

                RetainerTasks.OpenInventory();
                await Coroutine.Wait(3000, RetainerTasks.IsInventoryOpen);

                if (!RetainerTasks.IsInventoryOpen())
                {
                    LogCritical($"We were unable to open Retainer #{index.ToString()}!");
                    return;
                }
            }

            await Coroutine.Sleep(200);

            await CombineStacks(GeneralFunctions.MainBagsFilledSlots());
            await CombineStacks(InventoryManager.GetBagsByInventoryBagId(BagIdsByIndex(index)).SelectMany(x => x.FilledSlots));

            while (ShouldSortLoop(index))
            {
                bool depositResult = await DepositLoop(index);

                UpdatePlayerInventory();
                UpdateOpenedInventory(index);

                bool retrieveResult = await RetrieveLoop(index);

                UpdatePlayerInventory();
                UpdateOpenedInventory(index);

                await Coroutine.Sleep(250);

                if (!depositResult || !retrieveResult)
                {
                    break;
                }
            }

            if (openingSaddlebag)
            {
                InventoryBuddy.Instance.Close();
            }
            else
            {
                await GeneralFunctions.ExitRetainer();
            }

            await Coroutine.Sleep(250);
        }