예제 #1
0
 public static void AtStartup(RuleEngine GlobalRules)
 {
     PropertyManifest.RegisterProperty("portal?", typeof(bool), false, new BoolSerializer());
     PropertyManifest.RegisterProperty("link destination", typeof(String), "", new StringSerializer());
     PropertyManifest.RegisterProperty("link direction", typeof(Direction), Direction.NOWHERE, new EnumSerializer <Direction>());
     PropertyManifest.RegisterProperty("link anonymous?", typeof(bool), false, new BoolSerializer());
 }
예제 #2
0
        public T GetProperty <T>(String Name)
        {
            T r;

            if (Properties.ContainsKey(Name))
            {
                r = (T)Properties[Name];
            }
            else
            {
                var info = PropertyManifest.GetPropertyInformation(Name);
                if (info == null)
                {
                    throw new InvalidOperationException("Property " + Name + " does not exist.");
                }
                r = (T)info.DefaultValue;
            }

            var payload = new PropertyPayload <T>
            {
                Name  = Name,
                Value = r
            };

            ConsiderPerformRule("modify property", this, payload);

            return(payload.Value);
        }
예제 #3
0
파일: Set.cs 프로젝트: Blecki/RMUDReboot
        public override void Create(CommandParser Parser)
        {
            Parser.AddCommand(
                Sequence(
                    RequiredRank(500),
                    KeyWord("!SET"),
                    MustMatch("I don't see that here.",
                              Object("OBJECT", InScope)),
                    SingleWord("PROPERTY"),
                    Rest("VALUE")))
            .Manual("Set the value of a property on an object.")
            .ProceduralRule((match, actor) =>
            {
                var _object       = match["OBJECT"] as MudObject;
                var property_name = match["PROPERTY"].ToString();
                var stringValue   = match["VALUE"].ToString();

                var propertyInfo = PropertyManifest.GetPropertyInformation(property_name);

                if (propertyInfo == null)
                {
                    Core.SendMessage(actor, "That property does not exist.");
                    return(PerformResult.Stop);
                }

                var realValue = propertyInfo.Converter.ConvertFromString(stringValue);

                _object.SetProperty(property_name, realValue);

                Core.SendMessage(actor, "Property set.");
                return(PerformResult.Continue);
            });
        }
예제 #4
0
 public void SetProperty(String Name, Object Value)
 {
     if (PropertyManifest.CheckPropertyType(Name, Value))
     {
         Properties.Upsert(Name, Value);
     }
     else
     {
         throw new InvalidOperationException("Setting property with object of wrong type.");
     }
 }
예제 #5
0
        public override void Create(CommandParser Parser)
        {
            Parser.AddCommand(
                Sequence(
                    RequiredRank(500),
                    KeyWord("!INSPECT"),
                    MustMatch("I don't see that here.",
                              Or(
                                  Object("OBJECT", InScope),
                                  KeyWord("HERE")))))
            .Manual("Take a peek at the internal workings of any mud object.")
            .ProceduralRule((match, actor) =>
            {
                if (!match.ContainsKey("OBJECT"))
                {
                    match.Upsert("OBJECT", actor.Location);
                }
                return(PerformResult.Continue);
            }, "Convert locale option to standard form rule.")
            .ProceduralRule((match, actor) =>
            {
                var target = match["OBJECT"] as MudObject;

                Core.SendMessage(actor, "*** INSPECT LISTING ***");
                Core.SendMessage(actor, "Path: <s0>", target.Path);
                Core.SendMessage(actor, "Instance: <s0>", target.Instance);
                Core.SendMessage(actor, "Persistent: <s0>", target.IsPersistent.ToString());
                if (!target.Location.HasValue(out var loc))
                {
                    Core.SendMessage(actor, "Location: NOWHERE");
                }
                else
                {
                    Core.SendMessage(actor, "Location: <s0>", loc.GetFullName());
                }
                Core.SendMessage(actor, "*** DYNAMIC PROPERTIES ***");

                foreach (var property in target.Properties)
                {
                    var info = PropertyManifest.GetPropertyInformation(property.Key);
                    Core.SendMessage(actor, "<s0>: <s1>", property.Key, info.Converter.ConvertToString(property.Value));
                }

                Core.SendMessage(actor, "*** END OF LISTING ***");

                return(PerformResult.Continue);
            }, "List all the damn things rule.");
        }
