using System.Collections.Generic; using System.Linq; using SLSFramework.General; using UnityEngine; namespace Continentis.MainGame.Card { public partial class CombatBuffSubmodule : SubmoduleBase { public List buffList; public CombatBuffSubmodule(CardLogicBase owner) : base(owner) { buffList = new List(); } } public partial class CombatBuffSubmodule { public T GetBuff() where T : CombatBuffBase { return (T)buffList.Find(x => x.GetType() == typeof(T)); } public bool HasBuff() where T : CombatBuffBase { return buffList.Exists(x => x.GetType() == typeof(T)); } } public partial class CombatBuffSubmodule { public void Use() { buffList.For(buff => buff.usageSubmodule?.UpdateModule()); buffList.For(buff => buff.OnUsage()); } public void RoundStart() { buffList.For(buff => buff.combatRoundTimeSubmodule?.Update()); buffList.For(buff => buff.OnRoundStart()); } public void RoundEnd() { buffList.For(buff => buff.OnRoundEnd()); } public void ActionStart() { buffList.For(buff => buff.combatActionTimeSubmodule?.Update()); buffList.For(buff => buff.OnActionStart()); } public void ActionEnd() { buffList.For(buff => buff.OnActionEnd()); } } public partial class CombatBuffSubmodule { public void GetAttributeChange(string attributeName, out float numericChange, out float percentageChangeOfAccumulation, out float percentChangeOfMultiplication) { numericChange = buffList.Where(buff => buff.attributeSubmodule != null) .SelectMany(buff => buff.attributeSubmodule.numericChange) .Where(change => change.Key == attributeName) .Sum(change => change.Value); percentageChangeOfAccumulation = buffList.Where(buff => buff.attributeSubmodule != null) .SelectMany(buff => buff.attributeSubmodule.percentageChangeOfAccumulation) .Where(change => change.Key == attributeName) .Sum(change => change.Value); percentChangeOfMultiplication = buffList.Where(buff => buff.attributeSubmodule != null) .SelectMany(buff => buff.attributeSubmodule.percentageChangeOfMultiplication) .Where(change => change.Key == attributeName) .Aggregate, float>(1, (current, change) => current * change.Value); } } }