Blitz.cs 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. public partial class CardEffectFactory
  5. {
  6. #region Trigger effect of [Blitz] on oneself
  7. public static ActivateClass BlitzSelfEffect(
  8. bool isInheritedEffect,
  9. CardSource card,
  10. Func<bool> condition,
  11. bool isWhenDigivolving,
  12. ICardEffect rootCardEffect = null)
  13. {
  14. Permanent targetPermanent = card.PermanentOfThisCard() ?? new Permanent(new List<CardSource>() { card });
  15. bool CanUseCondition()
  16. {
  17. if (condition == null || condition())
  18. {
  19. return true;
  20. }
  21. return false;
  22. }
  23. return BlitzEffect(
  24. targetPermanent: targetPermanent,
  25. isInheritedEffect: isInheritedEffect,
  26. condition: CanUseCondition,
  27. isWhenDigivolving: isWhenDigivolving,
  28. rootCardEffect: rootCardEffect,
  29. card: card);
  30. }
  31. #endregion
  32. #region Trigger effect of [Blitz]
  33. public static ActivateClass BlitzEffect(
  34. Permanent targetPermanent,
  35. bool isInheritedEffect,
  36. Func<bool> condition,
  37. bool isWhenDigivolving,
  38. ICardEffect rootCardEffect,
  39. CardSource card,
  40. Func<IEnumerator> beforeOnAttackCoroutine = null)
  41. {
  42. if (targetPermanent == null) return null;
  43. if (targetPermanent.TopCard == null) return null;
  44. if (card == null) return null;
  45. ActivateClass activateClass = new ActivateClass();
  46. activateClass.SetUpICardEffect("Blitz", CanUseCondition, card);
  47. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  48. activateClass.SetIsInheritedEffect(isInheritedEffect);
  49. string EffectDiscription()
  50. {
  51. if (isWhenDigivolving)
  52. {
  53. return $"[When Digivolving] {DataBase.BilitzEffectDiscription()}.";
  54. }
  55. else
  56. {
  57. return $"[On Play] {DataBase.BilitzEffectDiscription()}.";
  58. }
  59. }
  60. if (rootCardEffect != null)
  61. {
  62. activateClass.SetIsInheritedEffect(false);
  63. activateClass.SetEffectSourcePermanent(targetPermanent);
  64. activateClass.SetRootCardEffect(rootCardEffect);
  65. }
  66. bool CanUseCondition(Hashtable hashtable)
  67. {
  68. if (isWhenDigivolving)
  69. {
  70. if (CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card))
  71. {
  72. return true;
  73. }
  74. }
  75. else
  76. {
  77. if (CardEffectCommons.CanTriggerOnPlay(hashtable, card))
  78. {
  79. return true;
  80. }
  81. }
  82. return false;
  83. }
  84. bool CanActivateCondition(Hashtable hashtable)
  85. {
  86. if (CardEffectCommons.CanActivateBlitz(targetPermanent.TopCard, activateClass))
  87. {
  88. if (condition == null || condition())
  89. {
  90. return true;
  91. }
  92. }
  93. return false;
  94. }
  95. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  96. {
  97. return CardEffectCommons.BlitzProcess(targetPermanent.TopCard, activateClass, beforeOnAttackCoroutine);
  98. }
  99. return activateClass;
  100. }
  101. #endregion
  102. }