BT24_070.cs 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. // Growlmon
  6. namespace DCGO.CardEffects.BT24
  7. {
  8. public class BT24_070 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region Shared OP/WD
  14. string SharedEffectName() => "Play 1 lvl 4 purple tamer from trash.";
  15. string SharedEffectDescription(string tag) => $"[{tag}] If you have 4 or fewer cards in your hand, you may play 1 purple Tamer card with a play cost of 4 or less from your trash without paying the cost.";
  16. bool SharedCanActivateCondition(Hashtable hashtable)
  17. {
  18. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  19. && card.Owner.HandCards.Count <= 4;
  20. }
  21. bool CanSelectCardCondition(CardSource cardSource, ActivateClass activateClass)
  22. {
  23. return cardSource.IsTamer
  24. && cardSource.GetCostItself <= 4
  25. && cardSource.HasCardColor(CardColor.Purple)
  26. && CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass);
  27. }
  28. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  29. {
  30. List<CardSource> selectedCards = new List<CardSource>();
  31. int maxCount = Math.Min(1, card.Owner.TrashCards.Count((cardSource) => CanSelectCardCondition(cardSource, activateClass)));
  32. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  33. selectCardEffect.SetUp(
  34. canTargetCondition: (cardSource) => CanSelectCardCondition(cardSource, activateClass),
  35. canTargetCondition_ByPreSelecetedList: null,
  36. canEndSelectCondition: null,
  37. canNoSelect: () => true,
  38. selectCardCoroutine: SelectCardCoroutine,
  39. afterSelectCardCoroutine: null,
  40. message: "Select 1 card to play.",
  41. maxCount: maxCount,
  42. canEndNotMax: false,
  43. isShowOpponent: true,
  44. mode: SelectCardEffect.Mode.Custom,
  45. root: SelectCardEffect.Root.Trash,
  46. customRootCardList: null,
  47. canLookReverseCard: true,
  48. selectPlayer: card.Owner,
  49. cardEffect: activateClass);
  50. selectCardEffect.SetUpCustomMessage("Select 1 purple Tamer with a play cost of 4 or less to play.", "The opponent is selecting 1 card to play.");
  51. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  52. yield return StartCoroutine(selectCardEffect.Activate());
  53. IEnumerator SelectCardCoroutine(CardSource cardSource)
  54. {
  55. selectedCards.Add(cardSource);
  56. yield return null;
  57. }
  58. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(cardSources: selectedCards, activateClass: activateClass, payCost: false, isTapped: false, root: SelectCardEffect.Root.Trash, activateETB: true));
  59. }
  60. #endregion
  61. #region On Play
  62. if (timing == EffectTiming.OnEnterFieldAnyone)
  63. {
  64. ActivateClass activateClass = new ActivateClass();
  65. activateClass.SetUpICardEffect(SharedEffectName(), CanUseCondition, card);
  66. activateClass.SetUpActivateClass(SharedCanActivateCondition, hash => SharedActivateCoroutine(hash, activateClass), -1, false, SharedEffectDescription("On Play"));
  67. cardEffects.Add(activateClass);
  68. bool CanUseCondition(Hashtable hashtable)
  69. {
  70. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  71. && CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  72. }
  73. }
  74. #endregion
  75. #region When Digivolving
  76. if (timing == EffectTiming.OnEnterFieldAnyone)
  77. {
  78. ActivateClass activateClass = new ActivateClass();
  79. activateClass.SetUpICardEffect(SharedEffectName(), CanUseCondition, card);
  80. activateClass.SetUpActivateClass(SharedCanActivateCondition, hash => SharedActivateCoroutine(hash, activateClass), -1, false, SharedEffectDescription("When Digivolving"));
  81. cardEffects.Add(activateClass);
  82. bool CanUseCondition(Hashtable hashtable)
  83. {
  84. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  85. && CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  86. }
  87. }
  88. #endregion
  89. #region When Attacking - ESS
  90. if (timing == EffectTiming.OnAllyAttack)
  91. {
  92. ActivateClass activateClass = new ActivateClass();
  93. activateClass.SetUpICardEffect("Delete opponents level 3 Digimon", CanUseCondition, card);
  94. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDescription());
  95. activateClass.SetIsInheritedEffect(true);
  96. activateClass.SetHashString("BT24_070_Inherited");
  97. cardEffects.Add(activateClass);
  98. string EffectDescription()
  99. {
  100. return "[When Attacking] [Once Per Turn] Delete 1 of your opponent's level 3 Digimon.";
  101. }
  102. bool SelectOpponentsLevel3Digimon(Permanent permanent)
  103. {
  104. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card)
  105. && permanent.TopCard.IsLevel3;
  106. }
  107. bool CanUseCondition(Hashtable hashtable)
  108. {
  109. return CardEffectCommons.CanTriggerOnAttack(hashtable, card)
  110. && CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  111. }
  112. bool CanActivateCondition(Hashtable hashtable)
  113. {
  114. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  115. }
  116. IEnumerator ActivateCoroutine(Hashtable hashtable)
  117. {
  118. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(SelectOpponentsLevel3Digimon));
  119. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  120. selectPermanentEffect.SetUp(
  121. selectPlayer: card.Owner,
  122. canTargetCondition: SelectOpponentsLevel3Digimon,
  123. canTargetCondition_ByPreSelecetedList: null,
  124. canEndSelectCondition: null,
  125. maxCount: maxCount,
  126. canNoSelect: false,
  127. canEndNotMax: false,
  128. selectPermanentCoroutine: null,
  129. afterSelectPermanentCoroutine: null,
  130. mode: SelectPermanentEffect.Mode.Destroy,
  131. cardEffect: activateClass);
  132. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  133. }
  134. }
  135. #endregion
  136. return cardEffects;
  137. }
  138. }
  139. }