Exemplo n.º 1
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;
        }
Exemplo n.º 2
0
        private async Task <bool> AfterGather()
        {
            Logger.Verbose(
                Localization.Localization.ExGather_Finished,
                Node.EnglishName,
                ExProfileBehavior.Me.CurrentGP,
                WorldManager.EorzaTime.ToShortTimeString());

            // in case we failed our rotation or window stuck open because items are somehow left
            if (GatheringManager.SwingsRemaining > SwingsRemaining)
            {
                // TODO: Look into possibly smarter behavior.
                await CloseGatheringWindow();
            }

            if (ExProfileBehavior.Me.CurrentGP >= ExProfileBehavior.Me.MaxGP - 30)
            {
                NodesGatheredAtMaxGp++;
            }
            else
            {
                NodesGatheredAtMaxGp = 0;
            }

            if (!ReferenceEquals(gatherRotation, initialGatherRotation))
            {
                gatherRotation = initialGatherRotation;
                Logger.Info(Localization.Localization.ExGather_RotationReset + initialGatherRotation.Attributes.Name);
            }

            var regenResult = await this.afterGatherGpRegenStrategy.RegenerateGp(
                this.Node,
                this.gatherRotation,
                this.GatherStrategy,
                this.CordialTime,
                this.CordialType
                );

            return(regenResult.StrategyState == GpRegenStrategyResult.GpRegenStrategyResultState.OK &&
                   regenResult.UseState == InventoryItem.UseResult.OK);
        }
Exemplo n.º 3
0
        private void CheckForGatherRotationOverride()
        {
            if (!gatherRotation.CanBeOverriden || DisableRotationOverride)
            {
                if (!GatherItem.IsUnknown)
                {
                    return;
                }

                Logger.Info(Localization.Localization.ExGather_RotationOverriding);
            }

            var rotation = GetOverrideRotation();

            if (rotation == null)
            {
                return;
            }

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

            gatherRotation = rotation;
        }
