Skip to content
This repository has been archived by the owner on Aug 28, 2024. It is now read-only.

Commit

Permalink
fix: action condition can use fix.
Browse files Browse the repository at this point in the history
  • Loading branch information
ArchiDog1998 committed Feb 27, 2024
1 parent 01fbd83 commit 7924c55
Show file tree
Hide file tree
Showing 17 changed files with 161 additions and 144 deletions.
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<TargetFramework>net7.0-windows</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Authors>ArchiTed</Authors>
<Version>4.0.3.3</Version>
<Version>4.0.3.4</Version>
<PlatformTarget>x64</PlatformTarget>
<Platforms>AnyCPU</Platforms>
<LangVersion>latest</LangVersion>
Expand Down
2 changes: 1 addition & 1 deletion Resources/RotationSolverRecord.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"ClickingCount": 86231,
"ClickingCount": 86236,
"SayingHelloCount": 75,
"SaidUsers": []
}
60 changes: 51 additions & 9 deletions RotationSolver.Basic/Actions/BaseAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,51 +6,72 @@
namespace RotationSolver.Basic.Actions;
public class BaseAction : IBaseAction
{
/// <inheritdoc/>
public TargetResult? Target { get; set; } = null;

/// <inheritdoc/>
public TargetResult? PreviewTarget { get; private set; } = null;

/// <inheritdoc/>
public Action Action { get; }

/// <inheritdoc/>
public ActionTargetInfo TargetInfo { get; }

/// <inheritdoc/>
public ActionBasicInfo Info { get; }

/// <inheritdoc/>
public ActionCooldownInfo Cooldown { get; }

ICooldown IAction.Cooldown => Cooldown;

/// <inheritdoc/>
public uint ID => Info.ID;

/// <inheritdoc/>
public uint AdjustedID => Info.AdjustedID;

/// <inheritdoc/>
public float AnimationLockTime => Info.AnimationLockTime;

/// <inheritdoc/>
public uint SortKey => Cooldown.CoolDownGroup;

public bool IsCoolingDown => Cooldown.IsCoolingDown;

/// <inheritdoc/>
public uint IconID => ID == 3 ? 104 : Info.IconID;

/// <inheritdoc/>
public string Name => Info.Name;


/// <inheritdoc/>
public string Description => string.Empty;

/// <inheritdoc/>
public byte Level => Info.Level;

/// <inheritdoc/>
public bool IsEnabled
{
get => Config.IsEnabled;
set => Config.IsEnabled = value;
}

/// <inheritdoc/>
public bool IsInCooldown
{
get => Config.IsInCooldown;
set => Config.IsInCooldown = value;
}

/// <inheritdoc/>
public bool EnoughLevel => Info.EnoughLevel;

/// <inheritdoc/>
public ActionSetting Setting { get; set; }

/// <inheritdoc/>
public ActionConfig Config
{
get
Expand All @@ -68,6 +89,11 @@ public ActionConfig Config
}
}

/// <summary>
/// The default constructor
/// </summary>
/// <param name="actionID">action id</param>
/// <param name="isDutyAction">is this action a duty action</param>
public BaseAction(ActionID actionID, bool isDutyAction = false)
{
Action = Service.GetSheet<Action>().GetRow((uint)actionID)!;
Expand All @@ -78,29 +104,30 @@ public BaseAction(ActionID actionID, bool isDutyAction = false)
Setting = new();
}

