Example #1
0
            public override void OnResponse(Mobile from, string text)
            {
                PlayerMobile pm = (PlayerMobile)from;

                text = text.Trim();
                if (!NameVerification.Validate(text, 2, 16, true, true, true, 1, NameVerification.SpaceDashPeriodQuote))
                {
                    return;
                }

                pm.Title = text + "";
                pm.SendMessage("Your Title be hence forth know as {0}", text);
            }
Example #2
0
        private static void OnLogin(LoginEventArgs e)
        {
            PlayerMobile mob = e.Mobile as PlayerMobile;

            if (AccessLevelToggler.GetRawAccessLevel(mob) == AccessLevel.Player)                 //Incase [staff was used
            {
                NameResultMessage result = NameVerification.Validate(mob.RawName, 2, 16, true, false, true, 1, NameVerification.SpaceDashPeriodQuote);
                if (result != NameResultMessage.Allowed)
                {
                    mob.SendGump(new NameChangeGump(mob));
                }
            }
        }
Example #3
0
        public override void OnResponse(NetState sender, RelayInfo info)
        {
            Mobile from = sender.Mobile;

            if (from == null)
            {
                return;
            }

            Container pack = from.Backpack;

            string name = GetString(info, 1);

            if (name != null)
            {
                name = name.Trim();
            }

            if (name == "Type here...")
            {
            }
            else if (name != "")
            {
                if (!NameVerification.Validate(name, 2, 16, true, false, true, 1, NameVerification.SpaceOnly))
                {
                    from.SendMessage(0X22, "That name is unacceptable or already taken.");
                    return;
                }
                else if (CharacterCreation.CheckDupe(from, name) && pack.ConsumeTotal(typeof(Gold), 2000))
                {
                    from.SendMessage(0X22, "Your name is now {0}.", name);
                    from.Name     = name;
                    from.CantWalk = false;
                    return;
                }
                else if (CharacterCreation.CheckDupe(from, name) && !(pack.ConsumeTotal(typeof(Gold), 2000)))
                {
                    from.SendMessage(0X22, "You do not have enough gold!");
                    return;
                }
                else
                {
                    from.SendMessage(0X22, "That name is unacceptable or already taken.");
                    return;
                }
            }
            else
            {
                from.SendMessage(0X22, "You must enter a name.");
            }
        }
Example #4
0
        public static bool CheckName(string name)
        {
            if (!StringUtils.HasText(name))
            {
                return(false);
            }

            if (!NameVerification.Validate(name, 2, 16, true, false, true, 1, NameVerification.SpaceDashPeriodQuote) || m_ReservedNames.Contains(name.ToLower()))
            {
                return(false);
            }

            return(true);
        }
Example #5
0
            public override void OnResponse(Mobile from, string text)
            {
                PlayerMobile pm = (PlayerMobile)from;

                text = text.Trim();
                if (!NameVerification.Validate(text, 2, 16, true, true, true, 1, NameVerification.SpaceDashPeriodQuote, false))
                {
                    pm.SendMessage("That name is unnacceptable.");
                    return;
                }
                m_Target.Name = text;
                pm.SendMessage("Your item will henceforth by known as {0}.", text);
                m_Deed.Delete();
            }
            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 etch numbers, letters, apostrophes and hyphens.");
                }
                else if (text.Length > 24)
                {
                    // Invalid length
                    from.SendMessage("You may only etch 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 etch it with this.");
                }
                else if (Utility.RandomDouble() < ((100 - ((from.Skills[SkillName.Tinkering].Base + from.Skills[SkillName.Inscribe].Base) / 2)) * 2) / 100)
                {
                    // Failed!!
                    from.SendMessage("You fail to etch the piece, ruining it in the process!");
                    m_jewel.Delete();
                }
                else
                {
                    // Make the change
                    m_jewel.Name = text + "\n\n";
                    from.SendMessage("You successfully etch your message.");

                    // Play a little sound
                    from.PlaySound(0x241);

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

                    // Check for 0 charges and delete if has none left
                    if (m_etchingkit.UsesRemaining == 0)
                    {
                        m_etchingkit.Delete();
                        from.SendMessage("You have used up your etching kit!");
                    }

                    // we want to hide the [Exceptional] attribute
                    m_jewel.HideAttributes = true;
                }
            }
        private static void EventSink_Speech(SpeechEventArgs e)
        {
            Mobile from = e.Mobile;

            if (from.AccessLevel > AccessLevel.Player)
            {
                return;
            }

            if (!NameVerification.Validate(e.Speech, 0, int.MaxValue, true, true, false, int.MaxValue, Exceptions,
                                           Disallowed, StartDisallowed))
            {
                e.Blocked = !OnProfanityDetected(from, e.Speech);
            }
        }
