public BuildElement(BuildCreator bc, Menu menu, LoLItem item, int index, ShopActionType action)
        {
            this.Action = action;
            this._bc    = bc;
            this.Item   = item;
            P           = index;

            _upBox     = new CheckBox("up", false);
            _removeBox = new CheckBox("remove", false);
            _itemName  = new Label(" ");
            _costSlots = new Label(" ");

            PropertyInfo property2 = typeof(CheckBox).GetProperty("Size");

            property2.GetSetMethod(true).Invoke(_itemName, new object[] { new Vector2(400, 0) });
            property2.GetSetMethod(true).Invoke(_costSlots, new object[] { new Vector2(400, 0) });
            property2.GetSetMethod(true).Invoke(_upBox, new object[] { new Vector2(40, 20) });
            property2.GetSetMethod(true).Invoke(_removeBox, new object[] { new Vector2(80, 20) });


            menu.Add(Position + "nam" + RandGen.R.Next(), _itemName);
            menu.Add(Position + "cs" + RandGen.R.Next(), _costSlots);
            menu.Add(Position + "up" + RandGen.R.Next(), _upBox);
            menu.Add(Position + "rem" + RandGen.R.Next(), _removeBox);
            UpdateText();

            _upBox.CurrentValue       = false;
            _removeBox.CurrentValue   = false;
            _upBox.OnValueChange     += upBox_OnValueChange;
            _removeBox.OnValueChange += removeBox_OnValueChange;
            _property = typeof(CheckBox).GetProperty("Position");
        }
 public static int SellItemSim(List <LoLItem> inventory, LoLItem item)
 {
     if (inventory.Contains(item))
     {
         inventory.Remove(item);
         return(-item.SellGold);
     }
     return(-1);
 }
Ejemplo n.º 3
0
        private void Chat_OnInput(ChatInputEventArgs args)
        {
            if (args.Input.ToLower().StartsWith("/b "))
            {
                args.Process = false;
                string  itemName = args.Input.Substring(2);
                LoLItem i        = BrutalItemInfo.FindBestItem(itemName);
                Chat.Print("Buy " + i.Name);

                if (_myBuild.Count == 0 && !i.Groups.Equals("RelicBase"))
                {
                    AddElement(BrutalItemInfo.GetItemById(3340), ShopActionType.Buy);
                    Chat.Print("Added also warding totem.");
                }
                AddElement(i, ShopActionType.Buy);
                SaveBuild();
            }
            else if (args.Input.ToLower().StartsWith("/s "))
            {
                args.Process = false;
                string  itemName = args.Input.Substring(2);
                LoLItem i        = BrutalItemInfo.FindBestItemAll(itemName);
                Chat.Print("Sell " + i.Name);

                AddElement(i, ShopActionType.Sell);
                SaveBuild();
            }
            else if (args.Input.ToLower().Equals("/buyhp"))
            {
                if (_myBuild.Count == 0)
                {
                    AddElement(BrutalItemInfo.GetItemById(3340), ShopActionType.Buy);
                    Chat.Print("Added also warding totem.");
                }
                AddElement(BrutalItemInfo.GetItemById(2003), ShopActionType.StartHpPot);
                SaveBuild();
                args.Process = false;
            }
            else if (args.Input.ToLower().Equals("/stophp"))
            {
                if (_myBuild.Count == 0)
                {
                    AddElement(BrutalItemInfo.GetItemById(3340), ShopActionType.Buy);
                    Chat.Print("Added also warding totem.");
                }
                AddElement(BrutalItemInfo.GetItemById(2003), ShopActionType.StopHpPot);
                SaveBuild();
                args.Process = false;
            }
        }
        public static int BuyItemSim(List <LoLItem> inventory, LoLItem item, bool root = true)
        {
            if (!root && inventory.Any(it => it.Id == item.Id))
            {
                inventory.Remove(inventory.First(it => it.Id == item.Id));
                return(0);
            }
            if (item.FromItems.Length == 0)
            {
                return(item.BaseGold);
            }
            int gold = item.BaseGold +
                       item.FromItems.Sum(
                fromItemId => BuyItemSim(inventory, ItemDb.First(it => it.Id == fromItemId), false));

            return(gold);
        }
Ejemplo n.º 5
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);
            }
        }