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)); }
public void ProcessWeakness(Enemy e, int element) { if (Weaknesses.ContainsKey(e.Name)) { var set = Weaknesses[e.Name]; if (!set.Contains(element)) { set.Add(element); } } else { var set = new HashSet <int>(); set.Add(element); Weaknesses.Add(e.Name, set); } }