public Hero GetHero(string name, int stars) { var faction = EnumExtensions.ParseEnum(name, Factions.Unknown); if (faction != Factions.Unknown) { return(new Hero() { Name = name, Stars = stars, MinStars = 4, MaxStars = 9, Faction = faction, Role = Roles.Unknown }); } var hero = _heroService.GetHero(name); if (hero == null) { return(null); } return(new Hero(hero) { Stars = stars }); }
public Hero GetHero(string name, int stars) { var hero = _heroService.GetHero(name); if (hero == null) { return(null); } return(new Hero(hero) { Stars = stars }); }
private IEnumerable <Costs> GetUpgradeRequirementsBase(int fromStars, int toStars, SQLiteContext context, Hero upgradeHero = null) { if (upgradeHero != null && toStars == upgradeHero.MinStars) { return(null); } var upgradeData = context.UpgradeData.Where(x => x.ToStars > fromStars && x.ToStars <= toStars).ToList(); if (upgradeData.Count() == 0) { return(null); } var result = new List <Costs>(); if (upgradeHero == null) { upgradeHero = new Hero() { Name = _defaultHeroName, Faction = Factions.Specific, Stars = toStars }; } var currentFaction = upgradeHero.Faction == Factions.Any ? Factions.Specific : upgradeHero.Faction; var fodderHeroName = upgradeHero.Stars - 1 == upgradeHero.MinStars ? upgradeHero.Fodder1 : upgradeHero.Fodder2 ?? upgradeHero.Fodder1; foreach (var item in upgradeData) { var fodderList = new List <Hero>(); var req = new Costs() { IsFusion = item.IsFusion, MinStones = item.MinStones, MaxStones = item.MaxStones, MinSpirit = item.MinSpirit, MaxSpirit = item.MaxSpirit, MinGold = item.MinGold, MaxGold = item.MaxGold, ToStars = item.ToStars, FromStars = item.ToStars - 1, Hero = upgradeHero }; //Always need one of our current var currentHero = new Hero(upgradeHero) { Stars = upgradeHero.Stars - 1 }; //if(currentHero.HasCosts) // currentHero.Costs = GetCosts(currentHero); fodderList.Add(currentHero); //Any additional of the current for (var i = 0; i < item.CurrentHeroCount; i++) { fodderList.Add(new Hero(upgradeHero) { Stars = item.CurrentHeroStars }); } //Get specific fodder heroes var fodderHero = new Hero(_heroDataService.GetHero(fodderHeroName)) { Stars = item.SpecificFodderHeroStars }; for (var i = 0; i < item.SpecificFodderHeroCount; i++) { fodderList.Add(new Hero(fodderHero) { Name = fodderHero?.Name ?? _defaultHeroName, Faction = currentFaction, Stars = item.SpecificFodderHeroStars }); } //Get typed fodder heroes for (var i = 0; i < item.TypedFodderHeroCount; i++) { fodderList.Add(new Hero() { Name = _defaultHeroName, Faction = currentFaction, Stars = item.TypedFodderHeroStars }); } for (var i = 0; i < item.TypedFodderHeroCount2; i++) { fodderList.Add(new Hero() { Name = _defaultHeroName, Faction = currentFaction, Stars = item.TypedFodderHeroStars2 }); } for (var i = 0; i < item.AnyFodderHeroCount; i++) { fodderList.Add(new Hero() { Name = _defaultHeroName, Faction = Factions.Any, Stars = item.AnyFodderHeroStars }); } req.Fodder = fodderList; result.Add(req); } return(result); }