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

Commit

Permalink
fix: add an invalid rotation option.
Browse files Browse the repository at this point in the history
  • Loading branch information
ArchiDog1998 committed Apr 16, 2023
1 parent d3daf7a commit d6aeb32
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 28 deletions.
17 changes: 0 additions & 17 deletions RotationSolver.Basic/Actions/BaseAction_BasicInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,6 @@ public virtual unsafe uint MPNeed
}
}

public BaseAction(ActionID actionID)
: this(actionID, ActionOption.None)
{

}


public BaseAction(ActionID actionID, ActionOption option = ActionOption.None)
{
_action = Service.GetSheet<Action>().GetRow((uint)actionID);
Expand All @@ -107,15 +100,5 @@ public BaseAction(ActionID actionID, ActionOption option = ActionOption.None)
CoolDownGroup = _action.GetCoolDownGroup();
}

private static ActionOption GetOption(bool isFriendly = false, bool endSpecial = false, bool isEot = false, bool isTimeline = false)
{
ActionOption option = ActionOption.None;
if (isFriendly) option |= ActionOption.Friendly;
if (endSpecial) option |= ActionOption.EndSpecial;
if (isEot) option |= ActionOption.Eot;
if (isTimeline) option |= ActionOption.Friendly;
return option;
}

public override string ToString() => Name;
}
5 changes: 3 additions & 2 deletions RotationSolver.Basic/Actions/BaseAction_Target.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ public partial class BaseAction
private uint _targetId = Service.Player?.ObjectId ?? 0;

private Func<IEnumerable<BattleChara>, bool, BattleChara> _choiceTarget = null;
public Func<IEnumerable<BattleChara>, bool, BattleChara> ChoiceTarget

