Beispiel #1
0
        public void Test_Add_AddsItemToInventory()
        {
            //Arrange
            PC testPC = new PC("Crom");

            testPC.Save();

            Item testItem = new Item("Sword");

            testItem.Save();

            Item testItem2 = new Item("Torch");

            testItem2.Save();

            //Act
            testPC.AddItemToPC(testItem);
            testPC.AddItemToPC(testItem2);

            List <Item> result   = testPC.GetItems();
            List <Item> testList = new List <Item> {
                testItem, testItem2
            };

            //Assert
            CollectionAssert.AreEqual(testList, result);
        }
Beispiel #2
0
        public ActionResult SelectItem(int pcId, int roomId, int itemId)
        {
            PC          newPC    = PC.Find(pcId);
            List <Item> newItem  = newPC.GetItems();
            Item        tempItem = Item.Find(itemId);

            newPC.AddItemToPC(Item.Find(itemId));
            tempItem.RemoveFromContents(itemId);

            // newPC.SetRoomId(pcId);
            Dictionary <int, int[]> myMap      = new Dictionary <int, int[]> {
            };
            Dictionary <string, object> myGame = new Dictionary <string, object> {
                { "room", Room.Find(newPC.GetRoomId()) }
            };

            //           Dictionary<string, object> myGame = new Dictionary<string, object>{"room", Room.Find(PC.GetRoomId()) };
            myGame.Add("pc", PC.Find(newPC.GetId()));
            myGame.Add("npc", Game.GetAllNPCs(newPC.GetRoomId()));
            myGame.Add("item", Game.GetAllItems(newPC.GetRoomId()));

            myGame.Add("command", Room.Find(newPC.GetRoomId()).GetCommands());

            myMap = Game.GetMap();
            myGame.Add("map", myMap);
            myGame.Add("stuff", newItem);

            return(View("Select", myGame));
        }