Example #8
0
        public override void OnResponse(NetState sender, RelayInfo info)
        {
            Mobile from = sender.Mobile;

            if (from == null)
            {
                return;
            }

            string name = GetString(info, 1);

            if (name != null)
            {
                name = name.Trim();
            }
            else
            {
                from.SendMessage(0X22, "You may enter a name.");
                from.SendGump(new NameAlterGump(from));
            }

            if (name != "")
            {
                if (!NameVerification.Validate(name, 2, 16, true, false, true, 1, NameVerification.SpaceOnly))
                {
                    from.SendMessage(0X22, "That name is unacceptable or already taken.");
                    return;
                }
                else if (CharacterCreation.CheckDupe(from, name))
                {
                    from.SendMessage(0X22, "Your name is now {0}.", name);
                    from.Name     = name;
                    from.CantWalk = false;
                    return;
                }
                else if (CharacterCreation.CheckDupe(from, name))
                {
                    from.SendMessage(0X22, "That name is unacceptable or already taken.");
                    return;
                }
            }
            else
            {
                from.SendMessage(0X22, "You must enter a name.");
            }

            from.SendGump(new NameAlterGump(from));
        }
Example #9
0
            public override void OnResponse(Mobile from, string text)
            {
                // Pattern match for invalid characters
                Regex InvalidPatt = new Regex("[^-a-zA-Z0-9' ]");

                if (m_ncdeed == null || m_ncdeed.Deleted == true)
                {
                    // error
                    from.SendLocalizedMessage(1042001);                      // Must be in pack to use!!
                }
                // Make sure is in pack (still)
                else if (!m_ncdeed.IsChildOf(from.Backpack))
                {
                    from.SendLocalizedMessage(1042001);                      // Must be in pack to use!!
                }
                else if (InvalidPatt.IsMatch(text))
                {
                    // Invalid chars
                    from.SendMessage("You may only use numbers, letters, apostrophes, hyphens and spaces in your name.");
                }
                else if (!NameVerification.Validate(text, 2, 16, true, true, true, 1, NameVerification.SpaceDashPeriodQuote))
                {
                    // Invalid for some other reason
                    from.SendMessage("That name is not allowed here.");
                }
                else
                {
                    // Log change
                    try
                    {
                        StreamWriter LogFile = new StreamWriter("logs/namechange.log", true);
                        LogFile.WriteLine("{0}: {1},{2},{3}", DateTime.Now, from.Account, from.Name, text);
                        LogFile.Close();
                    }
                    catch
                    {
                    }

                    // Make the change
                    from.Name = text;
                    from.SendMessage("You have successfully changed your name to {0}.", text);

                    // Destroy deed
                    m_ncdeed.Delete();
                }
            }
Example #10
0
        public static bool CheckProfanity(string s, int maxLength)
        {
            return(NameVerification.Validate(s, 1, 50, true, true, false, int.MaxValue, ProfanityProtection.Exceptions, NameVerification.DisallowedWords, NameVerification.StartDisallowed, NameVerification.DisallowedAnywhere) == NameResultMessage.Allowed);

/*
 *                      //With testing on OSI, Guild stuff seems to follow a 'simpler' method of profanity protection
 *                      if( s.Length < 1 || s.Length > maxLength )
 *                              return false;
 *
 *                      char[] exceptions = ProfanityProtection.Exceptions;
 *
 *                      s = s.ToLower();
 *
 *                      for ( int i = 0; i < s.Length; ++i )
 *                      {
 *                              char c = s[i];
 *
 *                              if ( (c < 'a' || c > 'z') && (c < '0' || c > '9'))
 *                              {
 *                                      bool except = false;
 *
 *                                      for( int j = 0; !except && j < exceptions.Length; j++ )
 *                                              if( c == exceptions[j] )
 *                                                      except = true;
 *
 *                                      if( !except )
 *                                              return false;
 *                              }
 *                      }
 *
 *                      string[] disallowed = ProfanityProtection.DisallowedWords;
 *
 *                      for( int i = 0; i < disallowed.Length; i++ )
 *                              if ( s.IndexOf( disallowed[i] ) != -1 )
 *                                      return false;
 *
 *                      string[] disallowed = ProfanityProtection.DisallowedAnywhere;
 *
 *                      for( int i = 0; i < disallowed.Length; i++ )
 *                              if ( s.IndexOf( disallowed[i] ) != -1 )
 *                                      return false;
 *
 *
 *                      return true;
 */
        }