internal Func<IEnumerable<BattleChara>, bool, BattleChara> ChoiceTarget
{
private get
{
Expand All @@ -35,7 +36,7 @@ private get

internal Func<IEnumerable<BattleChara>, IEnumerable<BattleChara>> FilterForHostiles { private get; set; } = null;

public StatusID[] TargetStatus { get; set; } = null;
public StatusID[] TargetStatus { get; internal set; } = null;

internal static bool TankDefenseSelf(BattleChara chara)
{
Expand Down
7 changes: 6 additions & 1 deletion RotationSolver.Basic/Actions/IBaseAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,13 @@ public interface IBaseAction : IAction

float Range { get; }

[EditorBrowsable(EditorBrowsableState.Never)]
bool IsFriendly { get; }

[EditorBrowsable(EditorBrowsableState.Never)]
bool IsTimeline { get; }

[EditorBrowsable(EditorBrowsableState.Never)]
bool IsEot { get; }

EnemyPositional EnemyPositional { get; }
Expand Down Expand Up @@ -123,7 +128,7 @@ public interface IBaseAction : IAction
/// <summary>
/// If target has these statuses from player self, this aciton will not used.
/// </summary>
StatusID[] TargetStatus { get; set; }
StatusID[] TargetStatus { get; }

BattleChara Target { get; }

Expand Down
24 changes: 19 additions & 5 deletions RotationSolver.Basic/Rotations/CustomRotation_BasicInfo.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Lumina.Excel.GeneratedSheets;
using Dalamud.Logging;
using Lumina.Excel.GeneratedSheets;

namespace RotationSolver.Basic.Rotations;

Expand Down Expand Up @@ -71,14 +72,27 @@ public bool IsEnabled

public IAction AntiKnockbackAbility { get; private set; }

/// <summary>
/// Description about the actions.
/// </summary>
//public virtual SortedList<DescType, string> DescriptionDict { get; } = new SortedList<DescType, string>();
public bool IsValid { get; } = false;

private protected CustomRotation()
{
IconID = IconSet.GetJobIcon(this);
Configs = CreateConfiguration();

try
{
for (byte i = 0; i < 3; i++)
{
Ability(i, GCD(i, true, true), out _, true, true);
}
IsValid = true;
}
catch (Exception ex)
{
PluginLog.Warning(ex, $"The rotation {Name} is not valid, please tell to the author");
IsValid = false;
}

}

protected virtual IRotationConfigSet CreateConfiguration()
Expand Down
2 changes: 2 additions & 0 deletions RotationSolver.Basic/Rotations/ICustomRotation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ namespace RotationSolver.Basic.Rotations;

public interface ICustomRotation : ITexture
{
bool IsValid { get; }

ClassJob Job { get; }
ClassJobID[] JobIDs { get; }

Expand Down
1 change: 1 addition & 0 deletions RotationSolver/Localization/Strings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ internal partial class Strings
public string ConfigWindow_Control_NeedToEnable { get; set; } = " (Need to enable)";
public string ConfigWindow_Control_ClickToUse { get; set; } = "Click to use it!";
public string ConfigWindow_Rotation_BetaRotation { get; set; } = "Beta Rotation!";
public string ConfigWindow_Rotation_InvalidRotation { get; set; } = "Invalid Rotation! Please contact to the author!";
public string ConfigWindow_Rotation_ResetToDefault { get; set; } = "Click to reset the rotation configuration to default!";
#endregion

Expand Down
3 changes: 2 additions & 1 deletion RotationSolver/RotationHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,8 @@ public static bool IsAllowed(this Assembly assembly)
}

public static Vector4 GetColor(this ICustomRotation rotation)
=> !rotation.IsAllowed(out _) ? ImGuiColors.DalamudViolet : rotation.IsBeta()
=> ! rotation.IsValid ? ImGuiColors.DPSRed :
!rotation.IsAllowed(out _) ? ImGuiColors.DalamudViolet : rotation.IsBeta()
? ImGuiColors.DalamudOrange : ImGuiColors.DalamudWhite ;

public static bool IsBeta(this ICustomRotation rotation)
Expand Down
8 changes: 6 additions & 2 deletions RotationSolver/UI/ImGuiHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,10 @@ public unsafe static void Display(this ICustomRotation rotation, ICustomRotation

ImGui.PushStyleColor(ImGuiCol.Text, rotation.GetColor());
ImGui.Text(rotation.GetType().Assembly.GetName().Name);
if(!rotation.IsValid)
{
HoveredString(LocalizationManager.RightLang.ConfigWindow_Rotation_InvalidRotation);
}
if (!rotation.IsAllowed(out _))
{
var showStr = string.Format(LocalizationManager.RightLang.ConfigWindow_Helper_HighEndWarning, rotation)
Expand All @@ -465,7 +469,7 @@ public unsafe static void Display(this ICustomRotation rotation, ICustomRotation

HoveredString(showStr);
}
if (rotation.IsBeta())
else if (rotation.IsBeta())
{
HoveredString(LocalizationManager.RightLang.ConfigWindow_Rotation_BetaRotation);
}
Expand Down Expand Up @@ -615,7 +619,7 @@ private unsafe static void Display(this IBaseAction action, bool IsActive) => ac
ImGui.Text($"Can Use: {action.CanUse(out _, option)} ");
ImGui.Text("Must Use:" + action.CanUse(out _, option | CanUseOption.MustUse).ToString());
ImGui.Text("Empty Use:" + action.CanUse(out _, option | CanUseOption.EmptyOrSkipCombo).ToString());
ImGui.Text("Must & Empty Use:" + action.CanUse(out _, option | CanUseOption.MustUse | CanUseOption.EmptyOrSkipCombo).ToString());
ImGui.Text("Must & Empty Use:" + action.CanUse(out _, option | CanUseOption.MustUseEmpty).ToString());
if (action.Target != null)
{
ImGui.Text("Target Name: " + action.Target.Name);
Expand Down

0 comments on commit d6aeb32

Please sign in to comment.