예제 #1
0
        public override void Initialize()
        {
            Actor();

            this.Response("who he is", (actor, npc, topic) =>
            {
                Core.SendLocaleMessage(actor, "\"Name's Bjorn,\" <the0> gasps. \"You going to buy something, or..?\"", this);
                GlobalRules.ConsiderPerformRule("introduce self", this);
                return(PerformResult.Stop);
            });

            Perform <MudObject, MudObject, MudObject>("topic response")
            .When((actor, npc, topic) => topic == null)
            .Do((actor, npc, topic) =>
            {
                Core.SendLocaleMessage(actor, "\"Eh?\" <the0> asks.", this);
                return(PerformResult.Stop);
            });

            Short = "Bjorn";

            AddNoun("shopkeeper", "shop", "keeper", "keep");
            AddNoun("bjorn", "b").When(a => GlobalRules.ConsiderValueRule <bool>("actor knows actor?", a, this));

            this.Wear("overalls", ClothingLayer.Outer, ClothingBodyPart.Legs);
            this.Wear("simple white shirt", ClothingLayer.Outer, ClothingBodyPart.Torso);
            this.Wear("kufi", ClothingLayer.Outer, ClothingBodyPart.Head);

            Perform <MudObject, MudObject>("describe in locale").Do((actor, item) =>
            {
                Core.SendMessage(actor, "The shopkeeper leans on the counter.");
                return(PerformResult.Continue);
            });
        }
예제 #2
0
        public override void Initialize()
        {
            Actor();

            this.Response("who he is", (actor, npc, topic) =>
            {
                Core.SendLocaleMessage(actor, "\"Jaygmunder,\" <the0> gasps. \"You can call me Jay though.\"", this);
                GlobalRules.ConsiderPerformRule("introduce self", this);
                return(PerformResult.Stop);
            });

            this.Response("his mechanical suit", "\"Huh, my suit? Whhat about it? When you get old, you'll need some help getting around too.\" <the0> sighs. \"Not that it does me much good now. I have't got any plasma for it.\"");

            this.Response("his plush chair", "\"Yeah it's pretty nice.\" <the0> pauses to stroke the arm of his chair. \"I'd let you sit in it if I could get up. Need plasma for that, though.\"");

            this.Response("plasma", (actor, nps, topic) =>
            {
                Core.SendLocaleMessage(actor, "\"The red stuff? In the bags? You know what plasma is, don't you?\"");
                var quest = Core.GetObject("Homestead.PlasmaQuest");
                if (GlobalRules.ConsiderValueRule <bool>("quest available?", actor, quest))
                {
                    Core.SendMessage(actor, "\"Think you can grab some for me?\" <the0> asks.", this);
                    this.OfferQuest(actor, quest);
                }
                return(PerformResult.Stop);
            });

            Perform <MudObject, MudObject, MudObject>("topic response")
            .When((actor, npc, topic) => topic == null)
            .Do((actor, npc, topic) =>
            {
                Core.SendLocaleMessage(actor, "\"Wut?\" <the0> asks.", this);
                return(PerformResult.Stop);
            });

            Short = "Jaygmundre";

            AddNoun("jaygmundre", "jay", "j").When(a => GlobalRules.ConsiderValueRule <bool>("actor knows actor?", a, this));

            this.Wear("mechanical suit", ClothingLayer.Outer, ClothingBodyPart.Torso);
        }
예제 #3
0
    public override void Initialize()
    {
        Actor();

        this.Response("who he is", (actor, npc, topic) =>
        {
            SendLocaleMessage(actor, "\"I am Soranus,\" <the0> says.", this);
            GlobalRules.ConsiderPerformRule("introduce self", this);
            return(PerformResult.Stop);
        });

        this.Response("the entrails", "\"These things?\" <the0> asks. \"Nothing special. They're for the wolves.\"");

        this.Response("wolves", (actor, npc, topic) =>
        {
            SendLocaleMessage(actor, "^<the0> grins, expossing a pair of wicked yellow canines. \"Oh don't worry, they aren't here now.\"", this);
            var quest = GetObject("palantine/entrail_quest");
            if (GlobalRules.ConsiderValueRule <bool>("quest available?", actor, quest))
            {
                SendMessage(actor, "\"Would you mind feeding them for me?\" <the0> asks.", this);
                this.OfferQuest(actor, quest);
            }
            return(PerformResult.Stop);
        });

        Perform <MudObject, MudObject, MudObject>("topic response")
        .When((actor, npc, topic) => topic == null)
        .Do((actor, npc, topic) =>
        {
            SendLocaleMessage(actor, "\"This is my default response,\" <the0> says, showing his sharp little teeth.", this);
            return(PerformResult.Stop);
        });

        Short = "Soranus";

        AddNoun("soranus").When(a => GlobalRules.ConsiderValueRule <bool>("actor knows actor?", a, this));

        this.Wear("toga", ClothingLayer.Outer, ClothingBodyPart.Torso);
        this.Wear(GetObject("palantine/entrails"));
    }