public bool CanUse(out IAction act, bool skipStatusProvideCheck = false, bool skipCombo = false, bool ignoreCastingCheck = false,
bool isEmpty = false, bool onLastAbility = false, bool ignoreClippingCheck = false, bool skipAoeCheck = false, byte gcdCountForAbility = 0)
/// <inheritdoc/>
public bool CanUse(out IAction act, bool skipStatusProvideCheck = false, bool skipCombo = false, bool skipCastingCheck = false,
bool usedUp = false, bool onLastAbility = false, bool skipClippingCheck = false, bool skipAoeCheck = false, byte gcdCountForAbility = 0)
{
act = this!;

Setting.EndSpecial = IBaseAction.ShouldEndSpecial;

if (IBaseAction.ActionPreview)
{
ignoreCastingCheck = ignoreClippingCheck = true;
skipCastingCheck = skipClippingCheck = true;
}
if (IBaseAction.AllEmpty)
{
isEmpty = true;
usedUp = true;
}
if (IBaseAction.IgnoreClipping)
{
ignoreClippingCheck = true;
skipClippingCheck = true;
}

if (!Info.BasicCheck(skipStatusProvideCheck, skipCombo, ignoreCastingCheck)) return false;
if (!Info.BasicCheck(skipStatusProvideCheck, skipCombo, skipCastingCheck)) return false;

if (!Cooldown.CooldownCheck(isEmpty, onLastAbility, ignoreClippingCheck, gcdCountForAbility)) return false;
if (!Cooldown.CooldownCheck(usedUp, onLastAbility, skipClippingCheck, gcdCountForAbility)) return false;


if (Setting.IsMeleeRange && IActionHelper.IsLastAction(IActionHelper.MovingActions)) return false; //No range actions after moving.
Expand All @@ -116,6 +143,21 @@ public bool CanUse(out IAction act, bool skipStatusProvideCheck = false, bool sk
return true;
}

/// <inheritdoc/>
public bool CanUse(out IAction act, CanUseOption option, byte gcdCountForAbility = 0)
{
return CanUse(out act,
option.HasFlag(CanUseOption.SkipStatusProvideCheck),
option.HasFlag(CanUseOption.SkipCombo),
option.HasFlag(CanUseOption.SkipCastingCheck),
option.HasFlag(CanUseOption.UsedUp),
option.HasFlag(CanUseOption.OnLastAbility),
option.HasFlag(CanUseOption.SkipClippingCheck),
option.HasFlag(CanUseOption.SkipAoeCheck),
gcdCountForAbility);
}

/// <inheritdoc/>
public unsafe bool Use()
{
if (!Target.HasValue) return false;
Expand Down
6 changes: 4 additions & 2 deletions RotationSolver.Basic/Actions/IBaseAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ public interface IBaseAction : IAction
ActionSetting Setting { get; set; }
internal ActionConfig Config { get; }

bool CanUse(out IAction act, bool skipStatusProvideCheck = false, bool skipCombo = false, bool ignoreCastingCheck = false,
bool isEmpty = false, bool onLastAbility = false, bool ignoreClippingCheck = false, bool skipAoeCheck = false, byte gcdCountForAbility = 0);
bool CanUse(out IAction act, bool skipStatusProvideCheck = false, bool skipCombo = false, bool skipCastingCheck = false,
bool usedUp = false, bool onLastAbility = false, bool skipClippingCheck = false, bool skipAoeCheck = false, byte gcdCountForAbility = 0);

bool CanUse(out IAction act, CanUseOption option, byte gcdCountForAbility = 0);
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ protected override bool IsTrueInside(ICustomRotation rotation)
return !_action.Cooldown.WillHaveOneChargeGCD((uint)Param1, Param2); // Smaller

case ActionConditionType.CanUse:
return _action.CanUse(out _);
return _action.CanUse(out _, (CanUseOption)Param1);

case ActionConditionType.EnoughLevel:
return _action.EnoughLevel;
Expand Down
83 changes: 0 additions & 83 deletions RotationSolver.Basic/Data/ActionOption.cs

This file was deleted.

61 changes: 61 additions & 0 deletions RotationSolver.Basic/Data/CanUseOption.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace RotationSolver.Basic.Data;

/// <summary>
/// the option for the <see cref="IBaseAction.CanUse(out IAction, CanUseOption, byte)"/>
/// </summary>
[Flags]
public enum CanUseOption : byte
{
/// <summary>
/// None.
/// </summary>
None,

/// <summary>
/// Skip Status Provide Check
/// </summary>
[Description("Skip Status Provide Check")]
SkipStatusProvideCheck = 1 << 0,

/// <summary>
/// Skip Combo Check
/// </summary>
[Description("Skip Combo Check")]
SkipCombo = 1 << 1,

/// <summary>
/// Skip Casting and Moving Check
/// </summary>
[Description("Skip Casting and Moving Check")]
SkipCastingCheck = 1 << 2,

/// <summary>
/// Is it used up all stacks
/// </summary>
[Description("Is it used up all stacks")]
UsedUp = 1 << 3,

/// <summary>
/// Is it on the last ability
/// </summary>
[Description("Is it on the last ability")]
OnLastAbility = 1 << 4,

/// <summary>
/// Skip clipping Check
/// </summary>
[Description("Skip clipping Check")]
SkipClippingCheck = 1 << 5,

/// <summary>
/// Skip aoe Check
/// </summary>
[Description("Skip aoe Check")]
SkipAoeCheck = 1 << 6,
}
8 changes: 4 additions & 4 deletions RotationSolver.Basic/Rotations/Basic/DancerRotation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ protected bool ExecuteStepGCD(out IAction? act)
[RotationDesc(ActionID.EnAvantPvE)]
protected sealed override bool MoveForwardAbility(out IAction act)
{
if (EnAvantPvE.CanUse(out act, isEmpty:true)) return true;
if (EnAvantPvE.CanUse(out act, usedUp:true)) return true;
return false;
}

Expand All @@ -277,8 +277,8 @@ protected sealed override bool MoveForwardAbility(out IAction act)
[RotationDesc(ActionID.CuringWaltzPvE, ActionID.ImprovisationPvE)]
protected sealed override bool HealAreaAbility(out IAction act)
{
if (CuringWaltzPvE.CanUse(out act, isEmpty: true)) return true;
if (ImprovisationPvE.CanUse(out act, isEmpty: true)) return true;
if (CuringWaltzPvE.CanUse(out act, usedUp: true)) return true;
if (ImprovisationPvE.CanUse(out act, usedUp: true)) return true;
return false;
}

Expand All @@ -290,7 +290,7 @@ protected sealed override bool HealAreaAbility(out IAction act)
[RotationDesc(ActionID.ShieldSambaPvE)]
protected sealed override bool DefenseAreaAbility(out IAction act)
{
if (ShieldSambaPvE.CanUse(out act, isEmpty: true)) return true;
if (ShieldSambaPvE.CanUse(out act, usedUp: true)) return true;
return false;
}
}
2 changes: 1 addition & 1 deletion RotationSolver.Basic/Rotations/Basic/DragoonRotation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ protected sealed override bool DefenseAreaAbility(out IAction? act)
[RotationDesc(ActionID.ElusiveJumpPvE)]
protected override bool MoveBackAbility(out IAction? act)
{
if (ElusiveJumpPvE.CanUse(out act, ignoreClippingCheck: true)) return true;
if (ElusiveJumpPvE.CanUse(out act, skipClippingCheck: true)) return true;
return base.MoveBackAbility(out act);
}
}
2 changes: 1 addition & 1 deletion RotationSolver.Basic/Rotations/Basic/MonkRotation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ protected sealed override bool HealAreaAbility(out IAction? act)
[RotationDesc(ActionID.RiddleOfEarthPvE)]
protected sealed override bool DefenseSingleAbility(out IAction? act)
{
if (RiddleOfEarthPvE.CanUse(out act, isEmpty: true)) return true;
if (RiddleOfEarthPvE.CanUse(out act, usedUp: true)) return true;
return base.DefenseSingleAbility(out act);
}
}
2 changes: 1 addition & 1 deletion RotationSolver.Basic/Rotations/Basic/ScholarRotation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ static partial void ModifyDeploymentTacticsPvE(ref ActionSetting setting)
[RotationDesc(ActionID.ExpedientPvE)]
protected override bool SpeedAbility(out IAction? act)
{
if (InCombat && ExpedientPvE.CanUse(out act, isEmpty: true)) return true;
if (InCombat && ExpedientPvE.CanUse(out act, usedUp: true)) return true;
return base.SpeedAbility(out act);
}
}
Loading

0 comments on commit 7924c55

Please sign in to comment.