Пример #1
0
        public static void TryTakingItem(string itemName)
        {
            List <IItem> itemsInRoom = CurrentRoom.GetItems();

            if (itemsInRoom == null)
            {
                IO.OutputNewLine(GameStrings.NoItemsSeen);
            }
            else
            {
                foreach (IItem item in itemsInRoom)
                {
                    if (item.GetName() == itemName)
                    {
                        // remove the item from the room if taken by player
                        if (Player.TakeItem(item))
                        {
                            CurrentRoom.RemoveItem(item);
                            return;
                        }
                        return;
                    }
                }
            }
            IO.OutputNewLine(GameStrings.NoItemAvailable);
        }