protected override List<Digimon> GetDigimons(Tamer tamer, bool isDetailed)
{
if (LogManager != null) {
LogManager.InfoFormat("Obtaining digimons for tamer \"{0}\"", tamer.Name);
}
List<Digimon> digimonList = new List<Digimon>();
using (IDatabaseContext context = DatabaseManager.CreateContext()) {
HtmlDocument doc;
//getting starter
HtmlNode tamerInfo = tryLoadNode(string.Format(STR_URL_TAMER_POPPAGE, tamer.AccountId, "srv" + tamer.Guild.Server.Identifier), "//div[@class='tamer-area']", out doc);
Digimon partner = new Digimon() {
Tamer = tamer,
SizePc = 100,
Name = ClearStr(tamerInfo.SelectNodes("//ul/li[@class='partner']/span")[0].InnerText)
};
partner.Type = context.FindDigimonTypeBySearchGDMO(context.PrepareDigimonSearch(partner.Name));
partner.SizeCm = partner.Type.SizeCm;
digimonList.Add(partner);
if (!GetStarterInfo(ref partner, tamer)) {
if (LogManager != null) {
LogManager.ErrorFormat("Unable to obtain info about starter digimon \"{0}\" for tamer \"{1}\"", partner.Name, tamer.Name);
}
}
HtmlNode mercenaryList = doc.DocumentNode.SelectNodes("//div[@id='rankingscroll']")[0];
HtmlNodeCollection dlist = mercenaryList.SelectNodes("//li/em[@class='partner']");
if (dlist != null) {
for (int i = 0; i < dlist.Count; i++) {
Digimon digimonInfo = new Digimon() {
Tamer = tamer,
Name = ClearStr(mercenaryList.SelectNodes("//em[@class='partner']")[i].InnerText),
Level = Convert.ToByte(ClearStr(mercenaryList.SelectNodes("//span[@class='level']")[i].InnerText)),
Rank = Convert.ToInt32(ClearStr(mercenaryList.SelectNodes("//span[@class='ranking']")[i].InnerText))
};
digimonInfo.Type = context.FindDigimonTypeBySearchGDMO(context.PrepareDigimonSearch(digimonInfo.Name));
if (digimonInfo.Type == null) {
continue;
}
digimonInfo.SizeCm = digimonInfo.Type.SizeCm;
if (digimonList.Count(d => d.Type.Equals(digimonInfo.Type)) == 0) {
if (isDetailed) {
if (!GetMercenaryInfo(ref digimonInfo, tamer)) {
if (LogManager != null) {
LogManager.ErrorFormat("Unable to obtain detailed data of digimon \"{0}\" for tamer \"{1}\"", digimonInfo.Name, tamer.Name);
}
}
}
digimonList.Add(digimonInfo);
if (LogManager != null) {
LogManager.Info(String.Format("Found digimon \"{0}\"", digimonInfo.Name));
}
}
}
}
}
return digimonList;
}