Dinobeemon_BT16_077.cs 13 KB

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