using System.Collections.Generic;
using System.Linq;
using UnityEngine;
namespace Continentis.MainGame.Card
{
public partial class CardBuffBase
{
public abstract class CardBuffSubmodule : BuffSubmodule
{
public CardInstance card => (buff as CardBuffBase)?.attachedCard;
protected CardBuffSubmodule(CardBuffBase buff) : base(buff)
{
}
}
///
/// Buff的卡牌属性调整模块
///
public class AttributeSubmodule : CardBuffSubmodule
{
public Dictionary numericChange;
public Dictionary percentageChangeOfAccumulation;
public Dictionary percentageChangeOfMultiplication;
public AttributeSubmodule(CardBuffBase buff) : base(buff)
{
this.numericChange = new Dictionary();
this.percentageChangeOfAccumulation = new Dictionary();
this.percentageChangeOfMultiplication = new Dictionary();
}
public List RefreshAllModifiedAttributes()
{
List modifiedAttributes = new List();
modifiedAttributes.AddRange(numericChange.Select(kvp => kvp.Key));
modifiedAttributes.AddRange(percentageChangeOfAccumulation.Select(kvp => kvp.Key));
modifiedAttributes.AddRange(percentageChangeOfMultiplication.Select(kvp => kvp.Key));
modifiedAttributes.ForEach(attr => card.attributeSubmodule.RefreshAttribute(attr));
return modifiedAttributes;
}
}
///
/// Buff的使用次数模块
///
public class UsageSubmodule : CardBuffSubmodule
{
public int currentUsage;
public int maxUsageCount;
public UsageSubmodule(CardBuffBase buff, int maxUsageCount) : base(buff)
{
this.maxUsageCount = maxUsageCount;
this.currentUsage = 0;
}
public void UpdateModule()
{
currentUsage++;
if (currentUsage >= maxUsageCount)
{
buff.Remove();
}
}
public void RefreshUsage()
{
currentUsage = 0;
}
public void ModifyMaxUsage(int change)
{
maxUsageCount += change;
if (maxUsageCount <= currentUsage)
{
buff.Remove();
}
}
}
}
}