Example #1
0
        /// <summary>
        /// Clone this match, but advance the clone to the end of input and give it an additional property.
        /// </summary>
        /// <param name="ArgumentName"></param>
        /// <param name="Value"></param>
        /// <returns></returns>
        public PossibleMatch EndWith(String ArgumentName, Object Value)
        {
            var r = new PossibleMatch(this, null, ParseDepth + 1);

            r.Upsert(ArgumentName, Value);
            return(r);
        }
Example #2
0
        override protected List <PossibleMatch> ImplementMatch(PossibleMatch State, MatchContext Context)
        {
            var r = new List <PossibleMatch>();

            if (State.Next == null)
            {
                return(r);
            }

            var word = State.Next.Value.ToUpper();

            if (word == "ON")
            {
                r.Add(State.AdvanceWith(ArgumentName, RelativeLocations.ON));
            }
            else if (word == "IN")
            {
                r.Add(State.AdvanceWith(ArgumentName, RelativeLocations.IN));
            }
            else if (word == "UNDER")
            {
                r.Add(State.AdvanceWith(ArgumentName, RelativeLocations.UNDER));
            }
            else if (word == "BEHIND")
            {
                r.Add(State.AdvanceWith(ArgumentName, RelativeLocations.BEHIND));
            }
            return(r);
        }
Example #3
0
        public List <PossibleMatch> Match(PossibleMatch State, MatchContext Context)
        {
            var r = new List <PossibleMatch>();

            if (State.Next == null)
            {
                return(r);
            }

            var word = State.Next.Value.ToUpper();

            if (word == "ON")
            {
                r.Add(State.AdvanceWith(ArgumentName, RelativeLocations.On));
            }
            else if (word == "IN")
            {
                r.Add(State.AdvanceWith(ArgumentName, RelativeLocations.In));
            }
            else if (word == "UNDER")
            {
                r.Add(State.AdvanceWith(ArgumentName, RelativeLocations.Under));
            }
            else if (word == "BEHIND")
            {
                r.Add(State.AdvanceWith(ArgumentName, RelativeLocations.Behind));
            }
            return(r);
        }
Example #4
0
        /// <summary>
        /// Clone this match, but give the clone an additional argument.
        /// </summary>
        /// <param name="ArgumentName"></param>
        /// <param name="Value"></param>
        /// <returns></returns>
        public PossibleMatch With(String ArgumentName, Object Value)
        {
            var r = new PossibleMatch(this, Next);

            r.Upsert(ArgumentName, Value);
            return(r);
        }
Example #5
0
 public List<PossibleMatch> Match(PossibleMatch State, MatchContext Context)
 {
     var R = new List<PossibleMatch>();
     R.AddRange(Sub.Match(State, Context));
     if (R.Count == 0) throw new CommandParser.MatchAborted(Message);
     return R;
 }
Example #6
0
 public List<PossibleMatch> Match(PossibleMatch State, MatchContext Context)
 {
     var R = new List<PossibleMatch>();
     R.AddRange(Sub.Match(State, Context));
     if (R.Count == 0) R.Add(State);
     return R;
 }
        public List<PossibleMatch> Match(PossibleMatch State, CommandParser.MatchContext Context)
        {
            var Matches = new List<PossibleMatch>();
            foreach (var Matcher in Matchers)
				Matches.AddRange(Matcher.Match(State, Context));
            return Matches;
        }
		public List<PossibleMatch> Match(PossibleMatch State, CommandParser.MatchContext Context)
		{
			var R = new List<PossibleMatch>();
			if (State.Next == null) return R;

			if ((Settings & ObjectMatcherSettings.UnderstandMe) == ObjectMatcherSettings.UnderstandMe)
			{
				if (State.Next.Value.ToUpper() == "ME")
				{
					var possibleMatch = new PossibleMatch(State.Arguments, State.Next.Next);
					possibleMatch.Arguments.Upsert(CaptureName, Context.ExecutingActor);
					R.Add(possibleMatch);
				}
			}

			foreach (var thing in ObjectSource.GetObjects(State, Context))
			{
				var possibleMatch = new PossibleMatch(State.Arguments, State.Next);
				bool matched = false;
				while (possibleMatch.Next != null && thing.Nouns.Contains(possibleMatch.Next.Value.ToUpper()))
				{
					matched = true;
					possibleMatch.Next = possibleMatch.Next.Next;
				}

				if (matched)
				{
					possibleMatch.Arguments.Upsert(CaptureName, thing);
					R.Add(possibleMatch);
				}
			}
			return R;
		}