Example #11
0
        private static void EventSink_RenameRequest(Mobile from, Mobile targ, string name)
        {
            if (from.CanSee(targ) && from.InRange(targ, 12) && targ.CanBeRenamedBy(from))
            {
                name = name.Trim();

                if (NameVerification.Validate(
                        name,
                        1,
                        16,
                        true,
                        false,
                        true,
                        0,
                        NameVerification.Empty,
                        NameVerification.StartDisallowed,
                        Core.ML ? NameVerification.Disallowed : new string[] { }
                        ))
                {
                    if (Core.ML)
                    {
                        var disallowed = ProfanityProtection.Disallowed;

                        for (var i = 0; i < disallowed.Length; i++)
                        {
                            if (name.IndexOf(disallowed[i]) != -1)
                            {
                                from.SendLocalizedMessage(1072622); // That name isn't very polite.
                                return;
                            }
                        }

                        from.SendLocalizedMessage(
                            1072623,
                            $"{targ.Name}\t{name}"
                            ); // Pet ~1_OLDPETNAME~ renamed to ~2_NEWPETNAME~.
                    }

                    targ.Name = name;
                }
                else
                {
                    from.SendMessage("That name is unacceptable.");
                }
            }
        }
Example #12
0
        private static void EventSink_RenameRequest(Mobile from, Mobile targ, string name)
        {
            if (from.CanSee(targ) && from.InRange(targ, 12) && targ.CanBeRenamedBy(from))
            {
                name = name.Trim();

                if (NameVerification.Validate(name, 1, 16, true, false, true, 0, NameVerification.Empty,
                                              NameVerification.StartDisallowed, new string[] { }))
                {
                    targ.Name = name;
                }
                else
                {
                    from.SendMessage("That name is unacceptable.");
                }
            }
        }
        protected override void OnAccept(GumpButton button)
        {
            if (String.IsNullOrWhiteSpace(InputText) || !NameVerification.Validate(
                    InputText,
                    2,
                    20,
                    true,
                    false,
                    true,
                    1,
                    NameVerification.SpaceDashPeriodQuote))
            {
                Html = ("The name \"" + InputText + "\" is invalid.\n\n").WrapUOHtmlColor(Color.OrangeRed, HtmlColor) +
                       "It appears that another character is already using the name \"" +                     //
                       User.RawName.WrapUOHtmlColor(Color.LawnGreen, HtmlColor) + "\"!\n\n" +                 //
                       "Please enter a new name for your character...";

                InputText = NameList.RandomName(User.Female ? "female" : "male");

                Refresh(true);
                return;
            }

            if (InputText == User.RawName || PlayerNames.FindPlayers(
                    InputText,
                    p => p != User && p.GameTime > ((PlayerMobile)User).GameTime)
                .Any())
            {
                Html = "It appears that another character is already using the name \"" +                 //
                       InputText.WrapUOHtmlColor(Color.LawnGreen, HtmlColor) + "\"!\n\n" +                //
                       "Please enter a new name for your character...";

                InputText = NameList.RandomName(User.Female ? "female" : "male");

                Refresh(true);
                return;
            }

            User.RawName = InputText;

            PlayerNames.Register((PlayerMobile)User);

            base.OnAccept(button);
        }
Example #14
0
            public override void OnResponse(Mobile from, string text)
            {
                if (!m_Vendor.CanInteractWith(from, true))
                {
                    return;
                }

                string name = text.Trim();

                if (!NameVerification.Validate(name, 1, 20, true, true, true, 0, NameVerification.Empty))
                {
                    m_Vendor.SayTo(from, "That name is unacceptable.");
                    return;
                }

                m_Vendor.ShopName = Utility.FixHtml(name);

                from.SendGump(new NewPlayerVendorOwnerGump(m_Vendor));
            }
Example #15
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!");
                    }
                }
            }
Example #16
0
 public override void OnResponse(Mobile from, string text)
 {
     if (m_Item == null || m_Item.Deleted || !m_Item.IsChildOf(from.Backpack))
     {
         from.SendLocalizedMessage(1042001);
     }
     else
     {
         text = text.Trim();
         if (NameVerification.Validate(text, 2, 10, true, false, true, 1, NameVerification.SpaceDashPeriodQuote) != NameResultMessage.Allowed)
         {
             from.SendMessage("Titles must contain 2-10 alphabetic characters.");
         }
         else
         {
             from.Title = text;
             m_Item.Delete();
         }
     }
 }
            public override void OnResponse(Mobile from, string text)
            {
                Regex InvalidPatt = new Regex("[^-a-zA-Z0-9' ]");

                if (InvalidPatt.IsMatch(text))
                {
                    // Invalid chars
                    from.SendMessage("You may only use numbers, letters, apostrophes, hyphens and spaces in the name to be changed.");
                }
                else if (!NameVerification.Validate(text, 2, 16, true, true, true, 1, NameVerification.SpaceDashPeriodQuote, NameVerification.BuildList(true, true, false, true)))
                {
                    // Invalid for some other reason
                    from.SendMessage("That title is not allowed here.");
                }
                else
                {
                    vendor.Title = text;
                    from.SendMessage("Thou hast successfully changed thy servant's title.");
                    m_deed.Delete();
                }
            }
