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

Commit

Permalink
fix: add a rank system for rotations.
Browse files Browse the repository at this point in the history
  • Loading branch information
ArchiDog1998 committed Aug 18, 2023
1 parent 81ab082 commit c08f456
Show file tree
Hide file tree
Showing 8 changed files with 106 additions and 23 deletions.
1 change: 1 addition & 0 deletions Resources/downloadList.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[
"ArchiDog1998|FFXIVRotations|DefaultRotations",
"IncognitoWater|IncognitoWaterRotations|IcWaRotations",
"thunderebolt|BoltsRotations|BoltsRotations",
"BrakusTapus|KirboRotations|KirboRotations"
]
3 changes: 2 additions & 1 deletion RotationSolver.Basic/Actions/BaseAction_ActionInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,10 @@ private bool WillCooldown
/// <returns></returns>
public unsafe virtual bool CanUse(out IAction act, CanUseOption option = CanUseOption.None, byte aoeCount = 0, byte gcdCountForAbility = 0)
{
act = this;

option |= OtherOption;

act = this;
var mustUse = option.HasFlag(CanUseOption.MustUse);

var player = Player.Object;
Expand Down
2 changes: 1 addition & 1 deletion RotationSolver.Basic/Configuration/Configs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ public enum PluginConfigFloat : byte

[Default(0.5f, 0f, 3f)] CountdownDelayMin,
[Default(1f)] CountdownDelayMax,
[Default(0.6f, 0.5f, 0.7f)] CountDownAhead,
[Default(0.6f, 0f, 0.7f)] CountDownAhead,

[Default(24f, 0f, 90f)] MoveTargetAngle,
[Default(60f, 10f, 1800f)] DeadTimeBoss,
Expand Down
13 changes: 10 additions & 3 deletions RotationSolver.Basic/Rotations/CustomRotation_Invoke.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using Dalamud.Logging;

namespace RotationSolver.Basic.Rotations;
namespace RotationSolver.Basic.Rotations;

public abstract partial class CustomRotation
{
Expand All @@ -18,7 +16,16 @@ public bool TryInvoke(out IAction newAction, out IAction gcdAction)
{
UpdateInfo();
UpdateActions(ClassJob.GetJobRole());

CountingOfNonRecommendedMembersUsing = 0;
newAction = Invoke(out gcdAction);
if (InCombat || AverageCountOfNonRecommendedMembersUsing == 0)
{
AverageCountOfNonRecommendedMembersUsing =
(AverageCountOfNonRecommendedMembersUsing * CountOfTracking + CountingOfNonRecommendedMembersUsing)
/ ++CountOfTracking;
}

if (!IsValid) IsValid = true;
}
catch (Exception ex)
Expand Down
98 changes: 81 additions & 17 deletions RotationSolver.Basic/Rotations/CustomRotation_OtherInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -194,12 +194,6 @@ public abstract partial class CustomRotation
/// </summary>
protected static SpecialCommandType SpecialType => DataCenter.SpecialType;

/// <summary>
///
/// </summary>
[Obsolete("Please use State or IsManual instead!", true)]
protected static StateCommandType StateType => StateCommandType.None;

/// <summary>
/// True for On, false for off.
/// </summary>
Expand Down Expand Up @@ -268,15 +262,43 @@ public abstract partial class CustomRotation
/// <returns></returns>
public static ActionID AdjustId(ActionID id) => Service.GetAdjustedActionId(id);

/// <summary>
///
/// </summary>
public double AverageCountOfNonRecommendedMembersUsing { get; internal set; } = 0;
internal long CountOfTracking { get; set; } = 0;

internal static float CountingOfNonRecommendedMembersUsing { get; set; } = 0;

private const float COMBAT_TIME_WEIGHT = 0.5f;

private const string USE_LESS_WARNING = "Please use this as less as possible. If you use it too much, your rotation will be marked as not general.";

/// <summary>
/// The actions that were used by player successfully. The first one is the latest successfully used one.
/// </summary>
protected static ActionRec[] RecordActions => DataCenter.RecordActions;
[Obsolete(USE_LESS_WARNING)]
protected static ActionRec[] RecordActions
{
get
{
CountingOfNonRecommendedMembersUsing++;
return DataCenter.RecordActions;
}
}

/// <summary>
/// How much time has passed since the last action was released.
/// </summary>
protected static TimeSpan TimeSinceLastAction => DataCenter.TimeSinceLastAction;
[Obsolete(USE_LESS_WARNING)]
protected static TimeSpan TimeSinceLastAction
{
get
{
CountingOfNonRecommendedMembersUsing++;
return DataCenter.TimeSinceLastAction;
}
}

/// <summary>
/// Check for GCD Record.
Expand All @@ -285,17 +307,25 @@ public abstract partial class CustomRotation
/// <param name="isAdjust">Check for adjust id not raw id.</param>
/// <param name="actions">True if any of this is matched.</param>
/// <returns></returns>
[Obsolete(USE_LESS_WARNING)]
public static bool IsLastGCD(bool isAdjust, params IAction[] actions)
=> IActionHelper.IsLastGCD(isAdjust, actions);
{
CountingOfNonRecommendedMembersUsing++;
return IActionHelper.IsLastGCD(isAdjust, actions);
}

/// <summary>
/// Check for GCD Record.
/// <br>WARNING: Do Not make this method the main of your rotation.</br>
/// </summary>
/// <param name="ids">True if any of this is matched.</param>
/// <returns></returns>
[Obsolete(USE_LESS_WARNING)]
public static bool IsLastGCD(params ActionID[] ids)
=> IActionHelper.IsLastGCD(ids);
{
CountingOfNonRecommendedMembersUsing++;
return IActionHelper.IsLastGCD(ids);
}

/// <summary>
/// Check for ability Record.
Expand All @@ -304,17 +334,25 @@ public static bool IsLastGCD(params ActionID[] ids)
/// <param name="isAdjust">Check for adjust id not raw id.</param>
/// <param name="actions">True if any of this is matched.</param>
/// <returns></returns>
[Obsolete(USE_LESS_WARNING)]
public static bool IsLastAbility(bool isAdjust, params IAction[] actions)
=> IActionHelper.IsLastAbility(isAdjust, actions);
{
CountingOfNonRecommendedMembersUsing++;
return IActionHelper.IsLastAbility(isAdjust, actions);
}

/// <summary>
/// Check for ability Record.
/// <br>WARNING: Do Not make this method the main of your rotation.</br>
/// </summary>
/// <param name="ids">True if any of this is matched.</param>
/// <returns></returns>
[Obsolete(USE_LESS_WARNING)]
public static bool IsLastAbility(params ActionID[] ids)
=> IActionHelper.IsLastAbility(ids);
{
CountingOfNonRecommendedMembersUsing++;
return IActionHelper.IsLastAbility(ids);
}

/// <summary>
/// Check for action Record.
Expand All @@ -323,37 +361,63 @@ public static bool IsLastAbility(params ActionID[] ids)
/// <param name="isAdjust">Check for adjust id not raw id.</param>
/// <param name="actions">True if any of this is matched.</param>
/// <returns></returns>
[Obsolete(USE_LESS_WARNING)]
public static bool IsLastAction(bool isAdjust, params IAction[] actions)
=> IActionHelper.IsLastAction(isAdjust, actions);
{
CountingOfNonRecommendedMembersUsing++;
return IActionHelper.IsLastAction(isAdjust, actions);
}

/// <summary>
/// Check for action Record.
/// <br>WARNING: Do Not make this method the main of your rotation.</br>
/// </summary>
/// <param name="ids">True if any of this is matched.</param>
/// <returns></returns>
[Obsolete(USE_LESS_WARNING)]
public static bool IsLastAction(params ActionID[] ids)
=> IActionHelper.IsLastAction(ids);
{
CountingOfNonRecommendedMembersUsing++;
return IActionHelper.IsLastAction(ids);
}

/// <summary>
/// <br>WARNING: Do Not make this method the main of your rotation.</br>
/// </summary>
/// <param name="GCD"></param>
/// <returns></returns>
protected static bool CombatElapsedLessGCD(int GCD) => CombatElapsedLess(GCD * DataCenter.WeaponTotal);
[Obsolete(USE_LESS_WARNING)]
protected static bool CombatElapsedLessGCD(int GCD)
{
CountingOfNonRecommendedMembersUsing += COMBAT_TIME_WEIGHT;
return CombatElapsedLess(GCD * DataCenter.WeaponTotal);
}

/// <summary>
/// Whether the battle lasted less than <paramref name="time"/> seconds
/// <br>WARNING: Do Not make this method the main of your rotation.</br>
/// </summary>
/// <param name="time">time in second.</param>
/// <returns></returns>
protected static bool CombatElapsedLess(float time) => CombatTime <= time;
[Obsolete(USE_LESS_WARNING)]
protected static bool CombatElapsedLess(float time)
{
CountingOfNonRecommendedMembersUsing += COMBAT_TIME_WEIGHT;
return CombatTime <= time;
}

/// <summary>
/// The combat time.
/// </summary>
public static float CombatTime => InCombat ? DataCenter.CombatTimeRaw + DataCenter.WeaponRemain : 0;
[Obsolete(USE_LESS_WARNING)]
public static float CombatTime
{
get
{
CountingOfNonRecommendedMembersUsing += COMBAT_TIME_WEIGHT;
return InCombat ? DataCenter.CombatTimeRaw + DataCenter.WeaponRemain : 0;
}
}

/// <summary>
/// <br>WARNING: Do Not make this method the main of your rotation.</br>
Expand Down
5 changes: 5 additions & 0 deletions RotationSolver.Basic/Rotations/ICustomRotation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ namespace RotationSolver.Basic.Rotations;
/// </summary>
public interface ICustomRotation : ITexture
{
/// <summary>
/// The count of not recommend members using.
/// </summary>
double AverageCountOfNonRecommendedMembersUsing { get; }

/// <summary>
/// Whether show the status in the formal page.
/// </summary>
Expand Down
5 changes: 4 additions & 1 deletion RotationSolver/Localization/Localization.json
Original file line number Diff line number Diff line change
Expand Up @@ -481,5 +481,8 @@
"ConfigWindow_List_AddPosition": "Add One territory position",
"ConfigWindow_Actions_MoveUp": "Move Up",
"ConfigWindow_Actions_MoveDown": "Move Down",
"ConfigWindow_NotInJob": "This option is unavailable while using your current job\n \nRoles or jobs needed:\n{0}"
"ConfigWindow_NotInJob": "This option is unavailable while using your current job\n \nRoles or jobs needed:\n{0}",
"ConfigWindow_Searching": "Searching...",
"ConfigWindow_UI_HideWarning": "Hide Warning",
"ConfigWindow_Auto_BeneficialAreaStrategy": "Beneficial area strategy"
}
2 changes: 2 additions & 0 deletions RotationSolver/UI/RotationConfigWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -611,6 +611,8 @@ private static void DrawRotation()
var rotation = RotationUpdater.RightNowRotation;
if (rotation == null) return;

ImGui.Text(rotation.AverageCountOfNonRecommendedMembersUsing.ToString("F2"));

var desc = rotation.Description;
if (!string.IsNullOrEmpty(desc))
{
Expand Down

0 comments on commit c08f456

Please sign in to comment.