BT10_048.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using System.Linq;
  5. using Photon;
  6. using System;
  7. using Photon.Pun;
  8. namespace DCGO.CardEffects.BT10
  9. {
  10. public class BT10_048 : CEntity_Effect
  11. {
  12. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  13. {
  14. List<ICardEffect> cardEffects = new List<ICardEffect>();
  15. if (timing == EffectTiming.OnEnterFieldAnyone)
  16. {
  17. ActivateClass activateClass = new ActivateClass();
  18. activateClass.SetUpICardEffect("Suspend your Digimon to play a Digimon from hand", CanUseCondition, card);
  19. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  20. cardEffects.Add(activateClass);
  21. string EffectDiscription()
  22. {
  23. return "[When Digivolving] By suspending 1 of your green Digimon, you may play 1 Digimon card with [Vegetation], [Plant] or [Fairy] in its traits and 3000 DP or less from your hand without paying its memory cost.";
  24. }
  25. bool CanSelectPermanentCondition(Permanent permanent)
  26. {
  27. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  28. {
  29. if (permanent.TopCard.CardColors.Contains(CardColor.Green))
  30. {
  31. if (CardEffectCommons.CanActivateSuspendCostEffect(permanent.TopCard))
  32. {
  33. return true;
  34. }
  35. }
  36. }
  37. return false;
  38. }
  39. bool CanSelectCardCondition(CardSource cardSource)
  40. {
  41. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  42. {
  43. if (cardSource.CardDP <= 3000)
  44. {
  45. if (cardSource.IsDigimon)
  46. {
  47. if (cardSource.HasPlantTraits)
  48. {
  49. return true;
  50. }
  51. if (cardSource.HasFairyTraits)
  52. {
  53. return true;
  54. }
  55. }
  56. }
  57. }
  58. return false;
  59. }
  60. bool CanUseCondition(Hashtable hashtable)
  61. {
  62. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  63. }
  64. bool CanActivateCondition(Hashtable hashtable)
  65. {
  66. if (CardEffectCommons.IsExistOnBattleArea(card))
  67. {
  68. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  69. {
  70. return true;
  71. }
  72. }
  73. return false;
  74. }
  75. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  76. {
  77. Permanent selectedPermanent = null;
  78. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  79. {
  80. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  81. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  82. selectPermanentEffect.SetUp(
  83. selectPlayer: card.Owner,
  84. canTargetCondition: CanSelectPermanentCondition,
  85. canTargetCondition_ByPreSelecetedList: null,
  86. canEndSelectCondition: null,
  87. maxCount: maxCount,
  88. canNoSelect: true,
  89. canEndNotMax: false,
  90. selectPermanentCoroutine: SelectPermanentCoroutine,
  91. afterSelectPermanentCoroutine: null,
  92. mode: SelectPermanentEffect.Mode.Custom,
  93. cardEffect: activateClass);
  94. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to suspend.", "The opponent is selecting 1 Digimon to suspend.");
  95. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  96. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  97. {
  98. selectedPermanent = permanent;
  99. yield return null;
  100. }
  101. }
  102. if (selectedPermanent != null)
  103. {
  104. if (selectedPermanent.TopCard != null)
  105. {
  106. if (!selectedPermanent.TopCard.CanNotBeAffected(activateClass))
  107. {
  108. if (!selectedPermanent.IsSuspended && selectedPermanent.CanSuspend)
  109. {
  110. Permanent suspendTargetPermanent = selectedPermanent;
  111. yield return ContinuousController.instance.StartCoroutine(new SuspendPermanentsClass(new List<Permanent>() { suspendTargetPermanent }, CardEffectCommons.CardEffectHashtable(activateClass)).Tap());
  112. if (suspendTargetPermanent.TopCard != null)
  113. {
  114. if (suspendTargetPermanent.IsSuspended)
  115. {
  116. if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  117. {
  118. List<CardSource> selectedCards = new List<CardSource>();
  119. int maxCount = 1;
  120. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  121. selectHandEffect.SetUp(
  122. selectPlayer: card.Owner,
  123. canTargetCondition: CanSelectCardCondition,
  124. canTargetCondition_ByPreSelecetedList: null,
  125. canEndSelectCondition: null,
  126. maxCount: maxCount,
  127. canNoSelect: true,
  128. canEndNotMax: false,
  129. isShowOpponent: true,
  130. selectCardCoroutine: SelectCardCoroutine,
  131. afterSelectCardCoroutine: null,
  132. mode: SelectHandEffect.Mode.Custom,
  133. cardEffect: activateClass);
  134. selectHandEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  135. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  136. yield return StartCoroutine(selectHandEffect.Activate());
  137. IEnumerator SelectCardCoroutine(CardSource cardSource)
  138. {
  139. selectedCards.Add(cardSource);
  140. yield return null;
  141. }
  142. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  143. cardSources: selectedCards,
  144. activateClass: activateClass,
  145. payCost: false,
  146. isTapped: false,
  147. root: SelectCardEffect.Root.Hand,
  148. activateETB: true));
  149. }
  150. }
  151. }
  152. }
  153. }
  154. }
  155. }
  156. }
  157. }
  158. if (timing == EffectTiming.OnTappedAnyone)
  159. {
  160. ActivateClass activateClass = new ActivateClass();
  161. activateClass.SetUpICardEffect("Draw 1", CanUseCondition, card);
  162. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDiscription());
  163. activateClass.SetIsInheritedEffect(true);
  164. activateClass.SetHashString("Draw1_BT10_047");
  165. cardEffects.Add(activateClass);
  166. string EffectDiscription()
  167. {
  168. return "[Your Turn][Once Per Turn] When an effect suspends one of your Digimon, <Draw 1>. (Draw 1 card from your deck.)";
  169. }
  170. bool PermanentCondition(Permanent permanent)
  171. {
  172. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card);
  173. }
  174. bool CanUseCondition(Hashtable hashtable)
  175. {
  176. if (CardEffectCommons.IsExistOnBattleArea(card))
  177. {
  178. if (CardEffectCommons.IsOwnerTurn(card))
  179. {
  180. if (CardEffectCommons.CanTriggerWhenPermanentSuspends(hashtable, PermanentCondition))
  181. {
  182. if (CardEffectCommons.IsByEffect(hashtable, null))
  183. {
  184. return true;
  185. }
  186. }
  187. }
  188. }
  189. return false;
  190. }
  191. bool CanActivateCondition(Hashtable hashtable)
  192. {
  193. if (CardEffectCommons.IsExistOnBattleArea(card))
  194. {
  195. return true;
  196. }
  197. return false;
  198. }
  199. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  200. {
  201. yield return ContinuousController.instance.StartCoroutine(new DrawClass(card.Owner, 1, activateClass).Draw());
  202. }
  203. }
  204. return cardEffects;
  205. }
  206. }
  207. }