using System.Collections.Generic; using System.Linq; using Continentis.MainGame.Card; namespace Continentis.MainGame { /// /// 攻击上下文,携带来源卡牌和标签信息。 /// 替代 Attack() 方法中零散的 boolean 参数,提供可扩展的伤害标记体系。 /// public class AttackContext { /// 触发此次攻击的来源卡牌(可为 null)。 public CardInstance sourceCard; /// 攻击标签集合,用于控制伤害计算与事件触发行为。 public HashSet tags; /// /// 伤害属性关键词(如 "Physics"、"Fire"),驱动 offset 和元素乘区计算。 /// 为 null 时回退到卡牌元素关键词(向后兼容)。 /// public List damageKeywords; /// /// 基础伤害读取的属性名(如 "Damage_Physics")。 /// 为 null 或空时默认读取 "Damage"。 /// public string baseDamageAttributeName; public AttackContext() { tags = new HashSet(); } public AttackContext(CardInstance sourceCard) : this() { this.sourceCard = sourceCard; } /// 检查是否包含指定标签。 public bool HasTag(string tag) { return tags != null && tags.Contains(tag); } /// 检查是否包含任意一个指定标签。 public bool HasAnyTag(params string[] checkTags) { if (tags == null || tags.Count == 0) return false; return checkTags.Any(t => tags.Contains(t)); } /// 链式添加标签。 public AttackContext WithTag(string tag) { tags ??= new HashSet(); tags.Add(tag); return this; } /// 链式添加多个标签。 public AttackContext WithTags(params string[] newTags) { tags ??= new HashSet(); foreach (string tag in newTags) { tags.Add(tag); } return this; } /// 链式设置伤害属性关键词。 public AttackContext WithDamageKeywords(params string[] keywords) { damageKeywords = new List(keywords); return this; } /// 链式设置基础伤害属性名。 public AttackContext WithBaseDamageAttribute(string attributeName) { baseDamageAttributeName = attributeName; return this; } /// 创建一个携带来源卡牌的默认上下文。 public static AttackContext Default(CardInstance card = null) { return new AttackContext(card); } } /// /// 预定义的攻击标签常量。 /// Mod 开发者可以使用自定义字符串扩展标签体系,无需修改此类。 /// public static class AttackTags { /// /// 完全静默攻击:不触发任何攻击事件(角色 EventSubmodule + Buff 层均跳过)。 /// 等价于旧 API 的 triggerAttackEvent = false。 /// public const string Silent = "Silent"; /// /// 响应式攻击:由 Buff 被动效果产生的附带攻击。 /// 触发角色 EventSubmodule 事件,但跳过 Buff 层的 onDealAttack/onGetAttacked, /// 从机制上杜绝 Buff 触发链的无限递归。 /// public const string Reactive = "Reactive"; /// /// 生命移除:无视闪避、格挡、护盾,不触发任何事件。 /// 直接对目标造成生命值扣减,类似 Dota 2 的 HP Removal。 /// public const string HpRemoval = "HpRemoval"; /// /// 反弹伤害:由反弹/反伤机制产生的伤害。 /// Buff 可检查此标签以避免"反弹的反弹"导致无限循环。 /// public const string Reflected = "Reflected"; /// 必中,无视闪避。 public const string GuaranteedHit = "GuaranteedHit"; /// 穿透,无视格挡。 public const string Penetrating = "Penetrating"; } }