Example #18
0
            public override void OnResponse(Mobile from, string text)
            {
                char[] exceptions  = new char[] { ' ', '-', '.', '\'', ':', ',' };
                Regex  InvalidPatt = new Regex("[^-a-zA-Z0-9':, ]");

                if (InvalidPatt.IsMatch(text))
                {
                    // Invalid chars
                    from.SendMessage("You may only use numbers, letters, apostrophes, hyphens, colons, commas, and spaces in the inscription.");
                }
                else if (!NameVerification.Validate(text, 2, 32, true, true, true, 4, exceptions, NameVerification.BuildList(true, true, false, true)))
                {
                    // Invalid for some other reason
                    from.SendMessage("That inscription is not allowed here.");
                }
                else
                {
                    m_rose.Name         = text;
                    m_rose.Personalized = true;
                    from.SendMessage("Thou hast successfully inscribed thy rose.");
                }
            }
Example #19
0
            public override void OnResponse(Mobile from, string text)
            {
                PlayerMobile pm = (PlayerMobile)from;

                text = text.Trim();
                if (!NameVerification.Validate(text, 2, 16, true, true, true, 1, NameVerification.SpaceDashPeriodQuote))
                {
                    pm.SendMessage("That name is either already taken or otherwise unnacceptable.");
                    return;
                }

                if (pm.PreviousNames == null)
                {
                    pm.PreviousNames = new List <string>();
                }

                pm.PreviousNames.Add(pm.RawName);

                pm.Name = text;
                pm.SendMessage("You will henceforth by known as {0}.", text);
                m_NameChangeDeed.Delete();
            }
Example #20
0
        static bool HasValidName(Mobile m)
        {
            if (m.AccessLevel != AccessLevel.Player)
            {
                return(true);
            }

            if (m.RawName == "Generic Player" || !NameVerification.Validate(m.RawName, 2, 16, true, false, true, 1, NameVerification.SpaceDashPeriodQuote))
            {
                return(false);
            }

            foreach (Mobile otherPlayer in World.Mobiles.Values)
            {
                if (otherPlayer is PlayerMobile && otherPlayer != m && otherPlayer.RawName != null && m.RawName != null && otherPlayer.RawName.ToLower() == m.RawName.ToLower() && m.CreationTime > otherPlayer.CreationTime)
                {
                    return(false);
                }
            }

            return(true);
        }
Example #21
0
    public override void OnResponse(NetState sender, RelayInfo info)
    {
        if (m_Sender?.Deleted != false || info.ButtonID != 1 || m_Sender.RootParent != sender.Mobile)
        {
            return;
        }

        var m         = sender.Mobile;
        var nameEntry = info.GetTextEntry(0);

        var newName = nameEntry?.Text.Trim();

        if (!NameVerification.Validate(newName, 2, 16, true, false, true, 1, NameVerification.SpaceDashPeriodQuote))
        {
            m.SendMessage("That name is unacceptable.");
            return;
        }

        m.RawName = newName;
        m.SendMessage("Your name has been changed!");
        m.SendMessage($"You are now known as {newName}");
        m_Sender.Delete();
    }
        public override void OnResponse(NetState state, RelayInfo info)
        {
            if (info.ButtonID == 1) // Chose Name
            {
                bool isValid = true;

                string newName = (string)info.GetTextEntry(0).Text;

                if (m_Item.Deleted)
                {
                    isValid = false;
                }

                if (!m_Item.IsChildOf(m_From.Backpack)) // Make sure its in their pack
                {
                    isValid = false;

                    m_From.SendLocalizedMessage(1042001); // That must be in your pack for you to use it.
                }


                if (!NameVerification.Validate(newName, 2, 16, true, true, true, 1, NameVerification.SpaceDashPeriodQuote))
                {
                    isValid = false;

                    m_From.SendLocalizedMessage(1005572); // This is not an acceptable name
                }

                if (isValid)
                {
                    m_From.Name = newName;

                    m_Item.Delete();
                }
            }
        }
