BT13_031.cs 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.BT13
  6. {
  7. public class BT13_031 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. if (timing == EffectTiming.WhenPermanentWouldBeDeleted)
  13. {
  14. cardEffects.Add(CardEffectFactory.EvadeSelfEffect(isInheritedEffect: false, card: card, condition: null));
  15. }
  16. if (timing == EffectTiming.OnEnterFieldAnyone)
  17. {
  18. ActivateClass activateClass = new ActivateClass();
  19. activateClass.SetUpICardEffect("Return 1 Tamer to hand", CanUseCondition, card);
  20. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  21. cardEffects.Add(activateClass);
  22. string EffectDiscription()
  23. {
  24. return "[When Digivolving] Return 1 of your opponent's Tamers to the hand.";
  25. }
  26. bool CanSelectPermanentCondition(Permanent permanent)
  27. {
  28. if (permanent != null)
  29. {
  30. if (permanent.TopCard != null)
  31. {
  32. if (permanent.IsTamer)
  33. {
  34. if (permanent.TopCard.Owner == card.Owner.Enemy)
  35. {
  36. if (permanent.TopCard.Owner.GetBattleAreaPermanents().Contains(permanent))
  37. {
  38. return true;
  39. }
  40. }
  41. }
  42. }
  43. }
  44. return false;
  45. }
  46. bool CanUseCondition(Hashtable hashtable)
  47. {
  48. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  49. }
  50. bool CanActivateCondition(Hashtable hashtable)
  51. {
  52. if (isExistOnField(card))
  53. {
  54. if (card.Owner.GetBattleAreaPermanents().Contains(card.PermanentOfThisCard()))
  55. {
  56. if (card.Owner.Enemy.GetBattleAreaPermanents().Count(CanSelectPermanentCondition) >= 1)
  57. {
  58. return true;
  59. }
  60. }
  61. }
  62. return false;
  63. }
  64. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  65. {
  66. if (isExistOnField(card))
  67. {
  68. if (card.Owner.GetBattleAreaDigimons().Contains(card.PermanentOfThisCard()))
  69. {
  70. if (card.Owner.Enemy.GetBattleAreaPermanents().Count(CanSelectPermanentCondition) >= 1)
  71. {
  72. int maxCount = Math.Min(1, card.Owner.Enemy.GetBattleAreaPermanents().Count(CanSelectPermanentCondition));
  73. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  74. selectPermanentEffect.SetUp(
  75. selectPlayer: card.Owner,
  76. canTargetCondition: CanSelectPermanentCondition,
  77. canTargetCondition_ByPreSelecetedList: null,
  78. canEndSelectCondition: null,
  79. maxCount: maxCount,
  80. canNoSelect: false,
  81. canEndNotMax: false,
  82. selectPermanentCoroutine: null,
  83. afterSelectPermanentCoroutine: null,
  84. mode: SelectPermanentEffect.Mode.Bounce,
  85. cardEffect: activateClass);
  86. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  87. }
  88. }
  89. }
  90. }
  91. }
  92. if (timing == EffectTiming.OnAddHand)
  93. {
  94. ActivateClass activateClass = new ActivateClass();
  95. activateClass.SetUpICardEffect("Play 1 [Thomas H. Norstein] from hand", CanUseCondition, card);
  96. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  97. activateClass.SetHashString("Play_BT13_031");
  98. cardEffects.Add(activateClass);
  99. string EffectDiscription()
  100. {
  101. return "[All Turns][Once Per Turn] When an effect adds cards to your opponent's hand, you may play 1 [Thomas H. Norstein] from your hand without paying the cost.";
  102. }
  103. bool CanSelectCardCondition(CardSource cardSource)
  104. {
  105. if (cardSource.CardNames.Contains("Thomas H. Norstein") || cardSource.CardNames.Contains("ThomasH.Norstein"))
  106. {
  107. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  108. {
  109. return true;
  110. }
  111. }
  112. return false;
  113. }
  114. bool CanUseCondition(Hashtable hashtable)
  115. {
  116. if (CardEffectCommons.IsExistOnBattleArea(card))
  117. {
  118. if (CardEffectCommons.CanTriggerWhenAddHand(hashtable, player => player == card.Owner.Enemy, cardEffect => cardEffect != null))
  119. {
  120. return true;
  121. }
  122. }
  123. return false;
  124. }
  125. bool CanActivateCondition(Hashtable hashtable)
  126. {
  127. if (CardEffectCommons.IsExistOnBattleArea(card))
  128. {
  129. if (card.Owner.HandCards.Count >= 1)
  130. {
  131. return true;
  132. }
  133. }
  134. return false;
  135. }
  136. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  137. {
  138. if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  139. {
  140. List<CardSource> selectedCards = new List<CardSource>();
  141. int maxCount = 1;
  142. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  143. selectHandEffect.SetUp(
  144. selectPlayer: card.Owner,
  145. canTargetCondition: CanSelectCardCondition,
  146. canTargetCondition_ByPreSelecetedList: null,
  147. canEndSelectCondition: null,
  148. maxCount: maxCount,
  149. canNoSelect: true,
  150. canEndNotMax: false,
  151. isShowOpponent: true,
  152. selectCardCoroutine: SelectCardCoroutine,
  153. afterSelectCardCoroutine: null,
  154. mode: SelectHandEffect.Mode.Custom,
  155. cardEffect: activateClass);
  156. selectHandEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  157. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  158. yield return StartCoroutine(selectHandEffect.Activate());
  159. IEnumerator SelectCardCoroutine(CardSource cardSource)
  160. {
  161. selectedCards.Add(cardSource);
  162. yield return null;
  163. }
  164. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(cardSources: selectedCards, activateClass: activateClass, payCost: false, isTapped: false, root: SelectCardEffect.Root.Hand, activateETB: true));
  165. }
  166. }
  167. }
  168. return cardEffects;
  169. }
  170. }
  171. }