/// <summary> /// Add a proceedural rule to this command that considers the specified perform rule. Unlike Perform above, /// if the perform rule returns stop, the proceedural rules will also be stopped. /// </summary> /// <param name="RuleName"></param> /// <param name="RuleArguments"></param> /// <returns>This command</returns> public CommandEntry AbideBy(String RuleName, params String[] RuleArguments) { GeneratedManual.AppendLine("Consider the perform rulebook '" + RuleName + "' with arguments " + String.Join(", ", RuleArguments) + " and abide by the result."); var rule = new Rule<PerformResult> { BodyClause = RuleDelegateWrapper<PerformResult>.MakeWrapper<PossibleMatch, Actor>( (match, actor) => Core.GlobalRules.ConsiderPerformRule(RuleName, RuleArguments.Select(a => match.ValueOrDefault(a)).ToArray()) ), DescriptiveName = "Procedural rule to abide by " + RuleName }; ProceduralRules.AddRule(rule); return this; }
/// <summary> /// Add a procedural rule to this command. /// </summary> /// <param name="Rule"></param> /// <param name="Name"></param> /// <returns>This command</returns> public CommandEntry ProceduralRule(Func<PossibleMatch, Actor, PerformResult> Rule, String Name = "an unamed procedural rule") { GeneratedManual.AppendLine("Consider " + Name); var rule = new Rule<PerformResult> { BodyClause = RuleDelegateWrapper<PerformResult>.MakeWrapper(Rule), DescriptiveName = Name }; ProceduralRules.AddRule(rule); return this; }
/// <summary> /// Add a procedural rule to this command that marks the locale of the actor that entered the command /// for update. /// </summary> /// <returns>This command</returns> public CommandEntry MarkLocaleForUpdate() { GeneratedManual.AppendLine("Consider the mark locale for update rule"); var rule = new Rule<PerformResult> { BodyClause = RuleDelegateWrapper<PerformResult>.MakeWrapper<PossibleMatch, Actor>( (match, actor) => { Core.MarkLocaleForUpdate(match["ACTOR"] as MudObject); return PerformResult.Continue; }), DescriptiveName = "Procedural rule to mark locale for update." }; ProceduralRules.AddRule(rule); return this; }
/// <summary> /// Add a new procedural rule to this command that invokes a check rule. If the checkrule fails, /// processing of the proceedural rules is stopped. /// </summary> /// <param name="RuleName"></param> /// <param name="RuleArguments"></param> /// <returns>This command</returns> public CommandEntry Check(String RuleName, params String[] RuleArguments) { GeneratedManual.AppendLine("Consider the check rulebook '" + RuleName + "' with arguments " + String.Join(", ", RuleArguments)); var rule = new Rule<PerformResult> { BodyClause = RuleDelegateWrapper<PerformResult>.MakeWrapper<PossibleMatch, Actor>( (match, actor) => { if (Core.GlobalRules.ConsiderCheckRule(RuleName, RuleArguments.Select(a => match.ValueOrDefault(a)).ToArray()) == CheckResult.Allow) return PerformResult.Continue; return PerformResult.Stop; }), DescriptiveName = "Procedural rule to check " + RuleName }; ProceduralRules.AddRule(rule); return this; }
public void AddRule(Rule Rule) { CheckRule(Rule); Rules.Add(Rule); NeedsSort = true; }
public virtual void CheckRule(Rule Rule) { throw new NotImplementedException(); }