/// <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); }
/// <summary> /// Renders a small diagram detailing the targets a currently selected action can hit. /// </summary> /// <param name="action">The action to detail the targets for.</param> /// <returns>A list of string containing the action targets panel.</returns> private List <string> RenderActionTargets(IDisplayAction action) { int maxWidth = 25; int maxRowsInFormation = 3; var actionTargets = new List <string>(); actionTargets.Add("│" + new string(' ', (maxWidth - 9) / 2) + "Targets" + new string(' ', (maxWidth - 9) / 2) + "║"); for (int i = 0; i < maxRowsInFormation * 2; i++) { string line = ""; for (int j = 1; j <= 6; j++) { // If the action can't switch targets and one of its targets is in one of the player's positions, then render a focused square. if (j <= 3 && action.GetActionTargets().Contains(j + i / 2 * 3) && !action.CanSwitchTargetPosition) { if (i % 2 == 1) { line += "╚╝"; } else { line += "╔╗"; } } // If the action can't switch targets and one of its targets is in one of the enemy's positions, then render a focused square. // Or if the action can switch targets, render a focused square if this is one of the target positions else if ((j > 3 && action.GetActionTargets().Contains(j + 6 + i / 2 * 3) && !action.CanSwitchTargetPosition) || (j > 3 && action.GetActionTargets().Contains(j - 3 + i / 2 * 3))) { if (i % 2 == 1) { line += "╚╝"; } else { line += "╔╗"; } } else { if (i % 2 == 1) { line += "└┘"; } else { line += "┌┐"; } } if (j == 3) { line += " "; } } int spaces = (maxWidth - line.Count()) / 2 + (maxWidth - line.Count()) % 2 - 1; line = "│ " + new string(' ', spaces - 2) + line + new string(' ', spaces); line += line.Count() == maxWidth - 1 ? "║" : " ║"; actionTargets.Add(line); } actionTargets.Add("│" + new string(' ', maxWidth - 2) + "║"); string str1 = ""; string str2 = ""; if (action.CanSwitchTargetPosition) { str1 = " - Can switch target position"; } else { str1 = " - Can't switch target position"; } if (action.CanTargetThroughUnits) { str2 = " - Position not affected by formation"; } else { str2 = " - Position is affected by formation"; } var arr1 = str1.GetStringAsList(maxWidth - 4); var arr2 = str2.GetStringAsList(maxWidth - 4); foreach (var item in arr1) { actionTargets.Add("│ " + item + new string(' ', maxWidth - item.Count() - 4) + " ║"); } foreach (var item in arr2) { actionTargets.Add("│ " + item + new string(' ', maxWidth - item.Count() - 4) + " ║"); } return(actionTargets); }