Exemple #1
0
        public void before_routine_blocks_continuation()
        {
            var lamp    = Objects.Get <BrassLantern>();
            var message = "The lamp is glued to the floor.";
            var after   = false;

            lamp.Before <Take>(() =>
            {
                Print(message);
                return(true); // not handled
            });

            lamp.After <Take>(() =>
            {
                after = true;
            });

            Assert.True(CurrentRoom.Has <BrassLantern>());

            Execute("take lamp");

            Assert.False(after);
            Assert.False(Inventory.Contains <BrassLantern>());
            Assert.True(CurrentRoom.Has <BrassLantern>());

            Assert.Contains(message, ConsoleOut);
        }
Exemple #2
0
        public void should_run_before_after_routines_from_expects()
        {
            var lamp   = Objects.Get <BrassLantern>();
            var before = false;
            var after  = false;

            lamp.Before <Take>(() =>
            {
                before = true;
                return(false); // not handled
            });

            lamp.After <Take>(() =>
            {
                after = true;
            });

            Assert.True(CurrentRoom.Has <BrassLantern>());

            Execute("take lamp");

            Assert.True(Inventory.Contains <BrassLantern>());
            Assert.False(CurrentRoom.Has <BrassLantern>());

            Assert.True(before);
            Assert.True(after);
        }
Exemple #3
0
        public void implicit_take_is_blocked_by_before()
        {
            var blocked = "The food disappears before you can take it.";

            // eat command requires that object be in players inventory
            // here it's not, but it is in the room - so take it for
            // the player automatically
            var tastyFood = Objects.Get <TastyFood>();

            tastyFood.Before <Take>(() =>
            {
                Print(blocked);
                return(true);
            });

            Assert.False(Inventory.Contains(tastyFood));

            var result = Execute("eat food");

            // Assert.Equal("(first taking the tasty food)", Line1);
            Assert.Equal(blocked, Line1);

            Assert.True(CurrentRoom.Has <TastyFood>());
            Assert.False(Inventory.Contains(tastyFood));
        }
Exemple #4
0
        public void no_implicit_take()
        {
            var tastyFood = Objects.Get <TastyFood>();

            Inventory.Add(tastyFood);

            Execute("eat food");

            Assert.Equal("Delicious!", Line1);

            Assert.False(CurrentRoom.Has <TastyFood>());
            Assert.False(Inventory.Contains(tastyFood));
        }
Exemple #5
0
        public SideOfChasm()
        {
            Before <Jump>(() =>
            {
                var rickety = Get <RicketyBridge>();

                if (CurrentRoom.Has <RicketyBridge>())
                {
                    return(Print("I respectfully suggest you go across the bridge instead of jumping."));
                }

                Print("You didn't make it.");
                GameOver.Dead();
                return(true);
            });
        }
Exemple #6
0
        public void should_take_bird()
        {
            var cage = Objects.Get <WickerCage>();

            Inventory.Add(cage);

            var bird = Objects.Get <LittleBird>();

            ObjectMap.MoveObject(bird, CurrentRoom.Location);

            Execute("take bird");

            Assert.Equal("You catch the bird in the wicker cage.", Line1);
            Assert.False(CurrentRoom.Has <LittleBird>());
            Assert.True(cage.Contains <LittleBird>());
            Assert.True(bird.InInventory);
        }
Exemple #7
0
        public void implicit_take()
        {
            // eat command requires that object be in players inventory
            // here it's not, but it is in the room - so take it for
            // the player automatically
            var tastyFood = Objects.Get <TastyFood>();

            Assert.False(Inventory.Contains(tastyFood));

            Execute("eat food");

            Assert.Equal("(first taking the tasty food)", Line1);
            Assert.Equal("Delicious!", Line2);

            Assert.False(CurrentRoom.Has <TastyFood>());
            Assert.False(Inventory.Contains(tastyFood));
        }
Exemple #8
0
        public void bird_should_be_released_when_removed()
        {
            var bird = Objects.Get <LittleBird>();
            var cage = Objects.Get <WickerCage>();

            cage.Add(bird);
            cage.Open = false;
            Inventory.Add(cage);

            Assert.True(cage.Contains <LittleBird>());

            Execute("remove bird");

            Assert.Equal("(The bird is released from the cage.)", Line1);
            Assert.Equal("The little bird flies free.", Line2);

            Assert.True(CurrentRoom.Has <LittleBird>());
            Assert.False(cage.Contains <LittleBird>());
        }