Example #23
0
        public override void OnResponse(NetState sender, RelayInfo info)
        {
            if (m_Sender == null || m_Sender.Deleted || info.ButtonID != 1 || m_Sender.RootParent != sender.Mobile)
            {
                return;
            }

            Mobile    m         = sender.Mobile;
            TextRelay nameEntry = info.GetTextEntry(0);

            string newName = nameEntry == null ? null : nameEntry.Text.Trim();

            if (!NameVerification.Validate(newName, 2, 16, true, true, true, 1, NameVerification.SpaceDashPeriodQuote))
            {
                m.SendLocalizedMessage(501144); // That name is not permissible.
            }
            else
            {
                m.RawName = newName;
                m.SendMessage("Your name has been changed!");
                m.SendMessage(string.Format("You are now known as {0}", newName));
                m_Sender.Delete();
            }
        }
Example #24
0
        public override void OnResponse(Network.NetState sender, RelayInfo info)
        {
            if (info.ButtonID != (int)Buttons.btnApply)
            {
                return;
            }
            try
            {
                Mobile m = sender.Mobile;

                TextRelay name = info.GetTextEntry((int)Buttons.TextEntry);

                string text = name.Text.Trim();

                short a;
                if (text.Length < 1 || Int16.TryParse(text.Substring(0, 1), out a) || !NameVerification.Validate(text, 2, 16, true, true, true, 1, NameVerification.SpaceDashPeriodQuote, NameVerification.Disallowed, NameVerification.StartDisallowed))
                {
                    m.SendMessage("That name is either already taken or otherwise unnacceptable. Please choose a different name.");

                    if (m.HasGump(typeof(NameChangeGump)))
                    {
                        m.CloseGump(typeof(NameChangeGump));
                    }

                    m.SendGump(new NameChangeGump(m, text));

                    return;
                }

                m.Name = text;
                m.SendMessage("You will henceforth be known as {0}.", text);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Name Change Gump OnResponse: {0}", ex.Message);
            }
        }
