BT17_039.cs 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.BT17
  6. {
  7. public class BT17_039 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region When Digivolving
  13. if (timing == EffectTiming.OnEnterFieldAnyone)
  14. {
  15. ActivateClass activateClass = new ActivateClass();
  16. activateClass.SetUpICardEffect("Play 1 [Marcus Damon] from hand", CanUseCondition, card);
  17. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  18. cardEffects.Add(activateClass);
  19. string EffectDiscription()
  20. {
  21. return "[When Digivolving] You may play 1 [Marcus Damon] from your hand without paying the cost.";
  22. }
  23. bool CanSelectCardCondition(CardSource cardSource)
  24. {
  25. if (cardSource.CardNames.Contains("Marcus Damon") || cardSource.CardNames.Contains("MarcusDamon"))
  26. {
  27. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  28. {
  29. return true;
  30. }
  31. }
  32. return false;
  33. }
  34. bool CanUseCondition(Hashtable hashtable)
  35. {
  36. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  37. }
  38. bool CanActivateCondition(Hashtable hashtable)
  39. {
  40. if (CardEffectCommons.IsExistOnBattleArea(card))
  41. {
  42. if (card.Owner.HandCards.Count >= 1)
  43. {
  44. return true;
  45. }
  46. }
  47. return false;
  48. }
  49. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  50. {
  51. if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  52. {
  53. List<CardSource> selectedCards = new List<CardSource>();
  54. int maxCount = 1;
  55. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  56. selectHandEffect.SetUp(
  57. selectPlayer: card.Owner,
  58. canTargetCondition: CanSelectCardCondition,
  59. canTargetCondition_ByPreSelecetedList: null,
  60. canEndSelectCondition: null,
  61. maxCount: maxCount,
  62. canNoSelect: true,
  63. canEndNotMax: false,
  64. isShowOpponent: true,
  65. selectCardCoroutine: SelectCardCoroutine,
  66. afterSelectCardCoroutine: null,
  67. mode: SelectHandEffect.Mode.Custom,
  68. cardEffect: activateClass);
  69. selectHandEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  70. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  71. yield return StartCoroutine(selectHandEffect.Activate());
  72. IEnumerator SelectCardCoroutine(CardSource cardSource)
  73. {
  74. selectedCards.Add(cardSource);
  75. yield return null;
  76. }
  77. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(cardSources: selectedCards, activateClass: activateClass, payCost: false, isTapped: false, root: SelectCardEffect.Root.Hand, activateETB: true));
  78. }
  79. }
  80. }
  81. #endregion
  82. #region All Turns
  83. if (timing == EffectTiming.WhenRemoveField)
  84. {
  85. ActivateClass activateClass = new ActivateClass();
  86. activateClass.SetUpICardEffect("Return 1 Tamer to hand to prevent this Digimon from leaving Battle Area", CanUseCondition, card);
  87. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  88. activateClass.SetHashString("Protection_BT17_039");
  89. cardEffects.Add(activateClass);
  90. string EffectDiscription()
  91. {
  92. return "[All Turns] When this Digimon would leave the battle area by an opponent's effect, by returning 1 of your yellow Tamers to the hand, prevent it from leaving.";
  93. }
  94. bool CanUseCondition(Hashtable hashtable)
  95. {
  96. if (CardEffectCommons.IsExistOnBattleArea(card))
  97. {
  98. if (CardEffectCommons.CanTriggerWhenRemoveField(hashtable, card))
  99. {
  100. if (CardEffectCommons.IsByEffect(hashtable, cardEffect => CardEffectCommons.IsOpponentEffect(cardEffect, card)))
  101. {
  102. return true;
  103. }
  104. }
  105. }
  106. return false;
  107. }
  108. bool CanSelectPermanentCondition(Permanent permanent)
  109. {
  110. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card))
  111. {
  112. if (permanent.TopCard.IsTamer && permanent.TopCard.CardColors.Contains(CardColor.Yellow))
  113. {
  114. return true;
  115. }
  116. }
  117. return false;
  118. }
  119. bool CanActivateCondition(Hashtable hashtable)
  120. {
  121. if (CardEffectCommons.IsExistOnBattleArea(card))
  122. {
  123. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  124. {
  125. return true;
  126. }
  127. }
  128. return false;
  129. }
  130. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  131. {
  132. if (CardEffectCommons.IsExistOnBattleArea(card))
  133. {
  134. Permanent thisCardPermanent = card.PermanentOfThisCard();
  135. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  136. {
  137. Permanent bounceTargetPermanent = null;
  138. int maxCount = Math.Min(1, card.Owner.GetBattleAreaPermanents().Count(CanSelectPermanentCondition));
  139. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  140. selectPermanentEffect.SetUp(
  141. selectPlayer: card.Owner,
  142. canTargetCondition: CanSelectPermanentCondition,
  143. canTargetCondition_ByPreSelecetedList: null,
  144. canEndSelectCondition: null,
  145. maxCount: maxCount,
  146. canNoSelect: true,
  147. canEndNotMax: false,
  148. selectPermanentCoroutine: SelectPermanentCoroutine,
  149. afterSelectPermanentCoroutine: null,
  150. mode: SelectPermanentEffect.Mode.Custom,
  151. cardEffect: activateClass);
  152. selectPermanentEffect.SetUpCustomMessage("Select 1 Yellow Tamer to return to hand.", "The opponent is selecting 1 Tamer to return to hand.");
  153. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  154. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  155. {
  156. bounceTargetPermanent = permanent;
  157. yield return null;
  158. }
  159. if (bounceTargetPermanent != null)
  160. {
  161. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.BouncePeremanentAndProcessAccordingToResult(
  162. targetPermanents: new List<Permanent>() { bounceTargetPermanent },
  163. activateClass: activateClass,
  164. successProcess: SuccessProcess(),
  165. failureProcess: null));
  166. IEnumerator SuccessProcess()
  167. {
  168. Permanent thisCardPermanent = card.PermanentOfThisCard();
  169. thisCardPermanent.willBeRemoveField = false;
  170. thisCardPermanent.HideDeleteEffect();
  171. thisCardPermanent.HideHandBounceEffect();
  172. thisCardPermanent.HideDeckBounceEffect();
  173. thisCardPermanent.HideWillRemoveFieldEffect();
  174. yield return null;
  175. }
  176. }
  177. }
  178. }
  179. }
  180. }
  181. #endregion
  182. return cardEffects;
  183. }
  184. }
  185. }