internal static async Task <EquipItemResult> EquipItem(uint itemId, EquipmentSlot slot)
        {
            var equipmentBagSlot = GetEquipmentSlotBagSlot(slot);

            if (equipmentBagSlot == null)
            {
                return(EquipItemResult.Failure);
            }

            if (equipmentBagSlot.RawItemId == itemId)
            {
                return(EquipItemResult.Success);
            }

            if (!ConditionParser.HasItem(itemId))
            {
                return(EquipItemResult.ItemNotFound);
            }

            var itemBagSlot = GetBagSlotByItemId(itemId);

            if (itemBagSlot == null)
            {
                return(EquipItemResult.BagSlotNotFound);
            }

            Logger.SendDebugLog(itemBagSlot.EnglishName + " is in bag: " + itemBagSlot.BagId + ", slot: " + itemBagSlot.Slot + ".");
            itemBagSlot.Move(equipmentBagSlot);
            return(equipmentBagSlot.RawItemId == itemId ? EquipItemResult.Success : EquipItemResult.Failure);
        }
Beispiel #2
0
        /// <summary>
        /// Main task executor for the Loot logic.
        /// </summary>
        /// <returns>Returns <c>true</c> if any action was executed, otherwise <c>false</c>.</returns>
        internal new Task <bool> ExecuteLogic()
        {
            if (BotBase.Instance.IsPaused)
            {
                return(Task.FromResult(false));
            }

            if (!LootManager.HasLoot || BotBase.Instance.LootMode == LootMode.DontLoot || !WaitHelper.Instance.IsDoneWaiting("LootTimer", TimeSpan.FromMilliseconds(500)))
            {
                return(Task.FromResult(false));
            }

            switch (BotBase.Instance.LootMode)
            {
            case LootMode.NeedAndGreed:
                var need = LootManager.AvailableLoots.FirstOrDefault(i => !i.Rolled && !(i.Item.Unique && ConditionParser.HasItem(i.ItemId)));
                if (need.Valid)
                {
                    if (need.RollState == RollState.UpToNeed)
                    {
                        need.Need();
                    }
                    else if (need.RollState == RollState.UpToGreed)
                    {
                        need.Greed();
                    }
                    return(Task.FromResult(true));
                }
                break;

            case LootMode.GreedAll:
                var greed = LootManager.AvailableLoots.FirstOrDefault(i => !i.Rolled && !(i.Item.Unique && ConditionParser.HasItem(i.ItemId)));
                if (greed.Valid)
                {
                    if (greed.RollState == RollState.UpToNeed || greed.RollState == RollState.UpToGreed)
                    {
                        greed.Greed();
                    }
                    return(Task.FromResult(true));
                }
                break;

            case LootMode.PassAll:
                var pass = LootManager.AvailableLoots.FirstOrDefault(i => i.RolledState < RollOption.Pass);
                if (pass.Valid)
                {
                    if (pass.RolledState <= RollOption.Pass)
                    {
                        pass.Pass();
                    }
                    return(Task.FromResult(true));
                }
                break;
            }

            return(Task.FromResult(false));
        }