Example #25
0
        public override void OnResponse(Server.Network.NetState sender, RelayInfo info)
        {
            if (!AuctionSystem.Running)
            {
                sender.Mobile.SendMessage(AuctionConfig.MessageHue, AuctionSystem.ST[15]);

                m_Auction.Cancel();

                return;
            }

            int buttonid = info.ButtonID;

            //right click
            if (buttonid == 0)
            {
                m_Auction.Cancel();
                m_User.SendGump(new AuctionGump(m_User));
                return;
            }

            if (buttonid > 1)
            {
                m_User.SendMessage("Invalid option.  Please try again.");
                return;
            }
            bool   allowBuyNow  = info.Switches.Length > 0;          // Just one switch
            String errormessage = "";

            switch (info.ButtonID)
            {
            case 0:                     // Cancel the auction

                m_Auction.Cancel();
                m_User.SendGump(new AuctionGump(m_User));
                break;

            case 1:                     // Commit the auction

                // Collect information
                int    minbid      = 100;                // text 0
                int    reserve     = minbid;             // text 1
                int    days        = 7;                  // text 2
                string name        = m_Auction.ItemName; // text 3
                string description = " ";                // text 4
                string weblink     = " ";                // text 5
                int    buynow      = 0;                  // text 6

                // The 3D client sucks

                string[] tr = new string[7];

                foreach (TextRelay t in info.TextEntries)
                {
                    try
                    {
                        tr[t.EntryID] = t.Text;
                    }
                    catch (Exception e)
                    {
                        errormessage = e.Message;
                    }
                }


                try { minbid = (int)uint.Parse(tr[0], NumberStyles.AllowThousands); }
                catch {}

                try { reserve = (int)uint.Parse(tr[1], NumberStyles.AllowThousands); }
                catch { }

                try { days = (int)uint.Parse(tr[2]); }
                catch {}

                try { buynow = (int)uint.Parse(tr[6], NumberStyles.AllowThousands); }
                catch {}

                if (buynow < 1)
                {
                    allowBuyNow = false;
                }

                if (tr[3] != null)
                {
                    if (NameVerification.Validate(tr[3], 2, 40, true, true, true, 2, NameVerification.Empty))
                    {
                        string[] disallowed = ProfanityProtection.Disallowed;

                        for (int i = 0; i < disallowed.Length; i++)
                        {
                            if (tr[3].IndexOf(disallowed[i]) != -1)
                            {
                                m_User.SendLocalizedMessage(1072622); // That name isn't very polite.
                                goto case 0;                          // Pretty much cancel the auction
                            }
                        }
                    }
                    else
                    {
                        name = tr[3];
                    }
                    name = tr[3];
                }

                if (tr[4] != null)
                {
                    if (NameVerification.Validate(tr[4], 0, 100, true, true, true, 2, NameVerification.Empty))
                    {
                        string[] disallowed = ProfanityProtection.Disallowed;

                        for (int i = 0; i < disallowed.Length; i++)
                        {
                            if (tr[4].IndexOf(disallowed[i]) != -1)
                            {
                                m_User.SendLocalizedMessage(1072622); // That name isn't very polite.
                                goto case 0;                          // Pretty much cancel the auction
                            }
                        }
                    }
                    else
                    {
                        description = tr[4];
                        //name = tr[3];
                    }
                    description = tr[4];
                }

                if (tr[5] != null)
                {
                    weblink = tr[5];
                }

                bool ok = true;

                if (minbid < 1)
                {
                    m_User.SendMessage(AuctionConfig.MessageHue, AuctionSystem.ST[109]);
                    ok = false;
                }
                if (reserve < 1)
                {
                    reserve = minbid;
                }

                if (reserve < minbid)
                {
                    reserve = minbid;
                    m_User.SendMessage(214, AuctionSystem.ST[110]);
                    ok = false;
                }

                if (days < AuctionSystem.MinAuctionDays && m_User.AccessLevel < AccessLevel.GameMaster || days < 1)
                {
                    m_User.SendMessage(AuctionConfig.MessageHue, AuctionSystem.ST[111], AuctionSystem.MinAuctionDays);
                    ok = false;
                }

                if (days > AuctionSystem.MaxAuctionDays && m_User.AccessLevel < AccessLevel.GameMaster)
                {
                    m_User.SendMessage(AuctionConfig.MessageHue, AuctionSystem.ST[112], AuctionSystem.MaxAuctionDays);
                    ok = false;
                }

                if (name.Length == 0)
                {
                    m_User.SendMessage(AuctionConfig.MessageHue, AuctionSystem.ST[113]);
                    ok = false;
                }

                if (minbid * AuctionConfig.MaxReserveMultiplier < reserve && m_User.AccessLevel < AccessLevel.GameMaster)
                {
                    m_User.SendMessage(AuctionConfig.MessageHue, AuctionSystem.ST[114]);
                    ok = false;
                }

                if (allowBuyNow && buynow < reserve)
                {
                    m_User.SendMessage(AuctionConfig.MessageHue, AuctionSystem.ST[209]);
                    ok = false;
                }

                if (ok && AuctionConfig.CostOfAuction > 0.0)
                {
                    int toPay = 0;

                    if (AuctionConfig.CostOfAuction <= 1.0)
                    {
                        toPay = (int)(Math.Max(minbid, reserve) * AuctionConfig.CostOfAuction);
                    }
                    else
                    {
                        toPay = (int)AuctionConfig.CostOfAuction;
                    }

                    if (toPay > 0)
                    {
                        if (Server.Mobiles.Banker.Withdraw(m_User, toPay))
                        {
                            m_User.SendMessage(AuctionConfig.MessageHue, AuctionSystem.ST[228], toPay);
                        }
                        else
                        {
                            m_User.SendMessage(AuctionConfig.MessageHue, AuctionSystem.ST[229], toPay);
                            goto case 0;     // Pretty much cancel the auction
                        }
                    }
                }

                m_Auction.MinBid      = minbid;
                m_Auction.Reserve     = reserve;
                m_Auction.ItemName    = name;
                m_Auction.Duration    = TimeSpan.FromDays(days);
                m_Auction.Description = description;
                m_Auction.WebLink     = weblink;
                m_Auction.BuyNow      = allowBuyNow ? buynow : 0;

                if (ok && AuctionSystem.Running)
                {
                    World.Broadcast(0x35, true, "A {0} just became available on [Myauction for {1}", m_Auction.ItemName, minbid);
                    m_Auction.Confirm();
                    m_User.SendGump(new AuctionViewGump(m_User, m_Auction, new AuctionGumpCallback(AuctionCallback)));
                }
                else if (AuctionSystem.Running)
                {
                    m_User.SendGump(new NewAuctionGump(m_User, m_Auction));
                }
                else
                {
                    m_User.SendMessage(AuctionConfig.MessageHue, AuctionSystem.ST[115]);
                }

                break;
            }
        }
