mirror of
https://github.com/waynebian01/Shigure.git
synced 2026-09-03 07:15:24 +08:00
添加了icon, 一键辅助
This commit is contained in:
@@ -77,6 +77,23 @@ public sealed class DefaultClassLogic : IClassLogic
|
||||
|
||||
public LogicDecision Run(GameState state, string? specName)
|
||||
{
|
||||
var oneKeySpell = ModuleSpecialActions.GetOneKeySpell(state, _keymap.GetCurrentOneKeySpells());
|
||||
if (!string.IsNullOrWhiteSpace(oneKeySpell))
|
||||
{
|
||||
var hotkey = _keymap.GetHotkey(0, oneKeySpell);
|
||||
var info = new Dictionary<string, object?>
|
||||
{
|
||||
["命中条件"] = $"一键辅助 == {state.GetInt("一键辅助")}",
|
||||
["动作技能"] = oneKeySpell,
|
||||
["动作按键"] = string.IsNullOrWhiteSpace(hotkey) ? "-" : hotkey,
|
||||
["动作单位"] = 0
|
||||
};
|
||||
var step = string.IsNullOrWhiteSpace(hotkey)
|
||||
? $"未找到按键 {oneKeySpell}"
|
||||
: $"施放 {oneKeySpell}";
|
||||
return new LogicDecision(hotkey, step, info);
|
||||
}
|
||||
|
||||
var oneKeyAssist = state.GetInt("一键辅助");
|
||||
if (oneKeyAssist == 10)
|
||||
{
|
||||
|
||||
@@ -6,23 +6,7 @@ internal static class ModuleSpecialActions
|
||||
{
|
||||
public const string PauseSpell = "暂停";
|
||||
public const string FailedSpell = "失败法术";
|
||||
|
||||
private static readonly Dictionary<int, string> FailedSpellMap = new()
|
||||
{
|
||||
[1] = "心灵尖啸",
|
||||
[2] = "群体驱散",
|
||||
[3] = "真言术:障",
|
||||
[4] = "终极苦修",
|
||||
[5] = "神圣化身",
|
||||
[6] = "光晕",
|
||||
[7] = "神圣赞美诗",
|
||||
[8] = "虚空形态",
|
||||
[9] = "吸血鬼的拥抱",
|
||||
[30] = "真言术:耀",
|
||||
[35] = "福音"
|
||||
};
|
||||
|
||||
public static IReadOnlyCollection<string> FailedSpellNames => FailedSpellMap.Values;
|
||||
public const string OneKeySpell = "一键法术";
|
||||
|
||||
public static bool IsPauseSpell(string? spell)
|
||||
{
|
||||
@@ -34,10 +18,15 @@ internal static class ModuleSpecialActions
|
||||
return string.Equals(spell?.Trim(), FailedSpell, StringComparison.Ordinal);
|
||||
}
|
||||
|
||||
public static string? GetFailedSpell(GameState state)
|
||||
public static bool IsOneKeySpell(string? spell)
|
||||
{
|
||||
return string.Equals(spell?.Trim(), OneKeySpell, StringComparison.Ordinal);
|
||||
}
|
||||
|
||||
public static string? GetFailedSpell(GameState state, IReadOnlyDictionary<int, string>? failedSpellMap)
|
||||
{
|
||||
var failedSpellId = state.GetInt("法术失败");
|
||||
if (!FailedSpellMap.TryGetValue(failedSpellId, out var spellName))
|
||||
if (failedSpellMap is null || !failedSpellMap.TryGetValue(failedSpellId, out var spellName))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
@@ -48,6 +37,14 @@ internal static class ModuleSpecialActions
|
||||
: null;
|
||||
}
|
||||
|
||||
public static string? GetOneKeySpell(GameState state, IReadOnlyDictionary<int, string>? oneKeySpellMap)
|
||||
{
|
||||
var oneKeyAssist = state.GetInt("一键辅助");
|
||||
return oneKeySpellMap is not null && oneKeySpellMap.TryGetValue(oneKeyAssist, out var spellName)
|
||||
? spellName
|
||||
: null;
|
||||
}
|
||||
|
||||
private static bool IsZero(object? value)
|
||||
{
|
||||
return value switch
|
||||
|
||||
@@ -557,10 +557,25 @@ public static class ModuleLogic
|
||||
{
|
||||
var info = CreateInfo(module, state);
|
||||
var unitSlots = ResolveDynamicFields(module, state);
|
||||
var failedSpells = keymap.GetCurrentFailedSpells();
|
||||
var oneKeySpells = keymap.GetCurrentOneKeySpells();
|
||||
var oneKeySpell = ModuleSpecialActions.GetOneKeySpell(state, oneKeySpells);
|
||||
if (!string.IsNullOrWhiteSpace(oneKeySpell))
|
||||
{
|
||||
var hotkey = keymap.GetHotkey(0, oneKeySpell);
|
||||
info["命中条件"] = $"一键辅助 == {state.GetInt("一键辅助")}";
|
||||
info["动作技能"] = oneKeySpell;
|
||||
info["动作按键"] = string.IsNullOrWhiteSpace(hotkey) ? "-" : hotkey;
|
||||
info["动作单位"] = 0;
|
||||
var step = string.IsNullOrWhiteSpace(hotkey)
|
||||
? $"{module.Name}: 未找到按键 {oneKeySpell}"
|
||||
: $"{module.Name}: 施放 {oneKeySpell}";
|
||||
return new LogicDecision(hotkey, step, info, module.Name);
|
||||
}
|
||||
|
||||
foreach (var rule in module.Rules.Where(rule => rule.Enabled))
|
||||
{
|
||||
if (!ModuleConditionEvaluator.TryEvaluate(rule.Condition, state, out var conditionMatched, out var error))
|
||||
if (!ModuleConditionEvaluator.TryEvaluate(rule.Condition, state, out var conditionMatched, out var error, failedSpells))
|
||||
{
|
||||
info["条件错误"] = error;
|
||||
info["规则条件"] = rule.Condition;
|
||||
@@ -597,12 +612,22 @@ public static class ModuleLogic
|
||||
var actionSpell = rule.Spell;
|
||||
if (ModuleSpecialActions.IsFailedSpell(actionSpell))
|
||||
{
|
||||
actionSpell = ModuleSpecialActions.GetFailedSpell(state);
|
||||
actionSpell = ModuleSpecialActions.GetFailedSpell(state, failedSpells);
|
||||
if (string.IsNullOrWhiteSpace(actionSpell))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else if (ModuleSpecialActions.IsOneKeySpell(actionSpell))
|
||||
{
|
||||
actionSpell = ModuleSpecialActions.GetOneKeySpell(state, oneKeySpells);
|
||||
if (string.IsNullOrWhiteSpace(actionSpell))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
resolvedUnit = 0;
|
||||
}
|
||||
|
||||
var hotkey = string.IsNullOrWhiteSpace(rule.Hotkey)
|
||||
? string.IsNullOrWhiteSpace(actionSpell) ? null : keymap.GetHotkey(resolvedUnit, actionSpell)
|
||||
@@ -927,7 +952,12 @@ public static class ModuleConditionEvaluator
|
||||
@"^\s*(?<field>.+?)\s*(?<op>==|!=|>=|<=|>|<)\s*(?<value>.+?)\s*$",
|
||||
RegexOptions.Compiled);
|
||||
|
||||
public static bool TryEvaluate(string? expression, GameState state, out bool matched, out string? error)
|
||||
public static bool TryEvaluate(
|
||||
string? expression,
|
||||
GameState state,
|
||||
out bool matched,
|
||||
out string? error,
|
||||
IReadOnlyDictionary<int, string>? failedSpells = null)
|
||||
{
|
||||
matched = false;
|
||||
error = null;
|
||||
@@ -943,7 +973,7 @@ public static class ModuleConditionEvaluator
|
||||
var allAndMatched = true;
|
||||
foreach (var andPart in Regex.Split(orPart, @"\s*&&\s*"))
|
||||
{
|
||||
if (!TryEvaluateTerm(andPart, state, out var termMatched, out error))
|
||||
if (!TryEvaluateTerm(andPart, state, out var termMatched, out error, failedSpells))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -981,7 +1011,12 @@ public static class ModuleConditionEvaluator
|
||||
public static bool TryResolveDouble(GameState state, string fieldName, out double value)
|
||||
=> TryToDouble(ResolveValue(state, fieldName), out value);
|
||||
|
||||
private static bool TryEvaluateTerm(string term, GameState state, out bool matched, out string? error)
|
||||
private static bool TryEvaluateTerm(
|
||||
string term,
|
||||
GameState state,
|
||||
out bool matched,
|
||||
out string? error,
|
||||
IReadOnlyDictionary<int, string>? failedSpells)
|
||||
{
|
||||
matched = false;
|
||||
error = null;
|
||||
@@ -995,7 +1030,7 @@ public static class ModuleConditionEvaluator
|
||||
var inMatch = InRegex.Match(trimmed);
|
||||
if (inMatch.Success)
|
||||
{
|
||||
var inLeft = ResolveValue(state, inMatch.Groups["field"].Value.Trim());
|
||||
var inLeft = ResolveValue(state, inMatch.Groups["field"].Value.Trim(), failedSpells);
|
||||
var inOp = NormalizeOperator(inMatch.Groups["op"].Value);
|
||||
var values = ParseListLiterals(inMatch.Groups["value"].Value);
|
||||
return TryCompareIn(inLeft, inOp, values, out matched, out error);
|
||||
@@ -1006,18 +1041,21 @@ public static class ModuleConditionEvaluator
|
||||
{
|
||||
var invert = trimmed.StartsWith('!');
|
||||
var fieldName = invert ? trimmed[1..].Trim() : trimmed;
|
||||
var value = ResolveValue(state, fieldName);
|
||||
var value = ResolveValue(state, fieldName, failedSpells);
|
||||
matched = invert ? !IsTruthy(value) : IsTruthy(value);
|
||||
return true;
|
||||
}
|
||||
|
||||
var left = ResolveValue(state, comparison.Groups["field"].Value.Trim());
|
||||
var left = ResolveValue(state, comparison.Groups["field"].Value.Trim(), failedSpells);
|
||||
var op = comparison.Groups["op"].Value;
|
||||
var right = ParseLiteral(comparison.Groups["value"].Value.Trim());
|
||||
return TryCompare(left, op, right, out matched, out error);
|
||||
}
|
||||
|
||||
private static object? ResolveValue(GameState state, string fieldName)
|
||||
private static object? ResolveValue(
|
||||
GameState state,
|
||||
string fieldName,
|
||||
IReadOnlyDictionary<int, string>? failedSpells = null)
|
||||
{
|
||||
var key = fieldName.Trim();
|
||||
if (key.StartsWith("state.", StringComparison.OrdinalIgnoreCase))
|
||||
@@ -1037,7 +1075,7 @@ public static class ModuleConditionEvaluator
|
||||
|
||||
if (ModuleSpecialActions.IsFailedSpell(key))
|
||||
{
|
||||
return ModuleSpecialActions.GetFailedSpell(state);
|
||||
return ModuleSpecialActions.GetFailedSpell(state, failedSpells);
|
||||
}
|
||||
|
||||
if (key.StartsWith("group.", StringComparison.OrdinalIgnoreCase))
|
||||
|
||||
Reference in New Issue
Block a user