public PartnerWrapper(FullWrapper info, int tax) { foreach (ResTypes res in Enum.GetValues(typeof(ResTypes))) { BoostsInfo[res] = new PartnerBoostInfo(info.BaseInfo.house, info.BaseInfo.equipmentEquipped, info.BaseInfo.boosts, res); } foreach (var pet in info.BaseInfo.pets) { PetsInfo[pet.id] = new PetInfo(pet); } GlobalInfo = new PartnerGlobalInfo(info.BaseInfo.kingdom, info.BaseInfo.village, tax, info.Vip); foreach (var partner in info.BaseInfo.partners) { PartnersInfo[partner.id] = new PartnerInfo(partner, info.BaseInfo.stats); } foreach (var partner in PartnersInfo) { PartnersIncomeInfo[partner.Key] = new PartnerIncomeInfo(partner.Value, BoostsInfo[partner.Value.ResType], GlobalInfo); } foreach (ResTypes res in Enum.GetValues(typeof(ResTypes))) { Totals[res] = new PartnerTotalInfo(res, PartnersIncomeInfo.Values.ToList(), PetsInfo.Values.ToList()); } Difference = new PartnerDifference(PartnersInfo.Values.ToList(), Totals); }
public FighterWrapper(FullWrapper info) { RootInfo = info; SetupMobs(); SetupFighters(); DoMath(); }
public void Unload() { ApiKey = ""; Valid = false; FullWrapper = null; Values = new Dictionary <Type, BaseQueslar>(); }
public async Task <Double> GetPlayerForEnchantingService(string player) { var db = DB; var dbObjects = db.QueslarKeys.Where(x => x.Username == player); Full info; if (dbObjects.Count() == 1) { var dbObject = dbObjects.First(); if (dbObject.DateUpdated < DateTime.Now.AddHours(-1)) { var client = new HttpClient(); info = await client.GetFromJsonAsync <Full>("https://queslar.com/api/player/full/" + dbObject.ApiKey ); dbObject.Data = System.Text.Json.JsonSerializer.Serialize(info); dbObject.DateUpdated = DateTime.Now; db.QueslarKeys.Update(dbObject); db.SaveChanges(); } else { info = System.Text.Json.JsonSerializer.Deserialize <Full>(dbObject.Data); } var wrapper = new FullWrapper(info); var enchantingAvg = new EnchantingAvg(wrapper); return(enchantingAvg.CalculateAvg()); } return(0.0); }
public FullWrapper GetFullWrapper() { if (FullWrapper != null) { return(FullWrapper); } if (Values.ContainsKey(typeof(Full)) && Values[typeof(Full)] != null) { FullWrapper = new FullWrapper((Full)Values[typeof(Full)]); FullWrapper.AddPartnerWrapper(); return(FullWrapper); } else { } return(null); }
public async Task <T> Update <T>(string apiKey) where T : BaseQueslar, new() { Valid = false; var client = new HttpClient(); BaseQueslar info = new T(); apiKey = apiKey.Trim(); try { info = await client.GetFromJsonAsync <T>("https://queslar.com/api/" + info.ApiPath + apiKey); Values[typeof(T)] = info; if (info.GetType() == typeof(Full)) { FullWrapper = new FullWrapper((Full)info); FullWrapper.AddPartnerWrapper(Tax); } } catch (Exception) { return(null); } Valid = true; ApiKey = apiKey; return((T)info); }
public EnchantingAvg(FullWrapper info) { RootInfo = info; }