Files
Continentis/Assets/Scripts/MainGame/Card/CardAssistanceFunctions.cs
SoulliesOfficial ac98ec3aef 更新
2026-04-17 12:01:50 -04:00

121 lines
3.7 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using System.Collections.Generic;
using SLSUtilities.General;
namespace Continentis.MainGame.Card
{
#region Fundamental
public partial class CardInstance
{
public List<string> GetElementalKeywords(List<string> 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
{
/// <summary>
/// 设置可变属性值
/// </summary>
/// <param name="attributeName">属性名,通常为</param>
/// <param name="additive">是否为叠加true为叠加false为覆盖true时originalValue为外部传入值</param>
/// <param name="originalValue">原始伤害值仅在additive为true时有效否则此值被覆盖为BaseAttribute</param>
/// <param name="baseOffset">伤害增量</param>
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);
}
/// <summary>
/// 检查卡牌是否具有某属性
/// </summary>
public bool HasAttribute(string attributeName)
{
return attributeSubmodule.attributeGroup.current.ContainsKey(attributeName);
}
/// <summary>
/// 获取卡牌的属性值
/// </summary>
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);
}
/// <summary>
/// 设置卡牌的属性值
/// </summary>
public void SetAttribute(string attributeName, int value)
{
attributeSubmodule.attributeGroup.current[attributeName] = value;
}
/// <summary>
/// 设置卡牌的属性值
/// </summary>
public void SetAttribute(string attributeName, float value)
{
attributeSubmodule.attributeGroup.current[attributeName] = value;
}
/// <summary>
/// 修改卡牌的属性值
/// </summary>
public void ModifyAttribute(string attributeName, int delta)
{
attributeSubmodule.attributeGroup.current[attributeName] += delta;
}
}
#endregion
}