public string GetWeaknessString(Enemy e, Files.SkillManager sm) { var str = new StringBuilder(); if (Weaknesses.ContainsKey(e.Name)) { var set = Weaknesses[e.Name]; foreach (int w in e.Weakness) { if (set.Contains(w)) { str.Append(sm.ElementToString(w)); } else { str.Append("???"); } str.Append(", "); } } else { foreach (int w in e.Weakness) { str.Append("???, "); } } string ret_str = str.ToString(); // "string, " --> 8 chars --> 8 - 2 = 6... string (excludes "right" value) return(ret_str.Substring(0, ret_str.Length - 2)); }
// weaknesses YOU are aware of public string GetWeaknessStringPlayer(string image) { StringBuilder weak = new StringBuilder(); weak.Append("["); int num = Reality[image].Count; if (Index.ContainsKey(image)) { HashSet <int> w = Index[image]; foreach (int i in w) { weak.Append($"{SkillManager.ElementToString(i)}, "); } while (num > w.Count) { weak.Append("???, "); num--; } } else { Console.WriteLine("here"); for (int i = 0; i < num; i++) { weak.Append("???, "); } } string result = $"{weak.ToString().TrimEnd(' ').TrimEnd(',')}]"; return(result); }