Example #9
0
 public List<PossibleMatch> Match(PossibleMatch State, MatchContext Context)
 {
     var r = new List<PossibleMatch>();
     if (State.Next != null)
         r.Add(State.AdvanceWith(ArgumentName, State.Next.Value));
     return r;
 }
        public List<PossibleMatch> Match(PossibleMatch State, CommandParser.MatchContext Context)
        {
            var R = new List<PossibleMatch>();
			if (Context.ExecutingActor.Rank >= RequiredRank)
				R.Add(State);
			return R;
        }
Example #11
0
        /// <summary>
        /// Clone this match, but advance the clone to the next token and give it an additional property.
        /// </summary>
        /// <param name="ArgumentName"></param>
        /// <param name="Value"></param>
        /// <returns></returns>
        public PossibleMatch AdvanceWith(String ArgumentName, Object Value)
        {
            var r = new PossibleMatch(this, Next.Next, ParseDepth + 1);

            r.Upsert(ArgumentName, Value);
            return(r);
        }
        public List<PossibleMatch> Match(PossibleMatch State, CommandParser.MatchContext Context)
        {
            var R = new List<PossibleMatch>();
			if (Filter(State, Context))
				R.Add(State);
			return R;
        }
Example #13
0
 public List<PossibleMatch> Match(PossibleMatch State, MatchContext Context)
 {
     if (Test(State, Context)) throw new CommandParser.MatchAborted(Message);
     var r = new List<PossibleMatch>();
     r.Add(State);
     return r;
 }
Example #14
0
 public List<PossibleMatch> Match(PossibleMatch State, MatchContext Context)
 {
     var R = new List<PossibleMatch>();
     if (Context.ExecutingActor.Rank >= RequiredRank)
         R.Add(State);
     //else
     //    throw new CommandParser.MatchAborted("You do not have sufficient rank to use that command.");
     return R;
 }
        public List<PossibleMatch> Match(PossibleMatch State, CommandParser.MatchContext Context)
        {
            var R = new List<PossibleMatch>();
			if (State.Next != null && State.Next.Value.ToUpper() == Word)
				R.Add(new PossibleMatch(State.Arguments, State.Next.Next));
            if (Optional)
                R.Add(new PossibleMatch(State.Arguments, State.Next));
            return R;
        }
Example #16
0
 public List<PossibleMatch> Match(PossibleMatch State, MatchContext Context)
 {
     var R = new List<PossibleMatch>();
     if (State.Next != null && State.Next.Value.ToUpper() == Word)
         R.Add(State.Advance());
     else if (Optional) //Greedy match
         R.Add(State);
     return R;
 }
Example #17
0
        override protected List <PossibleMatch> ImplementMatch(PossibleMatch State, MatchContext Context)
        {
            var r = new List <PossibleMatch>();

            if (State.Next != null)
            {
                r.Add(State.AdvanceWith(ArgumentName, State.Next.Value));
            }
            return(r);
        }
Example #18
0
        public List <PossibleMatch> Match(PossibleMatch State, CommandParser.MatchContext Context)
        {
            var R = new List <PossibleMatch>();

            if (Filter(State, Context))
            {
                R.Add(State);
            }
            return(R);
        }
        public List <PossibleMatch> Match(PossibleMatch State, CommandParser.MatchContext Context)
        {
            var R = new List <PossibleMatch>();

            if (Context.ExecutingActor.Rank >= RequiredRank)
            {
                R.Add(State);
            }
            return(R);
        }