Exemplo n.º 4
0
        private void ResolveGatherRotation()
        {
            if (gatherRotation != null)
            {
                return;
            }

            if (GatheringSkillOrder != null && GatheringSkillOrder.GatheringSkills.Count > 0)
            {
                initialGatherRotation = gatherRotation = new GatheringSkillOrderGatheringRotation();

                Logger.Info(Localization.Localization.ExGather_RotationUse + gatherRotation.Attributes.Name);
                return;
            }

            IGatheringRotation rotation;

            if (!Rotations.TryGetValue(GatherRotation, out rotation))
            {
                // ReSharper disable once ConvertIfStatementToConditionalTernaryExpression
                if (!Rotations.TryGetValue("RegularNode", out rotation))
                {
                    rotation = new RegularNodeGatheringRotation();
                }
                else
                {
                    rotation = Rotations["RegularNode"];
                }

                Logger.Warn(Localization.Localization.ExGather_RotationNotFound);
            }

            initialGatherRotation = gatherRotation = rotation;

            Logger.Info(string.Format("Using rotation -> {0} ({1} gp per tick)", rotation.Attributes.Name, this.GpPerTick));
        }
        /// <summary>
        /// Executes the strategy logic in charge of regenerating GP after the gather.
        /// </summary>
        /// <returns></returns>
        public async Task <GpRegenStrategyResult> RegenerateGp(GatheringPointObject node, IGatheringRotation gatherRotation, GatherStrategy gatherStrategy, CordialTime cordialTime, CordialType cordialType)
        {
            var rtn = new GpRegenStrategyResult()
            {
                StrategyState        = GpRegenStrategyResult.GpRegenStrategyResultState.OK,
                EffectiveCordialType = cordialType,
                OriginalCordialType  = cordialType,
            };

            var useCordial = cordialTime.HasFlag(CordialTime.AfterGather) &&
                             this.cordialStock.HasStock() &&
                             this.cordialStock.GetCordialCooldown() == TimeSpan.Zero;

            var currentGp = ExProfileBehavior.Me.CurrentGP;
            var maxGp     = ExProfileBehavior.Me.MaxGP;
            var missingGp = maxGp - currentGp;
            var cordial   = this.cordialStock.GetBestCordial(missingGp, cordialType);

            // Return OK if there is no cordial to use
            if (cordial == null)
            {
                rtn.UseState = InventoryItem.UseResult.OK;
                return(rtn);
            }

            // Use the cordial
            rtn.UseState = await cordial.Use(
                ExProfileBehavior.Me
                );

            // Log the result
            this.LogCordialResult(
                rtn.UseState ?? InventoryItem.UseResult.CantUse,
                cordial,
                currentGp
                );

            return(rtn);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Executes the strategy logic in charge of regenerating GP before the gather.
        /// </summary>
        /// <returns></returns>
        public async Task <GpRegenStrategyResult> RegenerateGp(GatheringPointObject node, IGatheringRotation gatherRotation, GatherStrategy gatherStrategy, CordialTime cordialTime, CordialType cordialType)
        {
            var rtn = new GpRegenStrategyResult()
            {
                EffectiveCordialType = this.effectiveCordialType,
                OriginalCordialType  = this.requestedCordialType,
            };

            // Return OK immediately if there is no node
            if (node == null)
            {
                this.logger.GatheringNodeIsGone();

                rtn.StrategyState = GpRegenStrategyResult.GpRegenStrategyResultState.NodeGone;
                return(rtn);
            }

            // Configure the strategy and report to the log
            this.Configure(node, gatherRotation, gatherStrategy, cordialTime, cordialType);
            this.logger.LogReport(this);

            // Return not enough time if player has less than 3 seconds to gather
            if (this.EffectiveTimeTillGather.TotalSeconds < 3)
            {
                this.logger.GatheringNotEnoughTime();

                rtn.StrategyState = GpRegenStrategyResult.GpRegenStrategyResultState.NotEnoughTime;
                return(rtn);
            }

            if (this.gatherStrategy == GatherStrategy.GatherOrCollect)
            {
                // Return not enough GP if we cannot meet the target breakpoint for the rotation
                if (this.BreakpointGp > this.TargetGp)
                {
                    this.logger.RegeneratingNotEnoughGp();

                    rtn.StrategyState = GpRegenStrategyResult.GpRegenStrategyResultState.NotEnoughGp;
                    return(rtn);
                }
            }

            // Use the cordial if one was selected
            if (this.Cordial != null)
            {
                rtn.UseState = await this.Cordial.Use(
                    ExProfileBehavior.Me,
                    maxTimeout : this.EffectiveTimeTillGather,
                    dismount : true
                    );

                this.LogCordialResult(rtn.UseState.Value);

                // Recalculate player's ability to gather after cordial use failure
                if (rtn.UseState != InventoryItem.UseResult.OK)
                {
                    this.effectiveCordialType = CordialType.None;
                    this.CalculateTargetAndCordialSelection();

                    this.logger.LogReport(this);

                    // Return not enough GP if we cannot meet the target breakpoint for the rotation
                    if (this.BreakpointGp > this.TargetGp)
                    {
                        this.logger.RegeneratingNotEnoughGp();

                        rtn.StrategyState = GpRegenStrategyResult.GpRegenStrategyResultState.NotEnoughGp;
                        return(rtn);
                    }
                }
            }

            // Handle TouchAndGo overrides
            if (this.gatherStrategy == GatherStrategy.TouchAndGo)
            {
                // Do nothing if this is not ephemeral
                if (!node.IsEphemeral())
                {
                    this.logger.GatheringNodeSkippedNotEphemeral();

                    rtn.StrategyState = GpRegenStrategyResult.GpRegenStrategyResultState.OK;
                    return(rtn);
                }

                if (this.EffectiveTimeToRegenerate.TotalSeconds > MAX_TOUCHANDGO_WAIT)
                {
                    this.logger.RegeneratingSkippedExceedsEphemeralMaxWait(
                        this.EffectiveTimeToRegenerate.TotalSeconds,
                        MAX_TOUCHANDGO_WAIT
                        );

                    rtn.StrategyState = GpRegenStrategyResult.GpRegenStrategyResultState.OK;
                    return(rtn);
                }
            }

            // Return OK immediately if the rotation forcefully gathers the item
            if (gatherRotation.ShouldForceGather(node))
            {
                rtn.StrategyState = GpRegenStrategyResult.GpRegenStrategyResultState.OK;
                return(rtn);
            }

            // Execute wait logic
            rtn.StrategyState = await this.WaitForGpRegeneration();

            return(rtn);
        }
Exemplo n.º 7
0
        /// <summary>
        /// Configures the strategy for use
        /// </summary>
        protected void Configure(GatheringPointObject node, IGatheringRotation gatherRotation, GatherStrategy gatherStrategy, CordialTime cordialTime, CordialType cordialType)
        {
            if (gatherRotation == null)
            {
                throw new ArgumentNullException("gatherRotation");
            }

            // Set gathering parameters
            this.gatherRotation = gatherRotation;
            this.gatherStrategy = gatherStrategy;

            // Set cordial parameters
            this.cordialTime          = cordialTime;
            this.requestedCordialType = this.effectiveCordialType = cordialType;

            // Override cordial type
            if (this.requestedCordialType > CordialType.None)
            {
                // Turn off cordial when there is no stock
                if (!this.cordialStockManager.HasStock())
                {
                    this.effectiveCordialType = CordialType.None;

                    this.logger.RegeneratingCordialUseDisabledNoStock();
                }

                // Turn off cordial when node is not ephemeral in TnG strategies
                if (this.gatherStrategy == GatherStrategy.TouchAndGo && !node.IsEphemeral())
                {
                    this.effectiveCordialType = CordialType.None;
                }
            }
            else
            {
                this.effectiveCordialType = this.requestedCordialType;
            }

            // Set node lifespan parameters
            this.NodeLifespan = new EffectiveNodeLifespan(NodeHelper.GetNodeLifespan(node), this.gatherRotation.Attributes.RequiredTimeInSeconds);
            if (this.gatherStrategy == GatherStrategy.TouchAndGo)
            {
                this.NodeLifespan.Clamp(TimeSpan.Zero, TimeSpan.FromSeconds(MAX_TOUCHANDGO_WAIT));
            }
            this.EffectiveTimeTillGather = this.NodeLifespan.DeSpawn;

            // Set GP parameters
            this.StartingGp  = this.CurrentGp;
            this.MaxGp       = ExProfileBehavior.Me.MaxGP;
            this.EffectiveGp = CharacterResource.GetEffectiveGp(this.NodeLifespan.DeSpawnTicks);

            // Set breakpoint and cordial parameters
            this.CalculateTargetAndCordialSelection();

            // Calculate regeneration parameters
            this.RegeneratedGp = (ushort)(this.TargetGp - this.CordialGp - this.StartingGp);
            if (this.RegeneratedGp < 0)
            {
                this.RegeneratedGp = 0;
            }
            this.EffectiveTimeToRegenerate = CharacterResource.EstimateExpectedRegenerationTime(this.RegeneratedGp);
        }
Exemplo n.º 8
0
		private bool ResolveGatherRotation()
		{
			if (gatherRotation != null)
			{
				return false;
			}

			if (GatheringSkillOrder != null && GatheringSkillOrder.GatheringSkills.Count > 0)
			{
				initialGatherRotation = gatherRotation = new GatheringSkillOrderGatheringRotation();

				Logger.Info("Using rotation -> " + gatherRotation.Attributes.Name);
				return true;
			}

			IGatheringRotation rotation;
			if (!Rotations.TryGetValue(GatherRotation, out rotation))
			{
				// ReSharper disable once ConvertIfStatementToConditionalTernaryExpression
				if (!Rotations.TryGetValue("RegularNode", out rotation))
				{
					rotation = new RegularNodeGatheringRotation();
				}
				else
				{
					rotation = Rotations["RegularNode"];
				}

				Logger.Warn("Could not find rotation, using RegularNode instead.");
			}

			initialGatherRotation = gatherRotation = rotation;

			Logger.Info("Using rotation -> " + rotation.Attributes.Name);

			return true;
		}
Exemplo n.º 9
0
		private async Task<bool> AfterGather()
		{
			// in case we failed our rotation or window stuck open because items are somehow left
			if (GatheringManager.SwingsRemaining > 0)
			{
				// TODO: Look into possibly smarter behavior.
				await CloseGatheringWindow();
			}

			if (Me.CurrentGP >= Me.MaxGP - 30)
			{
				NodesGatheredAtMaxGp++;
			}
			else
			{
				NodesGatheredAtMaxGp = 0;
			}

			if (!object.ReferenceEquals(gatherRotation, initialGatherRotation))
			{
				gatherRotation = initialGatherRotation;
				Logger.Info("Rotation reset -> " + initialGatherRotation.Attributes.Name);
			}

			if (CordialTime.HasFlag(CordialTime.AfterGather))
			{
				if (CordialType == CordialType.Auto)
				{
					if (Me.MaxGP - Me.CurrentGP > 550)
					{
						if (await UseCordial(CordialType.HiCordial))
						{
							return true;
						}
					}

					if (Me.MaxGP - Me.CurrentGP > 390)
					{
						if (await UseCordial(CordialType.Cordial))
						{
							return true;
						}
					}
				}

				if (CordialType == CordialType.HiCordial)
				{
					if (Me.MaxGP - Me.CurrentGP > 430)
					{
						if (await UseCordial(CordialType.HiCordial))
						{
							return true;
						}

						if (await UseCordial(CordialType.Cordial))
						{
							return true;
						}
					}
				}

				if (CordialType == CordialType.Cordial && Me.MaxGP - Me.CurrentGP > 330)
				{
					if (await UseCordial(CordialType.Cordial))
					{
						return true;
					}
				}
			}

			return true;
		}
Exemplo n.º 10
0
		private void CheckForGatherRotationOverride()
		{
			if (!gatherRotation.CanBeOverriden || DisableRotationOverride)
			{
				if (!GatherItem.IsUnknown)
				{
					return;
				}

				Logger.Info("Item to gather is unknown, we are overriding the rotation to ensure we can collect it.");
			}

			var rotation = GetOverrideRotation();

			if (rotation == null)
			{
				return;
			}

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

			gatherRotation = rotation;
		}
Exemplo n.º 11
0
		private void CheckForGatherRotationOverride()
		{
			if (!gatherRotation.CanBeOverriden || DisableRotationOverride)
			{
				if (!GatherItem.IsUnknown)
				{
					return;
				}

				Logger.Info("Item to gather is unknown, we are overriding the rotation to ensure we can collect it.");
			}

			var rotationAndTypes =
				Rotations.Select(r => new { Rotation = r.Value, OverrideValue = r.Value.ResolveOverridePriority(this) })
					.Where(r => r.OverrideValue > -1)
					.OrderByDescending(r => r.OverrideValue)
					.ToArray();

			var rotation = rotationAndTypes.FirstOrDefault();

			if (rotation == null || object.ReferenceEquals(rotation.Rotation, gatherRotation))
			{
				return;
			}

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

			gatherRotation = rotation.Rotation;
		}
Exemplo n.º 12
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;
		}
