Пример #1
0
        public void TestInvalidLook()
        {
            Player TestPlayer = new Player ("TestPlayer", "For testing");
            LookCommand TestLook = new LookCommand ();

            Assert.IsTrue (TestLook.Execute (TestPlayer, new string[1] {"hello"}) == "i don't know how to look like that");
        }
        static void  Main(string[] args)
        {
            string text, descrip, n;   //test

            string[] option = new string[5];

            var slist = new  List <string> ();

            Console.WriteLine("Enter players text");
            text = Console.ReadLine();
            Console.WriteLine("Enter players description");
            descrip = Console.ReadLine();

            /*
             * Console.WriteLine ( "Enter players text");
             * text  =  Console.ReadLine ();
             * Console.WriteLine ("Enter players description");
             * descrip  =  Console.ReadLine();*/

            Player player = new Player(text, descrip);

            Item item1 = new  Item(new  String[]
                                   { "item1" }, "an item", "The first item"); //item1

            Item item2 = new  Item(new String[]
                                   { "item2" }, "an item", "The second item"); //item2

            Bag bag = new  Bag(new String[] { "bag" }, "My bag", "first bag"); //bag

            Item item3 = new  Item(new String[]
                                   { "item3" }, "an item", "The third item"); //item3

            LookCommand look = new LookCommand(new string[] { "look" });      // LookCommand  look  =  new LookCommand(new string[] { "look" });


            player.Inventory.Put(item1); //item1

            player.Inventory.Put(item2); //item2

            /*player.Inventory.Put (item1);
            *  player.Inventory.Put (item2);*/

            player.Inventory.Put(bag);
            bag.Inventory.Put(item3);


            for (int x = 0; x < 10; x++)                                          //(int x = 0; x < 10; x++)
            {
                Console.WriteLine("Enter command, put spaces between the words"); //Console.WriteLine ("Enter command, put spaces between the words");
                n = Console.ReadLine();                                           // n = Console.ReadLine ();


                slist = n.Split(' ').ToList();

                option = slist.ToArray();
                /* option  =  slist.ToArray();*/

                Console.WriteLine(look.Execute(player, option));
            }
        }
Пример #3
0
 public void TestLookAtGem()
 {
     LookCommand test = new LookCommand ();
     Player testPlayer = new Player ("Player 1", "a funny wizard");
     testPlayer.Inventory.Put (new Item( new String[] {"gun", "rifle" }, "a gun", "This is a a long spirally grooved ..." ));
     Assert.AreEqual (test.Execute(testPlayer, new String[]{"look", "at", "gun", "in", "inventory"}),"This is a a long spirally grooved ...");
 }
Пример #4
0
        public static void Main(string[] args)
        {
            Player player = CreatePlayer();

            InitialisePlayerInventory(player);

            bool exit = false;
            var  cmd  = new LookCommand();

            while (!exit)
            {
                string   input = Console.ReadLine();
                string[] text  = input.Split(' ');

                if (text[0] == "exit")
                {
                    exit = true;
                }
                else
                {
                    string response = cmd.Execute(player, text);
                    Console.WriteLine(response);
                }
            }
        }
Пример #5
0
        private static void Main(string[] args)
        {
            Console.Write("please enter your name: ");
            string name = Console.ReadLine();

            Console.Write("please enter your description: ");
            string desc   = Console.ReadLine();
            Player player = new Player(name, desc);

            name = null;
            desc = null;
            Item item1 = new Item(new string[] { "item1" }, "item1", "this is item 1");
            Item item2 = new Item(new string[] { "item2" }, "item2", "this is item 2");

            player.Inventory.Put(item1);
            player.Inventory.Put(item2);
            Bag  bag   = new Bag(new string[] { "bag" }, "bag", "this is the bag");
            Item item3 = new Item(new string[] { "item3" }, "item3", "this is item 3");

            bag.Inventory.Put(item3);
            player.Inventory.Put(bag);
            Item     item4    = new Item(new string[] { "item4" }, "item4", "this is item 4");
            Location location = new Location(new string[] { "home" }, "home", "this is home");

            location.Inventory.Put(item4);
            player.Location = location;
            while (true)
            {
                Console.Write("Please enter your command here > ");
                string  commandText       = Console.ReadLine();
                Command command           = new LookCommand();
                var     commandText_split = commandText.Split(new char[] { ' ' });
                Console.WriteLine(command.Execute(player, commandText_split));
            }
        }