Example #20
0
 private IEnumerable <RuleSet> EnumerateMatchRules(PossibleMatch Match)
 {
     foreach (var arg in Match)
     {
         if (arg.Value is MudObject && (arg.Value as MudObject).Rules != null)
         {
             yield return((arg.Value as MudObject).Rules);
         }
     }
 }
Example #21
0
        public List<PossibleMatch> Match(PossibleMatch State, MatchContext Context)
        {
            var r = new List<PossibleMatch>();
            if (State.Next == null) return r;

            if (Link.IsCardinal(State.Next.Value.ToUpper()))
                r.Add(State.AdvanceWith(ArgumentName, Link.ToCardinal(State.Next.Value.ToUpper())));

            return r;
        }
Example #22
0
        override protected List <PossibleMatch> ImplementMatch(PossibleMatch State, MatchContext Context)
        {
            var Matches = new List <PossibleMatch>();

            foreach (var Matcher in Matchers)
            {
                Matches.AddRange(Matcher.Match(State, Context));
            }
            return(Matches);
        }
Example #23
0
        public List <PossibleMatch> Match(PossibleMatch State, MatchContext Context)
        {
            var Matches = new List <PossibleMatch>();

            foreach (var Matcher in Matchers)
            {
                Matches.AddRange(Matcher.Match(State, Context));
            }
            return(Matches);
        }
Example #24
0
        private static MatchPreference GetScore(PossibleMatch Match, String ScoreArgumentName)
        {
            if (Match.ContainsKey(ScoreArgumentName + "-SCORE"))
            {
                var argScore = Match[ScoreArgumentName + "-SCORE"] as MatchPreference?;
                if (argScore.HasValue) return argScore.Value;
            }

            return MatchPreference.Plausible; //If there is no score, the match is neutral.
        }
Example #25
0
        public List <PossibleMatch> Match(PossibleMatch State, MatchContext Context)
        {
            var r = new List <PossibleMatch>();

            if (State.Next != null)
            {
                r.Add(State.AdvanceWith(ArgumentName, State.Next.Value));
            }
            return(r);
        }
Example #26
0
 public List<PossibleMatch> Match(PossibleMatch State, MatchContext Context)
 {
     var Matches = new List<PossibleMatch>();
     foreach (var Matcher in Matchers)
     {
         Matches.AddRange(Matcher.Match(State, Context));
         if (Matches.Count > 0) return Matches;
     }
     return Matches;
 }
Example #27
0
        public MatchedCommand ParseCommand(PendingCommand Command)
        {
            var tokens = new LinkedList<String>(Command.RawCommand.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries));

            var rootMatch = new PossibleMatch(tokens.First);
            rootMatch.Upsert("ACTOR", Command.Actor);
            rootMatch.Upsert("LOCATION", Command.Actor == null ? null : Command.Actor.Location);

            // A pending command can have some properties set when it is queued. For example, the 'go' action
            // generates a 'look' command after processing. It will give the 'look' command a property named
            // 'auto' to indicate that the look command was generated. Rules can then use this property to
            // implement behavior. From the same example, 'look' may emit a brief description if it is generated
            // by the 'go' action, but emit a more detailed description if the player enters the command 'look'.
            //      See StandardActions.Go
            if (Command.PreSettings != null)
                foreach (var setting in Command.PreSettings)
                    rootMatch.Upsert(setting.Key.ToUpper(), setting.Value);

            var matchContext = new MatchContext { ExecutingActor = Command.Actor };

            // Try every single command defined, until one matches.
            foreach (var command in Commands)
            {
                IEnumerable<PossibleMatch> matches;

                try
                {
                    matches = command.Matcher.Match(rootMatch, matchContext);
                }
                catch (MatchAborted ma)
                {
                    // The match didn't fail; it generated an error. These means the match progressed to a point
                    // where the author of the command felt that the input could not logically match any other
                    // command, however, the input was still malformed in some way. Abort matching, and dummy up
                    // a command entry to display the error message to the player.
                    return new MatchedCommand(
                        new CommandEntry().ProceduralRule((match, actor) =>
                        {
                            MudObject.SendMessage(actor, ma.Message);
                            return PerformResult.Continue;
                        }),
                        // We need a fake match just so it can be passed to the procedural rule.
                        new PossibleMatch[] { new PossibleMatch(null) });
                }

                // Only accept matches that consumed all of the input.
                matches = matches.Where(m => m.Next == null);

                // If we did consume all of the input, we will assume this match is successful. Note it is
                // possible for a command to generate multiple matches, but not possible to match multiple commands.
                if (matches.Count() > 0)
                    return new MatchedCommand(command, matches);
            }
            return null;
        }
