using System.Collections.Generic;
using Continentis.MainGame;
using Continentis.MainGame.Card;
using Continentis.MainGame.Character;
using Continentis.MainGame.Commands;
using Continentis.Mods.Basic.Buffs;
using SLSUtilities.General;
namespace Continentis.Mods.Basic.Cards
{
///
/// 余烬打击:消耗一张手牌,对单体目标造成火焰伤害并施加灼烧 Buff。
/// 若手牌中没有其他牌可消耗,跳过所有后续效果。
///
public class CinderStrike : CardLogicBase
{
private const string BUFF_BURN_STACK = "Buff_Burn_Stack";
private AttackContext FireCtx => AttackContext.Default(card)
.WithDamageKeywords(CardKeywords.Fire);
public override void SetUpLogicComponents()
{
AddLogicComponent();
AddLogicComponent()
.SetCondition(c => c != card)
.SetEffect(c => CommandQueueManager.Instance.AddCommand(
user.deckSubmodule.DiscardCard(c, true, 0f)));
}
/// 选中目标时更新伤害预览。
public override void TargetingEffect(CharacterBase target)
{
card.SetAttribute("Display_Damage", GetTargetedFinalDamage(target, FireCtx));
}
/// 取消选中时以无目标模式刷新预览。
public override void UntargetingEffect()
{
card.SetAttribute("Display_Damage", GetNoTargetFinalDamage(FireCtx));
}
public override CommandGroup PlayEffect(List targetList)
{
// 手牌中(排除自身)没有可弃的牌,跳过所有后续效果
if (user.deckSubmodule.HandPile.Exclude(card).Count == 0)
{
return Cmd.Sequential(new Cmd_PlayAnimation(user.characterView, "Attack"));
}
CommandGroup mainGroup = Cmd.Sequential(
new Cmd_PlayAnimation(user.characterView, "Attack")
);
// 弹出手牌选择 UI,强制选择 1 张弃掉
LogicComponent()
.AddSelectionCommands(ref mainGroup, "Card_Basic_CinderStrike_SelectHandCards_Title".Localize(), 1, forceMax: true);
// 弃牌完成后再造成伤害和灼烧
mainGroup.AddCommand(Cmd.Do(() =>
{
foreach (CharacterBase target in targetList)
{
AttackContext ctx = FireCtx;
AttackTarget(target, GetTargetedFinalDamage(target, ctx), ctx);
CreateCharacterBuff(GetAttribute(BUFF_BURN_STACK)).Apply(target, user, this);
}
}));
return mainGroup;
}
public override void ApplyAttributeChangesByCard()
{
LogicComponent().SetDamage_Magic();
}
}
}