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 parameter called mustUse in the ActionCheck.
Browse files Browse the repository at this point in the history
  • Loading branch information
ArchiDog1998 committed May 14, 2023
1 parent 5e11739 commit 85cd1b9
Show file tree
Hide file tree
Showing 24 changed files with 188 additions and 199 deletions.
4 changes: 2 additions & 2 deletions RotationSolver.Basic/Actions/BaseAction_ActionInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public partial class BaseAction

public virtual StatusID[] StatusNeed { get; init; } = null;

public Func<BattleChara, bool> ActionCheck { get; init; } = null;
public Func<BattleChara, bool, bool> ActionCheck { get; init; } = null;

private bool WillCooldown
{
Expand Down Expand Up @@ -107,7 +107,7 @@ public unsafe virtual bool CanUse(out IAction act, CanUseOption option = CanUseO

if (!FindTarget(mustUse, out var target) || target == null) return false;

if (ActionCheck != null && !ActionCheck(target)) return false;
if (ActionCheck != null && !ActionCheck(target, mustUse)) return false;

Target = target;
if(!option.HasFlag(CanUseOption.IgnoreTarget)) _targetId = target.ObjectId;
Expand Down
4 changes: 2 additions & 2 deletions RotationSolver.Basic/Actions/BaseAction_Target.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ private get

public StatusID[] TargetStatus { get; init; } = null;

internal static bool TankDefenseSelf(BattleChara chara)
internal static bool TankDefenseSelf(BattleChara chara, bool mustUse)
{
return DataCenter.TarOnMeTargets.Any();
return DataCenter.TarOnMeTargets.Any() | mustUse;
}
internal static bool TankBreakOtherCheck(ClassJobID id)
{
Expand Down
2 changes: 1 addition & 1 deletion RotationSolver.Basic/Actions/IBaseAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public interface IBaseAction : IAction
/// Check for this action, but not for the rotation. It is some additional conditions for this action.
/// Input data is the target for this action.
/// </summary>
Func<BattleChara, bool> ActionCheck { get; }
Func<BattleChara, bool, bool> ActionCheck { get; }

/// <summary>
/// Is a GCD action.
Expand Down
22 changes: 11 additions & 11 deletions RotationSolver.Basic/Rotations/Basic/AST_Base.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public abstract class AST_Base : CustomRotation

public static IBaseAction AspectedHelios { get; } = new BaseAction(ActionID.AspectedHelios, ActionOption.Hot)
{
ActionCheck = b => !IsLastGCD(ActionID.AspectedHelios),
ActionCheck = (b, m) => !IsLastGCD(ActionID.AspectedHelios),
StatusProvide = new StatusID[] { StatusID.AspectedHelios },
};

Expand Down Expand Up @@ -96,7 +96,7 @@ public abstract class AST_Base : CustomRotation

public static IBaseAction Astrodyne { get; } = new BaseAction(ActionID.Astrodyne)
{
ActionCheck = b =>
ActionCheck = (b, m) =>
{
if (JobGauge.Seals.Length != 3) return false;
if (JobGauge.Seals.Contains(SealType.NONE)) return false;
Expand All @@ -108,56 +108,56 @@ public abstract class AST_Base : CustomRotation

public static IBaseAction Draw { get; } = new BaseAction(ActionID.Draw)
{
ActionCheck = b => DrawnCard == CardType.NONE,
ActionCheck = (b, m) => DrawnCard == CardType.NONE,
};

public static IBaseAction Redraw { get; } = new BaseAction(ActionID.Redraw)
{
StatusNeed = new[] { StatusID.ClarifyingDraw },
ActionCheck = b => DrawnCard != CardType.NONE && Seals.Contains(GetCardSeal(DrawnCard)),
ActionCheck = (b, m) => DrawnCard != CardType.NONE && Seals.Contains(GetCardSeal(DrawnCard)),
};


public static IBaseAction MinorArcana { get; } = new BaseAction(ActionID.MinorArcana)
{
ActionCheck = b => InCombat,
ActionCheck = (b, m) => InCombat,
};

static IBaseAction Balance { get; } = new BaseAction(ActionID.Balance)
{
ChoiceTarget = TargetFilter.ASTMeleeTarget,
ActionCheck = b => DrawnCard == CardType.BALANCE,
ActionCheck = (b, m) => DrawnCard == CardType.BALANCE,
};

static IBaseAction Arrow { get; } = new BaseAction(ActionID.Arrow)
{
ChoiceTarget = TargetFilter.ASTMeleeTarget,
ActionCheck = b => DrawnCard == CardType.ARROW,
ActionCheck = (b, m) => DrawnCard == CardType.ARROW,
};

static IBaseAction Spear { get; } = new BaseAction(ActionID.Spear)
{
ChoiceTarget = TargetFilter.ASTMeleeTarget,
ActionCheck = b => DrawnCard == CardType.SPEAR,
ActionCheck = (b, m) => DrawnCard == CardType.SPEAR,
};

static IBaseAction Bole { get; } = new BaseAction(ActionID.Bole)
{
ChoiceTarget = TargetFilter.ASTRangeTarget,
ActionCheck = b => DrawnCard == CardType.BOLE,
ActionCheck = (b, m) => DrawnCard == CardType.BOLE,
};

static IBaseAction Ewer { get; } = new BaseAction(ActionID.Ewer)
{
ChoiceTarget = TargetFilter.ASTRangeTarget,
ActionCheck = b => DrawnCard == CardType.EWER,
ActionCheck = (b, m) => DrawnCard == CardType.EWER,

};

static IBaseAction Spire { get; } = new BaseAction(ActionID.Spire)
{
ChoiceTarget = TargetFilter.ASTRangeTarget,
ActionCheck = b => DrawnCard == CardType.SPIRE,
ActionCheck = (b, m) => DrawnCard == CardType.SPIRE,
};
#endregion

Expand Down
26 changes: 13 additions & 13 deletions RotationSolver.Basic/Rotations/Basic/BLM_Base.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,39 +98,39 @@ public override bool CanUse(out IAction act, CanUseOption option = CanUseOption.

public static IBaseAction Fire3 { get; } = new Fire3Action(ActionID.Fire3)
{
ActionCheck = b => !IsLastGCD(ActionID.Fire3),
ActionCheck = (b, m) => !IsLastGCD(ActionID.Fire3),
};
public static IBaseAction Fire4 { get; } = new ElementAction(ActionID.Fire4)
{
ActionCheck = b => InAstralFire && !ElementTimeEndAfter(Fire4.CastTime),
ActionCheck = (b, m) => InAstralFire && !ElementTimeEndAfter(Fire4.CastTime),
};

public static IBaseAction Despair { get; } = new ElementAction(ActionID.Despair)
{
ActionCheck = b => InAstralFire && !ElementTimeEndAfter(Despair.CastTime),
ActionCheck = (b, m) => InAstralFire && !ElementTimeEndAfter(Despair.CastTime),
};

public static IBaseAction Blizzard { get; } = new BaseAction(ActionID.Blizzard);

public static IBaseAction Blizzard3 { get; } = new BaseAction(ActionID.Blizzard3)
{
ActionCheck = b => !IsLastGCD(ActionID.Blizzard3),
ActionCheck = (b, m) => !IsLastGCD(ActionID.Blizzard3),
};
public static IBaseAction Blizzard4 { get; } = new ElementAction(ActionID.Blizzard4)
{
ActionCheck = b => InUmbralIce && !ElementTimeEndAfter(Blizzard4.CastTime),
ActionCheck = (b, m) => InUmbralIce && !ElementTimeEndAfter(Blizzard4.CastTime),
};

public static IBaseAction Thunder { get; } = new ThunderAction(ActionID.Thunder);

public static IBaseAction Xenoglossy { get; } = new BaseAction(ActionID.Xenoglossy)
{
ActionCheck = b => PolyglotStacks > 0
ActionCheck = (b, m) => PolyglotStacks > 0
};

public static IBaseAction Paradox { get; } = new BaseAction(ActionID.Paradox)
{
ActionCheck = b => IsParadoxActive,
ActionCheck = (b, m) => IsParadoxActive,
};
public static IBaseAction Scathe { get; } = new BaseAction(ActionID.Scathe);
#endregion
Expand All @@ -140,7 +140,7 @@ public override bool CanUse(out IAction act, CanUseOption option = CanUseOption.

public static IBaseAction Flare { get; } = new ElementAction(ActionID.Flare)
{
ActionCheck = b => InAstralFire && !ElementTimeEndAfter(Flare.CastTime),
ActionCheck = (b, m) => InAstralFire && !ElementTimeEndAfter(Flare.CastTime),
};

public static IBaseAction Blizzard2 { get; } = new BaseAction(ActionID.Blizzard2);
Expand All @@ -163,14 +163,14 @@ public override bool CanUse(out IAction act, CanUseOption option = CanUseOption.

public static IBaseAction Amplifier { get; } = new BaseAction(ActionID.Amplifier)
{
ActionCheck = b => !EnchinaEndAfter(10) && PolyglotStacks < 2
ActionCheck = (b, m) => !EnchinaEndAfter(10) && PolyglotStacks < 2
};

public static IBaseAction Manaward { get; } = new BaseAction(ActionID.Manaward, ActionOption.Defense);

public static IBaseAction Manafont { get; } = new BaseAction(ActionID.Manafont)
{
ActionCheck = b => Player.CurrentMp <= 7000,
ActionCheck = (b, m) => Player.CurrentMp <= 7000,
};

public static IBaseAction LeyLines { get; } = new BaseAction(ActionID.LeyLines, ActionOption.Buff | ActionOption.EndSpecial)
Expand All @@ -186,7 +186,7 @@ public override bool CanUse(out IAction act, CanUseOption option = CanUseOption.
public static IBaseAction SharpCast { get; } = new BaseAction(ActionID.SharpCast)
{
StatusProvide = new[] { StatusID.SharpCast },
ActionCheck = b => HasHostilesInRange,
ActionCheck = (b, m) => HasHostilesInRange,
};

public static IBaseAction TripleCast { get; } = new BaseAction(ActionID.TripleCast)
Expand All @@ -196,12 +196,12 @@ public override bool CanUse(out IAction act, CanUseOption option = CanUseOption.

public static IBaseAction Transpose { get; } = new BaseAction(ActionID.Transpose)
{
ActionCheck = b => DataCenter.ActionRemain.IsLessThan(ElementTime)
ActionCheck = (b, m) => DataCenter.ActionRemain.IsLessThan(ElementTime)
};

public static IBaseAction UmbralSoul { get; } = new BaseAction(ActionID.UmbralSoul)
{
ActionCheck = b => JobGauge.InUmbralIce && Transpose.ActionCheck(b)
ActionCheck = (b, m) => JobGauge.InUmbralIce && Transpose.ActionCheck(b, m)
};
#endregion

Expand Down
25 changes: 10 additions & 15 deletions RotationSolver.Basic/Rotations/Basic/BLU_Base.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ internal BLUAction(ActionID actionID, BLUActionType type, ActionOption option =
: base(actionID, option)
{
_type = type;
ActionCheck = t => OnSlot && RightType;
ActionCheck = (t, m) => OnSlot && RightType;
}

public override bool CanUse(out IAction act, CanUseOption option = CanUseOption.None, byte gcdCountForAbility = 0)
Expand All @@ -95,7 +95,7 @@ public override bool CanUse(out IAction act, CanUseOption option = CanUseOption.

public static IBLUAction BloodDrain { get; } = new BLUAction(ActionID.BloodDrain, BLUActionType.Magical)
{
ActionCheck = b => Player.CurrentMp <= 9500,
ActionCheck = (b, m) => Player.CurrentMp <= 9500,
};

public static IBLUAction SonicBoom { get; } = new BLUAction(ActionID.SonicBoom, BLUActionType.Magical);
Expand All @@ -112,7 +112,7 @@ public override bool CanUse(out IAction act, CanUseOption option = CanUseOption.

public static IBLUAction WhiteDeath { get; } = new BLUAction(ActionID.WhiteDeath, BLUActionType.Magical)
{
ActionCheck = b => Player.HasStatus(true, StatusID.TouchOfFrost)
ActionCheck = (b, m) => Player.HasStatus(true, StatusID.TouchOfFrost)
};
#endregion

Expand Down Expand Up @@ -194,19 +194,19 @@ public override bool CanUse(out IAction act, CanUseOption option = CanUseOption.

public static IBLUAction DivineCataract { get; } = new BLUAction(ActionID.DivineCataract, BLUActionType.Magical)
{
ActionCheck = b => Player.HasStatus(true, StatusID.AuspiciousTrance)
ActionCheck = (b, m) => Player.HasStatus(true, StatusID.AuspiciousTrance)
};

public static IBLUAction PhantomFlurry2 { get; } = new BLUAction(ActionID.PhantomFlurry2, BLUActionType.Magical)
{
ActionCheck = b => Player.HasStatus(true, StatusID.PhantomFlurry)
ActionCheck = (b, m) => Player.HasStatus(true, StatusID.PhantomFlurry)
};
#endregion

#region Physical Single
public static IBLUAction FinalSting { get; } = new BLUAction(ActionID.FinalSting, BLUActionType.Physical)
{
ActionCheck = b => !Player.HasStatus(true, StatusID.BrushWithDeath),
ActionCheck = (b, m) => !Player.HasStatus(true, StatusID.BrushWithDeath),
};

public static IBLUAction SharpenedKnife { get; } = new BLUAction(ActionID.SharpenedKnife, BLUActionType.Physical);
Expand All @@ -219,7 +219,7 @@ public override bool CanUse(out IAction act, CanUseOption option = CanUseOption.

public static IBLUAction RevengeBlast { get; } = new BLUAction(ActionID.RevengeBlast, BLUActionType.Physical)
{
ActionCheck = b => b.GetHealthRatio() < 0.2f,
ActionCheck = (b, m) => b.GetHealthRatio() < 0.2f,
};
#endregion

Expand Down Expand Up @@ -264,7 +264,7 @@ public override bool CanUse(out IAction act, CanUseOption option = CanUseOption.

public static IBLUAction SelfDestruct { get; } = new BLUAction(ActionID.SelfDestruct, BLUActionType.None)
{
ActionCheck = b => !Player.HasStatus(true, StatusID.BrushWithDeath),
ActionCheck = (b, m) => !Player.HasStatus(true, StatusID.BrushWithDeath),
};

public static IBLUAction Faze { get; } = new BLUAction(ActionID.Faze, BLUActionType.None);
Expand Down Expand Up @@ -360,7 +360,7 @@ public override bool CanUse(out IAction act, CanUseOption option = CanUseOption.
#region Heal
public static IBLUAction WhiteWind { get; } = new BLUAction(ActionID.WhiteWind, BLUActionType.None, ActionOption.Heal)
{
ActionCheck = b => Player.GetHealthRatio() is > 0.3f and < 0.5f,
ActionCheck = (b, m) => Player.GetHealthRatio() is > 0.3f and < 0.5f,
};

public static IBLUAction Stotram { get; } = new BLUAction(ActionID.Stotram, BLUActionType.Magical, ActionOption.Heal);
Expand All @@ -380,12 +380,7 @@ public override bool CanUse(out IAction act, CanUseOption option = CanUseOption.
public static IBLUAction BasicInstinct { get; } = new BLUAction(ActionID.BasicInstinct, BLUActionType.None)
{
StatusProvide = new StatusID[] { StatusID.BasicInstinct },
ActionCheck = b =>
{
//TODO: 还需要判断是否为多人本
return Service.Conditions[Dalamud.Game.ClientState.Conditions.ConditionFlag.BoundByDuty56]
&& DataCenter.PartyMembers.Count(p => p.GetHealthRatio() > 0) == 1;
},
ActionCheck = (b, m) => Service.Conditions[Dalamud.Game.ClientState.Conditions.ConditionFlag.BoundByDuty56] && DataCenter.PartyMembers.Count(p => p.GetHealthRatio() > 0) == 1,
};

private static IBLUAction AethericMimicry { get; } = new BLUAction(ActionID.AethericMimicry, BLUActionType.None, ActionOption.Friendly)
Expand Down
16 changes: 7 additions & 9 deletions RotationSolver.Basic/Rotations/Basic/BRD_Base.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,14 @@ protected static bool SongEndAfterGCD(uint gctCount = 0, float offset = 0)
public static IBaseAction IronJaws { get; } = new BaseAction(ActionID.IronJaws, ActionOption.Dot)
{
TargetStatus = VenomousBite.TargetStatus.Union(WindBite.TargetStatus).ToArray(),
ActionCheck = b => b.HasStatus(true, VenomousBite.TargetStatus) & b.HasStatus(true, WindBite.TargetStatus),
ActionCheck = (b, m) => b.HasStatus(true, VenomousBite.TargetStatus) & b.HasStatus(true, WindBite.TargetStatus),
};

public static IBaseAction EmpyrealArrow { get; } = new BaseAction(ActionID.EmpyrealArrow);

public static IBaseAction PitchPerfect { get; } = new BaseAction(ActionID.PitchPerfect)
{
ActionCheck = b => Song == Song.WANDERER && Repertoire > 0,
ActionCheck = (b, m) => Song == Song.WANDERER && Repertoire > 0,
};

public static IBaseAction Bloodletter { get; } = new BaseAction(ActionID.Bloodletter);
Expand All @@ -76,12 +76,12 @@ protected static bool SongEndAfterGCD(uint gctCount = 0, float offset = 0)

public static IBaseAction ApexArrow { get; } = new BaseAction(ActionID.ApexArrow)
{
ActionCheck = b => SoulVoice >= 20 && !Player.HasStatus(true, StatusID.BlastArrowReady),
ActionCheck = (b, m) => SoulVoice >= 20 && !Player.HasStatus(true, StatusID.BlastArrowReady),
};

public static IBaseAction BlastArrow { get; } = new BaseAction(ActionID.BlastArrow)
{
ActionCheck = b => Player.HasStatus(true, StatusID.BlastArrowReady),
ActionCheck = (b, m) => Player.HasStatus(true, StatusID.BlastArrowReady),
};

public static IBaseAction RainOfDeath { get; } = new BaseAction(ActionID.RainOfDeath)
Expand All @@ -95,7 +95,7 @@ protected static bool SongEndAfterGCD(uint gctCount = 0, float offset = 0)

public static IBaseAction RadiantFinale { get; } = new BaseAction(ActionID.RadiantFinale, ActionOption.Buff)
{
ActionCheck = b => JobGauge.Coda.Any(s => s != Song.NONE),
ActionCheck = (b, m) => JobGauge.Coda.Any(s => s != Song.NONE),
};

public static IBaseAction Barrage { get; } = new BaseAction(ActionID.Barrage);
Expand All @@ -116,10 +116,8 @@ protected static bool SongEndAfterGCD(uint gctCount = 0, float offset = 0)

public static IBaseAction Troubadour { get; } = new BaseAction(ActionID.Troubadour, ActionOption.Defense)
{
ActionCheck = b => !Player.HasStatus(false, StatusID.Troubadour,
StatusID.Tactician1,
StatusID.Tactician2,
StatusID.ShieldSamba),
ActionCheck = (b, m) => !Player.HasStatus(false, StatusID.Troubadour,
StatusID.Tactician1, StatusID.Tactician2, StatusID.ShieldSamba),
};
#endregion

Expand Down
Loading

0 comments on commit 85cd1b9

Please sign in to comment.