public static TRE GetTre(dal.UserData.Hero h) { TRE it = new TRE() { id = h.id, H = h.hid, L = CML.ComUtility.XInt(h.hl.ToUpper().Replace("LV", ""), 0), R = CML.ComUtility.XInt(h.hr.ToUpper().Replace("R", ""), 0), P = CML.ComUtility.XInt(h.hp.ToUpper().Replace("+", ""), 0), }; dal.Hero hero = CML.ComUtility.QueryFirst(from x in Bll.webcache.wiki.heroes where x.Id == it.H select x, null); if (hero != null) { it.N = hero.Name; it.W = hero.WeaponClassId; it.M = hero.MoveTypeId; } SetTreProp(it.H, it.R, h.var[0], (o => o.HP), ref it.Hp); SetTreProp(it.H, it.R, h.var[1], (o => o.ATK), ref it.Atk); SetTreProp(it.H, it.R, h.var[2], (o => o.SPD), ref it.Spd); SetTreProp(it.H, it.R, h.var[3], (o => o.DEF), ref it.Def); SetTreProp(it.H, it.R, h.var[4], (o => o.RES), ref it.Res); return(it); }
private void updateHeroesStats(ref Wiki db) { var responseString = CML.ComUrl.Post(API, Param.QueryHeroesStats, proxyip, proxyport); QueryHeroesStats tmp = CML.ComUtility.FromJson <QueryHeroesStats>(responseString); int[] Lvs = new int[] { 1, 40 }; int[] Raritys = new int[] { 3, 4, 5 }; string[] Props = new string[] { "HP", "ATK", "SPD", "DEF", "RES" }; string[] Vars = new string[] { "Bane", "Neut", "Boon" }; foreach (string name in tmp.query.results.Keys) { dal.Hero h = CML.ComUtility.QueryFirst(from x in db.heroes.Query() where x.Name == name select x, null); if (h != null) { foreach (int Lv in Lvs) { foreach (int Rarity in Raritys) { for (int i = 0; i < Vars.Length; i++) { dal.HeroEntity entity = new dal.HeroEntity() { Level = Lv, Rarity = Rarity, HeroId = h.Id, Variation = i - 1, }; List <int> PropValue = new List <int>(); Dictionary <string, string[]> prints = tmp.query.results[name].printouts; foreach (string Prop in Props) { string key = string.Format("Lv{0}R{1}{2}{3}", Lv, Rarity, Prop, Vars[i]); if (prints.Keys.Contains(key) && prints[key].Length > 0) { if (prints[key].Length > 1) { Console.WriteLine("TooMany!"); } PropValue.Add(CML.ComUtility.XInt(prints[key][0], 0)); } else { PropValue.Add(0); } } entity.HP = PropValue[0]; entity.ATK = PropValue[1]; entity.SPD = PropValue[2]; entity.DEF = PropValue[3]; entity.RES = PropValue[4]; dal.Weapon w = CML.ComUtility.QueryFirst(from x in db.weapons.Query() where x.Id == h.Weapon[Rarity - 1] select x, null); if (w != null) { entity.W_ATK = w.Damage; if (w.Effect == 15) { //Console.WriteLine(w.Name); entity.W_SPD = -5; } } if (entity.HP > 0 || entity.ATK > 0 || entity.SPD > 0 || entity.DEF > 0 || entity.RES > 0) { if (entity.HP > 0 && entity.ATK > 0 && entity.SPD > 0 && entity.DEF > 0 && entity.RES > 0) { db.stats.And(entity); } else { Console.WriteLine("Has Zero!"); } } } } } } } }