public void TestPlayerLocatesThemselves()
        {
            GameObject expected = p;
            GameObject actual   = p.Locate("me");

            Assert.AreEqual(expected, actual, "Test player can locate themselves");
        }
Exemplo n.º 2
0
        public void LocateItemsTest()
        {
            Player TestPlayer = new Player ("TestPlayer", "For testing");
            Item TestItem = new Item (new string[] { "potato", "baked" }, "baked potato", "a baked potato");

            TestPlayer.Inventory.PutItem (TestItem);

            //Assert.IsTrue (TestPlayer.Locate ("TestPlayer")== TestPlayer);

            Assert.IsTrue (TestPlayer.Locate ("potato") == TestItem);
            Assert.IsTrue (TestPlayer.Locate ("potato") == TestItem);
        }
Exemplo n.º 3
0
        public void LocateItemsTest()
        {
            Player TestPlayer = new Player("TestPlayer", "For testing");
            Item   TestItem   = new Item(new string[] { "potato", "baked" }, "baked potato", "a baked potato");

            TestPlayer.Inventory.PutItem(TestItem);

            //Assert.IsTrue (TestPlayer.Locate ("TestPlayer")== TestPlayer);

            Assert.IsTrue(TestPlayer.Locate("potato") == TestItem);
            Assert.IsTrue(TestPlayer.Locate("potato") == TestItem);
        }
Exemplo n.º 4
0
 public void TestLocatesItem()
 {
     Player test = new Player ("Player 1", "a funny wizard");
     Item item1 = new Item( new String[] {"shovel", "spade" }, "a shovel", "This is a might fine ..." );
     test.Inventory.Put (item1);
     Assert.AreEqual(test.Locate ("shovel"),item1);
 }
Exemplo n.º 5
0
        [Test] // LOCATE: The Player returns itself if asked to locate "me" or "inventory":
        public void testLocatePlayerOrInventory()
        {
            Player     testPlayer       = new Player("Fred", "The Mighty Programmer");
            GameObject locatedPlayer    = testPlayer.Locate("me");
            GameObject locatedInventory = testPlayer.Locate("inventory");
            bool       actual           = false;

            if (locatedPlayer == testPlayer && locatedInventory != null)
            {
                actual = true;
            }

            bool expected = true;

            Assert.AreEqual(expected, actual, "Player is not returning itself or its inventory correctly.");
        }
Exemplo n.º 6
0
        public void LocatePlayerTest()
        {
            Player TestPlayer = new Player ("TestPlayer", "For testing");

            //Assert.IsTrue (TestPlayer.Locate ("TestPlayer")== TestPlayer);

            Assert.IsTrue (TestPlayer.Locate ("me") == TestPlayer);
        }
Exemplo n.º 7
0
        public void LocateNothingTest()
        {
            Player TestPlayer = new Player("TestPlayer", "For testing");

            //Assert.IsTrue (TestPlayer.Locate ("TestPlayer")== TestPlayer);

            Assert.IsTrue(TestPlayer.Locate("potato") == null);
        }
Exemplo n.º 8
0
        public void LocatePlayerTest()
        {
            Player TestPlayer = new Player("TestPlayer", "For testing");

            //Assert.IsTrue (TestPlayer.Locate ("TestPlayer")== TestPlayer);

            Assert.IsTrue(TestPlayer.Locate("me") == TestPlayer);
        }
Exemplo n.º 9
0
        public void LocateNothingTest()
        {
            Player TestPlayer = new Player ("TestPlayer", "For testing");

            //Assert.IsTrue (TestPlayer.Locate ("TestPlayer")== TestPlayer);

            Assert.IsTrue (TestPlayer.Locate ("potato") == null);
        }
Exemplo n.º 10
0
        public IHaveInventory FetchContainer(Player p, string containerId)
        {
            if (p.AreYou(containerId))
            {
                return(p);
            }

            return(p.Locate(containerId) as IHaveInventory);
        }
Exemplo n.º 11
0
        [Test] // LOCATE: The Player returns a null if asked to locate something it does not have
        public void TestLocateNot()
        {
            Player testPlayer = new Player("Fred", "The Mighty Programmer");

            GameObject actual   = testPlayer.Locate("non-existent item");
            GameObject expected = null;

            Assert.AreEqual(expected, actual, "Player has retrieved a non-existent item from inventory.");
        }
Exemplo n.º 12
0
 public void TestPlayerLocateinLocation()
 {
     Player test = new Player ("Player 1", "a funny wizard");
     Locations testLocation = new Locations("park","a nice park which is ...");
     Item item1 = new Item( new String[] {"shovel", "spade" }, "a shovel", "This is a might fine ..." );
     testLocation.Inventory.Put (item1);
     test.Location = testLocation;
     Assert.AreEqual (test.Location,testLocation);
     Assert.AreEqual (test.Locate("shovel"),item1);
 }
        public void TestPlayerCanLocateItems()
        {
            Loc.Inventory.Put(Itm);
            P.Location = Loc;

            GameObject expected = Itm;
            GameObject actual   = P.Locate(Itm.FirstID);

            Assert.AreEqual(expected, actual);
        }
        private IHaveInventory FetchContainer(Player p, string containerId)
        {
            GameObject obj = p.Locate(containerId);

            if (obj == null && p.Location.AreYou(containerId))
            {
                obj = p.Location;
            }
            IHaveInventory container = obj as IHaveInventory;

            return(container);
        }
        [Test] // PLAYERS CAN LOCATE ITEMS IN THEIR LOCATION:
        public void PlayerCanLocateItemsInLocation()
        {
            Location testLocation = new Location("room", "a large room");
            Player   andrew       = new Player("Andrew", "HD Student");
            Item     sword        = new Item(new string[] { "sword", "bronze sword" }, "a Sword", "A mighty fine Sword");

            testLocation.Inventory.Put(sword);
            andrew.Location = testLocation;

            GameObject actual   = andrew.Locate("sword");
            GameObject expected = sword;

            Assert.AreEqual(expected, actual, "Player not able to locate items in Player's location correctly.");
        }
