public AccessorySearcher(SearcherConfiguration config, IEnumerable <LeanMyWorldObject> accessories, CompletedSuit startingSuit = null) : base(config, accessories, startingSuit)
        {
            // Sort the list with the highest amount of epics
            // As a temp fix we just sort based on spell count
            Equipment.Sort((a, b) =>
            {
                if (a.CalcedStartingArmorLevel > 0 && b.CalcedStartingArmorLevel > 0)
                {
                    return(b.CalcedStartingArmorLevel.CompareTo(a.CalcedStartingArmorLevel));
                }
                if (a.CalcedStartingArmorLevel > 0 && b.CalcedStartingArmorLevel == 0)
                {
                    return(-1);
                }
                if (a.CalcedStartingArmorLevel == 0 && b.CalcedStartingArmorLevel > 0)
                {
                    return(1);
                }
                return(b.SpellsToUseInSearch.Count.CompareTo(a.SpellsToUseInSearch.Count));
            });

            // Remove any pieces that have armor
            for (int i = Equipment.Count - 1; i >= 0; i--)
            {
                if (Equipment[i].CalcedStartingArmorLevel > 0)
                {
                    Equipment.RemoveAt(i);
                }
            }
        }
Exemple #2
0
		public ArmorSearcher(SearcherConfiguration config, IEnumerable<SuitBuildableMyWorldObject> pieces, CompletedSuit startingSuit = null) : base(config, pieces, startingSuit)
		{
			// Sort the list with the highest armor first
			Equipment.Sort((a, b) => b.CalcedStartingArmorLevel.CompareTo(a.CalcedStartingArmorLevel));

			// Remove any pieces that have no armor
			for (int i = Equipment.Count - 1 ; i >= 0 ; i--)
			{
				if (Equipment[i].CalcedStartingArmorLevel <= 0)
					Equipment.RemoveAt(i);
			}
		}
        public ArmorSearcher(SearcherConfiguration config, IEnumerable <SuitBuildableMyWorldObject> pieces, CompletedSuit startingSuit = null) : base(config, pieces, startingSuit)
        {
            // Sort the list with the highest armor first
            Equipment.Sort((a, b) => b.CalcedStartingArmorLevel.CompareTo(a.CalcedStartingArmorLevel));

            // Remove any pieces that have no armor
            for (int i = Equipment.Count - 1; i >= 0; i--)
            {
                if (Equipment[i].CalcedStartingArmorLevel <= 0)
                {
                    Equipment.RemoveAt(i);
                }
            }
        }
		public AccessorySearcher(SearcherConfiguration config, IEnumerable<SuitBuildableMyWorldObject> accessories, CompletedSuit startingSuit = null) : base(config, accessories, startingSuit)
		{
			// Sort the list with the highest amount of epics
			// As a temp fix we just sort based on spell count
			Equipment.Sort((a, b) =>
			{
				if (a.CalcedStartingArmorLevel > 0 && b.CalcedStartingArmorLevel > 0) return b.CalcedStartingArmorLevel.CompareTo(a.CalcedStartingArmorLevel);
				if (a.CalcedStartingArmorLevel > 0 && b.CalcedStartingArmorLevel == 0) return -1;
				if (a.CalcedStartingArmorLevel == 0 && b.CalcedStartingArmorLevel > 0) return 1;
				return b.SpellsToUseInSearch.Count.CompareTo(a.SpellsToUseInSearch.Count);
			});

			// Remove any pieces that have armor
			for (int i = Equipment.Count - 1; i >= 0; i--)
			{
				if (Equipment[i].CalcedStartingArmorLevel > 0)
					Equipment.RemoveAt(i);
			}
		}
