Files
Continentis/Assets/Scripts/MainGame/Card/CardAssistanceFunctions.cs

121 lines
3.7 KiB
C#
Raw Normal View History

2025-10-03 00:02:43 -04:00
using System.Collections.Generic;
2025-10-23 00:49:44 -04:00
using SLSFramework.General;
2025-10-03 00:02:43 -04:00
namespace Continentis.MainGame.Card
{
2025-10-23 00:49:44 -04:00
#region Fundamental
2026-03-20 11:56:50 -04:00
2025-11-15 12:17:34 -05:00
public partial class CardInstance
2025-10-03 00:02:43 -04:00
{
2025-10-27 07:04:34 -04:00
public List<string> GetElementalKeywords(List<string> overrideKeywords = null)
2025-10-03 00:02:43 -04:00
{
2025-10-27 07:04:34 -04:00
overrideKeywords ??= contentSubmodule.keywords;
return overrideKeywords.Filtered(kw => MainGameManager.Instance.elementTags.Contains(kw));
2025-10-03 00:02:43 -04:00
}
2026-03-20 11:56:50 -04:00
2025-10-03 00:02:43 -04:00
public bool HasKeyword(string keyword)
{
return contentSubmodule.keywords.Contains(keyword);
}
2026-04-01 12:23:27 -04:00
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;
}
2025-10-03 00:02:43 -04:00
}
2026-03-20 11:56:50 -04:00
2025-10-23 00:49:44 -04:00
#endregion
2026-03-20 11:56:50 -04:00
#region Attributes
2025-11-15 12:17:34 -05:00
public partial class CardInstance
2025-10-03 00:02:43 -04:00
{
/// <summary>
2026-03-20 11:56:50 -04:00
/// 设置可变属性值
2025-10-03 00:02:43 -04:00
/// </summary>
/// <param name="attributeName">属性名,通常为</param>
/// <param name="additive">是否为叠加true为叠加false为覆盖true时originalValue为外部传入值</param>
/// <param name="originalValue">原始伤害值仅在additive为true时有效否则此值被覆盖为BaseAttribute</param>
/// <param name="baseOffset">伤害增量</param>
2026-03-20 11:56:50 -04:00
public void SetVariableAttribute(string attributeName, int baseOffset, bool additive = false,
int originalValue = 0)
2025-10-03 00:02:43 -04:00
{
2026-04-08 04:48:35 -04:00
var baseName = "Base_" + attributeName;
var baseOffsetName = "Base_" + attributeName + "_Offset";
2026-03-20 11:56:50 -04:00
2025-10-03 00:02:43 -04:00
if (!additive) originalValue = GetAttribute(baseName);
2026-03-20 11:56:50 -04:00
2025-10-03 00:02:43 -04:00
SetAttribute(attributeName, originalValue);
SetAttribute(baseOffsetName, baseOffset);
ModifyAttribute(attributeName, baseOffset);
}
2026-03-20 11:56:50 -04:00
2025-10-03 00:02:43 -04:00
/// <summary>
2026-03-20 11:56:50 -04:00
/// 检查卡牌是否具有某属性
2025-10-03 00:02:43 -04:00
/// </summary>
2025-10-23 00:49:44 -04:00
public bool HasAttribute(string attributeName)
2025-10-03 00:02:43 -04:00
{
2025-10-23 00:49:44 -04:00
return attributeSubmodule.attributeGroup.current.ContainsKey(attributeName);
2025-10-03 00:02:43 -04:00
}
2026-03-20 11:56:50 -04:00
2025-10-03 00:02:43 -04:00
/// <summary>
2026-03-20 11:56:50 -04:00
/// 获取卡牌的属性值
2025-10-03 00:02:43 -04:00
/// </summary>
2025-10-23 00:49:44 -04:00
public int GetAttribute(string attributeName, int defaultValue = 0)
2025-10-03 00:02:43 -04:00
{
2025-10-23 00:49:44 -04:00
return attributeSubmodule.GetRoundCurrentAttribute(attributeName, defaultValue);
2025-10-03 00:02:43 -04:00
}
2026-03-20 11:56:50 -04:00
2025-10-23 00:49:44 -04:00
public float GetRawAttribute(string attributeName, float defaultValue = 0)
2025-10-03 00:02:43 -04:00
{
2025-10-23 00:49:44 -04:00
return attributeSubmodule.GetCurrentAttribute(attributeName, defaultValue);
2025-10-03 00:02:43 -04:00
}
2026-03-20 11:56:50 -04:00
2025-10-03 00:02:43 -04:00
/// <summary>
2026-03-20 11:56:50 -04:00
/// 设置卡牌的属性值
2025-10-03 00:02:43 -04:00
/// </summary>
2025-10-23 00:49:44 -04:00
public void SetAttribute(string attributeName, int value)
2025-10-03 00:02:43 -04:00
{
2025-10-23 00:49:44 -04:00
attributeSubmodule.attributeGroup.current[attributeName] = value;
2025-10-03 00:02:43 -04:00
}
2026-03-20 11:56:50 -04:00
2025-10-03 00:02:43 -04:00
/// <summary>
2026-03-20 11:56:50 -04:00
/// 设置卡牌的属性值
2025-10-03 00:02:43 -04:00
/// </summary>
2025-10-23 00:49:44 -04:00
public void SetAttribute(string attributeName, float value)
2025-10-03 00:02:43 -04:00
{
2025-10-23 00:49:44 -04:00
attributeSubmodule.attributeGroup.current[attributeName] = value;
2025-10-03 00:02:43 -04:00
}
2026-03-20 11:56:50 -04:00
2025-10-03 00:02:43 -04:00
/// <summary>
2026-03-20 11:56:50 -04:00
/// 修改卡牌的属性值
2025-10-03 00:02:43 -04:00
/// </summary>
2025-10-23 00:49:44 -04:00
public void ModifyAttribute(string attributeName, int delta)
2025-10-03 00:02:43 -04:00
{
2025-10-23 00:49:44 -04:00
attributeSubmodule.attributeGroup.current[attributeName] += delta;
2025-10-03 00:02:43 -04:00
}
}
2026-03-20 11:56:50 -04:00
2025-10-23 00:49:44 -04:00
#endregion
2025-10-03 00:02:43 -04:00
}