Example #28
0
        public List <PossibleMatch> Match(PossibleMatch State, MatchContext Context)
        {
            var R = new List <PossibleMatch>();

            R.AddRange(Sub.Match(State, Context));
            if (R.Count == 0)
            {
                R.Add(State);
            }
            return(R);
        }
Example #29
0
        override protected List <PossibleMatch> ImplementMatch(PossibleMatch State, MatchContext Context)
        {
            var R = new List <PossibleMatch>();

            R.AddRange(Sub.Match(State, Context));
            if (R.Count == 0)
            {
                throw new CommandParser.MatchAborted(Message);
            }
            return(R);
        }
Example #30
0
 public List<PossibleMatch> Match(PossibleMatch State, MatchContext Context)
 {
     var r = Sub.Match(State, Context);
     var highestScoreFound = MatchPreference.VeryUnlikely;
     foreach (var match in r)
     {
         var score = GetScore(match, ScoreArgument );
         if (score > highestScoreFound) highestScoreFound = score;
     }
     return new List<PossibleMatch>(r.Where(m => highestScoreFound == GetScore(m, ScoreArgument)));
 }
Example #31
0
        override protected List <PossibleMatch> ImplementMatch(PossibleMatch State, MatchContext Context)
        {
            if (Test(State, Context))
            {
                throw new CommandParser.MatchAborted(Message);
            }
            var r = new List <PossibleMatch>();

            r.Add(State);
            return(r);
        }
Example #32
0
        public List <PossibleMatch> Match(PossibleMatch State, MatchContext Context)
        {
            if (Test(State, Context))
            {
                throw new CommandParser.MatchAborted(Message);
            }
            var r = new List <PossibleMatch>();

            r.Add(State);
            return(r);
        }
        public List<PossibleMatch> Match(PossibleMatch State, CommandParser.MatchContext Context)
        {
            var R = new List<PossibleMatch>();
			if (State.Next != null)
			{
				var possibleMatch = new PossibleMatch(State.Arguments, null);
				possibleMatch.Arguments.Upsert(ArgumentName, State.Next);
				R.Add(possibleMatch);
			}
			return R;
        }
Example #34
0
        public List<PossibleMatch> Match(PossibleMatch State, MatchContext Context)
        {
            var r = new List<PossibleMatch>();
            if (State.Next == null) return r;

            int value = 0;
            if (Int32.TryParse(State.Next.Value, out value))
                r.Add(State.AdvanceWith(ArgumentName, value));

            return r;
        }
Example #35
0
 public static void ProcessPlayerCommand(CommandEntry Command, PossibleMatch Match, Actor Actor)
 {
     ExecutingCommand = Match;
     try
     {
         ExecuteCommand(Command, Match, Actor);
     }
     finally
     {
         ExecutingCommand = null;
     }
 }
Example #36
0
        public List <PossibleMatch> Match(PossibleMatch State, MatchContext Context)
        {
            var R = new List <PossibleMatch>();

            if (Context.ExecutingActor.Rank >= RequiredRank)
            {
                R.Add(State);
            }
            //else
            //    throw new CommandParser.MatchAborted("You do not have sufficient rank to use that command.");
            return(R);
        }