Exemple #5
0
		List<Searcher> accessorySearchers = new List<Searcher>(); // We use this list to stop accessory searchers when the user stops the build.

		private void btnCalculatePossibilities_Click(object sender, System.EventArgs e)
		{
			btnCalculatePossibilities.Enabled = false;

			treeView1.Nodes.Clear();
			PopulateFromEquipmentGroup(null);

			if (armorSearcher != null)
			{
				armorSearcher.SuitCreated -= new Action<CompletedSuit>(armorSearcher_SuitCreated);
				armorSearcher.SearchCompleted -= new Action(armorSearcher_SearchCompleted);
			}

			accessorySearchers.Clear();

			SearcherConfiguration config = new SearcherConfiguration();
			config.CantripsToLookFor = filtersControl1.CantripsToLookFor;
			config.PrimaryArmorSet = filtersControl1.PrimaryArmorSetId;
			config.SecondaryArmorSet = filtersControl1.SecondaryArmorSetId;

			// Go through our Equipment and remove/disable any extra spells that we're not looking for
			foreach (var piece in boundList)
			{
				piece.SpellsToUseInSearch.Clear();

				foreach (Spell spell in piece.CachedSpells)
				{
					if (config.SpellPassesRules(spell) && !spell.IsOfSameFamilyAndGroup(Spell.GetSpell("Epic Impenetrability")))
						piece.SpellsToUseInSearch.Add(spell);
				}
			}

			// Build our base suit from locked in pieces
			CompletedSuit baseSuit = new CompletedSuit();

			// Add locked pieces in order of slots covered, starting with the fewest
			for (int slotCount = 1; slotCount <= 5; slotCount++)
			{
				foreach (SuitBuildableMyWorldObject item in boundList)
				{
					// Don't add items that we don't care about
					if (item.EquippableSlots == EquippableSlotFlags.None || item.EquippableSlots == EquippableSlotFlags.MeleeWeapon || item.EquippableSlots == EquippableSlotFlags.MissileWeapon || item.EquippableSlots == EquippableSlotFlags.TwoHandWeapon || item.EquippableSlots == EquippableSlotFlags.Wand || item.EquippableSlots == EquippableSlotFlags.MissileAmmo)
						continue;
					if (item.EquippableSlots == EquippableSlotFlags.Cloak || item.EquippableSlots == EquippableSlotFlags.BlueAetheria || item.EquippableSlots == EquippableSlotFlags.YellowAetheria || item.EquippableSlots == EquippableSlotFlags.RedAetheria)
						continue;

					if (item.Locked && item.EquippableSlots.GetTotalBitsSet() == slotCount)
					{
						try
						{
							if (item.EquippableSlots.GetTotalBitsSet() > 1 && item.EquippableSlots.IsBodyArmor() && MessageBox.Show(item.Name + " covers multiple slots. Would you like to reduce it?", "Add Item", MessageBoxButtons.YesNo) == DialogResult.Yes)
							{
								var reductionOptions = item.Coverage.ReductionOptions();

								EquippableSlotFlags slotFlag = EquippableSlotFlags.None;

								foreach (var option in reductionOptions)
								{
									if (option == CoverageFlags.Chest && baseSuit[EquippableSlotFlags.Chest] == null)			{ slotFlag = EquippableSlotFlags.Chest; break; }
									if (option == CoverageFlags.UpperArms && baseSuit[EquippableSlotFlags.UpperArms] == null)	{ slotFlag = EquippableSlotFlags.UpperArms; break; }
									if (option == CoverageFlags.LowerArms && baseSuit[EquippableSlotFlags.LowerArms] == null)	{ slotFlag = EquippableSlotFlags.LowerArms; break; }
									if (option == CoverageFlags.Abdomen && baseSuit[EquippableSlotFlags.Abdomen] == null)		{ slotFlag = EquippableSlotFlags.Abdomen; break; }
									if (option == CoverageFlags.UpperLegs && baseSuit[EquippableSlotFlags.UpperLegs] == null)	{ slotFlag = EquippableSlotFlags.UpperLegs; break; }
									if (option == CoverageFlags.LowerLegs && baseSuit[EquippableSlotFlags.LowerLegs] == null)	{ slotFlag = EquippableSlotFlags.LowerLegs; break; }
								}

								if (slotFlag == EquippableSlotFlags.None)
									MessageBox.Show("Unable to reduce " + item + " into an open single slot." + Environment.NewLine + "Reduction coverage option not expected or not open.");
								else
									baseSuit.AddItem(slotFlag, item);
							}
							else if (!baseSuit.AddItem(item))
								MessageBox.Show("Failed to add " + item.Name + " to base suit of armor.");
						}
						catch (ArgumentException) // Item failed to add
						{
							MessageBox.Show("Failed to add " + item.Name + " to base suit of armor. It overlaps another piece");
						}
					}
				}
			}

			if (baseSuit.Count > 0)
				AddCompletedSuitToTreeView(baseSuit);

			armorSearcher = new ArmorSearcher(config, boundList, baseSuit);

			armorSearcher.SuitCreated += new Action<CompletedSuit>(armorSearcher_SuitCreated);
			armorSearcher.SearchCompleted += new Action(armorSearcher_SearchCompleted);

			new Thread(() =>
			{
				//DateTime startTime = DateTime.Now;

				// Do the actual search here
				armorSearcher.Start();

				//DateTime endTime = DateTime.Now;

				//MessageBox.Show((endTime - startTime).TotalSeconds.ToString());
			}).Start();

			btnStopCalculating.Enabled = true;
			progressBar1.Style = ProgressBarStyle.Marquee;
		}
