Esempio n. 1
0
        public void TestSecondPerson()
        {
            TestThing roomThing = new TestThing("a non-descript room");
            TestThing thisThing = new TestThing("nothing");

            thisThing.Move(roomThing);
            TestThing otherThing = new TestThing("second nothing");

            otherThing.IsObserver = true;
            otherThing.Move(roomThing);
            Messages.Action("{o0} {v0look}.", thisThing);
            Assert.IsTrue(thisThing.LastMessage == "You look.");
            Assert.IsTrue(otherThing.LastMessage == "Nothing looks.");
            Messages.Action("{o0} {v0dance}.", thisThing);
            Assert.IsTrue(thisThing.LastMessage == "You dance.");
            Assert.IsTrue(otherThing.LastMessage == "Nothing dances.");
            Messages.Action("{o0} {v0ponder}.", thisThing);
            Assert.IsTrue(thisThing.LastMessage == "You ponder.");
            Assert.IsTrue(otherThing.LastMessage == "Nothing ponders.");
            Messages.Action("{o0} {V0look}.", thisThing);
            Assert.IsTrue(thisThing.LastMessage == "You Look.");
            Assert.IsTrue(otherThing.LastMessage == "Nothing Looks.");
            Messages.Action("{o0} {V0dance}.", thisThing);
            Assert.IsTrue(thisThing.LastMessage == "You Dance.");
            Assert.IsTrue(otherThing.LastMessage == "Nothing Dances.");
            Messages.Action("{o0} {V0ponder}.", thisThing);
            Assert.IsTrue(thisThing.LastMessage == "You Ponder.");
            Assert.IsTrue(otherThing.LastMessage == "Nothing Ponders.");
        }
Esempio n. 2
0
        public void TestCompleteVerbShouldFindPartialVerb()
        {
            Thing       thisThing  = new Thing("nothing");
            Func <bool> lookAction = new Func <bool>(() => {
                Messages.Action("{D0 v0look}", thisThing);
                return(true);
            });

            thisThing.AddVerb("l", new Thing.AllowUseAloneDelegate(lookAction));

            Assert.IsTrue(thisThing.AllowUseAlone("l"));
        }
Esempio n. 3
0
        public AdminThing(string name) : base(name)
        {
            this.AddVerb("look", new Func <bool>(() => {
                Messages.Action("{O0} {v0look} around.", this);
                var message = Messages.PersonalAction(this, this.Container.GetDescription(this));
                this.Tell(message);
                return(true);
            }));

            this.AddVerb("inventory", new Func <bool>(() => {
                var message = Messages.PersonalAction(this, "{O0} {v0do} not appear to be holding anything except: " + this.Inventory.Description + ".", this);
                this.Tell(message);
                return(true);
            }));

            this.AddVerb("take", new Func <bool>(() => {
                var message = Messages.PersonalAction(this, "What is it that you wish to take?");
                this.Tell(message);
                return(true);
            }));

            this.AddVerbWithDirectObject("take", new Func <Thing, bool>((directObject) => {
                Messages.Action("{O0} {v0take} {dt1}.", this, directObject);
                return(directObject.Move(this));
            }));

            this.AddVerb("drop", new Func <bool>(() => {
                Messages.PersonalAction(this, "But you aren't holding anything.");
                return(true);
            }));

            this.AddVerbWithDirectObject("drop", new Func <Thing, bool>((directObject) => {
                Messages.Action("{O0} {v0drop} {dt1}.", this, directObject);
                return(directObject.Move(this.Container));
            }));

            this.AddVerbWithDirectObject("go", new Func <Thing, bool>((directObject) => {
                Exit exit = (Exit)directObject;
                Messages.Action("{O0} {v0go} " + exit.Preposition + " {dt1}.", this, directObject);
                bool success = this.Move(exit.GetDestination());
                if (success)
                {
                    var message = Messages.PersonalAction(this, this.Container.GetDescription(this));
                    this.Tell(message);
                }

                return(success);
            }));
        }
Esempio n. 4
0
        public void TestSomeMessaging()
        {
            TestThing thisThing = new TestThing("nothing");

            Messages.Action("{o0} {v0look}.", thisThing);
            Assert.IsTrue(thisThing.LastMessage == "You look.");
            Messages.Action("{o0} {v0dance}.", thisThing);
            Assert.IsTrue(thisThing.LastMessage == "You dance.");
            Messages.Action("{o0} {v0ponder}.", thisThing);
            Assert.IsTrue(thisThing.LastMessage == "You ponder.");
            Messages.Action("{o0} {V0look}.", thisThing);
            Assert.IsTrue(thisThing.LastMessage == "You Look.");
            Messages.Action("{o0} {V0dance}.", thisThing);
            Assert.IsTrue(thisThing.LastMessage == "You Dance.");
            Messages.Action("{o0} {V0ponder}.", thisThing);
            Assert.IsTrue(thisThing.LastMessage == "You Ponder.");
        }