Пример #6
0
 public void TestLookAtNoGemInBag()
 {
     LookCommand test = new LookCommand ();
     Player testPlayer = new Player ("Player 1", "a funny wizard");
     Bag testBag = new Bag (new string[]{ "Bag", "Backpack" }, "a bag", "This is a bag for....");
     testPlayer.Inventory.Put (testBag);
     Assert.AreEqual (test.Execute(testPlayer, new String[]{"look", "at", "shovel", "in", "bag"}),"I cannot find the shovel in the bag");
 }
Пример #7
0
 public void TestInvalidLook()
 {
     LookCommand test = new LookCommand ();
     Player testPlayer = new Player ("Player 1", "a funny wizard");
     Assert.AreEqual (test.Execute(testPlayer, new String[]{"look", "around"}),"I don’t know how to look like that");
     Assert.AreEqual (test.Execute(testPlayer, new String[]{"Hello", "man", "there"}),"Error in look input");
     Assert.AreEqual (test.Execute(testPlayer, new String[]{"look", "at", "sth", "about", "me"}),"What do you want to look in?");
     Assert.AreEqual (test.Execute(testPlayer, new String[]{"look", "over", "that"}),"What do you want to look at?");
 }
Пример #8
0
        public void TestInvalidLook()
        {
            Player      TestPlayer = new Player("TestPlayer", "For testing");
            LookCommand TestLook   = new LookCommand();

            Assert.IsTrue(TestLook.Execute(TestPlayer, new string[1] {
                "hello"
            }) == "i don't know how to look like that");
        }
Пример #9
0
        [Test] // LOOK AT ME: Look returns player's description when looking at "inventory"
        public void LookAtMe()
        {
            LookCommand testLook   = new LookCommand();
            Player      testPlayer = new Player("Fred", "The Mighty Programmer");

            string actual   = testLook.Execute(testPlayer, new string[] { "Look", "at", "inventory" });
            string expected = testPlayer.ShortDescription;

            Assert.AreEqual(expected, actual, "Look At Me command not returning correct string");
        }
Пример #10
0
        [Test] // LOOK INVALID LOOK: Test look options to check all error conditions. For example: “look around”, or “hello”, “look at a at b”, etc.
        public void TestInvalidLookForAThing()
        {
            LookCommand testLook   = new LookCommand();
            Player      testPlayer = new Player("Fred", "The Mighty Programmer");

            string actual   = testLook.Execute(testPlayer, new string[] { "Look", "at", "a thing", "in ", "rubbish bin" });
            string expected = "What do you want to look in?";

            Assert.AreEqual(expected, actual, "Invalid Look command not returning expected result");
        }
Пример #11
0
        [Test] // LOOK INVALID LOOK: Test look options to check all error conditions. For example: “look around”, or “hello”, “look at a at b”, etc.
        public void TestInvalidLookWassup()
        {
            LookCommand testLook   = new LookCommand();
            Player      testPlayer = new Player("Fred", "The Mighty Programmer");

            string actual   = testLook.Execute(testPlayer, new string[] { "Wassssuuuuup" });
            string expected = "I don't know how to look like that";

            Assert.AreEqual(expected, actual, "Invalid Look command not returning expected result");
        }
Пример #12
0
        public void TestLookAtGemFail()
        {
            Player TestPlayer = new Player ("TestPlayer", "For testing");
            Item TestItem = new Item (new string[] { "baked", "potato" }, "Gem", "A Shiny Gem");

            TestPlayer.Inventory.PutItem (TestItem);

            LookCommand TestLook = new LookCommand ();

            Assert.IsFalse (TestLook.Execute (TestPlayer, new string[5] {"look", "at", "gem", "in", "TestPlayer"}) == TestItem.LongDesc);
        }
Пример #13
0
        [Test] // LOOK AT UNK: Returns "I can't find the gem" when the the player does not have a gem in their inventory.
        public void LookAtUnk()
        {
            LookCommand testLook   = new LookCommand();
            Player      testPlayer = new Player("Fred", "The Mighty Programmer");
            Item        gem        = new Item(new string[] { "Gem", "Shiny Gem" }, "a Gem", "A very shiny Gem");

            string actual   = testLook.Execute(testPlayer, new string[] { "Look", "at", "gem" });
            string expected = "I can't find the gem";

            Assert.AreEqual(expected, actual, "Look At Gem command not returning correct string");
        }
