Files
Continentis/Assets/Scripts/MainGame/Card/LogicComponents/CardLogicComponent_SelectHandCards.cs
SoulliesOfficial 61a397dd4c MOD!
2025-10-23 00:49:44 -04:00

56 lines
2.0 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using Continentis.MainGame.Commands;
using Continentis.MainGame.UI;
using SLSFramework.General;
namespace Continentis.MainGame.Card
{
public class CardLogicComponent_SelectHandCards : CardLogicComponentBase
{
private Func<CardInstance, bool> selectCondition;
private Action<CardInstance> selectEffect;
public List<CardInstance> selectedCards;
public CardLogicComponent_SelectHandCards SetCondition(Func<CardInstance, bool> condition)
{
selectCondition = condition;
return this;
}
public CardLogicComponent_SelectHandCards SetEffect(Action<CardInstance> effect)
{
selectEffect = effect;
return this;
}
/// <summary>
/// 添加选择手牌的指令
/// </summary>
/// <param name="commandGroup">目标指令组</param>
/// <param name="title">选择卡牌的描述性标题</param>
/// <param name="maxSelection">最大选择数量</param>
/// <param name="forceMax">是否强制选择最大数量</param>
public void AddSelectionCommands(ref CommandGroup commandGroup, string title, int maxSelection, bool forceMax = false)
{
selectedCards = new List<CardInstance>();
HandCardSelectionInterface handCardSelector = CombatUIManager.Instance.combatMainPage.handCardSelector;
commandGroup.AddCommand(new Cmd_Function(() =>
{
handCardSelector.Setup(title, card.cardInstance, maxSelection, selectCondition, forceMax);
}));
commandGroup.AddCommand(new Cmd_WaitForUI(handCardSelector));
commandGroup.AddCommand(new Cmd_Function(() =>
{
selectedCards = handCardSelector.selectedCards.ToList();
selectedCards.ForEach(selectEffect);
}));
}
}
}