using System.Collections; using System.Collections.Generic; using System; using System.Linq; using UnityEngine; public partial class CardEffectFactory { #region Static effect that changes origin DP public static ChangeBaseDPClass ChangeBaseDPStaticEffect(Permanent targetPermanent, T changeValue, bool isInheritedEffect, CardSource card, Func condition) { bool CanUseCondition() { return CardEffectCommons.IsPermanentExistsOnBattleArea(targetPermanent) && (condition == null || condition()); } bool PermanentCondition(Permanent permanent) { if (CardEffectCommons.IsPermanentExistsOnBattleArea(permanent)) { if (permanent == targetPermanent) { return true; } } return false; } return ChangeBaseDPGlobalEffect(PermanentCondition, changeValue, isInheritedEffect, card, CanUseCondition); } #endregion #region Static effect that changes origin DP of Multiple Digimon public static ChangeBaseDPClass ChangeBaseDPGlobalEffect(Func permanentCondition, T changeValue, bool isInheritedEffect, CardSource card, Func condition) { 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)(); string effectName() => $"Origin DP is {_changeValue()}"; ChangeBaseDPClass changeBaseDPClass = new ChangeBaseDPClass(); changeBaseDPClass.SetUpICardEffect("", CanUseCondition, card); changeBaseDPClass.SetUpChangeBaseDPClass(changeDPFunc: ChangeDP, permanentCondition: PermanentCondition, isUpDownFunc: _isUpDown, isMinusDPFunc: () => false); changeBaseDPClass.SetIsInheritedEffect(isInheritedEffect); bool CanUseCondition(Hashtable hashtable) { if (condition == null || condition()) { changeBaseDPClass.SetEffectName(effectName()); return true; } return false; } int ChangeDP(Permanent permanent, int DP) { if (PermanentCondition(permanent)) { DP = _changeValue(); } return DP; } bool PermanentCondition(Permanent permanent) { return permanentCondition != null && permanentCondition(permanent) && !permanent.TopCard.CanNotBeAffected(changeBaseDPClass); } bool _isUpDown() { return false; } return changeBaseDPClass; } #endregion }