Example #1
0
        public string SearchBasic(string objectName = null)
        {
            List <IItem> itemsInRoom = GetItems();

            // FLOW::
            // 1) If there are no items in the room, return default "no items to be found" string
            // 2) If the room has been searched, return the default "You see . . ." string appended to the list of the available items.
            // 3) If the room has NOT been searched, return the Room's "first-search-string" appended to the list of the available items.

            // 1
            string searchResults = GameStrings.NoItemsInRoom;

            if (itemsInRoom.Count > 0)
            {
                var itemsStringList = InventoryService.ConvertItemsInListToString(itemsInRoom);
                // 2
                if (HasBeenSearched == true)
                {
                    searchResults = RoomDescriptions.DefaultSearchDescription; // TODO: implement items-to-list
                }

                // 3
                else
                {
                    HasBeenSearched = true;
                    searchResults   = FirstSearchDescription; // TODO: implement items-to-list
                }

                searchResults += itemsStringList;
            }
            if (monster != null)
            {
                if (monster.isDead())
                {
                    searchResults += $"\nThere is a dead {monster.name} here.";
                }
                else
                {
                    searchResults += $"\nThere is a {monster.name} here.";
                }
            }
            //        ArrayList<iItem> itemsInRoom = this.getItems();
            //        if (itemsInRoom.isEmpty())
            //        {
            //            return "There are no items to be found here.";
            //        }
            //        if (!this.hasBeenSearched)
            //        {
            //            this.hasBeenSearched = true;
            //            return Shared.appendDescriptionToItemsString(
            //                    this.firstSearchDescription, itemsInRoom);
            //        }

            //        return Shared.appendDescriptionToItemsString(
            //                    RoomDescriptions.defaultSearchDescription, itemsInRoom);
            return(searchResults);
        }
Example #2
0
        public string ShowInventory()
        {
            string inventory = "You have no items in your inventory.";

            if (_inventory == null)
            {
                // This is an error state, and a confusing one
                inventory = "Null inventory??";
            }
            else if (_inventory.Count > 0)
            {
                inventory = "Player inventory:\n" + InventoryService.ConvertItemsInListToString(_inventory);
                //if (limitedInventory)
                //{
                //    inventory += "\nRemaining space: " + Double.toString(_remainingInventorySpace);
                //}
            }
            return(inventory);
        }