Пример #14
0
        [Test] // LOOK AT GEM IN ME: Returns the gem's description when looking at a gem in the player's inventory. "look at gem in inventory"
        public void LookAtGemInMe()
        {
            LookCommand testLook   = new LookCommand();
            Player      testPlayer = new Player("Fred", "The Mighty Programmer");
            Item        gem        = new Item(new string[] { "Gem", "Shiny Gem" }, "a Gem", "A very shiny Gem");

            testPlayer.Inventory.Put(gem);


            string actual   = testLook.Execute(testPlayer, new string[] { "Look", "at", "gem", "in", "inventory" });
            string expected = gem.ShortDescription;
        }
Пример #15
0
        public void TestLookAtGemInMe()
        {
            Player TestPlayer = new Player("TestPlayer", "For testing");
            Item   TestItem   = new Item(new string[] { "baked", "potato" }, "Gem", "A Shiny Gem");

            TestPlayer.Inventory.PutItem(TestItem);

            LookCommand TestLook = new LookCommand();

            Assert.IsTrue(TestLook.Execute(TestPlayer, new string[5] {
                "look", "at", "potato", "in", "me"
            }) == TestItem.LongDesc);
        }
Пример #16
0
        public void TestLookAtGemInBagFail()
        {
            Player TestPlayer = new Player ("TestPlayer", "For testing");
            Item TestItem = new Item (new string[] { "gem", "Shiny" }, "Gem", "A Shiny Gem");
            Bag TestBag = new Bag (new string[] { "bag", "test" }, "Test Bag", "A Testing Bag");

            TestBag.Inventory.PutItem (TestItem);
            TestPlayer.Inventory.PutItem (TestBag);

            LookCommand TestLook = new LookCommand ();

            Assert.IsTrue (TestLook.Execute (TestPlayer, new string[5] {"look", "at", "gem", "in", "nobag"}) == "i cannot find the nobag");
        }
Пример #17
0
        [Test] // LOOK AT GEM: Returns the gems description when looking at a gem in the player's inventory.
        public void LookAtGem()
        {
            LookCommand testLook   = new LookCommand();
            Player      testPlayer = new Player("Fred", "The Mighty Programmer");
            Item        gem        = new Item(new string[] { "Gem", "Shiny Gem" }, "Gem", "A very shiny Gem");

            testPlayer.Inventory.Put(gem);

            string actual   = testLook.Execute(testPlayer, new string[] { "Look", "at", "gem" });
            string expected = gem.ShortDescription;

            Assert.AreEqual(expected, actual, "Look At Gem command not returning correct string");
        }
Пример #18
0
        public void TestLookAtGem()
        {
            Player TestPlayer = new Player ("TestPlayer", "For testing");
            Item TestItem = new Item (new string[] { "gem", "Shiny" }, "Gem", "A Shiny Gem");

            TestPlayer.Inventory.PutItem (TestItem);

            LookCommand TestLook = new LookCommand ();

            Console.WriteLine (TestLook.Execute (TestPlayer, new string[3] {"look", "at", "gem"}));

            Assert.IsTrue (TestLook.Execute (TestPlayer, new string[3] {"look", "at", "gem"}) == TestItem.LongDesc);
        }
Пример #19
0
        static void Main(string[] args)
        {
            Console.WriteLine("Welcome to Swin Adventure!");
            Console.Write("Enter your player name: ");
            string name = Console.ReadLine();

            Console.Write("Enter your player description: ");
            string description = Console.ReadLine();
            Player player      = new Player(name, description);

            string[] identsGun = { "Weapon", "BFG", "Rocket Launcher" };

            Item weapon = new Item(identsGun,
                                   "Big Friggin Gun",
                                   "The biggest gun available in the game"
                                   );

            string[] identsArmour = { "Armour", "Platemail", "Heavy Armour" };
            Item     armour       = new Item(identsArmour,
                                             "Illidan's Plated Glory",
                                             "Tier 9 Epic Plate Mail"
                                             );

            player.Inventory.Put(weapon);
            player.Inventory.Put(armour);

            string[] identsBag = new[] { "bag", "backpack" };
            Bag      bag       = new Bag(identsBag, "Netherweave Bag", "A hand crafted elven bag.");

            player.Inventory.Put(bag);

            string[] identsConsumables = { "Food", "Consumable", "Health Regeneration" };
            Item     food = new Item(identsConsumables,
                                     "Kiwifruit Pie",
                                     "Heals Player on consumption for 2000 hp over 12 seconds"
                                     );

            bag.Inventory.Put(food);

            Console.WriteLine("Type 'quit' to exit.");
            string[] choiceList = new[] { "" };
            while (choiceList[0] != "quit")
            {
                LookCommand look = new LookCommand();
                Console.Write("Command - > ");
                string choice = Console.ReadLine();
                choiceList = choice.Split(" ");
                Console.Write(look.Execute(player, choiceList));
            }
        }
        public void LookTest()
        {
            Player TestPlayer = new Player ("TestPlayer", "For testing");

            LookCommand TestLook = new LookCommand ();

            CommandProcessor TestProcessor = new CommandProcessor ();

            TestProcessor.AddCommand (TestLook);

            Console.WriteLine(TestProcessor.Execute(TestPlayer, new string[3] {"look", "at", "me"}) );

            Assert.IsTrue (TestProcessor.Execute (TestPlayer, new string[3] {"look", "at", "me"}) == TestPlayer.LongDesc);
        }