예제 #6
0
        public override void Create(CommandParser Parser)
        {
            Parser.AddCommand(
                Sequence(
                    RequiredRank(500),
                    KeyWord("!PROPERTIES")))
            .Manual("List all properties that have been registered.")
            .ProceduralRule((match, actor) =>
            {
                foreach (var prop in PropertyManifest.GetAllPropertyInformation())
                {
                    Core.SendMessage(actor, "<s0> (<s1>) : <s2>", prop.Key, prop.Value.Type.ToString(), prop.Value.Converter.ConvertToString(prop.Value.DefaultValue));
                }

                return(PerformResult.Continue);
            });
        }
예제 #7
0
        public static void AtStartup(RMUD.RuleEngine GlobalRules)
        {
            PropertyManifest.RegisterProperty("lockable?", typeof(bool), false, new BoolSerializer());

            Core.StandardMessage("not lockable", "I don't think the concept of 'locked' applies to that.");
            Core.StandardMessage("you lock", "You lock <the0>.");
            Core.StandardMessage("they lock", "^<the0> locks <the1> with <the2>.");

            GlobalRules.DeclareCheckRuleBook <MudObject, MudObject, MudObject>("can lock?", "[Actor, Item, Key] : Can the item be locked by the actor with the key?", "actor", "item", "key");

            GlobalRules.Check <MudObject, MudObject, MudObject>("can lock?")
            .Do((actor, item, key) => Core.CheckIsVisibleTo(actor, item))
            .Name("Item must be visible to lock it.");

            GlobalRules.Check <MudObject, MudObject, MudObject>("can lock?")
            .Do((actor, item, key) => Core.CheckIsHolding(actor, key))
            .Name("Key must be held rule.");

            GlobalRules.Check <MudObject, MudObject, MudObject>("can lock?")
            .When((actor, item, key) => !item.GetProperty <bool>("lockable?"))
            .Do((a, b, c) =>
            {
                Core.SendMessage(a, "@not lockable");
                return(CheckResult.Disallow);
            })
            .Name("Can't lock the unlockable rule.");

            GlobalRules.Check <MudObject, MudObject, MudObject>("can lock?")
            .Do((a, b, c) => CheckResult.Allow)
            .Name("Default allow locking rule.");

            GlobalRules.DeclarePerformRuleBook <MudObject, MudObject, MudObject>("locked", "[Actor, Item, Key] : Handle the actor locking the item with the key.", "actor", "item", "key");

            GlobalRules.Perform <MudObject, MudObject, MudObject>("locked").Do((actor, target, key) =>
            {
                Core.SendMessage(actor, "@you lock", target);
                Core.SendExternalMessage(actor, "@they lock", actor, target, key);
                return(PerformResult.Continue);
            });
        }
