/// <summary> /// Make new stage info base by basic node in game data /// </summary> /// <returns>Created new equip page</returns> public static XmlDataNode MakeNewStageInfoBase() { List <XmlDataNode> baseBookUseNode = DM.GameInfos.staticInfos["StageInfo"].rootDataNode.GetXmlDataNodesByPathWithXmlInfo("Stage", attributeToCheck: new Dictionary <string, string>() { { "id", "2" } }); if (baseBookUseNode.Count > 0) { XmlDataNode bookUseIdBase = baseBookUseNode[0].Copy(); bookUseIdBase.attribute["id"] = Tools.MathTools.GetRandomNumber(1000000, 9999999).ToString(); bookUseIdBase.SetXmlInfoByPath("Name", ""); bookUseIdBase.SetXmlInfoByPath("Chapter", ""); bookUseIdBase.SetXmlInfoByPath("StoryType", ""); bookUseIdBase.RemoveXmlInfosByPath("Wave"); bookUseIdBase.RemoveXmlInfosByPath("Invitation/Book"); bookUseIdBase.ActionXmlDataNodesByPath("Story", (XmlDataNode storyNode) => { storyNode.innerText = ""; }); return(bookUseIdBase); } else { return(null); } }
/// <summary> /// Make new card base by basic node in game data /// </summary> /// <returns>Created new Card</returns> public static XmlDataNode MakeNewCardBase() { List <XmlDataNode> foundXmlDataNodes = DM.GameInfos.staticInfos["Card"].rootDataNode.GetXmlDataNodesByPathWithXmlInfo("Card", attributeToCheck: new Dictionary <string, string>() { { "ID", "100001" } }); if (foundXmlDataNodes.Count > 0) { XmlDataNode xmlDataNodeToAdd = foundXmlDataNodes[0].Copy(); string RANDOM_CARD_ID = Tools.MathTools.GetRandomNumber(DS.FilterDatas.CARD_DIV_SPECIAL, DS.FilterDatas.CARD_DIV_FINAL_STORY).ToString(); xmlDataNodeToAdd.attribute["ID"] = RANDOM_CARD_ID; xmlDataNodeToAdd.SetXmlInfoByPath("Name", ""); xmlDataNodeToAdd.SetXmlInfoByPath("Artwork", ""); xmlDataNodeToAdd.SetXmlInfoByPath("Rarity", "Common"); xmlDataNodeToAdd.RemoveXmlInfosByPath("BehaviourList/Behaviour"); return(xmlDataNodeToAdd); } else { return(null); } }
/// <summary> /// Make new static card drop table with given bookUseID /// </summary> /// <param name="CardDropTableID">Card drop table ID to use</param> /// <returns>If given card drop table id is already used in game. Load it</returns> public static XmlDataNode MakeNewStaticCardDropTableBase(string CardDropTableID = "") { List <XmlDataNode> foundCardDropTableIDs = DM.GameInfos.staticInfos["CardDropTable"].rootDataNode.GetXmlDataNodesByPathWithXmlInfo("DropTable", attributeToCheck: new Dictionary <string, string>() { { "ID", CardDropTableID } }); if (foundCardDropTableIDs != null && foundCardDropTableIDs.Count > 0) { return(foundCardDropTableIDs[0].Copy()); } else { List <XmlDataNode> baseCardDropTableNode = DM.GameInfos.staticInfos["CardDropTable"].rootDataNode.GetXmlDataNodesByPathWithXmlInfo("DropTable", attributeToCheck: new Dictionary <string, string>() { { "ID", "200001" } }); if (baseCardDropTableNode.Count > 0) { XmlDataNode cardDropTableNode = baseCardDropTableNode[0].Copy(); cardDropTableNode.RemoveXmlInfosByPath("Card"); return(cardDropTableNode); } else { return(null); } } }
/// <summary> /// Make new enemy unit info base by basic node in game data /// </summary> /// <returns>Created new equip page</returns> public static XmlDataNode MakeNewEnemyUnitInfoBase() { List <XmlDataNode> baseBookUseNode = DM.GameInfos.staticInfos["EnemyUnitInfo"].rootDataNode.GetXmlDataNodesByPathWithXmlInfo("Enemy", attributeToCheck: new Dictionary <string, string>() { { "ID", "1" } }); if (baseBookUseNode.Count > 0) { XmlDataNode bookUseIdBase = baseBookUseNode[0].Copy(); bookUseIdBase.attribute["ID"] = Tools.MathTools.GetRandomNumber(100000, 999999).ToString(); bookUseIdBase.SetXmlInfoByPath("NameID", ""); bookUseIdBase.SetXmlInfoByPath("MinHeight", ""); bookUseIdBase.SetXmlInfoByPath("MaxHeight", ""); bookUseIdBase.SetXmlInfoByPath("BookId", ""); bookUseIdBase.SetXmlInfoByPath("DeckId", ""); bookUseIdBase.RemoveXmlInfosByPath("DropTable"); return(bookUseIdBase); } else { return(null); } }
/// <summary> /// Make new wav info base by basic node in game data /// </summary> /// <returns></returns> public static XmlDataNode MakeNewWaveInfoBase() { List <XmlDataNode> baseBookUseNode = DM.GameInfos.staticInfos["StageInfo"].rootDataNode.GetXmlDataNodesByPathWithXmlInfo("Stage", attributeToCheck: new Dictionary <string, string>() { { "id", "2" } }); if (baseBookUseNode.Count > 0) { XmlDataNode STAGE_NODE_TO_USE = baseBookUseNode[0]; List <XmlDataNode> baseWaveNode = STAGE_NODE_TO_USE.GetXmlDataNodesByPath("Wave"); if (baseWaveNode.Count > 0) { XmlDataNode baseWaveNodeToUse = baseWaveNode[0].Copy(); baseWaveNodeToUse.SetXmlInfoByPath("Formation", ""); baseWaveNodeToUse.RemoveXmlInfosByPath("Unit"); return(baseWaveNodeToUse); } else { return(null); } } else { return(null); } }
/// <summary> /// Make new stage info base by basic node in game data /// </summary> /// <returns>Created new equip page</returns> public static XmlDataNode MakeNewDeckInfoBase() { List <XmlDataNode> baseDeckNode = DM.GameInfos.staticInfos["Deck"].rootDataNode.GetXmlDataNodesByPathWithXmlInfo("Deck", attributeToCheck: new Dictionary <string, string>() { { "ID", "200001" } }); if (baseDeckNode.Count > 0) { XmlDataNode deckNodeBase = baseDeckNode[0].Copy(); deckNodeBase.attribute["ID"] = Tools.MathTools.GetRandomNumber(999999, 5999999).ToString(); deckNodeBase.RemoveXmlInfosByPath("Card"); deckNodeBase.RemoveXmlInfosByPath("Random"); return(deckNodeBase); } else { return(null); } }
/// <summary> /// Make new localize books base by basic node in game data /// </summary> /// <returns>Created books info</returns> public static XmlDataNode MakeNewLocalizeBooksBase(string bookIdToSet = "", string nameToSet = "", string desc = "") { List <XmlDataNode> foundXmlDataNodes = DM.GameInfos.localizeInfos["Books"].rootDataNode.GetXmlDataNodesByPathWithXmlInfo("bookDescList/BookDesc", attributeToCheck: new Dictionary <string, string>() { { "BookID", "200001" } }); if (foundXmlDataNodes.Count > 0) { XmlDataNode xmlDataNodeToAdd = foundXmlDataNodes[0].Copy(); xmlDataNodeToAdd.attribute["BookID"] = bookIdToSet; xmlDataNodeToAdd.SetXmlInfoByPath("BookName", nameToSet); if (!string.IsNullOrEmpty(desc)) { xmlDataNodeToAdd.RemoveXmlInfosByPath("TextList/Desc"); foreach (string desPart in desc.Split(new string[] { "\r\n\r\n" }, StringSplitOptions.None)) { string DESC_TO_ADD = desPart.Replace("\r\n", " ").Replace("\r", "").Replace("\n", ""); xmlDataNodeToAdd.AddXmlInfoByPath("TextList/Desc", DESC_TO_ADD); } } else { xmlDataNodeToAdd.RemoveXmlInfosByPath("TextList/Desc"); xmlDataNodeToAdd.MakeEmptyNodeGivenPathIfNotExist("TextList/Desc"); } return(xmlDataNodeToAdd); } else { return(null); } }
/// <summary> /// Make new drop book info base by basic node in game data /// </summary> /// <returns>Created new equip page</returns> public static XmlDataNode MakeNewCardDropTableBase() { List <XmlDataNode> cardDropTableNodes = DM.GameInfos.staticInfos["CardDropTable"].rootDataNode.GetXmlDataNodesByPathWithXmlInfo("DropTable", attributeToCheck: new Dictionary <string, string>() { { "ID", "200001" } }); if (cardDropTableNodes.Count > 0) { XmlDataNode caedDropTableBase = cardDropTableNodes[0].Copy(); caedDropTableBase.attribute["ID"] = Tools.MathTools.GetRandomNumber(1000000, 9999999).ToString(); caedDropTableBase.RemoveXmlInfosByPath("Card"); return(caedDropTableBase); } else { return(null); } }
/// <summary> /// Make new drop book info base by basic node in game data /// </summary> /// <returns>Created new equip page</returns> public static XmlDataNode MakeNewDropBookInfoBase() { List <XmlDataNode> baseBookUseNode = DM.GameInfos.staticInfos["DropBook"].rootDataNode.GetXmlDataNodesByPathWithXmlInfo("BookUse", attributeToCheck: new Dictionary <string, string>() { { "ID", "230002" } }); if (baseBookUseNode.Count > 0) { XmlDataNode bookUseIdBase = baseBookUseNode[0].Copy(); bookUseIdBase.attribute["ID"] = Tools.MathTools.GetRandomNumber(1000000, 9999999).ToString(); bookUseIdBase.SetXmlInfoByPath("TextId", ""); bookUseIdBase.SetXmlInfoByPath("BookIcon", ""); bookUseIdBase.SetXmlInfoByPath("Chapter", "1"); bookUseIdBase.RemoveXmlInfosByPath("DropItem"); return(bookUseIdBase); } else { return(null); } }
/// <summary> /// Delete xml data node from path if exists /// </summary> /// <param name="path">XmlData path</param> /// <param name="innerTextToCheck">Inner text to check</param> /// <param name="attributeToCheck">Attribute dic to check</param> /// <param name="deleteOnce">If it true, Delete only first found XmlDataNode</param> public void RemoveXmlInfosByPath(string path, string innerTextToCheck = "", Dictionary <string, string> attributeToCheck = null, bool deleteOnce = false) { if (string.IsNullOrEmpty(path)) { return; } List <string> NAME_LIST = path.Split('/').ToList(); if (NAME_LIST.Count > 1) { XmlDataNode foundXmlDataNode = subNodes.Find((XmlDataNode xmlDataNode) => { return(xmlDataNode.name == NAME_LIST[0]); }); if (foundXmlDataNode != null) { foundXmlDataNode.RemoveXmlInfosByPath(String.Join("/", NAME_LIST.Skip(1)), innerTextToCheck, attributeToCheck, deleteOnce); } } else { List <XmlDataNode> foundNodesToRemove = subNodes.FindAll((XmlDataNode xmlDataNode) => { if (xmlDataNode.name != NAME_LIST[0]) { return(false); } if (!string.IsNullOrEmpty(innerTextToCheck) && attributeToCheck == null) { return(xmlDataNode.innerText == innerTextToCheck); } else if ((!string.IsNullOrEmpty(innerTextToCheck) && attributeToCheck != null) && (xmlDataNode.innerText == innerTextToCheck)) { bool attritubteCheck = true; attributeToCheck.ForEachKeyValuePairSafe((string atName, string atValue) => { if (xmlDataNode.attribute.ContainsKey(atName) && xmlDataNode.attribute[atName] != atValue) { attritubteCheck = false; } else if (!xmlDataNode.attribute.ContainsKey(atName)) { attritubteCheck = false; } }); return(attritubteCheck); } else if (string.IsNullOrEmpty(innerTextToCheck) && attributeToCheck != null) { bool attritubteCheck = true; attributeToCheck.ForEachKeyValuePairSafe((string atName, string atValue) => { if (xmlDataNode.attribute.ContainsKey(atName) && xmlDataNode.attribute[atName] != atValue) { attritubteCheck = false; } else if (!xmlDataNode.attribute.ContainsKey(atName)) { attritubteCheck = false; } }); return(attritubteCheck); } else { return(true); } }); if (deleteOnce && foundNodesToRemove.Count > 0) { subNodes.Remove(foundNodesToRemove[0]); } else if (!deleteOnce) { foundNodesToRemove.ForEachSafe((XmlDataNode xmlDataToRemove) => { subNodes.Remove(xmlDataToRemove); }); } MainWindow.mainWindow.UpdateDebugInfo(); } }