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.
feat: all options can be add some conditions!
- Loading branch information
1 parent
37ac0d3
commit 5cbafc8
Showing
32 changed files
with
553 additions
and
411 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
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
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
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
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
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
123 changes: 123 additions & 0 deletions
123
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,123 @@ | ||
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 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(); | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
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
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
2 changes: 1 addition & 1 deletion
2
RotationSolver.Basic/Configuration/Conditions/TraitCondition.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
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
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
Oops, something went wrong.