Пример #1
0
        public static void AtStartup(RMUD.RuleEngine GlobalRules)
        {
            Core.StandardMessage("not useable", "I don't know what I would do with that.");

            GlobalRules.DeclareCheckRuleBook<MudObject, MudObject>("can use?", "[Actor, Item] : Can the actor use the item?", "actor", "item");

            GlobalRules.DeclarePerformRuleBook<MudObject, MudObject>("used", "[Actor, Item] : Handle the actor using the item.", "actor", "item");

            GlobalRules.Check<MudObject, MudObject>("can use?")
                .When((actor, item) => !item.GetBooleanProperty("useable?"))
                .Do((a, b) =>
                {
                    MudObject.SendMessage(a, "@not useable");
                    return SharpRuleEngine.CheckResult.Disallow;
                })
                .Name("Can't use the unuseable rule.");

            GlobalRules.Check<MudObject, MudObject>("can use?")
                .Do((a, b) => SharpRuleEngine.CheckResult.Allow)
                .Name("Default go ahead and use it rule.");

            GlobalRules.Perform<MudObject, MudObject>("used").Do((actor, target) =>
            {
                MudObject.SendMessage(actor, "It doesn't do anything.");
                return SharpRuleEngine.PerformResult.Continue;
            }).Name("Default report using rule.");

            GlobalRules.Check<MudObject, MudObject>("can use?").First.Do((actor, item) => MudObject.CheckIsVisibleTo(actor, item)).Name("Item must be visible rule.");
        }
Пример #2
0
        public static void AtStartup(RMUD.RuleEngine GlobalRules)
        {
            // Heavy things can be picked up, but not carried around.

            Core.StandardMessage("cant carry heavy thing", "^<the0> is too heavy to carry around.");

            GlobalRules.Check<MudObject, MudObject>("can go?")
                .When((actor, link) => HasHeavyThing(actor))
                .Do((actor, link) =>
                {
                    MudObject.SendMessage(actor, "@cant carry heavy thing", FirstHeavyThing(actor));
                    return CheckResult.Disallow;
                })
                .Name("Can't carry around heavy things rule.");

            GlobalRules.Check<MudObject, MudObject, MudObject>("can push direction?")
                .When((actor, subject, link) => HasHeavyThing(actor))
                .Do((actor, subject, link) =>
                {
                    MudObject.SendMessage(actor, "@cant carry heavy thing", FirstHeavyThing(actor));
                    return CheckResult.Disallow;
                })
                .Name("Can't carry around heavy things while pushing rule.");
        }