121 lines
3.7 KiB
C#
121 lines
3.7 KiB
C#
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
|
||
} |