Esempio n. 1
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?");
 }
        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);
        }
        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");
        }
Esempio n. 4
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 ...");
 }
Esempio n. 5
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");
 }
        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);
        }
        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");
        }
Esempio n. 8
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 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);
        }
Esempio n. 10
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");
 }
Esempio n. 11
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");
 }
Esempio n. 12
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");
 }