Example #37
0
        override protected List <PossibleMatch> ImplementMatch(PossibleMatch State, MatchContext Context)
        {
            var R = new List <PossibleMatch>();

            if (Context.ExecutingActor.GetProperty <int>("rank") >= RequiredRank)
            {
                R.Add(State);
            }
            //else
            //    throw new CommandParser.MatchAborted("You do not have sufficient rank to use that command.");
            return(R);
        }
Example #38
0
        public List <PossibleMatch> Match(PossibleMatch State, CommandParser.MatchContext Context)
        {
            var R = new List <PossibleMatch>();

            if (State.Next != null)
            {
                var match = new PossibleMatch(State.Arguments, State.Next.Next);
                match.Arguments.Upsert(ArgumentName, State.Next.Value);
                R.Add(match);
            }
            return(R);
        }
Example #39
0
 public static void ProcessPlayerCommand(CommandEntry Command, PossibleMatch Match, MudObject Actor)
 {
     ExecutingCommand = Match;
     try
     {
         ExecuteCommand(Command, Match, Actor);
     }
     finally
     {
         ExecutingCommand = null;
     }
 }
        public List<PossibleMatch> Match(PossibleMatch State, CommandParser.MatchContext Context)
        {
            var r = new List<PossibleMatch>();
			if (State.Next == null) return r;

			if (Link.IsCardinal(State.Next.Value.ToUpper()))
			{
				var match = new PossibleMatch(State.Arguments, State.Next.Next);
				match.Arguments.Upsert(ArgumentName, Link.ToCardinal(State.Next.Value.ToUpper()));
				r.Add(match);
			}
			return r;
        }
Example #41
0
        /// <summary>
        /// Actually carryout the command, following all of it's rules, including the before and after command rules.
        /// </summary>
        /// <param name="Command"></param>
        /// <param name="Match"></param>
        /// <param name="Actor"></param>
        /// <returns>The result of the command's procedural rules.</returns>
        private static PerformResult ExecuteCommand(CommandEntry Command, PossibleMatch Match, MudObject Actor)
        {
            var result = PerformResult.Stop;

            Match.Upsert("COMMAND", Command);
            if (GlobalRules.ConsiderMatchBasedPerformRule("before command", Match, Actor) == PerformResult.Continue)
            {
                result = Command.ProceduralRules.Consider(Match, Actor);
                GlobalRules.ConsiderMatchBasedPerformRule("after command", Match, Actor);
            }
            GlobalRules.ConsiderPerformRule("after every command", Actor);
            return(result);
        }
Example #42
0
        private static MatchPreference GetScore(PossibleMatch Match, String ScoreArgumentName)
        {
            if (Match.ContainsKey(ScoreArgumentName + "-SCORE"))
            {
                var argScore = Match[ScoreArgumentName + "-SCORE"] as MatchPreference?;
                if (argScore.HasValue)
                {
                    return(argScore.Value);
                }
            }

            return(MatchPreference.Plausible); //If there is no score, the match is neutral.
        }
Example #43
0
        public List <PossibleMatch> Match(PossibleMatch State, CommandParser.MatchContext Context)
        {
            var R = new List <PossibleMatch>();

            if (State.Next != null && State.Next.Value.ToUpper() == Word)
            {
                R.Add(new PossibleMatch(State.Arguments, State.Next.Next));
            }
            if (Optional)
            {
                R.Add(new PossibleMatch(State.Arguments, State.Next));
            }
            return(R);
        }
Example #44
0
 /// <summary>
 /// Try to execute a command immediately. This does not bypass the before and after command rules. This is intended
 /// to be used by rules to implement implicit actions. For example, the 'go' command will attempt to open closed
 /// doors by calling
 ///     Core.Try("StandardActions:Open", Core.ExecutingCommand.With("SUBJECT", link), actor);
 /// </summary>
 /// <param name="CommandID">The ID of the command to try, assigned when the command is created.</param>
 /// <param name="Match"></param>
 /// <param name="Actor"></param>
 /// <returns>The result of the command's proceedural rules.</returns>
 public static PerformResult Try(String CommandID, PossibleMatch Match, Actor Actor)
 {
     var parentCommand = ExecutingCommand;
     try
     {
         var command = Core.DefaultParser.FindCommandWithID(CommandID);
         if (command == null) return PerformResult.Stop;
         return ExecuteCommand(command, Match, Actor);
     }
     finally
     {
         ExecutingCommand = parentCommand;
     }
 }
