feat(battle-engine): M1 auto-copy closure (782 battle-logic files)
Compile-driven bulk-copy loop (tools/engine-port/m1_copy_loop.py) pulled the precise reference closure of the battle-core roots, stopping at the classify god-object/View-VFX-UI boundary. 782 files; no re-explosion (M0 had estimated ~order 1000). Residual frontier = 52 shim-classified + 80 external (Unity/BCL) types to author next.
This commit is contained in:
269
SVSim.BattleEngine/Engine/Wizard/AIScriptArgumentExpressions.cs
Normal file
269
SVSim.BattleEngine/Engine/Wizard/AIScriptArgumentExpressions.cs
Normal file
@@ -0,0 +1,269 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace Wizard;
|
||||
|
||||
public class AIScriptArgumentExpressions
|
||||
{
|
||||
protected List<AIPolishConvertedExpression> _exprList;
|
||||
|
||||
private List<int> _referringIds;
|
||||
|
||||
protected AIScriptTokenArgType[] LegalSelectTypes { get; set; }
|
||||
|
||||
public AIScriptArgumentExpressions(string text)
|
||||
{
|
||||
CreateLegalSelectTypes();
|
||||
if (!(text == ""))
|
||||
{
|
||||
InitExpressions(text);
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void InitExpressions(string text)
|
||||
{
|
||||
InitExprList(text);
|
||||
}
|
||||
|
||||
protected void InitExprList(string text)
|
||||
{
|
||||
string[] array = text.Split(';');
|
||||
_exprList = new List<AIPolishConvertedExpression>();
|
||||
foreach (string expression in array)
|
||||
{
|
||||
AIPolishConvertedExpression aIPolishConvertedExpression = CreateArgumentExpression(expression);
|
||||
_exprList.Add(aIPolishConvertedExpression);
|
||||
List<int> referringIDLists = aIPolishConvertedExpression.GetReferringIDLists();
|
||||
if (referringIDLists != null)
|
||||
{
|
||||
if (_referringIds == null)
|
||||
{
|
||||
_referringIds = new List<int>();
|
||||
}
|
||||
_referringIds.AddRange(referringIDLists);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private AIPolishConvertedExpression CreateArgumentExpression(string expression)
|
||||
{
|
||||
string text = expression.TrimStart();
|
||||
if (text[0] == '*')
|
||||
{
|
||||
return new AIPolishConvertedExpression(text.Substring(1), isMultiplyMarked: true);
|
||||
}
|
||||
return new AIPolishConvertedExpression(expression);
|
||||
}
|
||||
|
||||
public bool IsArgID(int index)
|
||||
{
|
||||
return _exprList[index].IsID();
|
||||
}
|
||||
|
||||
public int EvalID(int index)
|
||||
{
|
||||
if (_exprList == null || index >= _exprList.Count)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
return _exprList[index].EvalID();
|
||||
}
|
||||
|
||||
public List<int> EvalIDList(int startIndex)
|
||||
{
|
||||
List<int> list = new List<int>();
|
||||
if (_exprList != null && startIndex < _exprList.Count)
|
||||
{
|
||||
for (int i = startIndex; i < _exprList.Count; i++)
|
||||
{
|
||||
list.Add(_exprList[i].EvalID());
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public string EvalText(int index)
|
||||
{
|
||||
if (_exprList == null || index >= _exprList.Count)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
return _exprList[index].EvalText();
|
||||
}
|
||||
|
||||
public virtual List<int> GetReferringOtherInplayIds()
|
||||
{
|
||||
return _referringIds;
|
||||
}
|
||||
|
||||
public float EvalArg(int index, AIVirtualCard tagOwner, List<int> playPtn, AIVirtualField field, AISituationInfo situation)
|
||||
{
|
||||
if (_exprList == null || index >= _exprList.Count)
|
||||
{
|
||||
return 0f;
|
||||
}
|
||||
return _exprList[index].EvalArg(tagOwner, playPtn, field, situation);
|
||||
}
|
||||
|
||||
public bool IsHoldingEVAL()
|
||||
{
|
||||
if (_exprList != null)
|
||||
{
|
||||
return _exprList.Any((AIPolishConvertedExpression expr) => expr.IsHoldingEVAL());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
protected string[] SplitTextToWords(string text)
|
||||
{
|
||||
string pattern = "\\s\\;\\s(?=\\{)";
|
||||
return Regex.Split(text, pattern);
|
||||
}
|
||||
|
||||
protected List<AIScriptTokenBase> GetFilters(List<AIPolishConvertedExpression> exprs)
|
||||
{
|
||||
List<AIScriptTokenBase> list = new List<AIScriptTokenBase>();
|
||||
for (int i = 0; i < exprs.Count; i++)
|
||||
{
|
||||
AIPolishConvertedExpression aIPolishConvertedExpression = exprs[i];
|
||||
if (aIPolishConvertedExpression.TokenList == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (aIPolishConvertedExpression.TokenList.Count > 1)
|
||||
{
|
||||
list.Add(aIPolishConvertedExpression.CreateCalculationToken());
|
||||
continue;
|
||||
}
|
||||
AIScriptTokenBase aIScriptTokenBase = aIPolishConvertedExpression.TokenList[0];
|
||||
if (!(aIScriptTokenBase is AIScriptArgumentToken { ArgumentType: AIScriptTokenArgType.FILTER_END }))
|
||||
{
|
||||
list.Add(aIScriptTokenBase);
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public virtual void Execute(AIVirtualCard tagOwner, AIVirtualField field, List<int> playPtn, AISituationInfo situation = null)
|
||||
{
|
||||
}
|
||||
|
||||
public virtual void ExecuteWhenRemove(AIVirtualCard tagOwner, AIVirtualField field, AIPlayTag removingTag)
|
||||
{
|
||||
}
|
||||
|
||||
protected AIScriptTokenArgType GetFirstTokenArgType(AIPolishConvertedExpression arg)
|
||||
{
|
||||
AIScriptTokenArgType result = AIScriptTokenArgType.NONE;
|
||||
if (arg.TokenList != null && arg.TokenList.Count > 0)
|
||||
{
|
||||
AIScriptTokenBase aIScriptTokenBase = arg.TokenList[0];
|
||||
if (aIScriptTokenBase is AIScriptArgumentToken)
|
||||
{
|
||||
result = ((AIScriptArgumentToken)aIScriptTokenBase).ArgumentType;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public virtual AITokenIdCollection GetAllRegisterTokenPoolInfo(AIVirtualCard owner)
|
||||
{
|
||||
if (_exprList == null || _exprList.Count <= 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
List<int> list = null;
|
||||
for (int i = 0; i < _exprList.Count; i++)
|
||||
{
|
||||
List<AIScriptTokenBase> tokenList = _exprList[i].TokenList;
|
||||
if (tokenList != null && tokenList.Count > 0 && tokenList.Count == 1 && tokenList[0] is AIScriptIDToken aIScriptIDToken)
|
||||
{
|
||||
list = AIParamQuery.AddElementToList(aIScriptIDToken.ID, list);
|
||||
}
|
||||
}
|
||||
if (list == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return CreateRegisterTokenPoolInfo(owner, list);
|
||||
}
|
||||
|
||||
protected virtual AITokenIdCollection CreateRegisterTokenPoolInfo(AIVirtualCard owner, List<int> idList)
|
||||
{
|
||||
return AISummonTokenUtility.CreateTokenIdCollectionFromIdList(owner, AIScriptTokenArgType.ALLY, idList, AITokenType.Default);
|
||||
}
|
||||
|
||||
protected bool IsFirstFiltersEnd(AIPolishConvertedExpression arg, AIScriptTokenArgType[] InitFilters, out AIScriptTokenArgType dstType)
|
||||
{
|
||||
dstType = AIScriptTokenArgType.NONE;
|
||||
if (arg.TokenList != null && arg.TokenList.Count > 0)
|
||||
{
|
||||
AIScriptTokenBase aIScriptTokenBase = arg.TokenList[0];
|
||||
if (aIScriptTokenBase is AIScriptArgumentToken)
|
||||
{
|
||||
dstType = ((AIScriptArgumentToken)aIScriptTokenBase).ArgumentType;
|
||||
if (InitFilters.Contains(dstType))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
protected bool IsTimingTokenArgType(AIPolishConvertedExpression arg, out AIScriptTokenArgType dstTokenArgType)
|
||||
{
|
||||
dstTokenArgType = GetFirstTokenArgType(arg);
|
||||
switch (dstTokenArgType)
|
||||
{
|
||||
case AIScriptTokenArgType.WHEN_PLAY:
|
||||
case AIScriptTokenArgType.WHEN_DESTROY:
|
||||
case AIScriptTokenArgType.WHEN_ATTACK:
|
||||
case AIScriptTokenArgType.WHEN_CLASH:
|
||||
case AIScriptTokenArgType.WHEN_DAMAGED:
|
||||
case AIScriptTokenArgType.WHEN_EVO:
|
||||
case AIScriptTokenArgType.WHEN_TURNEND:
|
||||
case AIScriptTokenArgType.WHEN_ALLY_TURNEND:
|
||||
case AIScriptTokenArgType.WHEN_OPPONENT_TURNEND:
|
||||
case AIScriptTokenArgType.WHEN_ALLY_TURNSTART:
|
||||
case AIScriptTokenArgType.WHEN_OPPONENT_TURNSTART:
|
||||
case AIScriptTokenArgType.WHEN_FUSION:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
protected bool IsSideTokenArgType(AIPolishConvertedExpression arg, out AIScriptTokenArgType dstTokenARgType)
|
||||
{
|
||||
dstTokenARgType = GetFirstTokenArgType(arg);
|
||||
AIScriptTokenArgType aIScriptTokenArgType = dstTokenARgType;
|
||||
if ((uint)(aIScriptTokenArgType - 84) <= 2u)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
protected bool IsLegalSelectType(AIPolishConvertedExpression arg, out AIScriptTokenArgType selectType)
|
||||
{
|
||||
selectType = AIScriptTokenArgType.NONE;
|
||||
if (arg.TokenList != null && arg.TokenList.Count > 0 && arg.TokenList[0] is AIScriptArgumentToken { ArgumentType: var argumentType } && Array.IndexOf(LegalSelectTypes, argumentType) >= 0)
|
||||
{
|
||||
selectType = argumentType;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
protected virtual void CreateLegalSelectTypes()
|
||||
{
|
||||
LegalSelectTypes = new AIScriptTokenArgType[2]
|
||||
{
|
||||
AIScriptTokenArgType.ALL_SELECT,
|
||||
AIScriptTokenArgType.RANDOM_SELECT
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user