Esempio n. 1
0
        private static bool BuyComponents(ItemId item)
        {
            ItemBuilding ibuild = Lists.ItemsBuiltList.FirstOrDefault(a => a.result == item);

            if (ibuild != null)
            {
                bool hasAllItems = ibuild.components.All(a =>
                                                         ibuild.components.Count(b => b == a) == _player.InventoryItems.Count(c => c.Id == a));

                if (!hasAllItems)
                {
                    foreach (ItemId component in ibuild.components
                             .Where(a => ibuild.components.Count(b => b == a)
                                    != _player.InventoryItems.Count(c => c.Id == a)))
                    {
                        if (ibuild.components.IndexOf(component) - 1 >= 0 &&
                            _player.InventoryItems.All(a => a.Id != ibuild.components[ibuild.components.IndexOf(component) - 1]))
                        {
                            break;
                        }

                        if (!Shop.BuyItem(component))
                        {
                            return(false);
                        }
                    }
                }
            }

            return(true);
        }
Esempio n. 2
0
        private static void BuyItem()
        {
            if (Shop.CanShop)
            {
                foreach (ItemId item in itemList)
                {
                    if (itemList.IndexOf(item) - 1 >= 0 &&
                        itemList[itemList.IndexOf(item) - 1] != ItemId.Farsight_Alteration &&
                        itemList[itemList.IndexOf(item) - 1] != ItemId.Oracle_Alteration &&
                        _player.InventoryItems.All(a => a.Id != itemList[itemList.IndexOf(item) - 1]))
                    {
                        break;
                    }

                    if (_player.InventoryItems.All(a => a.Id != item))
                    {
                        if (!Shop.BuyItem(item) ||
                            ((item == ItemId.Farsight_Alteration || item == ItemId.Oracle_Alteration) &&
                             _player.Level < 9))
                        {
                            if (!BuyComponents(item))
                            {
                                ItemBuilding ibuild = Lists.ItemsBuiltList.FirstOrDefault(a => a.result == item);

                                if (ibuild != null)
                                {
                                    foreach (ItemId id in ibuild.components)
                                    {
                                        BuyComponents(id);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }