public override bool CheckLocked(Mobile from)
        {
            if (Locked)
            {
                MongbatHideoutBossPuzzleChestSolution solution = GetLastGuess(from);
                if (solution != null)
                {
                    solution = new MongbatHideoutBossPuzzleChestSolution(solution);
                }
                else
                {
                    solution = new MongbatHideoutBossPuzzleChestSolution(MongbatHideoutBossPuzzleChestCylinder.None, MongbatHideoutBossPuzzleChestCylinder.None, MongbatHideoutBossPuzzleChestCylinder.None, MongbatHideoutBossPuzzleChestCylinder.None, MongbatHideoutBossPuzzleChestCylinder.None);
                }

                from.CloseGump(typeof(MongbatHideoutBossPuzzleGump));
                from.CloseGump(typeof(MongbatHideoutChestStatusGump));
                from.SendGump(new MongbatHideoutBossPuzzleGump(from, this, solution, 0));

                return(true);
            }
            else
            {
                return(false);
            }
        }
 public MongbatHideoutBossPuzzleChestSolution(MongbatHideoutBossPuzzleChestSolution solution)
 {
     for (int i = 0; i < m_Cylinders.Length; i++)
     {
         m_Cylinders[i] = solution.m_Cylinders[i];
     }
 }
        public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);

            int version = reader.ReadEncodedInt();

            m_Solution = new MongbatHideoutBossPuzzleChestSolution(reader);

            int length = reader.ReadEncodedInt();

            for (int i = 0; i < length; i++)
            {
                MongbatHideoutBossPuzzleChestCylinder cylinder = (MongbatHideoutBossPuzzleChestCylinder)reader.ReadInt();

                if (length == m_Hints.Length)
                {
                    m_Hints[i] = cylinder;
                }
            }
            if (length != m_Hints.Length)
            {
                InitHints();
            }

            int guesses = reader.ReadEncodedInt();

            for (int i = 0; i < guesses; i++)
            {
                Mobile m = reader.ReadMobile();
                MongbatHideoutBossPuzzleChestSolutionAndTime sol = new MongbatHideoutBossPuzzleChestSolutionAndTime(reader);

                m_Guesses[m] = sol;
            }
        }
        public void SubmitSolution(Mobile m, MongbatHideoutBossPuzzleChestSolution solution)
        {
            int correctCylinders, correctColors;

            if (solution.Matches(this.Solution, out correctCylinders, out correctColors))
            {
                LockPick(m);

                DisplayTo(m);
            }
            else
            {
                m_Guesses[m] = new MongbatHideoutBossPuzzleChestSolutionAndTime(DateTime.Now, solution);

                m.SendGump(new MongbatHideoutChestStatusGump(correctCylinders, correctColors));

                DoDamage(m);
            }
        }
        public bool Matches(MongbatHideoutBossPuzzleChestSolution solution, out int cylinders, out int colors)
        {
            cylinders = 0;
            colors    = 0;

            bool[] matchesSrc = new bool[solution.m_Cylinders.Length];
            bool[] matchesDst = new bool[solution.m_Cylinders.Length];

            for (int i = 0; i < m_Cylinders.Length; i++)
            {
                if (m_Cylinders[i] == solution.m_Cylinders[i])
                {
                    cylinders++;

                    matchesSrc[i] = true;
                    matchesDst[i] = true;
                }
            }

            for (int i = 0; i < m_Cylinders.Length; i++)
            {
                if (!matchesSrc[i])
                {
                    for (int j = 0; j < solution.m_Cylinders.Length; j++)
                    {
                        if (m_Cylinders[i] == solution.m_Cylinders[j] && !matchesDst[j])
                        {
                            colors++;

                            matchesDst[j] = true;
                        }
                    }
                }
            }

            return(cylinders == m_Cylinders.Length);
        }
        protected override void GenerateTreasure()
        {
            DropItem(new Gold(5000));

            List <Item> gems = new List <Item>();

            for (int i = 0; i < 9; i++)
            {
                Item gem     = Loot.RandomGem();
                Type gemType = gem.GetType();

                foreach (Item listGem in gems)
                {
                    if (listGem.GetType() == gemType)
                    {
                        listGem.Amount++;
                        gem.Delete();
                        break;
                    }
                }

                if (!gem.Deleted)
                {
                    gems.Add(gem);
                }
            }

            foreach (Item gem in gems)
            {
                DropItem(gem);
            }

            DropItem(new BagOfAllReagents(200));

            DropItem(new Arrow(500));

            switch (Utility.Random(3))
            {
            case 0: DropItem(new AshArrow(500)); break;

            case 1: DropItem(new OakArrow(400)); break;

            case 2: DropItem(new YewArrow(300)); break;
            }

            DropItem(new Bolt(200));

            switch (Utility.Random(3))
            {
            case 0: DropItem(new DullCopperBolt(500)); break;

            case 1: DropItem(new ShadowIronBolt(400)); break;

            case 2: DropItem(new BronzeBolt(300)); break;
            }

            DropItem(new Bandage(100));

            DropItem(new DyeTub());

            switch (Utility.Random(3))
            {
            case 0: DropItem(new DullCopperIngot(500)); break;

            case 1: DropItem(new ShadowIronIngot(400)); break;

            case 2: DropItem(new BronzeIngot(300)); break;
            }

            switch (Utility.Random(17))
            {
            case 0: DropItem(new ArcaneStone(200)); break;

            case 1: DropItem(new BeetleEgg(200)); break;

            case 2: DropItem(new BlackGear(200)); break;

            case 3: DropItem(new Bonemeal(200)); break;

            case 4: DropItem(new BronzeGear(200)); break;

            case 5: DropItem(new CharredFeather(200)); break;

            case 6: DropItem(new CrimsonGear(200)); break;

            case 7: DropItem(new DiamondDust(200)); break;

            case 8: DropItem(new DragonScale(200)); break;

            case 9: DropItem(new ElementalDust(200)); break;

            case 10: DropItem(new FishScale(200)); break;

            case 11: DropItem(new LichDust(200)); break;

            case 12: DropItem(new Nirnroot(200)); break;

            case 13: DropItem(new SerpentScale(200)); break;

            case 14: DropItem(new ShadowEssence(200)); break;

            case 15: DropItem(new SpiderEgg(200)); break;

            case 16: DropItem(new ThunderStone(200)); break;
            }

            for (int i = 0; i < 2; i++)
            {
                Item item;

                if (Core.AOS)
                {
                    item = Loot.RandomArmorOrShieldOrWeaponOrJewelry();
                }
                else
                {
                    item = Loot.RandomArmorOrShieldOrWeapon();
                }

                if (item is BaseWeapon)
                {
                    BaseWeapon weapon = (BaseWeapon)item;

                    if (Core.AOS)
                    {
                        int attributeCount;
                        int min, max;

                        GetRandomAOSStats(out attributeCount, out min, out max);

                        BaseRunicTool.ApplyAttributesTo(weapon, attributeCount, min, max);
                    }
                    else
                    {
                        weapon.DamageLevel     = (WeaponDamageLevel)Utility.Random(6);
                        weapon.AccuracyLevel   = (WeaponAccuracyLevel)Utility.Random(6);
                        weapon.DurabilityLevel = (WeaponDurabilityLevel)Utility.Random(6);
                    }

                    DropItem(item);
                }
                else if (item is BaseArmor)
                {
                    BaseArmor armor = (BaseArmor)item;

                    if (Core.AOS)
                    {
                        int attributeCount;
                        int min, max;

                        GetRandomAOSStats(out attributeCount, out min, out max);

                        BaseRunicTool.ApplyAttributesTo(armor, attributeCount, min, max);
                    }
                    else
                    {
                        armor.ProtectionLevel = (ArmorProtectionLevel)Utility.Random(6);
                        armor.Durability      = (ArmorDurabilityLevel)Utility.Random(6);
                    }

                    DropItem(item);
                }
                else if (item is BaseClothing)
                {
                    BaseClothing clothing = (BaseClothing)item;

                    if (Core.AOS)
                    {
                        int attributeCount;
                        int min, max;

                        GetRandomAOSStats(out attributeCount, out min, out max);

                        BaseRunicTool.ApplyAttributesTo(clothing, attributeCount, min, max);
                    }

                    DropItem(item);
                }
                else if (item is BaseHat)
                {
                    BaseHat hat = (BaseHat)item;

                    if (Core.AOS)
                    {
                        int attributeCount;
                        int min, max;

                        GetRandomAOSStats(out attributeCount, out min, out max);

                        BaseRunicTool.ApplyAttributesTo(hat, attributeCount, min, max);
                    }

                    DropItem(item);
                }
                else if (item is BaseJewel)
                {
                    int attributeCount;
                    int min, max;

                    GetRandomAOSStats(out attributeCount, out min, out max);

                    BaseRunicTool.ApplyAttributesTo((BaseJewel)item, attributeCount, min, max);

                    DropItem(item);
                }
            }

            Solution = new MongbatHideoutBossPuzzleChestSolution();
        }
            public MongbatHideoutBossPuzzleGump(Mobile from, MongbatHideoutBossPuzzleChest chest, MongbatHideoutBossPuzzleChestSolution solution, int check) : base(50, 50)
            {
                m_From     = from;
                m_Chest    = chest;
                m_Solution = solution;

                Dragable = false;

                AddBackground(25, 0, 500, 410, 0x53);

                AddImage(62, 20, 0x67);

                AddHtmlLocalized(80, 36, 110, 70, 1018309, true, false);                   // A Puzzle Lock

                /* Correctly choose the sequence of cylinders needed to open the latch.  Each cylinder
                 * may potentially be used more than once.  Beware!  A false attempt could be deadly!
                 */
                AddHtmlLocalized(214, 26, 270, 90, 1018310, true, true);

                AddLeftCylinderButton(62, 130, MongbatHideoutBossPuzzleChestCylinder.LightBlue, 10);
                AddLeftCylinderButton(62, 180, MongbatHideoutBossPuzzleChestCylinder.Blue, 11);
                AddLeftCylinderButton(62, 230, MongbatHideoutBossPuzzleChestCylinder.Green, 12);
                AddLeftCylinderButton(62, 280, MongbatHideoutBossPuzzleChestCylinder.Orange, 13);

                AddRightCylinderButton(451, 130, MongbatHideoutBossPuzzleChestCylinder.Purple, 14);
                AddRightCylinderButton(451, 180, MongbatHideoutBossPuzzleChestCylinder.Red, 15);
                AddRightCylinderButton(451, 230, MongbatHideoutBossPuzzleChestCylinder.DarkBlue, 16);
                AddRightCylinderButton(451, 280, MongbatHideoutBossPuzzleChestCylinder.Yellow, 17);

                double lockpicking = from.Skills.Lockpicking.Base;

                if (lockpicking >= 45.0)
                {
                    AddHtmlLocalized(160, 125, 230, 24, 1018308, false, false);                       // Lockpicking hint:

                    AddBackground(159, 150, 230, 95, 0x13EC);

                    if (lockpicking >= 50.0)
                    {
                        AddHtmlLocalized(165, 157, 200, 40, 1018312, false, false);                           // In the first slot:
                        AddCylinder(350, 165, chest.Solution.First);

                        AddHtmlLocalized(165, 197, 200, 40, 1018313, false, false);                           // Used in unknown slot:
                        AddCylinder(350, 200, chest.FirstHint);

                        if (lockpicking >= 65.0)
                        {
                            AddCylinder(350, 212, chest.SecondHint);
                        }

                        if (lockpicking >= 70.0)
                        {
                            AddCylinder(350, 224, chest.ThirdHint);
                        }
                    }
                    else
                    {
                        AddHtmlLocalized(165, 157, 200, 40, 1018313, false, false);                           // Used in unknown slot:
                        AddCylinder(350, 160, chest.FirstHint);

                        if (lockpicking >= 65.0)
                        {
                            AddCylinder(350, 172, chest.SecondHint);
                        }
                    }
                }

                MongbatHideoutBossPuzzleChestSolution lastGuess = chest.GetLastGuess(from);

                if (lastGuess != null)
                {
                    AddHtmlLocalized(127, 249, 170, 20, 1018311, false, false);                       // Thy previous guess:

                    AddBackground(290, 247, 115, 25, 0x13EC);

                    AddCylinder(281, 254, lastGuess.First);
                    AddCylinder(303, 254, lastGuess.Second);
                    AddCylinder(325, 254, lastGuess.Third);
                    AddCylinder(347, 254, lastGuess.Fourth);
                    AddCylinder(369, 254, lastGuess.Fifth);
                }

                AddPedestal(140, 270, solution.First, 0, check == 0);
                AddPedestal(195, 270, solution.Second, 1, check == 1);
                AddPedestal(250, 270, solution.Third, 2, check == 2);
                AddPedestal(305, 270, solution.Fourth, 3, check == 3);
                AddPedestal(360, 270, solution.Fifth, 4, check == 4);

                AddButton(258, 370, 0xFA5, 0xFA7, 1, GumpButtonType.Reply, 0);
            }
 public MongbatHideoutBossPuzzleChestSolutionAndTime(DateTime when, MongbatHideoutBossPuzzleChestSolution solution) : base(solution)
 {
     m_When = when;
 }