P_239.cs 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. // DemiDevimon
  4. namespace DCGO.CardEffects.P
  5. {
  6. public class P_239 : CEntity_Effect
  7. {
  8. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  9. {
  10. List<ICardEffect> cardEffects = new List<ICardEffect>();
  11. #region Blocker
  12. if (timing == EffectTiming.None)
  13. {
  14. cardEffects.Add(CardEffectFactory.BlockerSelfStaticEffect(isInheritedEffect: false, card: card, condition: null));
  15. }
  16. #endregion
  17. #region On Deletion
  18. if (timing == EffectTiming.OnDestroyedAnyone)
  19. {
  20. ActivateClass activateClass = new ActivateClass();
  21. activateClass.SetUpICardEffect("By placing this card under a [Myotismon] in text, that Digimon may digivolve into [Myotismon] in name from hand for free", CanUseCondition, card);
  22. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription());
  23. activateClass.SetIsSkippable(true);
  24. cardEffects.Add(activateClass);
  25. string EffectDescription()
  26. {
  27. return "[On Deletion] By placing this card from your trash as the bottom digivolution card of 1 of your Digimon with [Myotismon] in its text, that Digimon may digivolve into a Digimon card with [Myotismon] in its name in the hand without paying the cost.";
  28. }
  29. bool CanUseCondition(Hashtable hashtable)
  30. {
  31. return CardEffectCommons.CanTriggerOnDeletion(hashtable, card, activateClass);
  32. }
  33. bool CanActivateCondition(Hashtable hashtable)
  34. {
  35. return CardEffectCommons.CanActivateOnDeletion(card, activateClass)
  36. && CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition);
  37. }
  38. bool CanSelectPermanentCondition(Permanent permanent)
  39. {
  40. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card)
  41. && permanent.TopCard.HasText("Myotismon");
  42. }
  43. bool CanSelectCardCondition(CardSource cardSource)
  44. {
  45. return cardSource.IsDigimon
  46. && cardSource.ContainsCardName("Myotismon");
  47. }
  48. IEnumerator ActivateCoroutine(Hashtable hashtable)
  49. {
  50. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  51. selectPermanentEffect.SetUp(
  52. selectPlayer: card.Owner,
  53. canTargetCondition: CanSelectPermanentCondition,
  54. canTargetCondition_ByPreSelecetedList: null,
  55. canEndSelectCondition: null,
  56. maxCount: 1,
  57. canNoSelect: true,
  58. canEndNotMax: false,
  59. selectPermanentCoroutine: SelectPermanentCoroutine,
  60. afterSelectPermanentCoroutine: null,
  61. mode: SelectPermanentEffect.Mode.Custom,
  62. cardEffect: activateClass);
  63. selectPermanentEffect.SetUpCustomMessage("Select 1 [Myotismon] in text that will get a digivolution card.", "The opponent is selecting 1 [Myotismon] in text that will get a digivolution card.");
  64. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  65. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  66. {
  67. Permanent selectedPermanent = permanent;
  68. if (selectedPermanent != null)
  69. {
  70. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().ShowCardEffect2(new List<CardSource>() { card }, "Digivolution Cards", true, true));
  71. yield return ContinuousController.instance.StartCoroutine(selectedPermanent.AddDigivolutionCardsBottom(new List<CardSource>() { card }, activateClass));
  72. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DigivolveIntoHandOrTrashCard(
  73. targetPermanent: selectedPermanent,
  74. cardCondition: CanSelectCardCondition,
  75. payCost: false,
  76. reduceCostTuple: null,
  77. fixedCostTuple: null,
  78. ignoreDigivolutionRequirementFixedCost: -1,
  79. isHand: true,
  80. activateClass: activateClass,
  81. successProcess: null
  82. ));
  83. }
  84. }
  85. }
  86. }
  87. #endregion
  88. #region Inherited On Deletion
  89. if (timing == EffectTiming.OnDestroyedAnyone)
  90. {
  91. ActivateClass activateClass = new ActivateClass();
  92. activateClass.SetUpICardEffect("Trash 1 card from hand to delete 1 of enemy level 4- Digimon", CanUseCondition, card);
  93. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription());
  94. activateClass.SetIsSkippable(true);
  95. activateClass.SetIsInheritedEffect(true);
  96. cardEffects.Add(activateClass);
  97. string EffectDescription()
  98. {
  99. return "[On Deletion] By trashing 1 card in your hand, delete 1 of your opponent's level 4 or lower Digimon.";
  100. }
  101. bool CanUseCondition(Hashtable hashtable)
  102. {
  103. return CardEffectCommons.CanTriggerOnDeletion(hashtable, card, activateClass);
  104. }
  105. bool CanActivateCondition(Hashtable hashtable)
  106. {
  107. return CardEffectCommons.CanActivateOnDeletion(card, activateClass)
  108. && card.Owner.HandCards.Count >= 1;
  109. }
  110. bool CanSelectOpponentPermanentCondition(Permanent permanent)
  111. {
  112. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card)
  113. && permanent.TopCard.HasLevel
  114. && permanent.Level <= 4;
  115. }
  116. IEnumerator ActivateCoroutine(Hashtable hashtable)
  117. {
  118. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  119. selectHandEffect.SetUp(
  120. canTargetCondition: _ => true,
  121. canTargetCondition_ByPreSelecetedList: null,
  122. canEndSelectCondition: null,
  123. canNoSelect: true,
  124. selectCardCoroutine: null,
  125. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  126. maxCount: 1,
  127. canEndNotMax: false,
  128. isShowOpponent: true,
  129. mode: SelectHandEffect.Mode.Discard,
  130. selectPlayer: card.Owner,
  131. cardEffect: activateClass);
  132. selectHandEffect.SetUpCustomMessage("Select 1 card to discard.",
  133. "The opponent is selecting 1 card to discard.");
  134. yield return StartCoroutine(selectHandEffect.Activate());
  135. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  136. {
  137. if (cardSources.Count > 0 && CardEffectCommons.HasMatchConditionPermanent(CanSelectOpponentPermanentCondition))
  138. {
  139. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  140. selectPermanentEffect.SetUp(
  141. selectPlayer: card.Owner,
  142. canTargetCondition: CanSelectOpponentPermanentCondition,
  143. canTargetCondition_ByPreSelecetedList: null,
  144. canEndSelectCondition: null,
  145. maxCount: 1,
  146. canNoSelect: false,
  147. canEndNotMax: false,
  148. selectPermanentCoroutine: null,
  149. afterSelectPermanentCoroutine: null,
  150. mode: SelectPermanentEffect.Mode.Destroy,
  151. cardEffect: activateClass);
  152. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to delete.",
  153. "The opponent is selecting 1 Digimon to delete.");
  154. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  155. }
  156. }
  157. }
  158. }
  159. #endregion
  160. return cardEffects;
  161. }
  162. }
  163. }