예제 #8
0
 public static void AtStartup(RuleEngine GlobalRules)
 {
     PropertyManifest.RegisterProperty("container?", typeof(bool), false, new BoolSerializer());
     PropertyManifest.RegisterProperty("locale type", typeof(Locale), Locale.NotARoom, new EnumSerializer <Locale>());
     PropertyManifest.RegisterProperty("locale light", typeof(LightingLevel), LightingLevel.Dark, new EnumSerializer <LightingLevel>());
     PropertyManifest.RegisterProperty("ambient light", typeof(LightingLevel), LightingLevel.Dark, new EnumSerializer <LightingLevel>());
     PropertyManifest.RegisterProperty("actor?", typeof(bool), false, new BoolSerializer());
     PropertyManifest.RegisterProperty("preserve?", typeof(bool), false, new BoolSerializer());
     PropertyManifest.RegisterProperty("gender", typeof(Gender), Gender.Male, new EnumSerializer <Gender>());
     PropertyManifest.RegisterProperty("rank", typeof(int), 0, new IntSerializer());
     PropertyManifest.RegisterProperty("client", typeof(Client), null, new DefaultSerializer());
     PropertyManifest.RegisterProperty("command handler", typeof(ClientCommandHandler), null, new DefaultSerializer());
     PropertyManifest.RegisterProperty("emissive light", typeof(LightingLevel), LightingLevel.Dark, new EnumSerializer <LightingLevel>());
     PropertyManifest.RegisterProperty("locked?", typeof(bool), true, new BoolSerializer());
     PropertyManifest.RegisterProperty("scenery?", typeof(bool), false, new BoolSerializer());
     PropertyManifest.RegisterProperty("short", typeof(String), "unnamed object", new StringSerializer());
     PropertyManifest.RegisterProperty("long", typeof(String), "", new StringSerializer());
     PropertyManifest.RegisterProperty("article", typeof(String), "a", new StringSerializer());
     PropertyManifest.RegisterProperty("nouns", typeof(NounList), null, new DefaultSerializer());
     PropertyManifest.RegisterProperty("openable?", typeof(bool), false, new BoolSerializer());
     PropertyManifest.RegisterProperty("open?", typeof(bool), false, new BoolSerializer());
     PropertyManifest.RegisterProperty("combat target", typeof(MudObject), null, new DefaultSerializer());
 }
예제 #9
0
 public static void AtStartup(RuleEngine GlobalRules)
 {
     ProscriptionList = new ProscriptionList("proscriptions.txt");
     PropertyManifest.RegisterProperty("account", typeof(Account), null, new DefaultSerializer());
 }
예제 #10
0
        public static void AtStartup(RMUD.RuleEngine GlobalRules)
        {
            PropertyManifest.RegisterProperty("active-quest", typeof(MudObject), null, new DefaultSerializer());
            PropertyManifest.RegisterProperty("offered-quest", typeof(MudObject), null, new DefaultSerializer());

            GlobalRules.Perform <PossibleMatch, MudObject>("after acting")
            .Do((match, actor) =>
            {
                if (actor.GetProperty <MudObject>("active-quest") != null)
                {
                    var quest = actor.GetProperty <MudObject>("active-quest");

                    if (GlobalRules.ConsiderValueRule <bool>("quest complete?", actor, quest))
                    {
                        actor.SetProperty("active-quest", null);
                        GlobalRules.ConsiderPerformRule("quest completed", actor, quest);
                    }
                    else if (GlobalRules.ConsiderValueRule <bool>("quest failed?", actor, quest))
                    {
                        actor.SetProperty("active-quest", null);
                        GlobalRules.ConsiderPerformRule("quest failed", actor, quest);
                    }
                }

                return(PerformResult.Continue);
            })
            .Name("Check quest status after acting rule.");

            GlobalRules.DeclarePerformRuleBook <MudObject, MudObject>("quest reset", "[quest, thing] : The quest is being reset. Quests can call this on objects they interact with.", "quest", "item");

            GlobalRules.DeclarePerformRuleBook <MudObject, MudObject>("quest accepted", "[actor, quest] : Handle accepting a quest.", "actor", "quest");
            GlobalRules.DeclarePerformRuleBook <MudObject, MudObject>("quest completed", "[actor, quest] : Handle when a quest is completed.", "actor", "quest");
            GlobalRules.DeclarePerformRuleBook <MudObject, MudObject>("quest failed", "[actor, quest] : Handle when a quest is failed.", "actor", "quest");
            GlobalRules.DeclarePerformRuleBook <MudObject, MudObject>("quest abandoned", "[actor, quest] : Handle when a quest is abandoned.", "actor", "quest");

            GlobalRules.Perform <MudObject, MudObject>("quest abandoned")
            .Last
            .Do((actor, quest) =>
            {
                return(GlobalRules.ConsiderPerformRule("quest failed", actor, quest));
            })
            .Name("Abandoning a quest is failure rule.");

            GlobalRules.DeclareValueRuleBook <MudObject, MudObject, bool>("quest available?", "[actor, quest -> bool] : Is the quest available to this actor?", "actor", "quest");

            GlobalRules.Value <MudObject, MudObject, bool>("quest available?")
            .Do((Actor, quest) => false)
            .Name("Quests unavailable by default rule.");

            GlobalRules.DeclareValueRuleBook <MudObject, MudObject, bool>("quest complete?", "[actor, quest -> bool] : Has this actor completed this quest?", "actor", "quest");

            GlobalRules.Value <MudObject, MudObject, bool>("quest complete?")
            .Do((actor, quest) => false)
            .Name("Quests incomplete by default rule.");

            GlobalRules.DeclareValueRuleBook <MudObject, MudObject, bool>("quest failed?", "[actor, quest -> bool] : Has this actor failed this quest?", "actor", "quest");

            GlobalRules.Value <MudObject, MudObject, bool>("quest failed?")
            .Do((actor, quest) => false)
            .Name("Quests can't fail by default rule.");
        }