Exemple #6
0
		protected Searcher(SearcherConfiguration config, IEnumerable<SuitBuildableMyWorldObject> equipment, CompletedSuit startingSuit = null)
		{
			Config = config;

			foreach (var piece in equipment)
			{
				if (!piece.Exclude)
					Equipment.Add(piece);
			}

			// Remove pieces that don't meet our minimum requirements
			for (int i = Equipment.Count - 1; i >= 0; i--)
			{
				if (!config.ItemPassesRules(Equipment[i]))
					Equipment.RemoveAt(i);
			}

			// Remove surpassed pieces
			for (int i = Equipment.Count - 1; i >= 0; i--)
			{
				if (Equipment.ItemIsSurpassed(Equipment[i]))
					Equipment.RemoveAt(i);
			}

			// If we were given a starting suit, lets start our SuitBuilder off with all those items
			if (startingSuit != null)
			{
				foreach (var o in startingSuit)
					SuitBuilder.Push(o.Value, o.Key);
			}

			// Remove pieces that can provide no beneficial spell
			for (int i = Equipment.Count - 1; i >= 0; i--)
			{
				if (!SuitBuilder.CanGetBeneficialSpellFrom(Equipment[i]))
					Equipment.RemoveAt(i);
			}

			// Remove pieces we can't add to our base suit
			for (int i = Equipment.Count - 1; i >= 0; i--)
			{
				if (!SuitBuilder.SlotIsOpen(Equipment[i].EquippableSlots))
				{
					if (Equipment[i].EquippableSlots.GetTotalBitsSet() == 1)
						Equipment.RemoveAt(i);
					else
					{
						if (Equipment[i].EquippableSlots.IsBodyArmor())
						{
							var reductionOptions = Equipment[i].Coverage.ReductionOptions();

							foreach (var option in reductionOptions)
							{
								if (option == CoverageFlags.Chest && SuitBuilder.SlotIsOpen(EquippableSlotFlags.Chest)) goto end;
								if (option == CoverageFlags.UpperArms && SuitBuilder.SlotIsOpen(EquippableSlotFlags.UpperArms)) goto end;
								if (option == CoverageFlags.LowerArms && SuitBuilder.SlotIsOpen(EquippableSlotFlags.LowerArms)) goto end;
								if (option == CoverageFlags.Abdomen && SuitBuilder.SlotIsOpen(EquippableSlotFlags.Abdomen)) goto end;
								if (option == CoverageFlags.UpperLegs && SuitBuilder.SlotIsOpen(EquippableSlotFlags.UpperLegs)) goto end;
								if (option == CoverageFlags.LowerLegs && SuitBuilder.SlotIsOpen(EquippableSlotFlags.LowerLegs)) goto end;
							}

							Equipment.RemoveAt(i);
						}
						else
						{
							if ((Equipment[i].EquippableSlots.HasFlag(EquippableSlotFlags.LeftRing) || Equipment[i].EquippableSlots.HasFlag(EquippableSlotFlags.RightRing)) && !SuitBuilder.SlotIsOpen(EquippableSlotFlags.LeftRing) && !SuitBuilder.SlotIsOpen(EquippableSlotFlags.RightRing)) { Equipment.RemoveAt(i); goto end; }
							if ((Equipment[i].EquippableSlots.HasFlag(EquippableSlotFlags.LeftBracelet) || Equipment[i].EquippableSlots.HasFlag(EquippableSlotFlags.RightBracelet)) && !SuitBuilder.SlotIsOpen(EquippableSlotFlags.LeftBracelet) && !SuitBuilder.SlotIsOpen(EquippableSlotFlags.RightBracelet)) { Equipment.RemoveAt(i); goto end; }
						}
					}
				}

				end: ;
			}
		}
