BT20_078.cs 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. namespace DCGO.CardEffects.BT20
  4. {
  5. public class BT20_078 : CEntity_Effect
  6. {
  7. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  8. {
  9. List<ICardEffect> cardEffects = new List<ICardEffect>();
  10. #region Collision
  11. if (timing == EffectTiming.OnCounterTiming)
  12. {
  13. cardEffects.Add(CardEffectFactory.CollisionSelfStaticEffect(false, card, null));
  14. }
  15. #endregion
  16. #region Blocker
  17. if (timing == EffectTiming.None)
  18. {
  19. cardEffects.Add(CardEffectFactory.BlockerSelfStaticEffect(isInheritedEffect: false, card: card, condition: null));
  20. }
  21. #endregion
  22. #region All Turns
  23. if (timing == EffectTiming.OnEnterFieldAnyone)
  24. {
  25. ActivateClass activateClass = new ActivateClass();
  26. activateClass.SetUpICardEffect("<De-Digivolve 1> 1 your opponent's Digimon", CanUseCondition, card);
  27. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDescription());
  28. activateClass.SetHashString("AllTurn_BT20-078");
  29. cardEffects.Add(activateClass);
  30. string EffectDescription()
  31. {
  32. return
  33. "[All Turns] [Once Per Turn] When effects digivolve your opponent's Digimon, <De-Digivolve 1> 1 of your opponent's Digimon.";
  34. }
  35. bool CanUseCondition(Hashtable hashtable)
  36. {
  37. if (CardEffectCommons.CanTriggerWhenPermanentDigivolving(hashtable, IsOpponentDigimon))
  38. {
  39. if (CardEffectCommons.IsByEffect(hashtable, null))
  40. {
  41. return true;
  42. }
  43. }
  44. return false;
  45. }
  46. bool IsOpponentDigimon(Permanent permanent)
  47. {
  48. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  49. }
  50. bool CanActivateCondition(Hashtable hashtable)
  51. {
  52. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  53. CardEffectCommons.HasMatchConditionPermanent(IsOpponentDigimon);
  54. }
  55. IEnumerator ActivateCoroutine(Hashtable hashtable)
  56. {
  57. Permanent selectedPermanent = null;
  58. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  59. selectPermanentEffect.SetUp(
  60. selectPlayer: card.Owner,
  61. canTargetCondition: IsOpponentDigimon,
  62. canTargetCondition_ByPreSelecetedList: null,
  63. canEndSelectCondition: null,
  64. maxCount: 1,
  65. canNoSelect: false,
  66. canEndNotMax: false,
  67. selectPermanentCoroutine: SelectPermanentCoroutine,
  68. afterSelectPermanentCoroutine: null,
  69. mode: SelectPermanentEffect.Mode.Custom,
  70. cardEffect: activateClass);
  71. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to De-Digivolve.",
  72. "The opponent is selecting 1 Digimon to De-Digivolve.");
  73. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  74. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  75. {
  76. selectedPermanent = permanent;
  77. yield return null;
  78. }
  79. if (selectedPermanent != null)
  80. {
  81. yield return ContinuousController.instance.StartCoroutine(
  82. new IDegeneration(selectedPermanent, 1, activateClass).Degeneration());
  83. }
  84. }
  85. }
  86. #endregion
  87. #region On Deletion
  88. if (timing == EffectTiming.OnDestroyedAnyone)
  89. {
  90. ActivateClass activateClass = new ActivateClass();
  91. activateClass.SetUpICardEffect("Delete 1 of your opponent's Digimon or Tamers.", CanUseCondition, card);
  92. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription());
  93. cardEffects.Add(activateClass);
  94. string EffectDescription()
  95. {
  96. return "[On Deletion] Delete 1 of your opponent's play cost 4 or lower Digimon or Tamers.";
  97. }
  98. bool CanUseCondition(Hashtable hashtable)
  99. {
  100. return CardEffectCommons.CanTriggerOnDeletion(hashtable, card, activateClass);
  101. }
  102. bool CanSelectPermanentCondition(Permanent permanent)
  103. {
  104. return CardEffectCommons.IsPermanentExistsOnOpponentBattleArea(permanent, card) &&
  105. (permanent.IsDigimon || permanent.IsTamer) &&
  106. permanent.TopCard.HasPlayCost && permanent.TopCard.GetCostItself <= 4;
  107. }
  108. bool CanActivateCondition(Hashtable hashtable)
  109. {
  110. return CardEffectCommons.CanActivateOnDeletion(card, activateClass) &&
  111. CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition);
  112. }
  113. IEnumerator ActivateCoroutine(Hashtable hashtable)
  114. {
  115. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  116. selectPermanentEffect.SetUp(
  117. selectPlayer: card.Owner,
  118. canTargetCondition: CanSelectPermanentCondition,
  119. canTargetCondition_ByPreSelecetedList: null,
  120. canEndSelectCondition: null,
  121. maxCount: 1,
  122. canNoSelect: false,
  123. canEndNotMax: false,
  124. selectPermanentCoroutine: null,
  125. afterSelectPermanentCoroutine: null,
  126. mode: SelectPermanentEffect.Mode.Destroy,
  127. cardEffect: activateClass);
  128. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  129. }
  130. }
  131. #endregion
  132. return cardEffects;
  133. }
  134. }
  135. }