Overclock.cs 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. using System.Collections;
  2. using System;
  3. public partial class CardEffectFactory
  4. {
  5. #region Trigger effect of [Overclock] on oneself
  6. public static ActivateClass OverclockSelfEffect(string trait, bool isInheritedEffect, CardSource card, Func<bool> condition,
  7. ICardEffect rootCardEffect = null)
  8. {
  9. Permanent targetPermanent = card.PermanentOfThisCard();
  10. bool CanUseCondition()
  11. {
  12. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  13. (condition == null || condition());
  14. }
  15. return OverclockEffect(trait: trait, targetPermanent: targetPermanent, isInheritedEffect: isInheritedEffect,
  16. condition: CanUseCondition,
  17. rootCardEffect: rootCardEffect, card);
  18. }
  19. #endregion
  20. #region Trigger effect of [Overclock]
  21. public static ActivateClass OverclockEffect(string trait, Permanent targetPermanent, bool isInheritedEffect, Func<bool> condition,
  22. ICardEffect rootCardEffect, CardSource card)
  23. {
  24. if (targetPermanent == null) return null;
  25. if (targetPermanent.TopCard == null) return null;
  26. if (card == null) return null;
  27. ActivateClass activateClass = new ActivateClass();
  28. activateClass.SetUpICardEffect("Overclock", CanUseCondition, card);
  29. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, DataBase.OverclockEffectDiscription(trait));
  30. activateClass.SetIsInheritedEffect(isInheritedEffect);
  31. if (rootCardEffect != null)
  32. {
  33. activateClass.SetIsInheritedEffect(false);
  34. activateClass.SetEffectSourcePermanent(targetPermanent);
  35. activateClass.SetRootCardEffect(rootCardEffect);
  36. }
  37. bool CanUseCondition(Hashtable hashtable)
  38. {
  39. return CardEffectCommons.IsExistOnBattleArea(card) &&
  40. CardEffectCommons.IsOwnerTurn(card);
  41. }
  42. bool CanActivateCondition(Hashtable hashtable)
  43. {
  44. return CardEffectCommons.CanActivateOverclock(trait, targetPermanent.TopCard, activateClass) &&
  45. (condition == null || condition());
  46. }
  47. IEnumerator ActivateCoroutine(Hashtable hashtable)
  48. {
  49. return CardEffectCommons.OverclockProcess(trait, targetPermanent.TopCard, activateClass);
  50. }
  51. return activateClass;
  52. }
  53. #endregion
  54. }