Example #45
0
 public List<PossibleMatch> Match(PossibleMatch State, MatchContext Context)
 {
     var Matches = new List<PossibleMatch>();
     Matches.Add(State);
     foreach (var Matcher in Matchers)
     {
         var NextMatches = new List<PossibleMatch>();
         foreach (var Match in Matches)
             NextMatches.AddRange(Matcher.Match(Match, Context));
         Matches = NextMatches;
         if (Matches.Count == 0) return Matches; //Shortcircuit for when no matches are found.
     }
     return Matches;
 }
Example #46
0
        override protected List <PossibleMatch> ImplementMatch(PossibleMatch State, MatchContext Context)
        {
            var R = new List <PossibleMatch>();

            if (State.Next != null && State.Next.Value.ToUpper() == Word)
            {
                R.Add(State.Advance());
            }
            else if (Optional) //Greedy match
            {
                R.Add(State);
            }
            return(R);
        }
Example #47
0
        public List<MudObject> GetObjects(PossibleMatch State, MatchContext Context)
        {
            NPC source = null;
            if (!String.IsNullOrEmpty(LocutorArgument))
                source = State[LocutorArgument] as NPC;
            else if (Context.ExecutingActor.HasProperty<NPC>("interlocutor"))
                source = Context.ExecutingActor.GetProperty<NPC>("interlocutor");

            if (source != null)
                if (source.HasProperty<List<MudObject>>("conversation-topics"))
                    return new List<MudObject>(source.GetProperty<List<MudObject>>("conversation-topics").Where(t => Core.GlobalRules.ConsiderCheckRuleSilently("topic available?", Context.ExecutingActor, source, t) == CheckResult.Allow));

            return new List<MudObject>();
        }
Example #48
0
        public List <PossibleMatch> Match(PossibleMatch State, MatchContext Context)
        {
            var r = Sub.Match(State, Context);
            var highestScoreFound = MatchPreference.VeryUnlikely;

            foreach (var match in r)
            {
                var score = GetScore(match, ScoreArgument);
                if (score > highestScoreFound)
                {
                    highestScoreFound = score;
                }
            }
            return(new List <PossibleMatch>(r.Where(m => highestScoreFound == GetScore(m, ScoreArgument))));
        }
        internal MatchedCommand ParseCommand(String Command, Actor Actor)
        {
			var tokens = new LinkedList<String>(Command.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries));
			var rootMatch = new PossibleMatch(tokens.First);

			//Find all objects in scope
			var matchContext = new MatchContext { ExecutingActor = Actor };

			foreach (var command in Commands)
			{
				var matches = command.Matcher.Match(rootMatch, matchContext);
				var firstGoodMatch = matches.Find(m => m.Next == null);
				if (firstGoodMatch != null) return new MatchedCommand(command, firstGoodMatch);
			}
            return null;
        }
        public List<PossibleMatch> Match(PossibleMatch State, MatchContext Context)
        {
            var r = new List<PossibleMatch>();
            if (State.Next == null) return r;

            var word = State.Next.Value.ToUpper();
            if (word == "ON")
                r.Add(State.AdvanceWith(ArgumentName, RelativeLocations.On));
            else  if (word == "IN")
                r.Add(State.AdvanceWith(ArgumentName, RelativeLocations.In));
            else if (word == "UNDER")
                r.Add(State.AdvanceWith(ArgumentName, RelativeLocations.Under));
            else if (word == "BEHIND")
                r.Add(State.AdvanceWith(ArgumentName, RelativeLocations.Behind));
            return r;
        }
