This repository has been archived by the owner on Aug 28, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: changed the condition file location.
- Loading branch information
1 parent
d4c34a0
commit af219ec
Showing
20 changed files
with
1,135 additions
and
1,107 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -427,5 +427,8 @@ | |
35274, | ||
35268, | ||
35284, | ||
35279 | ||
35279, | ||
35312, | ||
35280, | ||
35269 | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
{ | ||
"ClickingCount": 15952, | ||
"ClickingCount": 17595, | ||
"SaidUsers": [] | ||
} |
80 changes: 80 additions & 0 deletions
80
RotationSolver.Basic/Configuration/Conditions/ActionCondition.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
namespace RotationSolver.ActionSequencer; | ||
|
||
internal class ActionCondition : DelayCondition | ||
{ | ||
internal IBaseAction _action; | ||
|
||
public ActionID ID { get; set; } = ActionID.None; | ||
|
||
public ActionConditionType ActionConditionType = ActionConditionType.Elapsed; | ||
|
||
public bool Condition { get; set; } | ||
|
||
public int Param1; | ||
public int Param2; | ||
public float Time; | ||
|
||
public override bool CheckBefore(ICustomRotation rotation) | ||
{ | ||
return CheckBaseAction(rotation, ID, ref _action) && base.CheckBefore(rotation); | ||
} | ||
|
||
public override bool IsTrueInside(ICustomRotation rotation) | ||
{ | ||
var result = false; | ||
|
||
switch (ActionConditionType) | ||
{ | ||
case ActionConditionType.Elapsed: | ||
result = _action.ElapsedOneChargeAfter(Time); // Bigger | ||
break; | ||
|
||
case ActionConditionType.ElapsedGCD: | ||
result = _action.ElapsedOneChargeAfterGCD((uint)Param1, Param2); // Bigger | ||
break; | ||
|
||
case ActionConditionType.Remain: | ||
result = !_action.WillHaveOneCharge(Time); //Smaller | ||
break; | ||
|
||
case ActionConditionType.RemainGCD: | ||
result = !_action.WillHaveOneChargeGCD((uint)Param1, Param2); // Smaller | ||
break; | ||
|
||
case ActionConditionType.CanUse: | ||
result = _action.CanUse(out _, (CanUseOption)Param1, (byte)Param2); | ||
break; | ||
|
||
case ActionConditionType.EnoughLevel: | ||
result = _action.EnoughLevel; | ||
break; | ||
|
||
case ActionConditionType.IsCoolDown: | ||
result = _action.IsCoolingDown; | ||
break; | ||
|
||
case ActionConditionType.CurrentCharges: | ||
result = _action.CurrentCharges > Param1; | ||
break; | ||
|
||
case ActionConditionType.MaxCharges: | ||
result = _action.MaxCharges > Param1; | ||
break; | ||
} | ||
|
||
return Condition ? !result : result; | ||
} | ||
} | ||
|
||
internal enum ActionConditionType : byte | ||
{ | ||
Elapsed, | ||
ElapsedGCD, | ||
Remain, | ||
RemainGCD, | ||
CanUse, | ||
EnoughLevel, | ||
IsCoolDown, | ||
CurrentCharges, | ||
MaxCharges, | ||
} |
30 changes: 30 additions & 0 deletions
30
RotationSolver.Basic/Configuration/Conditions/ConditionSet.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
namespace RotationSolver.ActionSequencer; | ||
|
||
internal class ConditionSet : DelayCondition | ||
{ | ||
public List<ICondition> Conditions { get; set; } = new List<ICondition>(); | ||
|
||
public LogicalType Type; | ||
|
||
public override bool IsTrueInside(ICustomRotation rotation) | ||
{ | ||
if (Conditions.Count == 0) return false; | ||
|
||
return Type switch | ||
{ | ||
LogicalType.And => Conditions.All(c => c.IsTrue(rotation)), | ||
LogicalType.Or => Conditions.Any(c => c.IsTrue(rotation)), | ||
LogicalType.NotAnd => !Conditions.All(c => c.IsTrue(rotation)), | ||
LogicalType.NotOr => !Conditions.Any(c => c.IsTrue(rotation)), | ||
_ => false, | ||
}; | ||
} | ||
} | ||
|
||
internal enum LogicalType: byte | ||
{ | ||
And, | ||
Or, | ||
NotAnd, | ||
NotOr, | ||
} |
63 changes: 63 additions & 0 deletions
63
RotationSolver.Basic/Configuration/Conditions/DelayCondition.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
using ECommons.GameHelpers; | ||
|
||
namespace RotationSolver.ActionSequencer; | ||
|
||
internal abstract class DelayCondition : ICondition | ||
{ | ||
public float DelayMin = 0; | ||
public float DelayMax = 0; | ||
|
||
RandomDelay _delay = default; | ||
|
||
public bool IsTrue(ICustomRotation rotation) | ||
{ | ||
if(_delay.GetRange == null) | ||
{ | ||
_delay = new(() => (DelayMin, DelayMax)); | ||
} | ||
|
||
return _delay.Delay(CheckBefore(rotation) && IsTrueInside(rotation)); | ||
} | ||
|
||
public abstract bool IsTrueInside(ICustomRotation rotation); | ||
|
||
public virtual bool CheckBefore(ICustomRotation rotation) | ||
{ | ||
return Player.Available; | ||
} | ||
|
||
internal static bool CheckBaseAction(ICustomRotation rotation, ActionID id, ref IBaseAction action) | ||
{ | ||
if (id != ActionID.None && (action == null || (ActionID)action.ID != id)) | ||
{ | ||
action = rotation.AllBaseActions.FirstOrDefault(a => (ActionID)a.ID == id); | ||
} | ||
if (action == null) return false; | ||
return true; | ||
} | ||
|
||
internal static bool CheckMemberInfo<T>(ICustomRotation rotation, ref string name, ref T value) where T : MemberInfo | ||
{ | ||
if (!string.IsNullOrEmpty(name) && (value == null || value.Name != name)) | ||
{ | ||
var memberName = name; | ||
if (typeof(T).IsAssignableFrom(typeof(PropertyInfo))) | ||
{ | ||
value = (T)GetAllMethods(rotation.GetType(), RuntimeReflectionExtensions.GetRuntimeProperties).FirstOrDefault(m => m.Name == memberName); | ||
} | ||
else if (typeof(T).IsAssignableFrom(typeof(MethodInfo))) | ||
{ | ||
value = (T)GetAllMethods(rotation.GetType(), RuntimeReflectionExtensions.GetRuntimeMethods).FirstOrDefault(m => m.Name == memberName); | ||
} | ||
} | ||
return true; | ||
} | ||
|
||
private static IEnumerable<MemberInfo> GetAllMethods(Type type, Func<Type, IEnumerable<MemberInfo>> getFunc) | ||
{ | ||
if (type == null || getFunc == null) return Array.Empty<MemberInfo>(); | ||
|
||
var methods = getFunc(type); | ||
return methods.Union(GetAllMethods(type.BaseType, getFunc)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
112 changes: 112 additions & 0 deletions
112
RotationSolver.Basic/Configuration/Conditions/RotationCondition.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
namespace RotationSolver.ActionSequencer; | ||
|
||
internal class RotationCondition : DelayCondition | ||
{ | ||
public ComboConditionType ComboConditionType = ComboConditionType.Float; | ||
internal PropertyInfo _prop; | ||
public string PropertyName = nameof(CustomRotation.CombatTime); | ||
|
||
MethodInfo _method; | ||
public string MethodName = string.Empty; | ||
|
||
internal IBaseAction _action; | ||
public ActionID ID { get; set; } = ActionID.None; | ||
|
||
public int Condition; | ||
|
||
public int Param1; | ||
public float Param2; | ||
|
||
|
||
public override bool CheckBefore(ICustomRotation rotation) | ||
{ | ||
return CheckBaseAction(rotation, ID, ref _action) | ||
&& CheckMemberInfo(rotation, ref PropertyName, ref _prop) | ||
&& CheckMemberInfo(rotation, ref MethodName, ref _method) | ||
&& base.CheckBefore(rotation); | ||
} | ||
|
||
public override bool IsTrueInside(ICustomRotation rotation) | ||
{ | ||
switch (ComboConditionType) | ||
{ | ||
case ComboConditionType.Bool: | ||
if (_prop == null) return false; | ||
if (_prop.GetValue(rotation) is bool b) | ||
{ | ||
return Condition > 0 ? !b : b; | ||
} | ||
return false; | ||
|
||
case ComboConditionType.Integer: | ||
if (_prop == null) return false; | ||
|
||
var value = _prop.GetValue(rotation); | ||
if (value is byte by) | ||
{ | ||
switch (Condition) | ||
{ | ||
case 0: | ||
return by > Param1; | ||
case 1: | ||
return by < Param1; | ||
case 2: | ||
return by == Param1; | ||
} | ||
} | ||
else if (value is int i) | ||
{ | ||
switch (Condition) | ||
{ | ||
case 0: | ||
return i > Param1; | ||
case 1: | ||
return i < Param1; | ||
case 2: | ||
return i == Param1; | ||
} | ||
} | ||
return false; | ||
|
||
case ComboConditionType.Float: | ||
if (_prop == null) return false; | ||
if (_prop.GetValue(rotation) is float fl) | ||
{ | ||
switch (Condition) | ||
{ | ||
case 0: | ||
return fl > Param2; | ||
case 1: | ||
return fl < Param2; | ||
case 2: | ||
return fl == Param2; | ||
} | ||
} | ||
return false; | ||
|
||
case ComboConditionType.Last: | ||
try | ||
{ | ||
if (_method?.Invoke(rotation, new object[] { Param1 > 0, new IAction[] { _action } }) is bool boo) | ||
{ | ||
return Condition > 0 ? !boo : boo; | ||
} | ||
return false; | ||
} | ||
catch | ||
{ | ||
return false; | ||
} | ||
} | ||
|
||
return false; | ||
} | ||
} | ||
|
||
internal enum ComboConditionType : byte | ||
{ | ||
Bool, | ||
Integer, | ||
Float, | ||
Last, | ||
} |
Oops, something went wrong.