Пример #21
0
        public CommandProcessor(List <Location> locations)
        {
            LookCommand      look      = new LookCommand();
            MoveCommand      move      = new MoveCommand(locations);
            PutCommand       put       = new PutCommand();
            TakeCommand      take      = new TakeCommand();
            InventoryCommand inventory = new InventoryCommand();

            _commands.Add(look);
            _commands.Add(move);
            _commands.Add(put);
            _commands.Add(take);
            _commands.Add(inventory);
        }
Пример #22
0
        public void TestLookAtMe()
        {
            Player TestPlayer = new Player("TestPlayer", "For testing");

            LookCommand TestLook = new LookCommand();

            Console.WriteLine(TestLook.Execute(TestPlayer, new string[3] {
                "look", "at", "me"
            }));

            Assert.IsTrue(TestLook.Execute(TestPlayer, new string[3] {
                "look", "at", "me"
            }) == TestPlayer.LongDesc);
        }
Пример #23
0
        [Test] // LOOK AT GEM IN NO BAG: Returns "I can't find the bag" when the player does not have a bag in their inventory.
        public void LookAtGemInNoBag()
        {
            LookCommand testLook   = new LookCommand();
            Player      testPlayer = new Player("Fred", "The Mighty Programmer");
            Item        gem        = new Item(new string[] { "gem", "Shiny Gem" }, "a Gem", "A very shiny Gem");
            Bag         testBag    = new Bag(new string[] { "bag", "container" }, "a Bag", "A Container for items");

            testBag.Inventory.Put(gem);
            //testPlayer.Inventory.Put(testBag);

            string actual   = testLook.Execute(testPlayer, new string[] { "Look", "at", "gem", "in", "bag" });
            string expected = "I can't find the bag";

            Assert.AreEqual(expected, actual, "Look At Gem when Player doesn't have bag, command not returning correct string");
        }
Пример #24
0
        public void TestLookAtGemInBagFail()
        {
            Player TestPlayer = new Player("TestPlayer", "For testing");
            Item   TestItem   = new Item(new string[] { "gem", "Shiny" }, "Gem", "A Shiny Gem");
            Bag    TestBag    = new Bag(new string[] { "bag", "test" }, "Test Bag", "A Testing Bag");

            TestBag.Inventory.PutItem(TestItem);
            TestPlayer.Inventory.PutItem(TestBag);

            LookCommand TestLook = new LookCommand();

            Assert.IsTrue(TestLook.Execute(TestPlayer, new string[5] {
                "look", "at", "gem", "in", "nobag"
            }) == "i cannot find the nobag");
        }
