Esempio n. 1
0
 protected virtual void OnCommand(PvPBattleCommandState state)
 {
 }
Esempio n. 2
0
		protected virtual void OnCommand(PvPBattleCommandState state)
		{ }
Esempio n. 3
0
        public bool HandleSubCommand(PlayerMobile pm, string speech)
        {
            if (pm == null || pm.Deleted || String.IsNullOrWhiteSpace(speech))
            {
                return(false);
            }

            speech = speech.Trim();

            if (!speech.StartsWith(SubCommandPrefix.ToString(CultureInfo.InvariantCulture)))
            {
                return(false);
            }

            var command = String.Empty;
            var args    = new string[0];

            speech = speech.TrimStart(SubCommandPrefix);

            var split = speech.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);

            if (split.Length > 0)
            {
                command = split[0];
                args    = new string[split.Length - 1];

                for (var i = 0; i < args.Length; i++)
                {
                    args[i] = split[i + 1];
                }
            }

            if (!IsCommand(command))
            {
                pm.SendMessage("Command not found.");
                return(true);
            }

            var info = SubCommandHandlers[command];

            if (pm.AccessLevel < info.Access)
            {
                pm.SendMessage("You do not have access to that command.");
                return(true);
            }

            if (args.Length > 0 && (args[0] == "?" || Insensitive.Equals(args[0], "help")))
            {
                pm.SendMessage("Usage: {0}{1} {2}", SubCommandPrefix, info.Command, info.Usage);
                pm.SendMessage(info.Description);
                return(true);
            }

            var state = new PvPBattleCommandState(this, pm, command, args);

            if (info.Handler.Invoke(state))
            {
                OnCommand(state);
                return(true);
            }

            pm.SendMessage("Usage: {0}{1} {2}", SubCommandPrefix, info.Command, info.Usage);
            pm.SendMessage(info.Description);
            return(true);
        }
Esempio n. 4
0
		public bool HandleSubCommand(PlayerMobile pm, string speech)
		{
			if (pm == null || pm.Deleted || String.IsNullOrWhiteSpace(speech))
			{
				return false;
			}

			speech = speech.Trim();

			if (!speech.StartsWith(SubCommandPrefix.ToString(CultureInfo.InvariantCulture)))
			{
				return false;
			}

			string command = String.Empty;
			var args = new string[0];

			speech = speech.TrimStart(SubCommandPrefix);

			var split = speech.Split(new[] {' '}, StringSplitOptions.RemoveEmptyEntries);

			if (split.Length > 0)
			{
				command = split[0];
				args = new string[split.Length - 1];

				for (int i = 0; i < args.Length; i++)
				{
					args[i] = split[i + 1];
				}
			}

			if (!IsCommand(command))
			{
				pm.SendMessage("Command not found.");
				return true;
			}

			PvPBattleCommandInfo info = SubCommandHandlers[command];

			if (pm.AccessLevel < info.Access)
			{
				pm.SendMessage("You do not have access to that command.");
				return true;
			}

			if (args.Length > 0 && (args[0] == "?" || Insensitive.Equals(args[0], "help")))
			{
				pm.SendMessage("Usage: {0}{1} {2}", SubCommandPrefix, info.Command, info.Usage);
				pm.SendMessage(info.Description);
				return true;
			}

			PvPBattleCommandState state = new PvPBattleCommandState(this, pm, command, args);

			if (info.Handler.Invoke(state))
			{
				OnCommand(state);
				return true;
			}

			pm.SendMessage("Usage: {0}{1} {2}", SubCommandPrefix, info.Command, info.Usage);
			pm.SendMessage(info.Description);
			return true;
		}