예제 #4
0
        /// <summary>
        /// Format a list of mud objects using commas and a coordinating conjunction. EG, into the form 'a, b, and c'.
        /// </summary>
        /// <param name="Recipient">The actor that will, eventually, see the output.</param>
        /// <param name="ListObject">Either a MudObject or a List<MudObject>. The actual items to format.</param>
        /// <param name="FormattedMessage">Append the formatted message to this StringBuilder.</param>
        /// <param name="CoordinatingConjunction">The word that separates the final item of a list from those proceeding it. EG, and, or, nor.</param>
        private static void FormatList(
            MudObject Recipient,
            Object ListObject,
            StringBuilder FormattedMessage,
            String CoordinatingConjunction)
        {
            // ListObject can be a MudObject or a List<MudObject>. The algorithm expects a list, so transform it.
            List <MudObject> list = null;

            if (ListObject is MudObject)
            {
                list = new List <MudObject>();
                list.Add(ListObject as MudObject);
            }
            else
            {
                list = ListObject as List <MudObject>;
            }

            // If ListObject was neither a MudObject nor a List<MudObject>...
            if (list == null)
            {
                return;
            }

            for (int x = 0; x < list.Count; ++x)
            {
                FormattedMessage.Append(GlobalRules.ConsiderValueRule <String>("printed name", Recipient, list[x], list[x].GetProperty <String>("article")));
                if (x != list.Count - 1)
                {
                    FormattedMessage.Append(", ");
                }
                if (x == list.Count - 2 && !String.IsNullOrEmpty(CoordinatingConjunction))
                {
                    FormattedMessage.Append(CoordinatingConjunction + " ");
                }
            }
        }
예제 #5
0
        public void UpdateLighting()
        {
            Light = LightingLevel.Dark;

            if (RoomType == RMUD.RoomType.Exterior)
            {
                Light = AmbientExteriorLightingLevel;
            }

            foreach (var item in MudObject.EnumerateVisibleTree(this))
            {
                var lightingLevel = GlobalRules.ConsiderValueRule <LightingLevel>("light level", item);
                if (lightingLevel > Light)
                {
                    Light = lightingLevel;
                }
            }

            if (AmbientLighting > Light)
            {
                Light = AmbientLighting;
            }
        }
예제 #6
0
        /// <summary>
        /// Parse and format a message intended for a specific recipient.
        /// </summary>
        /// <param name="Recipient"></param>
        /// <param name="Message">The message, possibly containing specifiers.</param>
        /// <param name="Objects">Specifier indicies refer to this list of objects.</param>
        /// <returns></returns>
        public static String FormatMessage(MudObject Recipient, String Message, params Object[] Objects)
        {
            //A leading @ indicates that the message should be interpretted as an entry in the global message table.
            if (Message[0] == '@')
            {
                Message = Core.GetMessage(Message.Substring(1));
            }

            var formattedMessage = new StringBuilder();
            var iterator         = new StringIterator(Message);

            while (!iterator.AtEnd)
            {
                if (iterator.Next == '<') //We have located a specifier.
                {
                    var type  = "";
                    var index = 0;
                    if (MessageFormatParser.ReadSpecifier(iterator, out type, out index))
                    {
                        if (index < 0 || index >= Objects.Length)
                        {
                            continue;                                       //A blank in the output is preferable to crashing.
                        }
                        #region Expand Specifier
                        if (type == "the" && Objects[index] is MudObject)
                        {
                            //'the' overrides the object's article property.
                            formattedMessage.Append(GlobalRules.ConsiderValueRule <String>("printed name", Recipient, Objects[index], "the"));
                        }
                        else if (type == "a" && Objects[index] is MudObject)
                        {
                            formattedMessage.Append(GlobalRules.ConsiderValueRule <String>("printed name", Recipient, Objects[index], (Objects[index] as MudObject).GetProperty <String>("article")));
                        }
                        else if (type == "l") //No connective clause is used for this style of list. eg 1, 2, 3.
                        {
                            FormatList(Recipient, Objects[index], formattedMessage, "");
                        }
                        else if (type == "lor") //Use or. eg 1, 2, or 3.
                        {
                            FormatList(Recipient, Objects[index], formattedMessage, "or");
                        }
                        else if (type == "land") //Use and. eg 1, 2, and 3.
                        {
                            FormatList(Recipient, Objects[index], formattedMessage, "and");
                        }
                        else if (type == "lnor") //Use nor. eg 1, 2, nor 3.
                        {
                            FormatList(Recipient, Objects[index], formattedMessage, "nor");
                        }
                        else if (type == "s")
                        {
                            if (Objects[index] == null)
                            {
                                formattedMessage.Append("%NULL%");
                            }
                            else
                            {
                                formattedMessage.Append(Objects[index].ToString());
                            }
                        }
                        #endregion
                    }
                }
                else
                {
                    formattedMessage.Append(iterator.Next);
                    iterator.Advance();
                }
            }

            Message = formattedMessage.ToString();
            formattedMessage.Clear();
            iterator = new StringIterator(Message);

            //Apply the ^ transform: Capitalize the letter following the ^ and remove the ^.
            while (!iterator.AtEnd)
            {
                if (iterator.Next == '^')
                {
                    iterator.Advance();
                    if (iterator.AtEnd)
                    {
                        break;
                    }
                    formattedMessage.Append(new String(iterator.Next, 1).ToUpper());
                    iterator.Advance();
                }
                else
                {
                    formattedMessage.Append(iterator.Next);
                    iterator.Advance();
                }
            }

            return(formattedMessage.ToString());
        }