Пример #25
0
        public void MultipleCommandTest()
        {
            Player   TestPlayer    = new Player("TestPlayer", "For testing");
            Location TestLocation  = new Location(new string[] { "potato", "farm" }, "potato farm", "a potato farm");
            Location TestLocation2 = new Location(new string[] { "melon", "farm" }, "melon farm", "a melon farm");
            Location TestLocation3 = new Location(new string[] { "tomato", "farm" }, "tomato farm", "a tomato farm");

            Path TestPath  = new Path(new string[] { "potato", "path" });
            Path TestPath2 = new Path(new string[] { "melon", "path" });
            Path TestPath3 = new Path(new string[] { "tomato", "path" });


            TestLocation.Path = TestPath;
            TestPath.SetLocation('w', TestLocation2);
            TestPath.SetLocation('n', TestLocation3);

            TestLocation2.Path = TestPath2;
            TestPath2.SetLocation('e', TestLocation);
            TestPath2.SetLocation('a', TestLocation3);

            TestLocation3.Path = TestPath3;
            TestPath3.SetLocation('s', TestLocation);
            TestPath3.SetLocation('d', TestLocation2);

            TestPlayer.Location = TestLocation;


            MoveCommand      TestMove      = new  MoveCommand();
            LookCommand      TestLook      = new LookCommand();
            CommandProcessor TestProcessor = new CommandProcessor();

            TestProcessor.AddCommand(TestMove);

            TestProcessor.AddCommand(TestLook);

            Assert.IsTrue(TestProcessor.Execute(TestPlayer, new string[3] {
                "look", "at", "me"
            }) == TestPlayer.LongDesc);
            Assert.IsTrue(TestProcessor.Execute(TestPlayer, new string[3] {
                "move", "to", "west"
            }) == TestLocation2.LongDesc);
            Assert.IsTrue(TestProcessor.Execute(TestPlayer, new string[3] {
                "move", "to", "north_east"
            }) == TestLocation3.LongDesc);
        }
Пример #26
0
        public void LookTest()
        {
            Player TestPlayer = new Player("TestPlayer", "For testing");

            LookCommand TestLook = new LookCommand();

            CommandProcessor TestProcessor = new CommandProcessor();

            TestProcessor.AddCommand(TestLook);

            Console.WriteLine(TestProcessor.Execute(TestPlayer, new string[3] {
                "look", "at", "me"
            }));

            Assert.IsTrue(TestProcessor.Execute(TestPlayer, new string[3] {
                "look", "at", "me"
            }) == TestPlayer.LongDesc);
        }
Пример #27
0
        public void TestLookAtGem()
        {
            Player TestPlayer = new Player("TestPlayer", "For testing");
            Item   TestItem   = new Item(new string[] { "gem", "Shiny" }, "Gem", "A Shiny Gem");

            TestPlayer.Inventory.PutItem(TestItem);

            LookCommand TestLook = new LookCommand();

            Console.WriteLine(TestLook.Execute(TestPlayer, new string[3] {
                "look", "at", "gem"
            }));


            Assert.IsTrue(TestLook.Execute(TestPlayer, new string[3] {
                "look", "at", "gem"
            }) == TestItem.LongDesc);
        }
Пример #28
0
        public static void Main(string[] args)
        {
            string _playerName;
            string _playerDesc;
            LookCommand _lookCommand = new LookCommand ();

            Console.WriteLine ("Welcome to Swin-Adventure");
            Console.WriteLine ("+―++―++―++―++―++―++―+\r\n");
            Console.WriteLine ("Please enter your name:");
            _playerName = Console.ReadLine();
            Console.WriteLine ("Please enter your description:");
            _playerDesc = Console.ReadLine();

            Player _player = new Player (_playerName, _playerDesc);
            _player.Inventory.Put(new Item( new String[] {"map" }, "an incomplete map", "This is an incomplete map of......" ));
            _player.Inventory.Put(new Item( new String[] {"gun", "rifle" }, "a gun", "This is a a long spirally grooved ..." ));
            Bag _bag = new Bag (new string[]{"Bag", "Backpack"}, "a bag", "This is a bag for....");
            Item item1 = new Item( new String[] {"shovel", "spade" }, "a shovel", "This is a might fine ..." );
            _bag.Inventory.Put (item1);
            _player.Inventory.Put (_bag);

            string _command;
            string _output;
            String[] _commandArr;

            do {
                Console.WriteLine ("Enter a command or enter 'exit' to exit the game");
                _command = Console.ReadLine ();
                if (_command.ToLower () == "exit") {
                    Console.WriteLine ("Press enter to exit");
                    Console.ReadLine ();
                    break;
                } else {

                    _commandArr = ToStringArray (_command);
                    _output = _lookCommand.Execute (_player, _commandArr);
                    Console.WriteLine (_output);
                }
            } while (_command.ToLower () != "exit");
        }
        public void MultipleCommandTest()
        {
            Player TestPlayer = new Player ("TestPlayer", "For testing");
            Location TestLocation = new Location (new string[] { "potato", "farm" }, "potato farm", "a potato farm");
            Location TestLocation2 = new Location (new string[] { "melon", "farm" }, "melon farm", "a melon farm");
            Location TestLocation3 = new Location (new string[] { "tomato", "farm" }, "tomato farm", "a tomato farm");

            Path TestPath = new Path(new string[] { "potato", "path" });
            Path TestPath2 = new Path(new string[] { "melon", "path" });
            Path TestPath3 = new Path(new string[] { "tomato", "path" });

            TestLocation.Path = TestPath;
            TestPath.SetLocation('w', TestLocation2);
            TestPath.SetLocation('n', TestLocation3);

            TestLocation2.Path = TestPath2;
            TestPath2.SetLocation('e', TestLocation);
            TestPath2.SetLocation('a', TestLocation3);

            TestLocation3.Path = TestPath3;
            TestPath3.SetLocation('s', TestLocation);
            TestPath3.SetLocation('d', TestLocation2);

            TestPlayer.Location = TestLocation;

            MoveCommand TestMove = new  MoveCommand ();
            LookCommand TestLook = new LookCommand ();
            CommandProcessor TestProcessor = new CommandProcessor ();

            TestProcessor.AddCommand (TestMove);

            TestProcessor.AddCommand (TestLook);

            Assert.IsTrue (TestProcessor.Execute (TestPlayer, new string[3] {"look", "at", "me"}) == TestPlayer.LongDesc);
            Assert.IsTrue (TestProcessor.Execute (TestPlayer, new string[3] {"move", "to","west"}) == TestLocation2.LongDesc);
            Assert.IsTrue (TestProcessor.Execute (TestPlayer, new string[3] {"move", "to","north_east"}) == TestLocation3.LongDesc);
        }
