Beispiel #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);
        }
Beispiel #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);
        }
Beispiel #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);
        }
Beispiel #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);
        }
Beispiel #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;
 }
Beispiel #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;
		}
Beispiel #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;
        }
Beispiel #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;
        }
Beispiel #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;
 }
Beispiel #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;
        }
Beispiel #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;
 }
Beispiel #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);
        }
Beispiel #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);
        }
Beispiel #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);
         }
     }
 }
Beispiel #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;
        }
Beispiel #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);
        }
Beispiel #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);
        }
Beispiel #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.
        }
Beispiel #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);
        }
Beispiel #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;
 }
Beispiel #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;
        }
Beispiel #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);
        }
Beispiel #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);
        }
Beispiel #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)));
 }
Beispiel #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);
        }
Beispiel #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;
        }
Beispiel #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;
        }
Beispiel #35
0
 public static void ProcessPlayerCommand(CommandEntry Command, PossibleMatch Match, Actor Actor)
 {
     ExecutingCommand = Match;
     try
     {
         ExecuteCommand(Command, Match, Actor);
     }
     finally
     {
         ExecutingCommand = null;
     }
 }
Beispiel #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);
        }
Beispiel #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);
        }
Beispiel #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);
        }
Beispiel #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;
        }
Beispiel #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);
        }
Beispiel #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.
        }
Beispiel #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);
        }
Beispiel #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;
     }
 }
Beispiel #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;
 }
Beispiel #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);
        }
Beispiel #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>();
        }
Beispiel #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;
        }
Beispiel #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);
        }
Beispiel #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;
            }
        }
Beispiel #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;
            }
        }
Beispiel #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);
        }
Beispiel #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;
        }
Beispiel #57
0
 public List<MudObject> GetObjects(PossibleMatch State, MatchContext Context)
 {
     return new List<MudObject>(Context.ObjectsInScope);
 }
Beispiel #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;
			}