Exemple #9
0
        public void bird_should_kill_snake()
        {
            var cage = Objects.Get <WickerCage>();

            Inventory.Add(cage);

            var bird = Objects.Get <LittleBird>();

            cage.Add(bird);

            var snake = Objects.Get <Snake>();

            ObjectMap.MoveObject(snake, CurrentRoom.Location);

            Execute("release bird");

            Assert.Equal("The little bird attacks the green snake, and in an astounding flurry drives the snake away.", Line1);
            Assert.False(CurrentRoom.Has <Snake>());
            Assert.False(cage.Contains <LittleBird>());
            Assert.True(CurrentRoom.Has <LittleBird>());
        }
Exemple #10
0
        public override void Initialize()
        {
            Name = "black rod with a rusty star on the end";
            Synonyms.Are("rod", "star", "black", "rusty", "star", "three", "foot", "iron");
            Description        = "It's a three foot black rod with a rusty star on an end.";
            InitialDescription = "A three foot black rod with a rusty star on one end lies nearby.";

            Before <Wave>(() =>
            {
                var westSideOfFissure = Rooms.Get <WestSideOfFissure>();
                var eastBankOfFissure = Rooms.Get <EastBankOfFissure>();

                if (CurrentRoom.Is <WestSideOfFissure>() || CurrentRoom.Is <EastBankOfFissure>())
                {
                    // TODO: caves closed
                    // if (caves_closed) "Peculiar. Nothing happens.";

                    if (CurrentRoom.Has <CrystalBridge>())
                    {
                        Room <WestSideOfFissure>().BridgeDisappears();
                        Room <EastBankOfFissure>().BridgeDisappears();
                        Print("The crystal bridge has vanished!");
                    }
                    else
                    {
                        Room <WestSideOfFissure>().BridgeAppears();
                        Room <EastBankOfFissure>().BridgeAppears();
                        Print("A crystal bridge now spans the fissure.");
                    }

                    return(true);
                }

                Print("Nothing happens.");

                return(true);
            });
        }
Exemple #11
0
        public override void Initialize()
        {
            Name = "ming vase";
            Synonyms.Are("vase", "ming", "delicate");
            Description = "It's a delicate, precious, ming vase!";

            DepositPoints = 14;

            FoundIn <OrientalRoom>();

            Before <Attack>(() =>
            {
                RepaceVaseWithShards();
                Print("You have taken the vase and hurled it delicately to the ground.");
                return(true);
            });

            Receive((obj) =>
            {
                Print("The vase is too fragile to use as a container.");
                return(true);
            });

            Before <Drop>(() =>
            {
                if (CurrentRoom.Has <VelvetPillow>())
                {
                    Print("(coming to rest, delicately, on the velvet pillow)");
                    return(false);
                }

                RepaceVaseWithShards();

                Print("The ming vase drops with a delicate crash.");

                return(true);
            });
        }
Exemple #12
0
        public override void Initialize()
        {
            Before <Jump>(() =>
            {
                if (CurrentRoom.Has <CrystalBridge>())
                {
                    Print("I respectfully suggest you go across the bridge instead of jumping.");
                    return(true);
                }

                Print("You didn't make it.");

                GameOver.Dead();

                return(true);
            });

            DownTo(() =>
            {
                Output.Print("The fissure is too terrifying!");
                return(this);
            });
        }
Exemple #13
0
        public void dragon_should_kill_bird()
        {
            var cage = Objects.Get <WickerCage>();

            Inventory.Add(cage);

            var bird = Objects.Get <LittleBird>();

            cage.Add(bird);

            var dragon = Objects.Get <Dragon>();

            ObjectMap.MoveObject(dragon, CurrentRoom.Location);

            Execute("release bird");

            Assert.Contains("The little bird attacks the green dragon,", ConsoleOut);
            Assert.Contains("and in an astounding flurry gets burnt to a cinder.", ConsoleOut);
            Assert.Contains("The ashes blow away.", ConsoleOut);

            Assert.False(CurrentRoom.Has <LittleBird>());
            Assert.False(bird.InInventory);
            Assert.False(bird.InScope);
        }
Exemple #14
0
 public void cannot_drink_oil()
 {
     Execute("drink oil");
     Assert.Contains("Absolutely not.", ConsoleOut);
     Assert.True(CurrentRoom.Has <PoolOfOil>());
 }
Exemple #15
0
 public void vase_should_not_exist()
 {
     Execute("drop vase");
     Assert.False(Inventory.Contains(vase));
     Assert.False(CurrentRoom.Has <MingVase>());
 }