Пример #30
0
 public void TestLookAtGemInNoBag()
 {
     LookCommand test = new LookCommand ();
     Player testPlayer = new Player ("Player 1", "a funny wizard");
     Assert.AreEqual (test.Execute(testPlayer, new String[]{"look", "at", "shovel", "in", "bag"}),"I cannot find the bag");
 }
Пример #31
0
 public void TestLookAtMe()
 {
     LookCommand test = new LookCommand ();
     Player testPlayer = new Player ("Player 1", "a funny wizard");
     Assert.AreEqual (test.Execute(testPlayer, new String[]{"look", "at", "inventory"}),"You are carrying nothing");
 }
Пример #32
0
 public void TestLookAtUnk()
 {
     LookCommand test = new LookCommand ();
     Player testPlayer = new Player ("Player 1", "a funny wizard");
     Assert.AreEqual (test.Execute(testPlayer, new String[]{"look", "at", "gun"}),"I cannot find the gun");
 }
Пример #33
0
        public void TestLookAtMe()
        {
            Player TestPlayer = new Player ("TestPlayer", "For testing");

            LookCommand TestLook = new LookCommand ();

            Console.WriteLine(TestLook.Execute(TestPlayer, new string[3] {"look", "at", "me"}) );

            Assert.IsTrue (TestLook.Execute (TestPlayer, new string[3] {"look", "at", "me"}) == TestPlayer.LongDesc);
        }