예제 #11
0
        public static void AtStartup(RMUD.RuleEngine GlobalRules)
        {
            PropertyManifest.RegisterProperty("combat weapon", typeof(MudObject), null, new DefaultSerializer());
            PropertyManifest.RegisterProperty("combat health", typeof(int), 0, new IntSerializer());
            PropertyManifest.RegisterProperty("combat damage die", typeof(String), "", new StringSerializer());
            PropertyManifest.RegisterProperty("combat hit modifier", typeof(int), 0, new IntSerializer());
            PropertyManifest.RegisterProperty("combat armor class", typeof(int), 0, new IntSerializer());

            GlobalRules.DeclarePerformRuleBook <MudObject, MudObject>("attacked", "[Attacker, Target] => Attacker Attacked Target rule.", "Attacker", "Target");

            GlobalRules.Perform <MudObject>("inventory")
            .When(a => a.GetProperty <MudObject>("combat weapon") != null)
            .Do(a =>
            {
                Core.SendMessage(a, "@wielding", a, a.GetProperty <MudObject>("combat weapon"));
                return(PerformResult.Continue);
            })
            .Name("List weapon in inventory rule.");

            GlobalRules.Perform <MudObject, MudObject>("drop")
            .First
            .When((actor, target) => Object.ReferenceEquals(actor.GetProperty <MudObject>("combat weapon"), target))
            .Do((actor, target) =>
            {
                actor.SetProperty("combat weapon", null);
                return(PerformResult.Continue);
            }).Name("Unwield dropped item rule");

            GlobalRules.Perform <MudObject, MudObject>("describe")
            .When((viewer, item) => item.GetProperty <MudObject>("combat weapon") != null)
            .Do((viewer, item) =>
            {
                Core.SendMessage(viewer, "@wielding", item, item.GetProperty <MudObject>("combat weapon"));
                return(PerformResult.Continue);
            })
            .Name("Describe their weapon rule.");

            GlobalRules.Perform <MudObject>("heartbeat")
            .When(o => o.HasProperty("combat target") && o.GetProperty <MudObject>("combat target") != null)
            .Do((o) =>
            {
                var target = o.GetProperty <MudObject>("combat target");
                if (target == null || target.State == ObjectState.Destroyed)
                {
                    o.SetProperty("combat target", null);
                    return(PerformResult.Continue);
                }

                if (!Core.IsVisibleTo(o, target))
                {
                    Core.SendMessage(o, "Your target is no longer here.");
                    o.SetProperty("combat target", null);
                    return(PerformResult.Continue);
                }

                CombatSystem.MeleeAttack(o, target);
                GlobalRules.ConsiderPerformRule("attacked", o, target);
                return(PerformResult.Continue);
            })
            .Name("I'm in a fight, I'd better attack rule.");

            GlobalRules.Perform <MudObject, MudObject>("attacked")
            .Do((attacker, target) =>
            {
                target.SetProperty("combat target", attacker);
                return(PerformResult.Continue);
            })
            .Name("fight back rule");
        }
