Esempio n. 1
0
        /// <summary>
        /// Gets a list of all the items in the room.
        /// </summary>
        public string GetItemDetails()
        {
            string returnString = this.Formatter.Bold("Objects:");

            // Check if the character already exists or not.
            if ((this.RoomItems != null) && (this.RoomItems.Count > 0))
            {
                List <ItemCountObject> items = SMItemUtils.GetItemCountList(this.RoomItems);

                foreach (ItemCountObject item in items)
                {
                    string itemDetails = $"{item.Count} x ";

                    if (item.Count > 1)
                    {
                        itemDetails += item.PluralName;
                    }
                    else
                    {
                        itemDetails += item.SingularName;
                    }

                    returnString += this.Formatter.ListItem(itemDetails);
                }
            }
            else
            {
                returnString += this.Formatter.ListItem("Nothing");
            }

            return(returnString);
        }
Esempio n. 2
0
        /// <summary>
        /// Gets the items listing of a given container in a string ready for outputting.
        /// </summary>
        /// <param name="container">Container SMItem to get the listings for.</param>
        /// <returns>Containers item listings.</returns>
        public static string GetContainerContents(SMItem container)
        {
            // Return null it not a container
            if (!container.CanHoldOtherItems())
            {
                return(null);
            }

            // If the container is empty
            if (container.HeldItems == null || !container.HeldItems.Any())
            {
                return(OutputFormatterFactory.Get().Italic("Empty"));
            }

            // Get list of item counts
            // TODO bring this functionality into this class
            List <ItemCountObject> lines = SMItemUtils.GetItemCountList(container.HeldItems);

            string output = "";

            foreach (ItemCountObject line in lines)
            {
                string itemDetails = $"{line.Count} x ";

                if (line.Count > 1)
                {
                    itemDetails += line.PluralName;
                }
                else
                {
                    itemDetails += line.SingularName;
                }

                output += OutputFormatterFactory.Get().General(itemDetails);
            }

            return(output);
        }