public void the_attribute_is_not_generated_when_id_is_null() { var element = new GenericElement("fake").ID(null); element.ID.ShouldBe(null); element.ToString().ShouldNotContain("id=\""); }
public string Visit(GenericElement genericElement) { var genericText = genericElement.ToString(); switch (genericElement.Tag) { case TagType.Split: if (genericText == "<Split(<Highlight>ObjectParameter(1)</Highlight>, ,1)/>") { return("<span class=\"highlight\">Forename</span>"); } else if (genericText == "<Split(<Highlight>ObjectParameter(1)</Highlight>, ,2)/>") { return("<span class=\"highlight\">Surname</span>"); } else { throw new NotImplementedException(); } case TagType.Highlight: var content = genericElement.Content.Accept(this); return("<span class=\"highlight\">" + content + "</span>"); case TagType.Sheet: if (genericText == "<Sheet(Addon,9,0)/>") { return("<img class=\"hq-icon small\" src=\"images/item/hq.png\">"); } else if (genericText.Contains("GCRank")) { return("[GC Rank]"); } else if (genericText == "<Sheet(Race,PlayerParameter(71),0)/>") { return("[Race]"); } else if (genericText == "<Sheet(ClassJob,PlayerParameter(68),0)/>") { return("[Job]"); } else if (genericText == "<Sheet(Town,PlayerParameter(70),0)/>") { return("[Starting City]"); } else if (genericText == "<Sheet(ContentFinderCondition,IntegerParameter(1),18)/>") { return("[Item Level]"); } else if (genericText == "<Sheet(ContentFinderCondition,IntegerParameter(2),32)/>") { return("[Instance]"); } else if (genericText == "<Sheet(ContentFinderCondition,IntegerParameter(2),34)/>") { return("[Instance]"); } else if (genericText.StartsWith("<Sheet(") && !genericText.Contains("PlayerParameter(")) { var genericElementArgs = genericElement.Arguments.ToArray(); var sheetName = genericElementArgs[0].Accept(this); var sheetKeyRaw = genericElementArgs[1].Accept(this); if (int.TryParse(sheetKeyRaw.Trim(), out var sheetKey)) { var sheet = DatabaseBuilder.Instance.Realm.GameData.GetSheet(sheetName); var row = sheet[sheetKey]; var rowIndex = int.Parse(genericElementArgs[2].Accept(this).Trim()); return(row[rowIndex].ToString()); } return("[???]"); } else { throw new NotImplementedException(); } case TagType.Clickable: return(string.Join("", genericElement.Arguments.Select(v => v.Accept(this)))); case TagType.Gui: if (genericText == "<Gui(54)/>") { return("{"); } else if (genericText == "<Gui(55)/>") { return("}"); } else if (genericText == "<Gui(63)/>") { return("*"); // Not sure about this. } else { DatabaseBuilder.PrintLine($"Unknown GUI string flag: {genericText}, defaulting to *."); return("*"); } case TagType.Time: return("[Time]"); case TagType.SheetEn: case TagType.SheetDe: case TagType.SheetFr: case TagType.SheetJa: { var genericElementArgs = genericElement.Arguments.ToArray(); var args = genericElement.Arguments.Select(a => a.Accept(this)).ToArray(); var sheetName = genericElementArgs[0].Accept(this); try { var sheet = DatabaseBuilder.Instance.Realm.GameData.GetSheet(sheetName); if (genericElementArgs[2] is Parameter sheetKeyParam) { return("[Error]"); } var sheetKey = int.Parse(genericElementArgs[2].Accept(this).Trim()); var row = sheet[sheetKey]; return(row.ToString()); } catch (KeyNotFoundException e) { DatabaseBuilder.PrintLine($"Missing sheet for HTML String Formatter: {sheetName}"); return(""); } } case TagType.Value: return(genericElement.Content.Accept(this)); case TagType.CommandIcon: return("[???]"); default: return(""); } }