Divemon_BT16_023.cs 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System;
  5. namespace DCGO.CardEffects.BT16
  6. {
  7. public class Divemon_BT16_023 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. var cardEffects = new List<ICardEffect>();
  12. #region Alternate Digivolution Requirement
  13. if(timing == EffectTiming.None)
  14. {
  15. bool PermanentCondition(Permanent targetPermanent)
  16. {
  17. return targetPermanent.TopCard.HasPulsemonText && targetPermanent.TopCard.IsLevel4;
  18. }
  19. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  20. permanentCondition: PermanentCondition,
  21. digivolutionCost: 3,
  22. ignoreDigivolutionRequirement: false,
  23. card: card,
  24. condition: null)
  25. );
  26. }
  27. #endregion
  28. #region On Play/When Digivolving
  29. if (timing == EffectTiming.OnEnterFieldAnyone)
  30. {
  31. ActivateClass activateClass = new ActivateClass();
  32. activateClass.SetUpICardEffect("Unsuspend 1 Digimon and/or bottom deck an opponent's Level 4 or lower Digimon", CanUseCondition, card);
  33. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  34. cardEffects.Add(activateClass);
  35. string EffectDiscription()
  36. {
  37. return "[On Play] [When Digivolving] If you have 3 or more security cards, unsuspend 1 of your Digimon. If " +
  38. "you have 3 or fewer, return 1 of your opponent's level 4 or lower Digimon to the bottom of the deck.";
  39. }
  40. bool CanSelectPermanentUnsuspendCondition(Permanent permanent)
  41. {
  42. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  43. {
  44. if (permanent.TopCard.HasLevel)
  45. {
  46. return true;
  47. }
  48. }
  49. return false;
  50. }
  51. bool CanSelectPermanentBounceCondition(Permanent permanent)
  52. {
  53. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  54. {
  55. if (permanent.Level <= 4)
  56. {
  57. return true;
  58. }
  59. }
  60. return false;
  61. }
  62. bool CanUseCondition(Hashtable hashtable)
  63. {
  64. return CardEffectCommons.CanTriggerOnPlay(hashtable, card) || CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  65. }
  66. bool CanActivateCondition(Hashtable hashtable)
  67. {
  68. if (CardEffectCommons.IsExistOnBattleArea(card))
  69. {
  70. return true;
  71. }
  72. return false;
  73. }
  74. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  75. {
  76. if (isExistOnField(card))
  77. {
  78. if (card.Owner.GetBattleAreaDigimons().Contains(card.PermanentOfThisCard()))
  79. {
  80. if (card.Owner.SecurityCards.Count >= 3)
  81. {
  82. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  83. selectPermanentEffect.SetUp(
  84. selectPlayer: card.Owner,
  85. canTargetCondition: CanSelectPermanentUnsuspendCondition,
  86. canTargetCondition_ByPreSelecetedList: null,
  87. canEndSelectCondition: null,
  88. maxCount: 1,
  89. canNoSelect: false,
  90. canEndNotMax: false,
  91. selectPermanentCoroutine: null,
  92. afterSelectPermanentCoroutine: null,
  93. mode: SelectPermanentEffect.Mode.UnTap,
  94. cardEffect: activateClass);
  95. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  96. }
  97. if (card.Owner.SecurityCards.Count <= 3)
  98. {
  99. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  100. selectPermanentEffect.SetUp(
  101. selectPlayer: card.Owner,
  102. canTargetCondition: CanSelectPermanentBounceCondition,
  103. canTargetCondition_ByPreSelecetedList: null,
  104. canEndSelectCondition: null,
  105. maxCount: 1,
  106. canNoSelect: false,
  107. canEndNotMax: false,
  108. selectPermanentCoroutine: null,
  109. afterSelectPermanentCoroutine: null,
  110. mode: SelectPermanentEffect.Mode.PutLibraryBottom,
  111. cardEffect: activateClass);
  112. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  113. }
  114. }
  115. }
  116. }
  117. }
  118. #endregion
  119. #region Inherited Effect
  120. if (timing == EffectTiming.OnAllyAttack)
  121. {
  122. ActivateClass activateClass = new ActivateClass();
  123. activateClass.SetUpICardEffect("Trash 1 digivolution card", CanUseCondition, card);
  124. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false,
  125. EffectDiscription());
  126. activateClass.SetIsInheritedEffect(true);
  127. cardEffects.Add(activateClass);
  128. string EffectDiscription()
  129. {
  130. return "[When Attacking] Trash the top digivolution card of 1 of your opponent's Digimon.";
  131. }
  132. bool CanSelectPermanentCondition(Permanent permanent)
  133. {
  134. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card)
  135. && permanent.DigivolutionCards.Count(cardSource =>
  136. !cardSource.CanNotTrashFromDigivolutionCards(activateClass)) >= 1;
  137. }
  138. bool CanUseCondition(Hashtable hashtable)
  139. {
  140. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  141. }
  142. bool CanActivateCondition(Hashtable hashtable)
  143. {
  144. return CardEffectCommons.IsExistOnBattleArea(card) &&
  145. CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition);
  146. }
  147. IEnumerator ActivateCoroutine(Hashtable hashtable)
  148. {
  149. var maxCount = Math.Min(1,
  150. CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  151. var selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  152. selectPermanentEffect.SetUp(
  153. selectPlayer: card.Owner,
  154. canTargetCondition: CanSelectPermanentCondition,
  155. canTargetCondition_ByPreSelecetedList: null,
  156. canEndSelectCondition: null,
  157. maxCount: maxCount,
  158. canNoSelect: false,
  159. canEndNotMax: false,
  160. selectPermanentCoroutine: SelectPermanentCoroutine,
  161. afterSelectPermanentCoroutine: null,
  162. mode: SelectPermanentEffect.Mode.Custom,
  163. cardEffect: activateClass);
  164. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will trash digivolution cards.",
  165. "The opponent is selecting 1 Digimon that will trash digivolution cards.");
  166. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  167. yield break;
  168. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  169. {
  170. yield return ContinuousController.instance.StartCoroutine(
  171. CardEffectCommons.TrashDigivolutionCardsFromTopOrBottom(targetPermanent: permanent,
  172. trashCount: 1, isFromTop: true, activateClass: activateClass));
  173. }
  174. }
  175. }
  176. #endregion
  177. return cardEffects;
  178. }
  179. }
  180. }