private void DisplayItem(DofusItem.DofusItem res) { Console.WriteLine($"{res.Label} ({res.Level})"); Console.WriteLine(res.Description); Console.WriteLine("-"); foreach (string effect in res.Effects) { Console.WriteLine($"Effet : {effect}"); } if (res.Conditions != null) { if (res.Conditions.Any()) { Console.WriteLine("-"); foreach (string cdt in res.Conditions) { Console.WriteLine($"Condition : {cdt}"); } } } Console.WriteLine("--"); Console.WriteLine(); }
public bool Verify(DofusItem.DofusItem di) { foreach (string eff in di.Effects) { if (eff.ToLower().Contains("cequejeveux")) { return(true); } } return(false); }
public void LogItem(DofusItem.DofusItem dofus_item, string path, int line) { string propError = String.Empty; if (String.IsNullOrEmpty(dofus_item.Label) || StringHelper.HasUnwantedString(dofus_item.Label)) { propError = "LABEL"; } if (dofus_item.Level == 0) { propError = "LEVEL"; } if (String.IsNullOrEmpty(dofus_item.Description) || StringHelper.HasUnwantedString(dofus_item.Description)) { propError = "DESCRIPTION"; } foreach (string effect in dofus_item.Effects) { if (String.IsNullOrEmpty(effect) || StringHelper.HasUnwantedString(effect)) { propError = "EFFECT"; break; } } if (dofus_item.Conditions != null && dofus_item.Conditions.Count > 0) { foreach (string condition in dofus_item.Conditions) { if (String.IsNullOrEmpty(condition) || StringHelper.HasBadCondition(condition)) { propError = "CONDITION"; break; } } } string reason; if (HasDataError(dofus_item.Description, out reason)) { propError = "EXCLUDED"; } if (NeedsVerification(dofus_item.Label) || Verify(dofus_item)) { propError = "NEEDS VERIFICATION"; } if (!String.IsNullOrEmpty(propError)) { dofus_item.HasError = true; _countRessourcesErrors++; _logfile.WriteLine(_SUBBORDER); _logfile.WriteLine($"Error : {propError}."); if (propError == "EXCLUDED") { _logfile.WriteLine($"Reason : {reason}."); } _logfile.WriteLine($"File : {path}."); _logfile.WriteLine($"Line : {line}."); _logfile.WriteLine($"Label : {dofus_item.Label}"); _logfile.WriteLine($"Level : {dofus_item.Level}"); _logfile.WriteLine($"Description : {dofus_item.Description}"); _logfile.WriteLine($"Effects : " + (dofus_item.Effects.Count > 0 ? "" : "None.")); foreach (string effect in dofus_item.Effects) { _logfile.WriteLine($"\t{effect}"); } if (dofus_item.Conditions != null && dofus_item.Conditions.Count > 0) { _logfile.WriteLine($"Conditions :"); foreach (string c in dofus_item.Conditions) { _logfile.WriteLine($"\t{c}"); } } _logfile.WriteLine(_BOTBORDER); _logfile.WriteLine(_logfile.NewLine); } }
public void ImportItems(string path, string item_type) { Logger logger = new Logger(); logger.StartLogging(item_type); int success_count = 0; int total_count = 0; List <string> categories = new List <string>(); List <Ressource> ressources = new List <Ressource>(); List <Equipement> equipements = new List <Equipement>(); List <Arme> armes = new List <Arme>(); foreach (string dir in Directory.GetDirectories(path)) { string cat = new DirectoryInfo(dir).Name; categories.Add(cat); foreach (string file in Directory.GetFiles(dir, "*.html")) { HtmlDocument doc = this.OpenHtmlFromFile(file); HtmlNodeCollection DataNodes = this.SelectItemDataNodes(doc); foreach (HtmlNode node in DataNodes) { DofusItem.DofusItem dofus_item = new DofusItem.DofusItem() { Label = GetItemLabel(node), Description = GetItemDescription(node), Level = GetItemLevel(node), Effects = GetItemEffects(node) }; if (item_type == ItemTypes.equipement.ToString() || item_type == ItemTypes.arme.ToString()) { dofus_item.Conditions = GetItemConditions(node); if (item_type == ItemTypes.arme.ToString()) { // Assigner Caractéristique } } logger.LogItem(dofus_item, file, node.Line); if (!dofus_item.HasError) { if (item_type == ItemTypes.ressource.ToString()) { Ressource res = new Ressource(); res.Description = dofus_item.Description; res.Label = dofus_item.Label; res.Level = dofus_item.Level; res.RessourceEffect = GetRessourceEffects(dofus_item.Effects); res.TypeRessourceName = cat; ressources.Add(res); } else if (item_type == ItemTypes.equipement.ToString()) { Equipement eq = new Equipement(); // Equipement eq.Label = dofus_item.Label; eq.Description = dofus_item.Description; eq.Level = dofus_item.Level; eq.TypeEquipementName = cat; // Equipement Effects eq.EffectsList = dofus_item.Effects; // Equipement Condition eq.ConditionsList = dofus_item.Conditions; equipements.Add(eq); } DisplayItem(dofus_item); success_count++; } total_count++; } } } Injector i = new Injector(); if (item_type == ItemTypes.ressource.ToString()) { i.InjectRessources(ressources, categories); } else if (item_type == ItemTypes.equipement.ToString()) { i.InjectEquipements(equipements, categories); } Console.WriteLine($"{success_count} elements imported."); Console.WriteLine($"{(total_count - success_count)} elements NOT imported due to errors. (see '/Downloads/squidspy_log.txt')"); Console.WriteLine(); logger.LogCategories(categories); logger.EndLogging(); }