keyword + animation

This commit is contained in:
SoulliesOfficial
2025-10-27 07:04:34 -04:00
parent c3c4a17440
commit 2906206f0c
40 changed files with 512 additions and 384 deletions

View File

@@ -13,12 +13,7 @@ namespace Continentis.MainGame
static BuffTextInterpreter()
{
TextInterpreter = new Interpreter();
TextInterpreter.SetFunction("Value", new Func<float, string>((cv) => DynamicTextInterpreter.GetValue(cv, false)));
TextInterpreter.SetFunction("Value", new Func<float, float, string>((cv, bv) => DynamicTextInterpreter.GetValue(cv, bv, true, false)));
TextInterpreter.SetFunction("Value",
new Func<float, float, bool, string>((cv, bv, high) => DynamicTextInterpreter.GetValue(cv, bv, high, false)));
TextInterpreter.SetFunction("Value",
new Func<float, float, bool, bool, string>((cv, bv, high, percent) => DynamicTextInterpreter.GetValue(cv, bv, high, percent)));
DynamicTextInterpreter.InitializeInterpreter(ref TextInterpreter);
foreach (KeyValuePair<string, InterpretedKeyword> keyword in MainGameManager.Instance.keywordData.interpretedKeywords)
{
@@ -34,7 +29,7 @@ namespace Continentis.MainGame
TextInterpreter.SetFunction("ParameterFloat", new Func<string, string>((paramName) => GetParameterFloat(buff, paramName)));
TextInterpreter.SetFunction("ParameterString", new Func<string, string>((paramName) => GetParameterString(buff, paramName)));
string descriptionToParse = buff.contentSubmodule.originalFunctionText;
string result = DynamicTextInterpreter.Parse(TextInterpreter, descriptionToParse, new List<string>(), new List<string>());
string result = DynamicTextInterpreter.Parse(TextInterpreter, descriptionToParse);
buff.contentSubmodule.interpretedFunctionText = result;
}
}

View File

@@ -13,11 +13,7 @@ namespace Continentis.MainGame
static CardTextInterpreter()
{
TextInterpreter = new Interpreter();
TextInterpreter.SetFunction("Value", new Func<float, string>((cv) => DynamicTextInterpreter.GetValue(cv, false)));
TextInterpreter.SetFunction("Value", new Func<float, float, string>((cv, bv) => DynamicTextInterpreter.GetValue(cv, bv, true, false)));
TextInterpreter.SetFunction("Value", new Func<float, float, bool, string>((cv, bv, high) => DynamicTextInterpreter.GetValue(cv, bv, high, false)));
TextInterpreter.SetFunction("Value", new Func<float, float, bool, bool, string>((cv, bv, high, percent) => DynamicTextInterpreter.GetValue(cv, bv, high, percent)));
DynamicTextInterpreter.InitializeInterpreter(ref TextInterpreter);
foreach (KeyValuePair<string, InterpretedKeyword> keyword in MainGameManager.Instance.keywordData.interpretedKeywords)
{
@@ -27,7 +23,7 @@ namespace Continentis.MainGame
public static void InterpretText(CardLogicBase card, bool overrideDescription = false)
{
card.contentSubmodule.keywords.Clear();
//card.contentSubmodule.keywords.Clear();
foreach (KeyValuePair<string, float> attribute in card.attributeSubmodule.attributeGroup.current)
{
@@ -40,7 +36,7 @@ namespace Continentis.MainGame
TextInterpreter.SetFunction("Attribute", new Func<string, bool, bool, string>((name, high, percent) => GetAttribute(card, name, high, percent)));
string descriptionToParse = card.contentSubmodule.originalFunctionText;
string result = DynamicTextInterpreter.Parse(TextInterpreter, descriptionToParse, card.contentSubmodule.keywords, card.contentSubmodule.hintKeywords);
string result = DynamicTextInterpreter.Parse(TextInterpreter, descriptionToParse);
card.contentSubmodule.interpretedFunctionText = result;

View File

@@ -9,19 +9,34 @@ namespace Continentis.MainGame
{
public partial class DynamicTextInterpreter
{
public static string Parse(Interpreter interpreter, string template, List<string> keywords, List<string> hintKeywords)
public static void InitializeInterpreter(ref Interpreter interpreter)
{
interpreter.UnsetFunction("Keyword");
interpreter.SetFunction("Keyword", new Func<string, string>(kw => SetKeyword(ref keywords, kw, "#FFA500")));
interpreter.UnsetFunction("HintKeyword");
interpreter.SetFunction("HintKeyword", new Func<string, string>(kw => SetKeyword(ref hintKeywords, kw, "#FFA500")));
interpreter.SetFunction("HintKeyword", new Func<string, string, string>((kw, colorHex) => SetKeyword(ref hintKeywords, kw, colorHex)));
interpreter.UnsetFunction("DescKeyword");
interpreter.SetFunction("Keyword", new Func<string, string>(kw => SetKeyword(kw, "#FFA500")));
interpreter.SetFunction("HintKeyword", new Func<string, string>(kw => SetKeyword(kw, "#FFA500")));
interpreter.SetFunction("HintKeyword", new Func<string, string, string>(SetKeyword));
interpreter.SetFunction("DescKeyword", new Func<string, string>(kw =>DescKeyword(kw, "#FFA500")));
interpreter.SetFunction("DescKeyword", new Func<string, string, string>(DescKeyword));
interpreter.UnsetFunction("ColorText");
interpreter.SetFunction("ColorText", new Func<string, string, string>(ColorText));
interpreter.SetFunction("Value", new Func<float, string>((cv) => GetValue(cv, false)));
interpreter.SetFunction("Value", new Func<float, float, string>((cv, bv) => GetValue(cv, bv, true, false)));
interpreter.SetFunction("Value", new Func<float, float, bool, string>((cv, bv, high) => GetValue(cv, bv, high, false)));
interpreter.SetFunction("Value", new Func<float, float, bool, bool, string>((cv, bv, high, percent) => GetValue(cv, bv, high, percent)));
//本地函数,用于添加关键词到集合中并返回格式化后的关键词字符串
string SetKeyword(string keyword, string colorHex)
{
if (!string.IsNullOrEmpty(keyword))
{
return Keyword(keyword, colorHex);
}
return string.Empty;
}
}
public static string Parse(Interpreter interpreter, string template)
{
try
{
while (template.Contains("$"))
@@ -49,17 +64,6 @@ namespace Continentis.MainGame
}
return template;
//本地函数,用于添加关键词到集合中并返回格式化后的关键词字符串
string SetKeyword(ref List<string> collection, string keyword, string colorHex)
{
if (!string.IsNullOrEmpty(keyword) && !collection.Contains(keyword))
{
collection.Add(keyword);
}
return Keyword(keyword, colorHex);
}
}
private static int FindMatchingClosingParenthesis(string text, int startIndex)