using System.Collections.Generic; using SLSUtilities.General; namespace Continentis.MainGame.Card { #region Fundamental public partial class CardInstance { public List GetElementalKeywords(List overrideKeywords = null) { overrideKeywords ??= contentSubmodule.keywords; return overrideKeywords.Filtered(kw => MainGameManager.Instance.elementTags.Contains(kw)); } public bool HasKeyword(string keyword) { return contentSubmodule.keywords.Contains(keyword); } public bool HasAnyKeyword(params string[] keywords) { bool hasAny = false; foreach (var keyword in keywords) { hasAny = HasKeyword(keyword); if (hasAny) break; } return hasAny; } public bool HasAllKeywords(params string[] keywords) { bool hasAll = true; foreach (var keyword in keywords) { hasAll = HasKeyword(keyword); if (!hasAll) break; } return hasAll; } } #endregion #region Attributes public partial class CardInstance { /// /// 设置可变属性值 /// /// 属性名,通常为 /// 是否为叠加,true为叠加,false为覆盖,true时,originalValue为外部传入值 /// 原始伤害值,仅在additive为true时有效,否则此值被覆盖为BaseAttribute /// 伤害增量 public void SetVariableAttribute(string attributeName, int baseOffset, bool additive = false, int originalValue = 0) { var baseName = "Base_" + attributeName; var baseOffsetName = "Base_" + attributeName + "_Offset"; if (!additive) originalValue = GetAttribute(baseName); SetAttribute(attributeName, originalValue); SetAttribute(baseOffsetName, baseOffset); ModifyAttribute(attributeName, baseOffset); } /// /// 检查卡牌是否具有某属性 /// public bool HasAttribute(string attributeName) { return attributeSubmodule.attributeGroup.current.ContainsKey(attributeName); } /// /// 获取卡牌的属性值 /// public int GetAttribute(string attributeName, int defaultValue = 0) { return attributeSubmodule.GetRoundCurrentAttribute(attributeName, defaultValue); } public float GetRawAttribute(string attributeName, float defaultValue = 0) { return attributeSubmodule.GetCurrentAttribute(attributeName, defaultValue); } /// /// 设置卡牌的属性值 /// public void SetAttribute(string attributeName, int value) { attributeSubmodule.attributeGroup.current[attributeName] = value; } /// /// 设置卡牌的属性值 /// public void SetAttribute(string attributeName, float value) { attributeSubmodule.attributeGroup.current[attributeName] = value; } /// /// 修改卡牌的属性值 /// public void ModifyAttribute(string attributeName, int delta) { attributeSubmodule.attributeGroup.current[attributeName] += delta; } } #endregion }