Exemplo n.º 13
0
		private async Task<bool> AfterGather()
		{
			Logger.Verbose(
				"Finished gathering from {0} with {1} GP at {2} ET",
				Node.EnglishName,
				Me.CurrentGP,
				WorldManager.EorzaTime.ToShortTimeString());

			// in case we failed our rotation or window stuck open because items are somehow left
			if (GatheringManager.SwingsRemaining > SwingsRemaining)
			{
				// TODO: Look into possibly smarter behavior.
				await CloseGatheringWindow();
			}

			if (Me.CurrentGP >= Me.MaxGP - 30)
			{
				NodesGatheredAtMaxGp++;
			}
			else
			{
				NodesGatheredAtMaxGp = 0;
			}

			if (!ReferenceEquals(gatherRotation, initialGatherRotation))
			{
				gatherRotation = initialGatherRotation;
				Logger.Info("Rotation reset -> " + initialGatherRotation.Attributes.Name);
			}

			if (CordialTime.HasFlag(CordialTime.AfterGather))
			{
				if (CordialType == CordialType.Auto)
				{
					if (Me.MaxGP - Me.CurrentGP > 550)
					{
						if (await UseCordial(CordialType.HiCordial))
						{
							return true;
						}
					}

					if (Me.MaxGP - Me.CurrentGP > 390)
					{
						if (await UseCordial(CordialType.Cordial))
						{
							return true;
						}
					}
				}

				if (CordialType == CordialType.HiCordial)
				{
					if (Me.MaxGP - Me.CurrentGP > 430)
					{
						if (await UseCordial(CordialType.HiCordial))
						{
							return true;
						}

						if (await UseCordial(CordialType.Cordial))
						{
							return true;
						}
					}
				}

				if (CordialType == CordialType.Cordial && Me.MaxGP - Me.CurrentGP > 330)
				{
					if (await UseCordial(CordialType.Cordial))
					{
						return true;
					}
				}
			}

			return true;
		}
