BT16_077.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. namespace DCGO.CardEffects.BT16
  4. {
  5. public class BT16_077 : CEntity_Effect
  6. {
  7. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  8. {
  9. List<ICardEffect> cardEffects = new List<ICardEffect>();
  10. List<PartitionCondition> partitionConditions = new List<PartitionCondition>();
  11. partitionConditions.Add(new PartitionCondition(4, CardColor.Purple));
  12. partitionConditions.Add(new PartitionCondition(4, CardColor.Red));
  13. #region DNA Digivolution
  14. if (timing == EffectTiming.None)
  15. {
  16. AddJogressConditionClass addJogressConditionClass = new AddJogressConditionClass();
  17. addJogressConditionClass.SetUpICardEffect($"DNA Digivolution", CanUseCondition, card);
  18. addJogressConditionClass.SetUpAddJogressConditionClass(getJogressCondition: GetJogress);
  19. addJogressConditionClass.SetNotShowUI(true);
  20. cardEffects.Add(addJogressConditionClass);
  21. bool CanUseCondition(Hashtable hashtable)
  22. {
  23. return true;
  24. }
  25. JogressCondition GetJogress(CardSource cardSource)
  26. {
  27. if (cardSource == card)
  28. {
  29. bool PermanentCondition1(Permanent permanent)
  30. {
  31. if (permanent != null)
  32. {
  33. if (permanent.TopCard != null)
  34. {
  35. if (permanent.TopCard.Owner == card.Owner)
  36. {
  37. if (permanent.IsDigimon)
  38. {
  39. if (permanent.TopCard.Owner.GetBattleAreaPermanents().Contains(permanent))
  40. {
  41. if (permanent.TopCard.CardColors.Contains(CardColor.Purple))
  42. {
  43. if (permanent.Levels_ForJogress(card).Contains(4))
  44. {
  45. return true;
  46. }
  47. }
  48. }
  49. }
  50. }
  51. }
  52. }
  53. return false;
  54. }
  55. bool PermanentCondition2(Permanent permanent)
  56. {
  57. if (permanent != null)
  58. {
  59. if (permanent.TopCard != null)
  60. {
  61. if (permanent.TopCard.Owner == card.Owner)
  62. {
  63. if (permanent.IsDigimon)
  64. {
  65. if (permanent.TopCard.Owner.GetBattleAreaPermanents().Contains(permanent))
  66. {
  67. if (permanent.TopCard.CardColors.Contains(CardColor.Red))
  68. {
  69. if (permanent.Levels_ForJogress(card).Contains(4))
  70. {
  71. return true;
  72. }
  73. }
  74. }
  75. }
  76. }
  77. }
  78. }
  79. return false;
  80. }
  81. JogressConditionElement[] elements = new JogressConditionElement[]
  82. {
  83. new JogressConditionElement(PermanentCondition1, "a level 4 purple Digimon"),
  84. new JogressConditionElement(PermanentCondition2, "a level 4 red Digimon"),
  85. };
  86. JogressCondition jogressCondition = new JogressCondition(elements, 0);
  87. return jogressCondition;
  88. }
  89. return null;
  90. }
  91. }
  92. #endregion
  93. #region Raid
  94. if (timing == EffectTiming.OnAllyAttack)
  95. {
  96. cardEffects.Add(CardEffectFactory.RaidSelfEffect(isInheritedEffect: false, card: card, condition: null));
  97. }
  98. #endregion
  99. #region Partition & Partition Inherit
  100. if (timing == EffectTiming.WhenRemoveField)
  101. {
  102. cardEffects.Add(CardEffectFactory.PartitionSelfEffect(
  103. isInheritedEffect: false,
  104. card: card,
  105. condition: null,
  106. cardSourceConditions: partitionConditions)
  107. );
  108. }
  109. if (timing == EffectTiming.WhenRemoveField)
  110. {
  111. cardEffects.Add(CardEffectFactory.PartitionSelfEffect(
  112. isInheritedEffect: true,
  113. card: card,
  114. condition: null,
  115. cardSourceConditions: partitionConditions)
  116. );
  117. }
  118. #endregion
  119. #region When Digivolving
  120. if (timing == EffectTiming.OnEnterFieldAnyone)
  121. {
  122. ActivateClass activateClass = new ActivateClass();
  123. activateClass.SetUpICardEffect(
  124. "You may play 1 level 5 or lower Digimon with the [Free] trait. Then 1 Digimon can gain [Rush] and attack.",
  125. CanUseCondition, card);
  126. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDescription());
  127. cardEffects.Add(activateClass);
  128. string EffectDescription()
  129. {
  130. return
  131. "[When Digivolving] If DNA digivolving, you may play 1 level 5 or lower Digimon with the [Free] trait from your trash without paying the cost. Then, 1 of your Digimon may gain [Rush] for the turn and attack the player.";
  132. }
  133. bool CanUseCondition(Hashtable hashtable)
  134. {
  135. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  136. }
  137. bool CanSelectCardCondition(CardSource cardSource)
  138. {
  139. return cardSource.HasLevel && cardSource.Level <= 5 && cardSource.ContainsTraits("Free") &&
  140. CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass);
  141. }
  142. bool CanSelectPermanentCondition(Permanent permanent)
  143. {
  144. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card);
  145. }
  146. bool CanActivateCondition(Hashtable hashtable)
  147. {
  148. return CardEffectCommons.IsExistOnBattleArea(card);
  149. }
  150. IEnumerator ActivateCoroutine(Hashtable hashtable)
  151. {
  152. if (CardEffectCommons.IsJogress(hashtable) &&
  153. CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  154. {
  155. List<CardSource> selectedCards = new List<CardSource>();
  156. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  157. selectCardEffect.SetUp(
  158. canTargetCondition: CanSelectCardCondition,
  159. canTargetCondition_ByPreSelecetedList: null,
  160. canEndSelectCondition: null,
  161. canNoSelect: () => true,
  162. selectCardCoroutine: SelectCardCoroutine,
  163. afterSelectCardCoroutine: null,
  164. message: "Select cards to play.",
  165. maxCount: 1,
  166. canEndNotMax: false,
  167. isShowOpponent: true,
  168. mode: SelectCardEffect.Mode.Custom,
  169. root: SelectCardEffect.Root.Trash,
  170. customRootCardList: null,
  171. canLookReverseCard: true,
  172. selectPlayer: card.Owner,
  173. cardEffect: activateClass);
  174. selectCardEffect.SetUpCustomMessage("Select 1 trash card to play.",
  175. "The opponent is selecting 1 trash card to play.");
  176. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  177. IEnumerator SelectCardCoroutine(CardSource cardSource)
  178. {
  179. selectedCards.Add(cardSource);
  180. yield return null;
  181. }
  182. yield return StartCoroutine(selectCardEffect.Activate());
  183. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  184. cardSources: selectedCards,
  185. activateClass: activateClass,
  186. payCost: false,
  187. isTapped: false,
  188. root: SelectCardEffect.Root.Trash,
  189. activateETB: true));
  190. }
  191. Permanent selectedPermanent = null;
  192. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  193. {
  194. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  195. selectPermanentEffect.SetUp(
  196. selectPlayer: card.Owner,
  197. canTargetCondition: CanSelectPermanentCondition,
  198. canTargetCondition_ByPreSelecetedList: null,
  199. canEndSelectCondition: null,
  200. maxCount: 1,
  201. canNoSelect: true,
  202. canEndNotMax: false,
  203. selectPermanentCoroutine: SelectPermanentCoroutine,
  204. afterSelectPermanentCoroutine: null,
  205. mode: SelectPermanentEffect.Mode.Custom,
  206. cardEffect: activateClass);
  207. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will gain Rush and attack a player.",
  208. "The opponent is selecting 1 Digimon that will gain Rush and attack a player.");
  209. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  210. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  211. {
  212. selectedPermanent = permanent;
  213. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainRush(
  214. targetPermanent: permanent,
  215. effectDuration: EffectDuration.UntilEachTurnEnd,
  216. activateClass: activateClass));
  217. }
  218. if (selectedPermanent != null)
  219. {
  220. if (selectedPermanent.CanAttack(activateClass))
  221. {
  222. SelectAttackEffect selectAttackEffect = GManager.instance.GetComponent<SelectAttackEffect>();
  223. selectAttackEffect.SetUp(
  224. attacker: selectedPermanent,
  225. canAttackPlayerCondition: () => true,
  226. defenderCondition: _ => false,
  227. cardEffect: activateClass);
  228. selectAttackEffect.SetCanNotSelectNotAttack();
  229. yield return ContinuousController.instance.StartCoroutine(selectAttackEffect.Activate());
  230. }
  231. }
  232. }
  233. }
  234. }
  235. #endregion
  236. return cardEffects;
  237. }
  238. }
  239. }