Exemple #7
0
        protected Searcher(SearcherConfiguration config, IEnumerable <LeanMyWorldObject> equipment, CompletedSuit startingSuit = null)
        {
            Config = config;

            foreach (var piece in equipment)
            {
                Equipment.Add(piece);
            }

            // Remove surpassed pieces
            for (int i = Equipment.Count - 1; i >= 0; i--)
            {
                if (Equipment.ItemIsSurpassed(Equipment[i]))
                {
                    Equipment.RemoveAt(i);
                }
            }

            // If we were given a starting suit, lets start our SuitBuilder off with all those items
            if (startingSuit != null)
            {
                foreach (var o in startingSuit)
                {
                    SuitBuilder.Push(o.Value, o.Key);
                }
            }

            // Remove pieces that can provide no beneficial spell
            for (int i = Equipment.Count - 1; i >= 0; i--)
            {
                if (!SuitBuilder.CanGetBeneficialSpellFrom(Equipment[i]))
                {
                    Equipment.RemoveAt(i);
                }
            }

            // Remove pieces we can't add to our base suit
            for (int i = Equipment.Count - 1; i >= 0; i--)
            {
                if (!SuitBuilder.SlotIsOpen(Equipment[i].EquippableSlots))
                {
                    if (Equipment[i].EquippableSlots.GetTotalBitsSet() == 1)
                    {
                        Equipment.RemoveAt(i);
                    }
                    else
                    {
                        if (Equipment[i].EquippableSlots.IsBodyArmor())
                        {
                            var reductionOptions = Equipment[i].Coverage.ReductionOptions();

                            foreach (var option in reductionOptions)
                            {
                                if (option == CoverageMask.OuterwearChest && SuitBuilder.SlotIsOpen(EquipMask.ChestArmor))
                                {
                                    goto end;
                                }
                                if (option == CoverageMask.OuterwearUpperArms && SuitBuilder.SlotIsOpen(EquipMask.UpperArmArmor))
                                {
                                    goto end;
                                }
                                if (option == CoverageMask.OuterwearLowerArms && SuitBuilder.SlotIsOpen(EquipMask.LowerArmArmor))
                                {
                                    goto end;
                                }
                                if (option == CoverageMask.OuterwearAbdomen && SuitBuilder.SlotIsOpen(EquipMask.AbdomenArmor))
                                {
                                    goto end;
                                }
                                if (option == CoverageMask.OuterwearUpperLegs && SuitBuilder.SlotIsOpen(EquipMask.UpperLegArmor))
                                {
                                    goto end;
                                }
                                if (option == CoverageMask.OuterwearLowerLegs && SuitBuilder.SlotIsOpen(EquipMask.LowerLegArmor))
                                {
                                    goto end;
                                }
                            }

                            Equipment.RemoveAt(i);
                        }
                        else
                        {
                            if ((Equipment[i].EquippableSlots.HasFlag(EquipMask.FingerWearLeft) || Equipment[i].EquippableSlots.HasFlag(EquipMask.FingerWearRight)) && !SuitBuilder.SlotIsOpen(EquipMask.FingerWearLeft) && !SuitBuilder.SlotIsOpen(EquipMask.FingerWearRight))
                            {
                                Equipment.RemoveAt(i); goto end;
                            }
                            if ((Equipment[i].EquippableSlots.HasFlag(EquipMask.WristWearLeft) || Equipment[i].EquippableSlots.HasFlag(EquipMask.WristWearRight)) && !SuitBuilder.SlotIsOpen(EquipMask.WristWearLeft) && !SuitBuilder.SlotIsOpen(EquipMask.WristWearRight))
                            {
                                Equipment.RemoveAt(i); goto end;
                            }
                        }
                    }
                }

                end :;
            }
        }
        protected Searcher(SearcherConfiguration config, IEnumerable <SuitBuildableMyWorldObject> equipment, CompletedSuit startingSuit = null)
        {
            Config = config;

            foreach (var piece in equipment)
            {
                if (!piece.Exclude)
                {
                    Equipment.Add(piece);
                }
            }

            // Remove pieces that don't meet our minimum requirements
            for (int i = Equipment.Count - 1; i >= 0; i--)
            {
                if (!config.ItemPassesRules(Equipment[i]))
                {
                    Equipment.RemoveAt(i);
                }
            }

            // Remove surpassed pieces
            for (int i = Equipment.Count - 1; i >= 0; i--)
            {
                if (Equipment.ItemIsSurpassed(Equipment[i]))
                {
                    Equipment.RemoveAt(i);
                }
            }

            // If we were given a starting suit, lets start our SuitBuilder off with all those items
            if (startingSuit != null)
            {
                foreach (var o in startingSuit)
                {
                    SuitBuilder.Push(o.Value, o.Key);
                }
            }

            // Remove pieces that can provide no beneficial spell
            for (int i = Equipment.Count - 1; i >= 0; i--)
            {
                if (!SuitBuilder.CanGetBeneficialSpellFrom(Equipment[i]))
                {
                    Equipment.RemoveAt(i);
                }
            }

            // Remove pieces we can't add to our base suit
            for (int i = Equipment.Count - 1; i >= 0; i--)
            {
                if (!SuitBuilder.SlotIsOpen(Equipment[i].EquippableSlots))
                {
                    if (Equipment[i].EquippableSlots.GetTotalBitsSet() == 1)
                    {
                        Equipment.RemoveAt(i);
                    }
                    else
                    {
                        if (Equipment[i].EquippableSlots.IsBodyArmor())
                        {
                            var reductionOptions = Equipment[i].Coverage.ReductionOptions();

                            foreach (var option in reductionOptions)
                            {
                                if (option == CoverageFlags.Chest && SuitBuilder.SlotIsOpen(EquippableSlotFlags.Chest))
                                {
                                    goto end;
                                }
                                if (option == CoverageFlags.UpperArms && SuitBuilder.SlotIsOpen(EquippableSlotFlags.UpperArms))
                                {
                                    goto end;
                                }
                                if (option == CoverageFlags.LowerArms && SuitBuilder.SlotIsOpen(EquippableSlotFlags.LowerArms))
                                {
                                    goto end;
                                }
                                if (option == CoverageFlags.Abdomen && SuitBuilder.SlotIsOpen(EquippableSlotFlags.Abdomen))
                                {
                                    goto end;
                                }
                                if (option == CoverageFlags.UpperLegs && SuitBuilder.SlotIsOpen(EquippableSlotFlags.UpperLegs))
                                {
                                    goto end;
                                }
                                if (option == CoverageFlags.LowerLegs && SuitBuilder.SlotIsOpen(EquippableSlotFlags.LowerLegs))
                                {
                                    goto end;
                                }
                            }

                            Equipment.RemoveAt(i);
                        }
                        else
                        {
                            if ((Equipment[i].EquippableSlots.HasFlag(EquippableSlotFlags.LeftRing) || Equipment[i].EquippableSlots.HasFlag(EquippableSlotFlags.RightRing)) && !SuitBuilder.SlotIsOpen(EquippableSlotFlags.LeftRing) && !SuitBuilder.SlotIsOpen(EquippableSlotFlags.RightRing))
                            {
                                Equipment.RemoveAt(i); goto end;
                            }
                            if ((Equipment[i].EquippableSlots.HasFlag(EquippableSlotFlags.LeftBracelet) || Equipment[i].EquippableSlots.HasFlag(EquippableSlotFlags.RightBracelet)) && !SuitBuilder.SlotIsOpen(EquippableSlotFlags.LeftBracelet) && !SuitBuilder.SlotIsOpen(EquippableSlotFlags.RightBracelet))
                            {
                                Equipment.RemoveAt(i); goto end;
                            }
                        }
                    }
                }

                end :;
            }
        }