BT20_092.cs 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. namespace DCGO.CardEffects.BT20
  5. {
  6. public class BT20_092 : CEntity_Effect
  7. {
  8. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  9. {
  10. List<ICardEffect> cardEffects = new List<ICardEffect>();
  11. #region Start of Turn
  12. if (timing == EffectTiming.OnStartTurn)
  13. {
  14. cardEffects.Add(CardEffectFactory.SetMemoryTo3TamerEffect(card));
  15. }
  16. #endregion
  17. #region On Play
  18. if (timing == EffectTiming.OnEnterFieldAnyone)
  19. {
  20. ActivateClass activateClass = new ActivateClass();
  21. activateClass.SetUpICardEffect("Place 1 card under this Tamer from hand to Draw 1", CanUseCondition, card);
  22. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  23. cardEffects.Add(activateClass);
  24. string EffectDiscription()
  25. {
  26. return "[On Play] By placing 1 level 3 Digimon card from your hand under this Tamer, <Draw 1>.";
  27. }
  28. bool CanSelectCardCondition(CardSource cardSource)
  29. {
  30. if (cardSource.IsDigimon)
  31. {
  32. if (cardSource.HasLevel && cardSource.IsLevel3)
  33. {
  34. return true;
  35. }
  36. }
  37. return false;
  38. }
  39. bool CanUseCondition(Hashtable hashtable)
  40. {
  41. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  42. }
  43. bool CanActivateCondition(Hashtable hashtable)
  44. {
  45. if (CardEffectCommons.IsExistOnBattleArea(card))
  46. {
  47. if (CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectCardCondition))
  48. {
  49. return true;
  50. }
  51. }
  52. return false;
  53. }
  54. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  55. {
  56. bool placed = false;
  57. int maxCount = 1;
  58. List<CardSource> selectedCards = new List<CardSource>();
  59. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  60. selectHandEffect.SetUp(
  61. selectPlayer: card.Owner,
  62. canTargetCondition: CanSelectCardCondition,
  63. canTargetCondition_ByPreSelecetedList: null,
  64. canEndSelectCondition: CanEndSelectCondition,
  65. maxCount: maxCount,
  66. canNoSelect: true,
  67. canEndNotMax: false,
  68. isShowOpponent: true,
  69. selectCardCoroutine: SelectCardCoroutine,
  70. afterSelectCardCoroutine: null,
  71. mode: SelectHandEffect.Mode.Custom,
  72. cardEffect: activateClass);
  73. selectHandEffect.SetUpCustomMessage("Select 1 card to place in Digivolution cards.", "The opponent is selecting 1 card to place in Digivolution cards.");
  74. selectHandEffect.SetNotShowCard();
  75. yield return StartCoroutine(selectHandEffect.Activate());
  76. bool CanEndSelectCondition(List<CardSource> cardSources)
  77. {
  78. if (CardEffectCommons.HasNoElement(cardSources))
  79. {
  80. return false;
  81. }
  82. return true;
  83. }
  84. IEnumerator SelectCardCoroutine(CardSource cardSource)
  85. {
  86. selectedCards.Add(cardSource);
  87. yield return null;
  88. }
  89. if (selectedCards.Count >= 1)
  90. {
  91. if (!card.PermanentOfThisCard().IsToken)
  92. {
  93. yield return ContinuousController.instance.StartCoroutine(card.PermanentOfThisCard().AddDigivolutionCardsBottom(selectedCards, activateClass));
  94. placed = true;
  95. }
  96. }
  97. if (placed)
  98. {
  99. yield return ContinuousController.instance.StartCoroutine(new DrawClass(card.Owner, 1, activateClass).Draw());
  100. }
  101. }
  102. }
  103. #endregion
  104. #region Start of Main
  105. if (timing == EffectTiming.OnStartMainPhase)
  106. {
  107. ActivateClass activateClass = new ActivateClass();
  108. activateClass.SetUpICardEffect("play cost 3 or lower Digimon card from under this Tamer", CanUseCondition, card);
  109. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  110. cardEffects.Add(activateClass);
  111. string EffectDiscription()
  112. {
  113. return "[Start of Your Main Phase] If you don't have a Digimon by playing 1 play cost 3 or lower Digimon card from under this Tamer without paying the cost, delete this Tamer.";
  114. }
  115. bool Is3costDigimon(CardSource source)
  116. {
  117. return source.IsDigimon &&
  118. source.HasPlayCost && source.GetCostItself <= 3 &&
  119. CardEffectCommons.CanPlayAsNewPermanent(source, false,activateClass,SelectCardEffect.Root.DigivolutionCards);
  120. }
  121. bool CanUseCondition(Hashtable hashtable)
  122. {
  123. return CardEffectCommons.IsOwnerTurn(card);
  124. }
  125. bool CanActivateCondition(Hashtable hashtable)
  126. {
  127. return CardEffectCommons.IsExistOnBattleArea(card) &&
  128. card.Owner.GetBattleAreaDigimons().Count == 0 &&
  129. card.PermanentOfThisCard().DigivolutionCards.Count(Is3costDigimon) > 0;
  130. }
  131. IEnumerator ActivateCoroutine(Hashtable hashtable)
  132. {
  133. List<CardSource> selectedDigivolutionCards = new List<CardSource>();
  134. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  135. selectCardEffect.SetUp(
  136. canTargetCondition: Is3costDigimon,
  137. canTargetCondition_ByPreSelecetedList: null,
  138. canEndSelectCondition: null,
  139. canNoSelect: () => false,
  140. selectCardCoroutine: SelectCardCoroutine,
  141. afterSelectCardCoroutine: null,
  142. message: "Select 1 digivolution card.",
  143. maxCount: 1,
  144. canEndNotMax: false,
  145. isShowOpponent: true,
  146. mode: SelectCardEffect.Mode.Custom,
  147. root: SelectCardEffect.Root.Custom,
  148. customRootCardList: card.PermanentOfThisCard().DigivolutionCards,
  149. canLookReverseCard: true,
  150. selectPlayer: card.Owner,
  151. cardEffect: activateClass);
  152. selectCardEffect.SetUpCustomMessage("Select 1 digivolution card.", "The opponent is selecting 1 digivolution card.");
  153. selectCardEffect.SetUpCustomMessage_ShowCard("Digivolution Card");
  154. yield return StartCoroutine(selectCardEffect.Activate());
  155. IEnumerator SelectCardCoroutine(CardSource cardSource)
  156. {
  157. selectedDigivolutionCards.Add(cardSource);
  158. yield return null;
  159. }
  160. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(cardSources: selectedDigivolutionCards, activateClass: activateClass, payCost: false, isTapped: false, root: SelectCardEffect.Root.DigivolutionCards, activateETB: true));
  161. if (selectedDigivolutionCards.Count > 0)
  162. {
  163. Hashtable _hashtable = new Hashtable();
  164. _hashtable.Add("CardEffect", activateClass);
  165. yield return ContinuousController.instance.StartCoroutine(new DestroyPermanentsClass(
  166. new List<Permanent>() { card.PermanentOfThisCard() },
  167. _hashtable).Destroy());
  168. }
  169. }
  170. }
  171. #endregion
  172. #region Security Effect
  173. if (timing == EffectTiming.SecuritySkill)
  174. {
  175. cardEffects.Add(CardEffectFactory.PlaySelfTamerSecurityEffect(card));
  176. }
  177. #endregion
  178. return cardEffects;
  179. }
  180. }
  181. }