using System.Collections; using System.Collections.Generic; using System; using System.Linq; using UnityEngine; public partial class CardEffectFactory { #region Static effect that changes security Digimon card DP public static ChangeCardDPClass ChangeSecurityDigimonCardDPStaticEffect(Func cardCondition, T changeValue, bool isInheritedEffect, CardSource card, Func condition, string effectName) { bool isInt = typeof(T) == typeof(int); bool isIntFunc = typeof(T) == typeof(Func); if (!isInt && !isIntFunc) return null; if (isInt && (int)(object)changeValue == 0) return null; if (isIntFunc && changeValue as Func == null) return null; int _changeValue() => isInt ? (int)(object)changeValue : (changeValue as Func)(); bool isUpValue() => _changeValue() > 0; ChangeCardDPClass changeCardDPClass = new ChangeCardDPClass(); changeCardDPClass.SetUpICardEffect("", CanUseCondition, card); changeCardDPClass.SetUpChangeCardDPClass(changeDPFunc: ChangeDP, cardSourceCondition: CardCondition, isUpDown: _isUpDown, isMinusDP: () => !isUpValue()); changeCardDPClass.SetIsInheritedEffect(isInheritedEffect); bool CanUseCondition(Hashtable hashtable) { if (condition == null || condition()) { changeCardDPClass.SetEffectName(effectName); return true; } return false; } int ChangeDP(CardSource cardSource, int DP) { if (CardCondition(cardSource)) { DP += _changeValue(); } return DP; } bool CardCondition(CardSource cardSource) { if (cardSource != null) { if (GManager.instance.attackProcess.SecurityDigimon == cardSource) { if (cardCondition == null || cardCondition(cardSource)) { return true; } } } return false; } bool _isUpDown() { return true; } return changeCardDPClass; } #endregion }