Exemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="entry"></param>
        public void Add(AuctionEntry entry)
        {
            var templateId = entry.Item.TemplateId;
            var itemType   = entry.Item.Template.Type;

            AuctionCategory category = null;

            if (!m_categoriesByTemplate.ContainsKey(templateId))
            {
                m_categoriesByTemplate.Add(templateId, new List <AuctionCategory>());
            }

            category = m_categoriesByTemplate[templateId].Find(categ => categ.IsValidForThisCategory(entry.Item));

            if (category == null)
            {
                category = new AuctionCategory(itemType, templateId, m_nextCategoryId++);

                var type = entry.Item.Template.Type;
                if (!m_templatesByType.ContainsKey(type))
                {
                    m_templatesByType.Add(type, new List <int>());
                }
                if (!m_templatesByType[type].Contains(templateId))
                {
                    m_templatesByType[type].Add(templateId);
                }

                m_categoriesByTemplate[templateId].Add(category);
                m_categoryById.Add(category.Id, category);

                category.Add(entry);

                base.Dispatch(WorldMessage.AUCTION_HOUSE_CATEGORY_MOVEMENT(OperatorEnum.OPERATOR_ADD, category));
            }
            else
            {
                category.Add(entry);
            }

            if (!m_auctionsByAccount.ContainsKey(entry.OwnerId))
            {
                m_auctionsByAccount.Add(entry.OwnerId, new List <AuctionEntry>());
            }
            m_auctionsByAccount[entry.OwnerId].Add(entry);

            UpdateMiddlePrice(category.TemplateId);
        }
Exemplo n.º 2
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="category"></param>
 /// <returns></returns>
 public bool CheckEmptyCategory(AuctionCategory category)
 {
     if (category.IsEmpty)
     {
         m_categoryById.Remove(category.Id);
         m_categoriesByTemplate[category.TemplateId].Remove(category);
         if (m_categoriesByTemplate[category.TemplateId].Count == 0)
         {
             m_templatesByType[category.ItemType].Remove(category.TemplateId);
             m_categoriesByTemplate.Remove(category.TemplateId);
             base.Dispatch(WorldMessage.AUCTION_HOUSE_TEMPLATE_MOVEMENT(OperatorEnum.OPERATOR_REMOVE, category.TemplateId));
         }
         base.Dispatch(WorldMessage.AUCTION_HOUSE_CATEGORY_MOVEMENT(OperatorEnum.OPERATOR_REMOVE, category));
         return(true);
     }
     return(false);
 }
Exemplo n.º 3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="character"></param>
        /// <param name="itemId"></param>
        public void TryRemove(CharacterEntity character, long itemId)
        {
            Logger.Debug("AuctionHouse::TryRemove itemId=" + itemId);

            if (!m_auctionsByAccount.ContainsKey(character.AccountId))
            {
                character.Dispatch(WorldMessage.OBJECT_MOVE_ERROR());
                return;
            }

            var auction = m_auctionsByAccount[character.AccountId].Find(entry => entry.ItemId == itemId);

            if (auction == null)
            {
                character.Dispatch(WorldMessage.OBJECT_MOVE_ERROR());
                return;
            }

            m_auctionsByAccount[character.AccountId].Remove(auction);
            AuctionCategory category   = null;
            int             i          = 0;
            var             categories = m_categoriesByTemplate[auction.Item.TemplateId];

            while (i < categories.Count && category == null)
            {
                var current = categories[i];
                if (current.Remove(auction))
                {
                    category = current;
                }
            }

            CheckEmptyCategory(category);
            UpdateMiddlePrice(category.TemplateId);

            auction.Remove();
            character.Inventory.AddItem(auction.Item);

            SendAuctionOwnerList(character);
        }
 /// <summary>
 /// 
 /// </summary>
 /// <param name="category"></param>
 /// <returns></returns>
 public bool CheckEmptyCategory(AuctionCategory category)
 {
     if (category.IsEmpty)
     {
         m_categoryById.Remove(category.Id);
         m_categoriesByTemplate[category.TemplateId].Remove(category);
         if (m_categoriesByTemplate[category.TemplateId].Count == 0)
         {
             m_templatesByType[category.ItemType].Remove(category.TemplateId);
             m_categoriesByTemplate.Remove(category.TemplateId);
             base.Dispatch(WorldMessage.AUCTION_HOUSE_TEMPLATE_MOVEMENT(OperatorEnum.OPERATOR_REMOVE, category.TemplateId));
         }
         base.Dispatch(WorldMessage.AUCTION_HOUSE_CATEGORY_MOVEMENT(OperatorEnum.OPERATOR_REMOVE, category));
         return true;
     }
     return false;
 }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="entry"></param>
        public void Add(AuctionEntry entry)
        {
            var templateId = entry.Item.TemplateId;
            var itemType = entry.Item.Template.Type;

            AuctionCategory category = null;

            if (!m_categoriesByTemplate.ContainsKey(templateId))
                m_categoriesByTemplate.Add(templateId, new List<AuctionCategory>());

            category = m_categoriesByTemplate[templateId].Find(categ => categ.IsValidForThisCategory(entry.Item));

            if (category == null)
            {
                category = new AuctionCategory(itemType, templateId, m_nextCategoryId++);

                var type = entry.Item.Template.Type;
                if (!m_templatesByType.ContainsKey(type))
                    m_templatesByType.Add(type, new List<int>());
                if(!m_templatesByType[type].Contains(templateId))
                    m_templatesByType[type].Add(templateId);

                m_categoriesByTemplate[templateId].Add(category);
                m_categoryById.Add(category.Id, category);

                category.Add(entry);

                base.Dispatch(WorldMessage.AUCTION_HOUSE_CATEGORY_MOVEMENT(OperatorEnum.OPERATOR_ADD, category));
            }
            else
            {
                category.Add(entry);
            }

            if (!m_auctionsByAccount.ContainsKey(entry.OwnerId))
                m_auctionsByAccount.Add(entry.OwnerId, new List<AuctionEntry>());
            m_auctionsByAccount[entry.OwnerId].Add(entry);

            UpdateMiddlePrice(category.TemplateId);
        }