Example #1
0
        public void AddAllDungeonCoresInPack(Mobile from)
        {
            if (from == null)
            {
                return;
            }
            if (from.Backpack == null)
            {
                return;
            }

            List <DungeonCore> m_DungeonCores = from.Backpack.FindItemsByType <DungeonCore>();

            int totalCount = 0;

            Queue m_Queue = new Queue();

            foreach (DungeonCore dungeonCore in m_DungeonCores)
            {
                m_Queue.Enqueue(dungeonCore);
            }

            while (m_Queue.Count > 0)
            {
                DungeonCore             dungeonCore = (DungeonCore)m_Queue.Dequeue();
                DungeonCoreLibraryEntry entry       = GetEntryDetail(dungeonCore.Dungeon);

                if (entry == null)
                {
                    continue;
                }

                entry.Count++;
                totalCount++;

                dungeonCore.Delete();
            }

            if (totalCount > 1)
            {
                from.SendMessage("You add " + totalCount.ToString() + " dungeon cores to the library.");
                from.SendSound(addItemSound);
            }

            else if (totalCount == 1)
            {
                from.SendMessage("You add a dungeon core to the library.");
                from.SendSound(addItemSound);
            }

            else
            {
                from.SendMessage("You do not have any dungeon cores in your backpack.");
            }
        }
Example #2
0
        public static void ConsumeMaterials(Mobile from, Mobile mobileTarget, DungeonMould dungeonMould, bool newWeapon, DungeonEnum dungeon)
        {
            if (from == null || mobileTarget == null)
            {
                return;
            }

            List <DungeonCore>         m_DungeonCores         = mobileTarget.Backpack.FindItemsByType <DungeonCore>();
            List <DungeonDistillation> m_DungeonDistillations = mobileTarget.Backpack.FindItemsByType <DungeonDistillation>();

            List <DungeonCore>         m_MatchingDungeonCores         = new List <DungeonCore>();
            List <DungeonDistillation> m_MatchingDungeonDistillations = new List <DungeonDistillation>();

            int coresNeeded         = DungeonWeapon.CoresNeededForUpgrade;
            int distillationsNeeded = DungeonWeapon.DistillationNeededForUpgrade;

            if (newWeapon)
            {
                coresNeeded         = DungeonWeapon.CoresNeededForCreation;
                distillationsNeeded = DungeonWeapon.DistillationNeededForCreation;
            }

            Queue m_Queue = new Queue();

            foreach (DungeonCore dungeonCore in m_DungeonCores)
            {
                if (dungeonCore.Dungeon == dungeon)
                {
                    if (dungeonCore.Amount > coresNeeded)
                    {
                        dungeonCore.Amount -= coresNeeded;
                        coresNeeded         = 0;
                    }

                    else
                    {
                        //Queue for Deletion
                        coresNeeded -= dungeonCore.Amount;

                        m_Queue.Enqueue(dungeonCore);
                    }
                }

                if (coresNeeded <= 0)
                {
                    break;
                }
            }

            while (m_Queue.Count > 0)
            {
                DungeonCore dungeonCore = (DungeonCore)m_Queue.Dequeue();
                dungeonCore.Delete();
            }

            m_Queue = new Queue();

            foreach (DungeonDistillation dungeonDistillation in m_DungeonDistillations)
            {
                if (dungeonDistillation.Dungeon == dungeon)
                {
                    m_Queue.Enqueue(dungeonDistillation);
                    distillationsNeeded--;
                }

                if (distillationsNeeded <= 0)
                {
                    break;
                }
            }

            while (m_Queue.Count > 0)
            {
                DungeonDistillation dungeonDistillation = (DungeonDistillation)m_Queue.Dequeue();
                dungeonDistillation.Delete();
            }

            if (dungeonMould != null)
            {
                dungeonMould.Delete();
            }
        }