Exemple #1
0
        /// <summary>
        /// Renders the combat stats and description of an action.
        /// </summary>
        /// <param name="action">The action to display.</param>
        /// <param name="data">The data corresponding to the action to display.</param>
        /// <returns>A list of string that contains the action description.</returns>
        private List <string> RenderActionDescription(IDisplayAction action, ActionData data)
        {
            int maxLength   = 30;
            int maxHeight   = 12;
            var description = new List <string>();
            var reducedStr  = action.GetDescription().GetStringAsList(maxLength - 2);

            for (int i = 0; i < reducedStr.Count(); i++)
            {
                string st = "";
                st = reducedStr.ElementAt(i);
                description.Add("║ " + st + new string(' ', maxLength - st.Count() - 2));
            }
            description.Add("║ " + new string(' ', maxLength - 2));
            string str = "";

            // Display all values that are not 0 or null in the view model
            foreach (var item in data.GetDisplayableValues())
            {
                if (item.Value != null)
                {
                    if (item.Value is IEnumerable <string> )
                    {
                        foreach (var stringVal in item.Value as IEnumerable <string> )
                        {
                            str = $"Applies {stringVal}";
                            description.Add("║ " + str + new string(' ', maxLength - str.Count() - 2));
                        }
                    }
                    else
                    {
                        str = $"{item.Key} : {item.Value}";
                        description.Add("║ " + str + new string(' ', maxLength - str.Count() - 2));
                    }
                }
            }
            int currentCount = description.Count();

            // Adds empty lines if the description count is less than the max height.
            for (int i = 0; i < maxHeight - currentCount; i++)
            {
                description.Add("║ " + new string(' ', maxLength - 2));
            }
            return(description);
        }