예제 #1
0
        public void Setup()
        {
            _testLocation = new Location(new string[] { "woods" }, "The woods", "A dark, scary place..");
            _testPlayer   = new Player("Lawrence", "This is a fine character.", _testLocation);
            _testGem      = new Item(new string[] { "gem", "jewel" }, "gem", "A small, shining gem.");
            _testLook     = new Look_Command(new string[] { "test" });

            _testLocation.Inventory.Put(_testGem);
        }
예제 #2
0
        public void Setup()
        {
            _testLocation = new Location(new string[] { "woods" }, "The woods", "A dark, scary place..");
            _testLook     = new Look_Command(new string[] { "look", "command" });
            _testPlayer   = new Player("me", "inventory", _testLocation);
            _testGem      = new Item(new string[] { "gem", "jewel" }, "gem", "This is a shiny gem.");
            _testBag      = new Bag(new string[] { "bag", "lbag" }, "large pouch", "This is a large pouch.");

            _testBag.Inventory.Put(_testGem);
            _testPlayer.Inventory.Put(_testBag);
        }
예제 #3
0
        static void Main(string[] args)
        {
            // Getting user input for name and description
            Console.WriteLine("Write your name!");
            string name = Console.ReadLine();

            Console.WriteLine("Enter your character desription!");
            string desc = Console.ReadLine();

            // Adding player and location
            Location north = new Location(new string[] { "north" }, "the hallway", "the long, dark, scary hallway");
            Player   p     = new Player(name, desc, north);

            // Creation of items + Add to inventory
            Item _shovel = new Item(new string[] { "shovel", "spade" }, "shovel", "This might be a fine...");
            Item _pc     = new Item(new string[] { "pc" }, "computer", "This computer can do a lot of things!");

            p.Inventory.Put(_shovel);
            p.Inventory.Put(_pc);

            // Create bag and add to inventory
            Bag _b1 = new Bag(new string[] { "lbag", "lpouch" }, "large pouch", "This is a large pouch.");

            p.Inventory.Put(_b1);

            // Create item and add to bag
            Item _sword = new Item(new string[] { "sword" }, "sword", "This is a fine looking sword.");

            _b1.Inventory.Put(_sword);

            Console.WriteLine("Lets test some look commands! Write a look command. Remember that they have to start with the word look!");
            Console.WriteLine("Type in finish if you want to stop looking.");

            Look_Command look     = new Look_Command(new string[] { "look" });
            bool         lookloop = true;

            while (lookloop == true)
            {
                string lookCommand = Console.ReadLine();

                if (lookCommand.ToLower() == "finish")
                {
                    lookloop = false;
                }
                string[] commandWords = lookCommand.Split(' ');
                Console.WriteLine(look.Execute(p, commandWords));

                Console.WriteLine("If you want to stop, type 'Finish'. If you want to keep testing, keep typing in commands!");
            }

            Console.WriteLine("Press any key to exit.");
            Console.ReadLine();
        }