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 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #462 from ArchiDog1998/main
RP
- Loading branch information
Showing
239 changed files
with
2,307 additions
and
1,937 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
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
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 |
---|---|---|
|
@@ -420,5 +420,15 @@ | |
35385, | ||
36093, | ||
35420, | ||
36091 | ||
36091, | ||
30981, | ||
30961, | ||
30974, | ||
35274, | ||
35268, | ||
35284, | ||
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": 12212, | ||
"ClickingCount": 17599, | ||
"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.Basic.Configuration.Conditions; | ||
|
||
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.Basic.Configuration.Conditions; | ||
|
||
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.Basic.Configuration.Conditions; | ||
|
||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
namespace RotationSolver.Basic.Configuration.Conditions; | ||
|
||
internal interface ICondition | ||
{ | ||
bool IsTrue(ICustomRotation rotation); | ||
bool CheckBefore(ICustomRotation rotation); | ||
} |
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
135 changes: 135 additions & 0 deletions
135
RotationSolver.Basic/Configuration/Conditions/MajorConditionSet.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,135 @@ | ||
using ECommons.DalamudServices; | ||
using ECommons.ExcelServices; | ||
|
||
namespace RotationSolver.Basic.Configuration.Conditions; | ||
|
||
internal class MajorConditionSet | ||
{ | ||
const string conditionName = "Unnamed"; | ||
|
||
[JsonIgnore] | ||
public bool IsUnnamed => Name == conditionName; | ||
|
||
/// <summary> | ||
/// Key for action id. | ||
/// </summary> | ||
public Dictionary<Job, Dictionary<uint, ConditionSet>> Conditions { get; } = new(); | ||
|
||
[JsonIgnore] | ||
public Dictionary<uint, ConditionSet> ConditionDict | ||
{ | ||
get | ||
{ | ||
if (!Conditions.TryGetValue(DataCenter.Job, out var dict)) | ||
{ | ||
dict = Conditions[DataCenter.Job] = new(); | ||
} | ||
return dict; | ||
} | ||
} | ||
|
||
public Dictionary<Job, Dictionary<uint, ConditionSet>> DisabledConditions { get; } = new(); | ||
|
||
[JsonIgnore] | ||
public Dictionary<uint, ConditionSet> DisableConditionDict | ||
{ | ||
get | ||
{ | ||
if (!DisabledConditions.TryGetValue(DataCenter.Job, out var dict)) | ||
{ | ||
dict = DisabledConditions[DataCenter.Job] = new(); | ||
} | ||
return dict; | ||
} | ||
} | ||
|
||
public Dictionary<PluginConfigBool, ConditionSet> ForceEnableConditions { get; private set; } | ||
= new(); | ||
|
||
public Dictionary<PluginConfigBool, ConditionSet> ForceDisableConditions { get; private set; } | ||
= new(); | ||
|
||
public ConditionSet HealAreaConditionSet { get; set; } = new ConditionSet(); | ||
public ConditionSet HealSingleConditionSet { get; set; } = new ConditionSet(); | ||
public ConditionSet DefenseAreaConditionSet { get; set; } = new ConditionSet(); | ||
public ConditionSet DefenseSingleConditionSet { get; set; } = new ConditionSet(); | ||
public ConditionSet EsunaStanceNorthConditionSet { get; set; } = new ConditionSet(); | ||
public ConditionSet RaiseShirkConditionSet { get; set; } = new ConditionSet(); | ||
public ConditionSet MoveForwardConditionSet { get; set; } = new ConditionSet(); | ||
public ConditionSet MoveBackConditionSet { get; set; } = new ConditionSet(); | ||
public ConditionSet AntiKnockbackConditionSet { get; set; } = new ConditionSet(); | ||
public ConditionSet BurstConditionSet { get; set; } = new ConditionSet(); | ||
public ConditionSet SpeedConditionSet { get; set; } = new ConditionSet(); | ||
|
||
public string Name; | ||
|
||
public ConditionSet GetCondition(uint id) | ||
{ | ||
if (!ConditionDict.TryGetValue(id, out var conditionSet)) | ||
{ | ||
conditionSet = ConditionDict[id] = new ConditionSet(); | ||
} | ||
return conditionSet; | ||
} | ||
|
||
public ConditionSet GetDisabledCondition(uint id) | ||
{ | ||
if (!DisableConditionDict.TryGetValue(id, out var conditionSet)) | ||
{ | ||
conditionSet = DisableConditionDict[id] = new ConditionSet(); | ||
} | ||
return conditionSet; | ||
} | ||
|
||
public ConditionSet GetEnableCondition(PluginConfigBool config) | ||
{ | ||
if (!ForceEnableConditions.TryGetValue(config, out var conditionSet)) | ||
{ | ||
conditionSet = ForceEnableConditions[config] = new ConditionSet(); | ||
} | ||
return conditionSet; | ||
} | ||
|
||
public ConditionSet GetDisableCondition(PluginConfigBool config) | ||
{ | ||
if (!ForceDisableConditions.TryGetValue(config, out var conditionSet)) | ||
{ | ||
conditionSet = ForceDisableConditions[config] = new ConditionSet(); | ||
} | ||
return conditionSet; | ||
} | ||
|
||
public MajorConditionSet(string name = conditionName) | ||
{ | ||
Name = name; | ||
} | ||
|
||
public void Save(string folder) | ||
{ | ||
if (!Directory.Exists(folder)) return; | ||
var path = Path.Combine(folder, Name + ".json"); | ||
|
||
var str = JsonConvert.SerializeObject(this, Formatting.Indented); | ||
File.WriteAllText(path, str); | ||
} | ||
|
||
public static MajorConditionSet[] Read(string folder) | ||
{ | ||
if (!Directory.Exists(folder)) return Array.Empty<MajorConditionSet>(); | ||
|
||
return Directory.EnumerateFiles(folder, "*.json").Select(p => | ||
{ | ||
var str = File.ReadAllText(p); | ||
|
||
try | ||
{ | ||
return JsonConvert.DeserializeObject<MajorConditionSet>(str, new IConditionConverter()); | ||
} | ||
catch | ||
{ | ||
Svc.Chat.Print($"Failed to load the conditionSet from {p}"); | ||
return null; | ||
} | ||
}).Where(set => set != null && !string.IsNullOrEmpty(set.Name)).ToArray(); | ||
} | ||
} |
Oops, something went wrong.