Наследование: CollectableBase
Пример #1
0
		internal async Task<bool> ResolveGatherItem()
		{
			if (!GatheringManager.WindowOpen)
			{
				return false;
			}

			var previousGatherItem = GatherItem;
			GatherItemIsFallback = false;
			GatherItem = null;
			CollectableItem = null;

			var windowItems = GatheringManager.GatheringWindowItems.ToArray();

			// TODO: move method to common so we use it on fish too
			if (InventoryItemCount() >= 100)
			{
				if (ItemNames != null && ItemNames.Count > 0)
				{
					if (
						SetGatherItemByItemName(
							windowItems.OrderByDescending(i => i.SlotIndex).Where(i => i.IsFilled && !i.IsUnknown && i.ItemId < 20).ToArray()))
					{
						return true;
					}
				}

				GatherItem =
					windowItems.Where(i => i.IsFilled && !i.IsUnknown)
						.OrderByDescending(i => i.ItemId)
						.FirstOrDefault(i => i.ItemId < 20);

				if (GatherItem != null)
				{
					return true;
				}

				Logger.Warn("Inventory is full and no shards/crystals/clusters to gather. Gathering complete.");
				return false;
			}

			if (DiscoverUnknowns)
			{
				var items = new[] { 0U, 1U, 2U, 3U, 4U, 5U, 6U, 7U }.Select(GatheringManager.GetGatheringItemByIndex).ToArray();

				GatherItem = items.FirstOrDefault(i => i.IsUnknownChance() && i.Amount > 0);

				if (GatherItem != null)
				{
					return true;
				}
			}

			if (Collectables != null && Collectables.Count > 0)
			{
				foreach (var collectable in Collectables)
				{
					GatherItem =
						windowItems.FirstOrDefault(
							i =>
							i.IsFilled && !i.IsUnknown
							&& string.Equals(collectable.Name, i.ItemData.EnglishName, StringComparison.InvariantCultureIgnoreCase));

					if (GatherItem != null)
					{
						CollectableItem = collectable;
						return true;
					}
				}
			}

			if (ItemNames != null && ItemNames.Count > 0)
			{
				if (SetGatherItemByItemName(windowItems))
				{
					return true;
				}
			}

			if (Slot > -1 && Slot < 8)
			{
				GatherItem = GatheringManager.GetGatheringItemByIndex((uint)Slot);
			}

			if (GatherItem == null && (!AlwaysGather || GatherStrategy == GatherStrategy.TouchAndGo))
			{
				Poi.Clear("Skipping this node, no items we want to gather.");

				await CloseGatheringWindow();

				return false;
			}

			if (GatherItem != null)
			{
				return true;
			}

			GatherItemIsFallback = true;

			GatherItem =
				windowItems.Where(i => i.IsFilled && !i.IsUnknown)
					.OrderByDescending(i => i.ItemId)
					.FirstOrDefault(i => i.ItemId < 20) // Try to gather cluster/crystal/shard
				?? windowItems.FirstOrDefault(
					i => i.IsFilled && !i.IsUnknown && !i.ItemData.Unique && !i.ItemData.Untradeable && i.ItemData.ItemCount() > 0)
				// Try to collect items you have that stack
				?? windowItems.Where(i => i.Amount > 0 && !i.ItemData.Unique && !i.ItemData.Untradeable)
						.OrderByDescending(i => i.SlotIndex)
						.FirstOrDefault(); // Take last item that is not unique or untradeable

			// Seems we only have unknowns.
			if (GatherItem == null)
			{
				var items = new[] { 0U, 1U, 2U, 3U, 4U, 5U, 6U, 7U }.Select(GatheringManager.GetGatheringItemByIndex).ToArray();

				GatherItem = items.FirstOrDefault(i => i.IsUnknownChance() && i.Amount > 0);

				if (GatherItem != null)
				{
					return true;
				}

				Logger.Warn("Unable to find an item to gather, moving on.");

				return false;
			}

			if (previousGatherItem == null || previousGatherItem.ItemId != GatherItem.ItemId)
			{
				Logger.Info("could not find item by slot or name, gathering " + GatherItem.ItemData + " instead.");
			}

			return true;
		}
Пример #2
0
		internal void ResetInternal()
		{
			interactedWithNode = false;
			GatherSpot = null;
			Node = null;
			GatherItem = null;
			CollectableItem = null;
		}
Пример #3
0
		private void CheckForEstimatedGatherRotation()
		{
			if (!gatherRotation.CanBeOverriden || DisableRotationOverride)
			{
				return;
			}

			CollectableItem = Items.OfType<Collectable>().FirstOrDefault();

			if (CollectableItem != null)
			{
				Logger.Info("Estimating rotation based off {0}", CollectableItem);
			}
			else
			{
				Logger.Info("Estimating rotation based off GatherIncrease: '{0}'", GatherIncrease);
			}

			var rotation = GetOverrideRotation();

			if (rotation == null)
			{
				Logger.Info("Rotation did not change");
				return;
			}

			Logger.Info("Rotation Estimate -> Old: {0} , New: {1}", gatherRotation.Attributes.Name, rotation.Attributes.Name);

			gatherRotation = rotation;
		}
Пример #4
0
		private bool SetGatherItemByItemName(ICollection<GatheringItem> windowItems)
		{
			foreach (var item in Items)
			{
				GatherItem =
					windowItems.FirstOrDefault(
						i =>
						i.IsFilled && !i.IsUnknown
						&& string.Equals(item.Name, i.ItemData.EnglishName, StringComparison.InvariantCultureIgnoreCase)
						&& (!i.ItemData.Unique || i.ItemData.ItemCount() == 0));

				if (GatherItem != null)
				{
					// We don't need to check null...since it will be null anyway.
					CollectableItem = item as Collectable;
					return true;
				}
			}

			return false;
		}