Exemplo n.º 14
0
		private void CheckForGatherRotationOverride()
		{
			if (!gatherRotation.CanBeOverriden || DisableRotationOverride)
			{
				if (!GatherItem.IsUnknown)
				{
					return;
				}

				Logger.Info(Localization.Localization.ExGather_RotationOverriding);
			}

			var rotation = GetOverrideRotation();

			if (rotation == null)
			{
				return;
			}

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

			gatherRotation = rotation;
		}
Exemplo n.º 15
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;
		}
Exemplo n.º 16
0
		private void ResolveGatherRotation()
		{
			if (gatherRotation != null)
			{
				return;
			}

			if (GatheringSkillOrder != null && GatheringSkillOrder.GatheringSkills.Count > 0)
			{
				initialGatherRotation = gatherRotation = new GatheringSkillOrderGatheringRotation();

				Logger.Info(Localization.Localization.ExGather_RotationUse + gatherRotation.Attributes.Name);
				return;
			}

			IGatheringRotation rotation;
			if (!Rotations.TryGetValue(GatherRotation, out rotation))
			{
				// ReSharper disable once ConvertIfStatementToConditionalTernaryExpression
				if (!Rotations.TryGetValue("RegularNode", out rotation))
				{
					rotation = new RegularNodeGatheringRotation();
				}
				else
				{
					rotation = Rotations["RegularNode"];
				}

				Logger.Warn(Localization.Localization.ExGather_RotationNotFound);
			}

			initialGatherRotation = gatherRotation = rotation;

			Logger.Info("Using rotation -> " + rotation.Attributes.Name);
		}