Ejemplo n.º 1
0
		public static int GetMaxHouses( Account a )
		{
			int houses = Convert.ToInt32( a.GetTag( "maxHouses" ) );

			if ( houses < 1 )
			{
				houses = 1;
				a.SetTag( "maxHouses", "1" );
			}

			return houses;
		}
Ejemplo n.º 2
0
        public static void Command_Register(Server.Commands.CommandEventArgs e)
        {
            Mobile m = e.Mobile;

            if (AutoRestart.Restarting)
            {
                m.SendMessage("Validation requests expire during server wars. Please re-request after server restart.");
                return;
            }

            string key = e.ArgString;

            if (key == null || key == "")
            {
                m.SendMessage("You must enter a valid key.");
                return;
            }

            Account a = m.Account as Account;

            if (a == null)               // Sanity
            {
                return;
            }

            AuthKey ak = GetKey(a);

            if (ak == null)
            {
                m.SendMessage("You have no validations pending.");
                return;
            }
            else if (ak.Expired)
            {
                m.SendMessage("That validation key has expired.");
                return;
            }
            else if (ak.Key != key)
            {
                m.SendMessage("That validation key is incorrect.");
                return;
            }

            switch (ak.Type)
            {
            case AuthType.Register:
                string email = ak.State as string;
                a.SetTag("EMail", email);
                m.SendMessage("Your account has been registered.", email);
                break;

            case AuthType.EMail:
                a.RemoveTag("EMail");
                m.SendMessage("Your e-mail address has been reset.");
                m.SendMessage("You will be prompted to re-register on your next login.");
                break;

            case AuthType.Password:
                string pw = ak.State as string;
                a.SetPassword(pw);
                m.SendMessage("Your password has been changed.");
                break;

            default:
                m.SendMessage("ERROR: Invalid AuthType, please page an administrator for assistance.");
                break;
            }

            RemoveKey(a);
        }
        public static void OnCommand_Auth(CommandEventArgs e)
        {
            Mobile m = e.Mobile;

            if (m == null)
            {
                return;
            }

            if (e.ArgString == null || e.ArgString == "")
            {
                m.SendMessage("Usage: [auth <key>");
                return;
            }

            if (!_AuthList.ContainsKey(m.Serial))
            {
                m.SendMessage("You do not have any account requests that need authorization");
                return;
            }

            ChangeRequest req = _AuthList[m.Serial];

            bool Auth = req.Authenticate(e.ArgString);

            if (Auth)
            {
                switch (req.RequestType)
                {
                case RequestType.ChangeEmail:
                {
                    Account acc = (Account)m.Account;

                    if (acc != null)
                    {
                        acc.SetTag("EMAIL", req.RequestString);
                        m.SendMessage("Your registered email address has been changed.");
                    }

                    break;
                }

                case RequestType.Email:
                {
                    Account acc = (Account)m.Account;

                    if (acc != null)
                    {
                        acc.AddTag("EMAIL", req.RequestString);
                        m.SendMessage("Your email address has been registered with this account.");
                    }

                    break;
                }

                case RequestType.Password:
                {
                    Account acc = (Account)m.Account;

                    if (acc != null)
                    {
                        acc.SetPassword(req.RequestString);
                        m.SendMessage("Your account password has been changed.");
                    }

                    break;
                }
                }

                if (_Timers.ContainsKey(m.Serial))
                {
                    ChangeRequestTimer timer = _Timers[m.Serial];
                    timer.Stop();

                    _Timers.Remove(m.Serial);
                    _AuthList.Remove(m.Serial);
                }
            }
            else
            {
                m.SendMessage("That key was invalid");
            }
        }
		public static bool AddToSubscription( Account acc, TimeSpan duration )
		{
			DateTime DonationStart = DateTime.MinValue;
			TimeSpan DonationDuration = TimeSpan.Zero;

			try
			{
				DonationStart = DateTime.Parse( acc.GetTag( "DonationStart" ) );
				DonationDuration = TimeSpan.Parse( acc.GetTag( "DonationDuration" ) );
			}
			catch
			{
			}


			if (DonationStart == DateTime.MinValue && DonationDuration == TimeSpan.Zero)
			{
				try
				{
					acc.SetTag( "DonationStart", DateTime.Now.ToString() );
					acc.SetTag( "DonationDuration", duration.ToString() );
					//from.SendMessage("Your donation status has been updated.");
					//this.Delete();
					return true;
				}
				catch
				{
					//from.SendMessage("An error ocurred trying to update your donation status. Contact an Administrator.");
					return false;
				}
			}
			else if (DonationDuration == TimeSpan.MaxValue)
			{
				//already at max
				//from.SendMessage("You are already at permanent membership status.");
				return false;
			}
			else
			{
				//existing donation


				try
				{
					//Avoid overflow
					if (duration == TimeSpan.MaxValue)
						DonationDuration = duration;
					else
					{
						// Make sure that expired subscriptions don't cause people to get "negative time".
						if(DonationStart + DonationDuration < DateTime.Now)
							DonationDuration = (DateTime.Now - DonationStart) + duration;
						else
							DonationDuration += duration;
					}

					// Old stuff (next two lines) Should probably never be reintroduced - caleb
					//if ( DonationStart + DonationDuration < DateTime.Now + duration )
					//	DonationDuration = DateTime.Now + duration - DonationStart;

					acc.SetTag("DonationDuration", DonationDuration.ToString());
					//from.SendMessage("Your donation status has been updated.");
					//this.Delete();
					return true;
				}
				catch
				{
					//from.SendMessage("An error ocurred trying to update your donation status. Contact an Administrator.");
					return false;
				}
			}
		}
		public static void SetSubscriptionStatus( Account acc, DateTime started, TimeSpan duration )
		{
			acc.SetTag( "DonationStart", started.ToString() );
			acc.SetTag( "DonationDuration", duration.ToString() );
		}
        public static bool AddToSubscription(Account acc, TimeSpan duration)
        {
            DateTime DonationStart = DateTime.MinValue;
            TimeSpan DonationDuration = TimeSpan.Zero;

            try
            {
                DonationStart = DateTime.Parse(acc.GetTag("DonationStart"));
                DonationDuration = TimeSpan.Parse(acc.GetTag("DonationDuration"));
            }
            catch
            {
            }

            if (DonationStart == DateTime.MinValue && DonationDuration == TimeSpan.Zero)
            {
                try
                {
                    acc.SetTag("DonationStart", DateTime.Now.ToString());
                    acc.SetTag("DonationDuration", duration.ToString());
                    //from.SendMessage("Your donation status has been updated.");
                    //this.Delete();
                    return true;
                }
                catch
                {
                    //from.SendMessage("An error ocurred trying to update your donation status. Contact an Administrator.");
                    return false;
                }
            }
            else if (DonationDuration == TimeSpan.MaxValue)
            {
                //already at max
                //from.SendMessage("You are already at permanent membership status.");
                return false;
            }
            else
            {
                //existing donation

                try
                {
                    //Avoid overflow
                    if (duration == TimeSpan.MaxValue)
                        DonationDuration = duration;
                    else
                        DonationDuration += duration;

                    //if ( DonationStart + DonationDuration < DateTime.Now + duration )
                    //	DonationDuration = DateTime.Now + duration - DonationStart;

                    acc.SetTag("DonationDuration", DonationDuration.ToString());
                    //from.SendMessage("Your donation status has been updated.");
                    //this.Delete();
                    return true;
                }
                catch
                {
                    //from.SendMessage("An error ocurred trying to update your donation status. Contact an Administrator.");
                    return false;
                }
            }
        }