Exemplo n.º 16
0
        [Test] // LOCATE: The Player can locate items in its inventory
        public void TestLocateItems()
        {
            Player testPlayer = new Player("Fred", "The Mighty Programmer");
            Item   testItem   = new Item(new string[] { "a TestFirstId", "TestSecondId" }, "TestName", "TestDesc");

            testPlayer.Inventory.Put(testItem);

            // Locate the item and store in GameObject:
            GameObject locatedItem = testPlayer.Locate("TestName");

            // Search Inventory for item:
            bool actual = testPlayer.Inventory.HasItem("a testfirstid");

            bool expected = true;

            Assert.AreEqual(expected, actual, "Item in Players Inventory is not locating correctly.");
        }
Exemplo n.º 17
0
        /// <summary>
        /// Looks at in.
        /// </summary>
        private string LookAtIn(Player p, string thingId, string containerId)
        {
            string output = "";
            GameObject obj= p.Locate (containerId);

            if (obj != null) {
                IHaveInventory container = obj as IHaveInventory;
                if (container.Locate (thingId) != null) {
                    output = container.Locate (thingId).FullDescription;
                } else {
                    if (containerId == "inventory") {
                        output = "I cannot find the " + thingId;
                    } else {
                        output = "I cannot find the " + thingId + " in the " + containerId;
                    }
                }
            } else {
                output = "I cannot find the " + containerId;
            }
            return output;
        }
Exemplo n.º 18
0
        public string LookAtIn(Player p, string thingId, string containerId)
        {
            if (p.AreYou(thingId))
            {
                return(p.LongDesc);
            }

            GameObject     wantedItem      = null;
            IHaveInventory wantedInventory = p.Locate(containerId) as IHaveInventory;

            if (p.AreYou(containerId) || containerId == "")
            {
                wantedInventory = (IHaveInventory)p;
                //return p.LongDesc;
            }

            if (wantedInventory == null)
            {
                return("i cannot find the " + containerId);
            }

            wantedItem = wantedInventory.Locate(thingId);

            if (wantedItem == null)
            {
                if (containerId == "")
                {
                    return("i cannot find the " + thingId);
                }
                else
                {
                    return("i cannot find the " + thingId + " in " + containerId);
                }
            }

            return(wantedItem.LongDesc);
        }
Exemplo n.º 19
0
        public string LookAtIn(Player p, string thingId, string containerId)
        {
            if (p.AreYou(thingId))
            {
                return p.LongDesc;
            }

            GameObject wantedItem = null;
            IHaveInventory wantedInventory = p.Locate(containerId) as IHaveInventory;

            if (p.AreYou (containerId) || containerId == "")
            {
                wantedInventory = (IHaveInventory)p;
                //return p.LongDesc;
            }

            if (wantedInventory == null)
            {
                return "i cannot find the " + containerId;
            }

            wantedItem = wantedInventory.Locate (thingId);

            if (wantedItem == null)
            {
                if (containerId == "")
                {
                    return "i cannot find the " + thingId;
                }
                else
                {
                    return "i cannot find the " + thingId + " in " + containerId;
                }
            }

            return wantedItem.LongDesc;
        }
        public void TestLocatesNothing()
        {
            Player plr = new Player("name", "cool guy");

            Assert.IsNull(plr.Locate("obj1"), "should be null");
        }
Exemplo n.º 21
0
 public void TestLocatesItself()
 {
     Player test = new Player ("Player 1", "a funny wizard");
     Assert.AreEqual (test.Locate("me"),test);
 }
Exemplo n.º 22
0
 public void TestLocatesNothing()
 {
     Player test = new Player ("Player 1", "a funny wizard");
     Assert.AreEqual (test.Locate("123"),null);
 }
Exemplo n.º 23
0
 public void TestPlayerLocateItemsLocation()
 {
     Assert.AreEqual(_testGem, _testPlayer.Locate("gem"));
 }
Exemplo n.º 24
0
 private IHaveInventory FetchContainer(Player p, string containerId)
 {
     return((IHaveInventory)p.Locate(containerId));
 }
        public void TestPlayerLocatesSelf()
        {
            Player plr = new Player("name", "cool guy");

            Assert.AreEqual(plr.Locate("me"), plr, "should be equal");
        }
Exemplo n.º 26
0
 private IHaveInventory FetchContainer(Player p, string containerid)
 {
     return(p.Locate(containerid) as IHaveInventory);
 }
Exemplo n.º 27
0
        private IHasInventory FetchContainer(Player p, string containerId)
        {
            GameObject container = p.Locate(containerId);

            return(container as IHasInventory);
        }
Exemplo n.º 28
-39
 public void TestPlayerLocateNothing()
 {
     Assert.AreEqual(_player1.Locate("service"), null);
 }