Example #51
0
        public List <PossibleMatch> Match(PossibleMatch State, MatchContext Context)
        {
            var r = new List <PossibleMatch>();

            if (State.Next == null)
            {
                return(r);
            }

            if (Link.IsCardinal(State.Next.Value.ToUpper()))
            {
                r.Add(State.AdvanceWith(ArgumentName, Link.ToCardinal(State.Next.Value.ToUpper())));
            }

            return(r);
        }
        public List <PossibleMatch> Match(PossibleMatch State, CommandParser.MatchContext Context)
        {
            var r = new List <PossibleMatch>();

            if (State.Next == null)
            {
                return(r);
            }

            if (Link.IsCardinal(State.Next.Value.ToUpper()))
            {
                var match = new PossibleMatch(State.Arguments, State.Next.Next);
                match.Arguments.Upsert(ArgumentName, Link.ToCardinal(State.Next.Value.ToUpper()));
                r.Add(match);
            }
            return(r);
        }
Example #53
0
        public void ParseStage(PossibleMatch Match, String Description)
        {
            if (CurrentParseCommand.IsNamed("LOOK"))
            {
                var x = 5;
            }
            if (BestFailedMatch == null || Match.ParseDepth >= BestFailedMatch.ParseDepth)
            {
                if (!String.IsNullOrEmpty(Description) || !Object.ReferenceEquals(CurrentParseCommand, BestFailedCommand))
                {
                    BestFailedParseStageDescription = Description;
                }

                BestFailedCommand = CurrentParseCommand;
                BestFailedMatch   = Match;
            }
        }
Example #54
0
        /// <summary>
        /// Try to execute a command immediately. This does not bypass the before and after command rules. This is intended
        /// to be used by rules to implement implicit actions. For example, the 'go' command will attempt to open closed
        /// doors by calling
        ///     Core.Try("StandardActions:Open", Core.ExecutingCommand.With("SUBJECT", link), actor);
        /// </summary>
        /// <param name="CommandID">The ID of the command to try, assigned when the command is created.</param>
        /// <param name="Match"></param>
        /// <param name="Actor"></param>
        /// <returns>The result of the command's proceedural rules.</returns>
        public static PerformResult Try(String CommandID, PossibleMatch Match, MudObject Actor)
        {
            var parentCommand = ExecutingCommand;

            try
            {
                var command = Core.DefaultParser.FindCommandWithID(CommandID);
                if (command == null)
                {
                    return(PerformResult.Stop);
                }
                return(ExecuteCommand(command, Match, Actor));
            }
            finally
            {
                ExecutingCommand = parentCommand;
            }
        }
Example #55
0
        override protected List <PossibleMatch> ImplementMatch(PossibleMatch State, MatchContext Context)
        {
            var r = new List <PossibleMatch>();

            if (State.Next == null)
            {
                return(r);
            }

            int value = 0;

            if (Int32.TryParse(State.Next.Value, out value))
            {
                r.Add(State.AdvanceWith(ArgumentName, value));
            }

            return(r);
        }
Example #56
0
        public List<PossibleMatch> Match(PossibleMatch State, MatchContext Context)
        {
            var r = new List<PossibleMatch>();

            if (State.Next != null)
            {
                var builder = new StringBuilder();
                var node = State.Next;
                for (; node != null; node = node.Next)
                {
                    builder.Append(node.Value);
                    builder.Append(" ");
                }

                builder.Remove(builder.Length - 1, 1);
                r.Add(State.EndWith(ArgumentName, builder.ToString()));
            }

            return r;
        }
Example #57
0
 public List<MudObject> GetObjects(PossibleMatch State, MatchContext Context)
 {
     return new List<MudObject>(Context.ObjectsInScope);
 }
Example #58
0
 public List<PossibleMatch> Match(PossibleMatch State, MatchContext Context)
 {
     return MatchFunc(State, Context);
 }
 public List<MudObject> GetObjects(PossibleMatch State, MatchContext Context)
 {
     return new List<MudObject>(ChatChannel.ChatChannels);
 }
			public MatchedCommand(CommandEntry Command, PossibleMatch Match)
			{
				this.Command = Command;
				this.Match = Match;
			}