Пример #34
0
        public static void Main(string[] args)
        {
            //Get the player's name and description from the user, and use these details to create a
            //Player object.
            //■ Create two items and add them to the the player's inventory
            //■ Create a bag and add it to the player's inventory
            //■ Create another item and add it to the bag
            //■ Loop reading commands from the user, and getting the look command to execute them.
            Console.WriteLine("Enter Player Name:");
            string Name = Console.ReadLine();

            Console.WriteLine("Describe yourself:");
            string Desc = Console.ReadLine();

            Player GamePlayer = new Player(Name, Desc);
            Item   Sword      = new Item(new string[] { "Sword", "broadsword" }, "sword", "a broadsword");
            Item   Potato     = new Item(new string[] { "potato", "baked" }, "baked potato", "a baked potato");

            GamePlayer.Inventory.PutItem(Sword);
            GamePlayer.Inventory.PutItem(Potato);

            Bag Bag1 = new Bag(new string[] { "Test", "Bag" }, "Test Bag", "A Testing Bag");

            GamePlayer.Inventory.PutItem(Bag1);

            Item Gem = new Item(new string[] { "gem", "Shiny" }, "Gem", "A Shiny Gem");

            Bag1.Inventory.PutItem(Gem);

            Location PotatoFarm = new Location(new string[] { "potato", "farm" }, "potato farm", "a potato farm");
            Location MelonFarm  = new Location(new string[] { "melon", "farm" }, "melon farm", "a melon farm");
            Location TomatoFarm = new Location(new string[] { "tomato", "farm" }, "tomato farm", "a tomato farm");

            Path PotatoPath = new Path(new string[] { "potato", "path" });
            Path MelonPath  = new Path(new string[] { "melon", "path" });
            Path TomatoPath = new Path(new string[] { "tomato", "path" });


            PotatoFarm.Path = PotatoPath;
            PotatoPath.SetLocation('w', MelonFarm);
            PotatoPath.SetLocation('n', TomatoFarm);

            MelonFarm.Path = MelonPath;
            MelonPath.SetLocation('e', PotatoFarm);
            MelonPath.SetLocation('a', TomatoFarm);

            TomatoFarm.Path = TomatoPath;
            TomatoPath.SetLocation('s', PotatoFarm);
            TomatoPath.SetLocation('d', MelonFarm);

            GamePlayer.Location = PotatoFarm;

            CommandProcessor MainCommandProcessor = new CommandProcessor();
            LookCommand      Look = new LookCommand();
            MoveCommand      Move = new MoveCommand();

            MainCommandProcessor.AddCommand(Look);
            MainCommandProcessor.AddCommand(Move);

            do
            {
                Console.WriteLine("Enter Command:");
                string   UserInput = Console.ReadLine();
                String[] Command   = UserInput.Split(' ');

                Console.WriteLine(MainCommandProcessor.Execute(GamePlayer, Command));
            }while(true);
        }
Пример #35
0
        public static void Main(string[] args)
        {
            //Get the player's name and description from the user, and use these details to create a
            //Player object.
            //■ Create two items and add them to the the player's inventory
            //■ Create a bag and add it to the player's inventory
            //■ Create another item and add it to the bag
            //■ Loop reading commands from the user, and getting the look command to execute them.
            Console.WriteLine("Enter Player Name:");
            string Name = Console.ReadLine();
            Console.WriteLine ("Describe yourself:");
            string Desc = Console.ReadLine();

            Player GamePlayer = new Player (Name, Desc);
            Item Sword = new Item (new string[] { "Sword", "broadsword" }, "sword", "a broadsword");
            Item Potato = new Item (new string[] { "potato", "baked" }, "baked potato", "a baked potato");

            GamePlayer.Inventory.PutItem (Sword);
            GamePlayer.Inventory.PutItem (Potato);

            Bag Bag1 = new Bag (new string[] { "Test", "Bag" }, "Test Bag", "A Testing Bag");

            GamePlayer.Inventory.PutItem (Bag1);

            Item Gem = new Item (new string[] { "gem", "Shiny" }, "Gem", "A Shiny Gem");
            Bag1.Inventory.PutItem (Gem);

            Location PotatoFarm = new Location (new string[] { "potato", "farm" }, "potato farm", "a potato farm");
            Location MelonFarm = new Location (new string[] { "melon", "farm" }, "melon farm", "a melon farm");
            Location TomatoFarm = new Location (new string[] { "tomato", "farm" }, "tomato farm", "a tomato farm");

            Path PotatoPath = new Path(new string[] { "potato", "path" });
            Path MelonPath = new Path(new string[] { "melon", "path" });
            Path TomatoPath = new Path(new string[] { "tomato", "path" });

            PotatoFarm.Path = PotatoPath;
            PotatoPath.SetLocation('w', MelonFarm);
            PotatoPath.SetLocation('n', TomatoFarm);

            MelonFarm.Path = MelonPath;
            MelonPath.SetLocation('e', PotatoFarm);
            MelonPath.SetLocation('a', TomatoFarm);

            TomatoFarm.Path = TomatoPath;
            TomatoPath.SetLocation('s', PotatoFarm);
            TomatoPath.SetLocation('d', MelonFarm);

            GamePlayer.Location = PotatoFarm;

            CommandProcessor MainCommandProcessor = new CommandProcessor();
            LookCommand Look = new LookCommand ();
            MoveCommand Move = new MoveCommand ();

            MainCommandProcessor.AddCommand (Look);
            MainCommandProcessor.AddCommand (Move);

            do
            {
                Console.WriteLine("Enter Command:");
                string UserInput = Console.ReadLine();
                String[] Command = UserInput.Split(' ');

                Console.WriteLine(MainCommandProcessor.Execute(GamePlayer,Command));

            }while(true);
        }