Example #26
0
        public override void OnResponse(NetState sender, RelayInfo info)
        {
            if (info.ButtonID == (int)Buttons.Okay &&
                !String.IsNullOrEmpty(info.GetTextEntry((int)Buttons.NameEntry).Text))
            {
                Mobile from = sender.Mobile;

                if (!Directory.Exists(savePath))
                {
                    Directory.CreateDirectory(savePath);
                }

                String desiredSurname = info.GetTextEntry((int)Buttons.NameEntry).Text;
                desiredSurname = (string)(char.ToUpper(desiredSurname[0]) + desiredSurname.Substring(1));

                Regex rx         = new Regex(" ");
                Match match      = rx.Match(from.Name);
                bool  hasSurname = match.Success;

                rx    = new Regex(" |1|2|3|4|5|6|7|8|9|0");
                match = rx.Match(desiredSurname);

                bool invalidName = !NameVerification.Validate
                                       (desiredSurname, 2, 16, true, true, true, 1, NameVerification.SpaceDashPeriodQuote) || match.Success;

                if (desiredSurname.Length > 16)
                {
                    from.SendMessage("Your surname may be no longer than (16) characters.");
                    return;
                }

                if (invalidName)
                {
                    from.SendMessage("That is not an acceptable surname.");
                    return;
                }

                if (hasSurname)
                {
                    from.SendMessage("You already have a surname and may not register another.");
                    return;
                }

                if (surnames.Contains(desiredSurname))
                {
                    DetermineOrigin(desiredSurname);
                    InstantiateRequest(desiredSurname, caller as PlayerMobile);
                }

                if (!String.IsNullOrEmpty(desiredSurname) && !surnames.Contains(desiredSurname) &&
                    !invalidName && !hasSurname)
                {
                    from.Name += " " + desiredSurname;

                    using (StreamWriter writer = new StreamWriter(surnameFile))
                    {
                        XmlTextWriter xml = new XmlTextWriter(writer);

                        xml.Formatting  = Formatting.Indented;
                        xml.IndentChar  = '\t';
                        xml.Indentation = 1;

                        xml.WriteStartDocument(true);
                        xml.WriteStartElement("surnames");

                        for (int n = 0; n < surnames.Count; n++)
                        {
                            xml.WriteStartElement("surname");
                            xml.WriteAttributeString("origin", origins[n].ToString());
                            xml.WriteString(surnames[n]);
                            xml.WriteEndElement();
                        }

                        xml.WriteStartElement("surname");
                        xml.WriteAttributeString("origin", caller.Serial.ToString());
                        xml.WriteString(desiredSurname);
                        xml.WriteEndElement();

                        xml.WriteEndElement();
                        xml.WriteEndDocument();
                        xml.Close();
                    }
                }
            }
        }
Example #27
0
        public static void OpenChatWindowRequest(NetState state, PacketReader pvSrc)
        {
            Mobile from = state.Mobile;

            if (!m_Enabled)
            {
                from.SendMessage("The chat system has been disabled.");
                return;
            }

            pvSrc.Seek(2, System.IO.SeekOrigin.Begin);
            string chatName = pvSrc.ReadUnicodeStringSafe((0x40 - 2) >> 1).Trim();

            Account acct = state.Account as Account;

            string accountChatName = null;

            if (acct != null)
            {
                accountChatName = acct.GetTag("ChatName");
            }

            if (accountChatName != null)
            {
                accountChatName = accountChatName.Trim();
            }

            if (accountChatName != null && accountChatName.Length > 0)
            {
                if (chatName.Length > 0 && chatName != accountChatName)
                {
                    from.SendMessage("You cannot change chat nickname once it has been set.");
                }
            }
            else
            {
                if (chatName == null || chatName.Length == 0)
                {
                    SendCommandTo(from, ChatCommand.AskNewNickname);
                    return;
                }

                if (NameVerification.Validate(chatName, 2, 31, true, true, true, 0, NameVerification.SpaceDashPeriodQuote) && chatName.ToLower().IndexOf("system") == -1)
                {
                    // TODO: Optimize this search

                    foreach (Account checkAccount in Accounts.Table.Values)
                    {
                        string existingName = checkAccount.GetTag("ChatName");

                        if (existingName != null)
                        {
                            existingName = existingName.Trim();

                            if (Insensitive.Equals(existingName, chatName))
                            {
                                from.SendMessage("Nickname already in use.");
                                SendCommandTo(from, ChatCommand.AskNewNickname);
                                return;
                            }
                        }
                    }

                    accountChatName = chatName;

                    if (acct != null)
                    {
                        acct.AddTag("ChatName", chatName);
                    }
                }
                else
                {
                    from.SendAsciiMessage("That name is disallowed.");
                    SendCommandTo(from, ChatCommand.AskNewNickname);
                    return;
                }
            }

            SendCommandTo(from, ChatCommand.OpenChatWindow, accountChatName);
            ChatUser.AddChatUser(from);
        }
            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 embroider numbers, letters, apostrophes and hyphens.");
                }
                else if (m_clothing.Name != null)
                {
                    // Already embroidered
                    from.SendMessage("This piece has already been embroidered.");
                }
                else if (text.Length > 24)
                {
                    // Invalid length
                    from.SendMessage("You may only embroider 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 embroider it with this.");
                }
                else if (Utility.RandomDouble() < ((100 - ((from.Skills[SkillName.Tailoring].Base + from.Skills[SkillName.Inscribe].Base) / 2)) * 2) / 100)
                {
                    // Failed!!
                    from.SendMessage("You fail to embroider the piece, ruining it in the process!");
                    m_clothing.Delete();
                }
                else
                {
                    // Make the change
                    m_clothing.Name = text + "\n\n";
                    from.SendMessage("You successfully embroider the clothing.");

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

                    // Check for 0 charges and delete if has none left
                    if (m_embroidery.UsesRemaining == 0)
                    {
                        m_embroidery.Delete();
                        from.SendMessage("You have used up your embroidery!");
                    }

                    // Consume single charge from scribe pen...

                    Item[] skits = ((Container)from.Backpack).FindItemsByType(typeof(SewingKit), true);

                    if (--((SewingKit)skits[0]).UsesRemaining == 0)
                    {
                        from.SendMessage("You have worn out your tool!");
                        skits[0].Delete();
                    }

                    // we want to hide the [Exceptional] attribute
                    m_clothing.HideAttributes = true;
                }
            }
