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

            Assert.AreEqual(expected, actual, "Test player can locate themselves");
        }
        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);
        }
Exemple #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);
        }
Exemple #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);
 }
Exemple #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.");
        }
        public void LocatePlayerTest()
        {
            Player TestPlayer = new Player ("TestPlayer", "For testing");

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

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

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

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

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

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

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

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

            return(p.Locate(containerId) as IHaveInventory);
        }
Exemple #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.");
        }
Exemple #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.");
        }
Exemple #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.");
        }
Exemple #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;
        }
Exemple #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);
        }
        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");
        }
Exemple #21
0
 public void TestLocatesItself()
 {
     Player test = new Player ("Player 1", "a funny wizard");
     Assert.AreEqual (test.Locate("me"),test);
 }
Exemple #22
0
 public void TestLocatesNothing()
 {
     Player test = new Player ("Player 1", "a funny wizard");
     Assert.AreEqual (test.Locate("123"),null);
 }
Exemple #23
0
 public void TestPlayerLocateItemsLocation()
 {
     Assert.AreEqual(_testGem, _testPlayer.Locate("gem"));
 }
Exemple #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");
        }
Exemple #26
0
 private IHaveInventory FetchContainer(Player p, string containerid)
 {
     return(p.Locate(containerid) as IHaveInventory);
 }
Exemple #27
0
        private IHasInventory FetchContainer(Player p, string containerId)
        {
            GameObject container = p.Locate(containerId);

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