Ejemplo n.º 1
0
            public override void OnResponse(Mobile from, string text)
            {
                // Pattern match for invalid characters
                Regex InvalidPatt = new Regex("[^-a-zA-Z0-9' ]");

                if (InvalidPatt.IsMatch(text))
                {
                    // Invalid chars
                    from.SendMessage("You may only engrave numbers, letters, apostrophes and hyphens.");
                }
                else if (text.Length > 24)
                {
                    // Invalid length
                    from.SendMessage("You may only engrave a maximum of 24 characters.");
                }
                else if (!NameVerification.Validate(text, 2, 24, true, true, true, 1, NameVerification.SpaceDashPeriodQuote))
                {
                    // Invalid for some other reason
                    from.SendMessage("You may not name it this here.");
                }
                else if (Utility.RandomDouble() < (100 - from.Skills[SkillName.Carpentry].Base) / 100)
                {
                    // Failed!!
                    from.SendMessage("You fail to engrave the piece, ruining it in the process!");
                    m_container.Delete();
                }
                else
                {
                    // Make the change
                    m_container.Name = text;
                    from.SendMessage("You successfully engrave the container.");

                    // Decrement UsesRemaining of graver
                    m_graver.UsesRemaining--;

                    // Check for 0 charges and delete if has none left
                    if (m_graver.UsesRemaining == 0)
                    {
                        m_graver.Delete();
                        from.SendMessage("You have worn out your tool!");
                    }
                }
            }