Example #1
0
        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");
        }
Example #2
0
        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");
        }
Example #3
0
 public static int SellItemSim(List <LoLItem> inventory, LoLItem item)
 {
     if (inventory.Contains(item))
     {
         inventory.Remove(item);
         return(-item.sellGold);
     }
     return(-1);
 }
Example #4
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;
            }
        }
Example #5
0
 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;
 }
Example #6
0
        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);
        }
Example #7
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);
            }
        }
Example #8
0
 public static int SellItemSim(List<LoLItem> inventory, LoLItem item)
 {
     if (inventory.Contains(item))
     {
         inventory.Remove(item);
         return -item.sellGold;
     }
     return -1;
 }
Example #9
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);
        }