Пример #5
0
		private void CheckForEstimatedGatherRotation()
		{
			if (!gatherRotation.CanBeOverriden || DisableRotationOverride)
			{
				return;
			}

			CollectableItem = Items.OfType<Collectable>().FirstOrDefault();

			if (CollectableItem != null)
			{
				Logger.Info(Localization.Localization.ExGather_Rotationbaseoff, CollectableItem);
			}
			else
			{
				Logger.Info(Localization.Localization.ExGather_RotationbaseoffGatherIncrease, GatherIncrease);
			}

			var rotation = GetOverrideRotation();

			if (rotation == null)
			{
				Logger.Info(Localization.Localization.ExGather_RotationNotChange);
				return;
			}

			Logger.Info(Localization.Localization.ExGather_RotationEstimate, gatherRotation.Attributes.Name, rotation.Attributes.Name);

			gatherRotation = rotation;
		}
Пример #6
0
		internal async Task<bool> ResolveGatherItem()
		{
			if (!GatheringManager.WindowOpen)
			{
				return false;
			}

			var previousGatherItem = GatherItem;
			GatherItemIsFallback = false;
			GatherItem = null;
			CollectableItem = null;

			var windowItems = GatheringManager.GatheringWindowItems.ToArray();

			// TODO: move method to common so we use it on fish too
			if (InventoryItemCount() >= 100)
			{
				if (Items.Count > 0)
				{
					if (
						SetGatherItem(
							windowItems.OrderByDescending(i => i.SlotIndex).Where(i => i.IsFilled && !i.IsUnknown && i.ItemId < 20).ToArray()))
					{
						return true;
					}
				}

				GatherItem =
					windowItems.Where(i => i.IsFilled && !i.IsUnknown)
						.OrderByDescending(i => i.ItemId)
						.FirstOrDefault(i => i.ItemId < 20);

				if (GatherItem != null)
				{
					return true;
				}

				Logger.Warn(Localization.Localization.ExGather_FullInventory);
				return false;
			}

			if (DiscoverUnknowns)
			{
				var items = new[] { 0U, 1U, 2U, 3U, 4U, 5U, 6U, 7U }.Select(GatheringManager.GetGatheringItemByIndex);

				GatherItem = items.FirstOrDefault(i => i.IsUnknownChance() && i.Amount > 0);

				if (GatherItem != null)
				{
					return true;
				}
			}

			if (Items.Count > 0)
			{
				if (SetGatherItem(windowItems))
				{
					return true;
				}
			}

			if (Slot > -1 && Slot < 8)
			{
				GatherItem = GatheringManager.GetGatheringItemByIndex((uint) Slot);
			}

			if (GatherItem == null && (!AlwaysGather || GatherStrategy == GatherStrategy.TouchAndGo))
			{
				Poi.Clear(Localization.Localization.ExGather_SkipNode);

				await CloseGatheringWindow();

				return false;
			}

			if (GatherItem != null)
			{
				return true;
			}

			GatherItemIsFallback = true;

			GatherItem =
				windowItems.Where(i => i.IsFilled && !i.IsUnknown)
					.OrderByDescending(i => i.ItemId)
					.FirstOrDefault(i => i.ItemId < 20) // Try to gather cluster/crystal/shard
				?? windowItems.FirstOrDefault(
					i => i.IsFilled && !i.IsUnknown && !i.ItemData.Unique && !i.ItemData.Untradeable && i.ItemData.ItemCount() > 0)
					// Try to collect items you have that stack
				?? windowItems.Where(i => i.Amount > 0 && !i.ItemData.Unique && !i.ItemData.Untradeable)
					.OrderByDescending(i => i.SlotIndex)
					.FirstOrDefault(); // Take last item that is not unique or untradeable

			// Seems we only have unknowns.
			if (GatherItem == null)
			{
				var items = new[] {0U, 1U, 2U, 3U, 4U, 5U, 6U, 7U}.Select(GatheringManager.GetGatheringItemByIndex).ToArray();

				GatherItem = items.FirstOrDefault(i => i.IsUnknownChance() && i.Amount > 0);

				if (GatherItem != null)
				{
					return true;
				}

				Logger.Warn(Localization.Localization.ExGather_NothingToGather);

				return false;
			}

			if (previousGatherItem == null || previousGatherItem.ItemId != GatherItem.ItemId)
			{
				Logger.Info(Localization.Localization.ExGather_NothingToGather2 + GatherItem.ItemData + Localization.Localization.ExGather_NothingToGather3);
			}

			return true;
		}
Пример #7
0
		private bool SetGatherItem(ICollection<GatheringItem> windowItems)
		{
			foreach (var item in Items)
			{
				var items = windowItems.Where(i => i.IsFilled && !i.IsUnknown).ToArray();

				if (item.Id > 0)
				{
					GatherItem =
						items.FirstOrDefault(i => i.ItemData.Id == item.Id
						&& (!i.ItemData.Unique || i.ItemData.ItemCount() == 0));
				}

				GatherItem = GatherItem ??
					items.FirstOrDefault(
						i => string.Equals(item.LocalName, i.ItemData.CurrentLocaleName, StringComparison.InvariantCultureIgnoreCase)
						&& (!i.ItemData.Unique || i.ItemData.ItemCount() == 0)) ??
					items.FirstOrDefault(
						i => string.Equals(item.Name, i.ItemData.EngName, StringComparison.InvariantCultureIgnoreCase)
						&& (!i.ItemData.Unique || i.ItemData.ItemCount() == 0));

				if (GatherItem != null)
				{
					// We don't need to check null...since it will be null anyway.
					CollectableItem = item as Collectable;
					return true;
				}
			}

			return false;
		}