예제 #12
0
        public static void AtStartup(RMUD.RuleEngine GlobalRules)
        {
            PropertyManifest.RegisterProperty("introduction memory", typeof(Dictionary <String, bool>), null, new DefaultSerializer());

            GlobalRules.DeclareCheckRuleBook <MudObject, MudObject>("can introduce?", "[Actor A, Actor B] : Can A introduce B?", "actor", "itroductee");

            GlobalRules.Check <MudObject, MudObject>("can introduce?")
            .When((a, b) => !b.GetProperty <bool>("actor?"))
            .Do((a, b) =>
            {
                Core.SendMessage(a, "That just sounds silly.");
                return(CheckResult.Disallow);
            })
            .Name("Can only introduce actors rule.");

            GlobalRules.Check <MudObject, MudObject>("can introduce?")
            .Do((a, b) => Core.CheckIsVisibleTo(a, b))
            .Name("Introducee must be visible rule.");

            GlobalRules.Check <MudObject, MudObject>("can introduce?")
            .When((a, b) => !GlobalRules.ConsiderValueRule <bool>("actor knows actor?", a, b))
            .Do((a, b) =>
            {
                Core.SendMessage(a, "How can you introduce <the0> when you don't know them yourself?", b);
                return(CheckResult.Disallow);
            })
            .Name("Can't introduce who you don't know rule.");

            GlobalRules.Perform <MudObject, MudObject>("describe")
            .First
            .When((viewer, actor) => GlobalRules.ConsiderValueRule <bool>("actor knows actor?", viewer, actor))
            .Do((viewer, actor) =>
            {
                Core.SendMessage(viewer, "^<the0>, a " + (actor.GetProperty <Gender>("gender") == Gender.Male ? "man." : "woman."), actor);
                return(PerformResult.Continue);
            })
            .Name("Report gender of known actors rule.");

            #region Perform and report rules

            GlobalRules.DeclarePerformRuleBook <MudObject, MudObject>("introduce", "[Actor A, Actor B] : Handle A introducing B.", "actor", "introductee");

            GlobalRules.Perform <MudObject, MudObject>("introduce")
            .Do((actor, introductee) =>
            {
                var locale = Core.FindLocale(introductee);
                if (locale != null)
                {
                    foreach (var player in Core.EnumerateObjectTree(locale).Where(o => o.GetProperty <bool>("actor?")))
                    {
                        GlobalRules.ConsiderPerformRule("introduce to", introductee, player);
                    }
                }

                Core.SendExternalMessage(actor, "^<the0> introduces <the1>.", actor, introductee);
                Core.SendMessage(actor, "You introduce <the0>.", introductee);
                return(PerformResult.Continue);
            })
            .Name("Report introduction rule.");

            GlobalRules.DeclarePerformRuleBook <MudObject>("introduce self", "[Introductee] : Introduce the introductee");

            GlobalRules.Perform <MudObject>("introduce self")
            .Do((introductee) =>
            {
                var locale = Core.FindLocale(introductee);
                if (locale != null)
                {
                    foreach (var player in Core.EnumerateObjectTree(locale).Where(o => o.GetProperty <bool>("actor?")))
                    {
                        GlobalRules.ConsiderPerformRule("introduce to", introductee, player);
                    }
                }

                Core.SendExternalMessage(introductee, "^<the0> introduces themselves.", introductee);
                Core.SendMessage(introductee, "You introduce yourself.");

                return(PerformResult.Continue);
            })
            .Name("Introduce an actor to everyone present rule.");

            #endregion

            #region Printed name rules

            GlobalRules.Value <MudObject, MudObject, String, String>("printed name")
            .When((viewer, thing, article) => thing.GetProperty <bool>("actor?"))
            .When((viewer, thing, article) => GlobalRules.ConsiderValueRule <bool>("actor knows actor?", viewer, thing))
            .Do((viewer, actor, article) => actor.GetProperty <String>("short"))
            .Name("Name of introduced actor.");

            GlobalRules.Value <MudObject, MudObject, String, String>("printed name")
            .When((viewer, thing, article) => thing.GetProperty <bool>("actor?"))
            .When((viewer, thing, article) => thing.GetProperty <Gender>("gender") == Gender.Male)
            .Do((viewer, actor, article) => article + " man")
            .Name("Default name for unintroduced male actor.");

            GlobalRules.Value <MudObject, MudObject, String, String>("printed name")
            .When((viewer, thing, article) => thing.GetProperty <bool>("actor?"))
            .When((viewer, thing, article) => thing.GetProperty <Gender>("gender") == Gender.Female)
            .Do((viewer, actor, article) => article + " woman")
            .Name("Default name for unintroduced female actor.");

            #endregion

            #region Knowledge management rules

            GlobalRules.DeclareValueRuleBook <MudObject, MudObject, bool>("actor knows actor?", "[Player, Whom] : Does the player know the actor?");

            GlobalRules.Value <MudObject, MudObject, bool>("actor knows actor?")
            .Do((player, whom) => RecallActor(player, whom))
            .Name("Use player memory to recall actors rule.");

            GlobalRules.DeclarePerformRuleBook <MudObject, MudObject>("introduce to", "[Introductee, ToWhom] : Introduce the introductee to someone");

            GlobalRules.Perform <MudObject, MudObject>("introduce to")
            .Do((introductee, player) =>
            {
                RememberActor(player, introductee);
                return(PerformResult.Continue);
            })
            .Name("Players remember actors rule.");

            #endregion
        }
