private MappedJewel[] MapJewels(IEnumerable <SolverDataJewelModel> jewels, IDictionary <int, int> desiredDict, MappedSkill[] skills) { var orderedJewels = jewels.OrderByDescending(x => x.Jewel.SlotSize).ToList(); IList <MappedJewel> mappedJewels = new List <MappedJewel>(); foreach (SolverDataJewelModel jewel in orderedJewels) { IAbility ability = jewel.Jewel.Abilities[0]; if (!desiredDict.ContainsKey(ability.Skill.Id)) { continue; } MappedSkill skill = skills[desiredDict[ability.Skill.Id]].CopyWithLevel(ability.Level); var map = new MappedJewel(); map.Jewel = jewel; map.Skill = skill; mappedJewels.Add(map); } return(mappedJewels.ToArray()); }
private bool TrySlotJewels(MappedJewel mappedJewel, int[] totalSlots, int[] remainingLevels, out ArmorSetJewelResult jewelResult) { jewelResult = new ArmorSetJewelResult(); IJewel jewel = mappedJewel.Jewel.Jewel; MappedSkill ability = mappedJewel.Skill; int mappedId = ability.MappedId; int needLevels = remainingLevels[mappedId]; int needJewels = needLevels; int canTakeJewels = Math.Min(mappedJewel.Jewel.Available, needJewels); if (canTakeJewels < needJewels) { return(false); } int jewelsTaken = 0; for (int slot = jewel.SlotSize; slot <= CutoffSearchConstants.Slots && jewelsTaken < needJewels; ++slot) { int sizeSlotsAvailable = totalSlots[slot]; int canFitToSlot = Math.Min(sizeSlotsAvailable, canTakeJewels); totalSlots[slot] -= canFitToSlot; canTakeJewels -= canFitToSlot; jewelsTaken += canFitToSlot; } if (jewelsTaken < needJewels) { return(false); } remainingLevels[mappedId] -= jewelsTaken; jewelResult.Jewel = jewel; jewelResult.Count = jewelsTaken; return(true); }