BT19_072.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. namespace DCGO.CardEffects.BT19
  4. {
  5. public class BT19_072 : CEntity_Effect
  6. {
  7. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  8. {
  9. List<ICardEffect> cardEffects = new List<ICardEffect>();
  10. #region On Play
  11. if (timing == EffectTiming.OnEnterFieldAnyone)
  12. {
  13. ActivateClass activateClass = new ActivateClass();
  14. activateClass.SetUpICardEffect("You may play 1 level 4 or lower Digimon card from your trash.", CanUseCondition, card);
  15. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  16. cardEffects.Add(activateClass);
  17. string EffectDiscription()
  18. {
  19. return "[On Play] You may play 1 level 4 or lower Digimon card from your trash without paying the cost.";
  20. }
  21. bool DigimonToPlay(CardSource source)
  22. {
  23. return CardEffectCommons.CanPlayAsNewPermanent(source, false, activateClass, SelectCardEffect.Root.Trash) &&
  24. source.IsDigimon &&
  25. source.HasLevel && source.Level <= 4;
  26. }
  27. bool CanUseCondition(Hashtable hashtable)
  28. {
  29. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  30. }
  31. bool CanActivateCondition(Hashtable hashtable)
  32. {
  33. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  34. CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, DigimonToPlay);
  35. }
  36. IEnumerator ActivateCoroutine(Hashtable hashtable)
  37. {
  38. List<CardSource> selectedCards = new List<CardSource>();
  39. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  40. selectCardEffect.SetUp(
  41. canTargetCondition: DigimonToPlay,
  42. canTargetCondition_ByPreSelecetedList: null,
  43. canEndSelectCondition: null,
  44. canNoSelect: () => true,
  45. selectCardCoroutine: null,
  46. afterSelectCardCoroutine: SelectCardCoroutine,
  47. message: "Select 1 level 4 or lower Digimon card to play.",
  48. maxCount: 1,
  49. canEndNotMax: false,
  50. isShowOpponent: true,
  51. mode: SelectCardEffect.Mode.Custom,
  52. root: SelectCardEffect.Root.Trash,
  53. customRootCardList: null,
  54. canLookReverseCard: true,
  55. selectPlayer: card.Owner,
  56. cardEffect: activateClass);
  57. selectCardEffect.SetUpCustomMessage(
  58. "Select 1 level 4 or lower Digimon card to play.",
  59. "The opponent is selecting 1 level 4 or lower Digimon card to play.");
  60. selectCardEffect.SetUpCustomMessage_ShowCard("Play Card");
  61. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  62. IEnumerator SelectCardCoroutine(List<CardSource> sources)
  63. {
  64. selectedCards = sources;
  65. yield return null;
  66. }
  67. #region Place As Source
  68. if (selectedCards.Count > 0)
  69. {
  70. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  71. cardSources: selectedCards,
  72. activateClass: activateClass,
  73. payCost: false,
  74. isTapped: false,
  75. root: SelectCardEffect.Root.Trash,
  76. activateETB: true));
  77. }
  78. #endregion
  79. }
  80. }
  81. #endregion
  82. #region When Digivolving
  83. if (timing == EffectTiming.OnEnterFieldAnyone)
  84. {
  85. ActivateClass activateClass = new ActivateClass();
  86. activateClass.SetUpICardEffect("You may play 1 level 4 or lower Digimon card from your trash.", CanUseCondition, card);
  87. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  88. cardEffects.Add(activateClass);
  89. string EffectDiscription()
  90. {
  91. return "[When Digivolving] You may play 1 level 4 or lower Digimon card from your trash without paying the cost.";
  92. }
  93. bool DigimonToPlay(CardSource source)
  94. {
  95. return CardEffectCommons.CanPlayAsNewPermanent(source, false, activateClass, SelectCardEffect.Root.Trash) &&
  96. source.IsDigimon &&
  97. source.HasLevel && source.Level <= 4;
  98. }
  99. bool CanUseCondition(Hashtable hashtable)
  100. {
  101. if(CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  102. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  103. return false;
  104. }
  105. bool CanActivateCondition(Hashtable hashtable)
  106. {
  107. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  108. CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, DigimonToPlay);
  109. }
  110. IEnumerator ActivateCoroutine(Hashtable hashtable)
  111. {
  112. List<CardSource> selectedCards = new List<CardSource>();
  113. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  114. selectCardEffect.SetUp(
  115. canTargetCondition: DigimonToPlay,
  116. canTargetCondition_ByPreSelecetedList: null,
  117. canEndSelectCondition: null,
  118. canNoSelect: () => true,
  119. selectCardCoroutine: null,
  120. afterSelectCardCoroutine: SelectCardCoroutine,
  121. message: "Select 1 level 4 or lower Digimon card to play.",
  122. maxCount: 1,
  123. canEndNotMax: false,
  124. isShowOpponent: true,
  125. mode: SelectCardEffect.Mode.Custom,
  126. root: SelectCardEffect.Root.Trash,
  127. customRootCardList: null,
  128. canLookReverseCard: true,
  129. selectPlayer: card.Owner,
  130. cardEffect: activateClass);
  131. selectCardEffect.SetUpCustomMessage(
  132. "Select 1 level 4 or lower Digimon card to play.",
  133. "The opponent is selecting 1 level 4 or lower Digimon card to play.");
  134. selectCardEffect.SetUpCustomMessage_ShowCard("Play Card");
  135. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  136. IEnumerator SelectCardCoroutine(List<CardSource> sources)
  137. {
  138. selectedCards = sources;
  139. yield return null;
  140. }
  141. #region Place As Source
  142. if (selectedCards.Count > 0)
  143. {
  144. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  145. cardSources: selectedCards,
  146. activateClass: activateClass,
  147. payCost: false,
  148. isTapped: false,
  149. root: SelectCardEffect.Root.Trash,
  150. activateETB: true));
  151. }
  152. #endregion
  153. }
  154. }
  155. #endregion
  156. #region When Opponents Attacks
  157. if (timing == EffectTiming.OnAllyAttack)
  158. {
  159. ActivateClass activateClass = new ActivateClass();
  160. activateClass.SetUpICardEffect("You may change the attack target to 1 of your Digimon with the [Royal Knight] trait.", CanUseCondition, card);
  161. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  162. activateClass.SetHashString("Redirect_BT19-072");
  163. cardEffects.Add(activateClass);
  164. string EffectDiscription()
  165. {
  166. return "[Opponent's Turn] [Once Per Turn] When any of your opponent's Digimon attack, you may change the attack target to 1 of your Digimon with the [Royal Knight] trait.";
  167. }
  168. bool IsOpponentDigimon(Permanent permanent)
  169. {
  170. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  171. }
  172. bool IsRoyalKnight(Permanent permanent)
  173. {
  174. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card) &&
  175. permanent.TopCard.HasRoyalKnightTraits;
  176. }
  177. bool CanUseCondition(Hashtable hashtable)
  178. {
  179. return CardEffectCommons.IsOpponentTurn(card) &&
  180. CardEffectCommons.CanTriggerOnPermanentAttack(hashtable, IsOpponentDigimon);
  181. }
  182. bool CanActivateCondition(Hashtable hashtable)
  183. {
  184. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  185. CardEffectCommons.HasMatchConditionOwnersPermanent(card, IsRoyalKnight);
  186. }
  187. IEnumerator ActivateCoroutine(Hashtable hashtable)
  188. {
  189. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  190. selectPermanentEffect.SetUp(
  191. selectPlayer: card.Owner,
  192. canTargetCondition: IsRoyalKnight,
  193. canTargetCondition_ByPreSelecetedList: null,
  194. canEndSelectCondition: null,
  195. maxCount: 1,
  196. canNoSelect: false,
  197. canEndNotMax: false,
  198. selectPermanentCoroutine: SelectPermanentCoroutine,
  199. afterSelectPermanentCoroutine: null,
  200. mode: SelectPermanentEffect.Mode.Custom,
  201. cardEffect: activateClass);
  202. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to attack.",
  203. "The opponent is selecting 1 Digimon to attack.");
  204. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  205. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  206. {
  207. yield return ContinuousController.instance.StartCoroutine(GManager.instance.attackProcess.SwitchDefender(
  208. activateClass,
  209. false,
  210. permanent));
  211. }
  212. }
  213. }
  214. #endregion
  215. return cardEffects;
  216. }
  217. }
  218. }