예제 #13
0
        public static void AtStartup(RMUD.RuleEngine GlobalRules)
        {
            PropertyManifest.RegisterProperty("interlocutor", typeof(MudObject), null, new DefaultSerializer());
            PropertyManifest.RegisterProperty("conversation-topics", typeof(List <MudObject>), new List <MudObject>(), new DefaultSerializer());
            PropertyManifest.RegisterProperty("topic-discussed", typeof(bool), false, new BoolSerializer());

            Core.StandardMessage("convo topic prompt", "Suggested topics: <l0>");
            Core.StandardMessage("convo cant converse", "You can't converse with that.");
            Core.StandardMessage("convo greet whom", "Whom did you want to greet?");
            Core.StandardMessage("convo nobody", "You aren't talking to anybody.");
            Core.StandardMessage("convo no response", "There doesn't seem to be a response defined for that topic.");
            Core.StandardMessage("convo no topics", "There is nothing obvious to discuss.");

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

            GlobalRules.Check <MudObject, MudObject>("can converse?")
            .When((actor, item) => !item.GetProperty <bool>("actor?"))
            .Do((actor, item) =>
            {
                Core.SendMessage(actor, "@convo cant converse");
                return(CheckResult.Disallow);
            })
            .Name("Can only converse with NPCs rule.");

            GlobalRules.Check <MudObject, MudObject>("can converse?")
            .Do((actor, item) => Core.CheckIsVisibleTo(actor, item))
            .Name("Locutor must be visible rule.");

            GlobalRules.Check <MudObject, MudObject>("can converse?")
            .Last
            .Do((actor, item) => CheckResult.Allow)
            .Name("Let them chat rule.");

            GlobalRules.DeclarePerformRuleBook <MudObject, MudObject>("greet", "[Actor, NPC] : Handle an actor greeting an NPC.", "actor", "npc");

            GlobalRules.DeclarePerformRuleBook <MudObject>("list topics", "[Actor] : List conversation topics available to the actor.", "actor");

            GlobalRules.Perform <MudObject>("list topics")
            .When(actor => actor.GetProperty <MudObject>("interlocutor") == null)
            .Do(actor =>
            {
                Core.SendMessage(actor, "@convo nobody");
                return(PerformResult.Stop);
            })
            .Name("Need interlocutor to list topics rule.");

            GlobalRules.Perform <MudObject>("list topics")
            .Do(actor =>
            {
                var npc = actor.GetProperty <MudObject>("interlocutor");
                if (npc != null)
                {
                    var suggestedTopics = npc.GetProperty <List <MudObject> >("conversation-topics").AsEnumerable();

                    if (!ConversationSettings.ListDiscussedTopics)
                    {
                        suggestedTopics = suggestedTopics.Where(obj => !obj.GetProperty <bool>("topic-discussed"));
                    }

                    suggestedTopics = suggestedTopics.Where(topic => GlobalRules.ConsiderCheckRule("topic available?", actor, npc, topic) == CheckResult.Allow);

                    var enumeratedSuggestedTopics = new List <MudObject>(suggestedTopics);

                    if (enumeratedSuggestedTopics.Count != 0)
                    {
                        Core.SendMessage(actor, "@convo topic prompt", enumeratedSuggestedTopics);
                    }
                    else
                    {
                        GlobalRules.ConsiderPerformRule("no topics to discuss", actor, npc);
                    }
                }

                return(PerformResult.Continue);
            })
            .Name("List un-discussed available topics rule.");

            GlobalRules.DeclarePerformRuleBook <MudObject, MudObject>("no topics to discuss", "[Actor, NPC] : Handle there being no topics to list.");

            GlobalRules.Perform <MudObject, MudObject>("no topics to discuss")
            .Do((actor, npc) =>
            {
                Core.SendMessage(actor, "@convo no topics");
                return(PerformResult.Continue);
            })
            .Name("Default report no topics to discuss rule.");

            GlobalRules.DeclarePerformRuleBook <MudObject, MudObject, MudObject>("discuss topic", "[Actor, NPC, Topic] : Handle the actor discussing the topic with the npc.");

            GlobalRules.Perform <MudObject, MudObject, MudObject>("discuss topic")
            .Do((actor, npc, topic) =>
            {
                GlobalRules.ConsiderPerformRule("topic response", actor, npc, topic);
                if (topic != null)
                {
                    topic.SetProperty("topic-discussed", true);
                }
                return(PerformResult.Continue);
            })
            .Name("Show topic response when discussing topic rule.");

            GlobalRules.Perform <MudObject, MudObject, MudObject>("topic response")
            .Do((actor, npc, topic) =>
            {
                Core.SendMessage(actor, "@convo no response");
                return(PerformResult.Stop);
            })
            .Name("No response rule for the topic rule.");

            GlobalRules.DeclareCheckRuleBook <MudObject, MudObject, MudObject>("topic available?", "[Actor, NPC, Topic -> bool] : Is the topic available for discussion with the NPC to the actor?", "actor", "npc", "topic");

            GlobalRules.DeclarePerformRuleBook <MudObject, MudObject, MudObject>("topic response", "[Actor, NPC, Topic] : Display the response of the topic.", "actor", "npc", "topic");

            GlobalRules.Check <MudObject, MudObject, MudObject>("topic available?")
            .First
            .When((actor, npc, topic) => (topic != null) && (ConversationSettings.AllowRepeats == false) && topic.GetProperty <bool>("topic-discussed"))
            .Do((actor, npc, topic) => CheckResult.Disallow)
            .Name("Already discussed topics unavailable when repeats disabled rule.");

            GlobalRules.Check <MudObject, MudObject, MudObject>("topic available?")
            .Last
            .Do((actor, npc, topic) => CheckResult.Allow)
            .Name("Topics available by default rule.");
        }
예제 #14
0
파일: Alias.cs 프로젝트: Blecki/RMUDReboot
 public static void AtStartup(RMUD.RuleEngine GlobalRules)
 {
     PropertyManifest.RegisterProperty("aliases", typeof(Dictionary <String, String>), null, new DefaultSerializer());
 }