Example #29
0
        protected virtual void ApplyName(Mobile m, TEntity t, string name)
        {
            if (m == null || t == null)
            {
                return;
            }

            if (String.IsNullOrWhiteSpace(name))
            {
                m.SendMessage(0x22, "You cannot use a blank name.");
                OpenGump(m, t);
                return;
            }

            name = Utility.FixHtml(name.Trim());

            if (!NameVerification.Validate(name, 2, 20, true, t is Item, true, 1, NameVerification.SpaceDashPeriodQuote))
            {
                m.SendMessage(0x22, "That name is unacceptable.");
                OpenGump(m, t);
                return;
            }

            var item = t as Item;

            if (item != null)
            {
                if (item.Name == name)
                {
                    m.SendMessage(0x22, "The item is already named {0}.", name);
                    OpenGump(m, t);
                    return;
                }

                item.Name = name;

                m.SendMessage(0x55, "The item has been renamed.");
                Delete();
                return;
            }

            var mob = t as Mobile;

            if (mob != null)
            {
                if (mob.RawName == name)
                {
                    m.SendMessage(0x22, "{0} are already named {1}.", mob == m ? "You" : "They", name);
                    OpenGump(m, t);
                    return;
                }

                mob.RawName = name;

                m.SendMessage(0x55, "{0} name has been changed.", mob == m ? "Your" : "Their");
                Delete();

                if (mob is PlayerMobile)
                {
                    var pm = (PlayerMobile)mob;

                    PlayerNames.Register(pm);
                    PlayerNames.ValidateSharedName(pm);
                }

                return;
            }

            m.SendMessage(0x22, "Could not rename that object.");
        }
Example #30
0
        public virtual bool CanMessage(PlayerMobile user, string text, bool message = true)
        {
            if (!Available)
            {
                if (message)
                {
                    InternalMessage(user, "The channel '{0}' is currently unavailable.", Name);
                }

                return(false);
            }

            if (!IsUser(user) && user.AccessLevel < AccessLevel.Counselor)
            {
                if (message)
                {
                    InternalMessage(user, "You are not in the channel '{0}'", Name);
                }

                return(false);
            }

            if (user.AccessLevel < Access)
            {
                if (message)
                {
                    InternalMessage(user, "You do not have sufficient access to speak in the channel '{0}'", Name);
                }

                return(false);
            }

            if (IsUser(user) && user.AccessLevel < AccessLevel.Counselor && Users[user] > DateTime.Now)
            {
                if (message)
                {
                    InternalMessage(user, "Spam detected, message blocked.");
                }

                return(false);
            }

            if (!NameVerification.Validate(
                    text,
                    0,
                    Int32.MaxValue,
                    true,
                    true,
                    false,
                    Int32.MaxValue,
                    ProfanityProtection.Exceptions,
                    ProfanityProtection.Disallowed,
                    ProfanityProtection.StartDisallowed))
            {
                switch (ProfanityAction)
                {
                case ProfanityAction.None:
                    return(true);

                case ProfanityAction.Criminal:
                    user.Criminal = true;
                    return(true);

                case ProfanityAction.CriminalAction:
                    user.CriminalAction(true);
                    return(true);

                case ProfanityAction.Disallow:
                    return(false);

                case ProfanityAction.Disconnect:
                    Kick(user, false, message);
                    return(false);

                case ProfanityAction.Other:
                    return(OnProfanityDetected(user, text, message));
                }
            }

            return(true);
        }