Example #1
0
        public bool Remove(int index)
        {
            if (_myBuild.Count > 1 && index == 1)
            {
                return(false);
            }
            BuildElement th = _myBuild.First(ele => ele.Position == index);

            _myBuild.Remove(th);
            th.Remove(_menu);
            foreach (BuildElement el in _myBuild.OrderBy(b => b.Position).Where(b => b.Position > index))
            {
                el.Position--;


                List <LoLItem> c = new List <LoLItem>();
                BrutalItemInfo.InventorySimulator(_myBuild, c, el.Position - 1);
                el.Cost = BrutalItemInfo.InventorySimulator(new List <BuildElement> {
                    el
                }, c);
                el.FreeSlots = 7 - c.Count;
                el.UpdateText();
            }


            SaveBuild();
            return(true);
        }
Example #2
0
        private void AddElement(LoLItem it, ShopActionType ty)
        {
            if (ty != ShopActionType.Buy || ty != ShopActionType.Sell)
            {
                int hp = _myBuild.Count(e => e.Action == ShopActionType.StartHpPot) -
                         _myBuild.Count(e => e.Action == ShopActionType.StopHpPot);
                if (ty == ShopActionType.StartHpPot && hp != 0)
                {
                    return;
                }
                if (ty == ShopActionType.StopHpPot && hp == 0)
                {
                    return;
                }
            }

            BuildElement b = new BuildElement(this, _menu, it, _myBuild.Any() ? _myBuild.Max(a => a.Position) + 1 : 1, ty);

            List <LoLItem> c = new List <LoLItem>();

            BrutalItemInfo.InventorySimulator(_myBuild, c);
            b.Cost = BrutalItemInfo.InventorySimulator(new List <BuildElement> {
                b
            }, c);
            b.FreeSlots = 7 - c.Count;
            b.UpdateText();
            if (b.FreeSlots == -1)
            {
                Chat.Print("Couldn't add " + it + ", inventory is full.");
                b.Remove(_menu);
            }
            else
            {
                _myBuild.Add(b);
            }
        }