BT21_039.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. namespace DCGO.CardEffects.BT21
  5. {
  6. public class BT21_039 : CEntity_Effect
  7. {
  8. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  9. {
  10. List<ICardEffect> cardEffects = new List<ICardEffect>();
  11. #region Alternate Digivolution
  12. if (timing == EffectTiming.None)
  13. {
  14. bool PermanentCondition(Permanent targetPermanent)
  15. {
  16. return targetPermanent.TopCard.IsLevel5 && targetPermanent.TopCard.EqualsTraits("WG");
  17. }
  18. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  19. permanentCondition: PermanentCondition,
  20. digivolutionCost: 3,
  21. ignoreDigivolutionRequirement: false,
  22. card: card,
  23. condition: null));
  24. }
  25. #endregion
  26. #region DNA Digivolution
  27. if (timing == EffectTiming.None)
  28. {
  29. AddJogressConditionClass addJogressConditionClass = new AddJogressConditionClass();
  30. addJogressConditionClass.SetUpICardEffect($"DNA Digivolution", CanUseCondition, card);
  31. addJogressConditionClass.SetUpAddJogressConditionClass(getJogressCondition: GetJogress);
  32. addJogressConditionClass.SetNotShowUI(true);
  33. cardEffects.Add(addJogressConditionClass);
  34. bool CanUseCondition(Hashtable hashtable)
  35. {
  36. return true;
  37. }
  38. JogressCondition GetJogress(CardSource cardSource)
  39. {
  40. if (cardSource == card)
  41. {
  42. bool PermanentConditionA(Permanent permanent)
  43. {
  44. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card) &&
  45. (permanent.TopCard.CardColors.Contains(CardColor.Blue) ||
  46. permanent.TopCard.CardColors.Contains(CardColor.Yellow)) &&
  47. permanent.Levels_ForJogress(card).Contains(5);
  48. }
  49. bool PermanentConditionB(Permanent permanent)
  50. {
  51. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card) &&
  52. (permanent.TopCard.CardColors.Contains(CardColor.Green) ||
  53. permanent.TopCard.CardColors.Contains(CardColor.Red)) &&
  54. permanent.Levels_ForJogress(card).Contains(5);
  55. }
  56. JogressConditionElement[] elements =
  57. {
  58. new(PermanentConditionA, "a level 5 Blue or Yellow Digimon"),
  59. new(PermanentConditionB, "a level 5 Green or Red Digimon")
  60. };
  61. JogressCondition jogressCondition = new JogressCondition(elements, 0);
  62. return jogressCondition;
  63. }
  64. return null;
  65. }
  66. }
  67. #endregion
  68. #region Alliance
  69. if (timing == EffectTiming.OnAllyAttack)
  70. {
  71. cardEffects.Add(CardEffectFactory.AllianceSelfEffect(
  72. isInheritedEffect: false,
  73. card: card,
  74. condition: null));
  75. }
  76. #endregion
  77. #region When Digivolving
  78. if (timing == EffectTiming.OnEnterFieldAnyone)
  79. {
  80. ActivateClass activateClass = new ActivateClass();
  81. activateClass.SetUpICardEffect("You may play 1 level 4 or lower Digimon card from your hand.", CanUseCondition, card);
  82. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDescription());
  83. cardEffects.Add(activateClass);
  84. string EffectDescription()
  85. {
  86. return
  87. "[When Digivolving] You may play 1 level 4 or lower Digimon card with the [WG] trait from your hand without paying the cost.";
  88. }
  89. bool CanUseCondition(Hashtable hashtable)
  90. {
  91. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  92. }
  93. bool CanSelectDigimonCardCondition(CardSource source)
  94. {
  95. return source.IsDigimon &&
  96. source.HasLevel && source.Level <= 4 &&
  97. source.EqualsTraits("WG") &&
  98. CardEffectCommons.CanPlayAsNewPermanent(source, false, activateClass);
  99. }
  100. bool CanActivateCondition(Hashtable hashtable)
  101. {
  102. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  103. CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectDigimonCardCondition);
  104. }
  105. IEnumerator ActivateCoroutine(Hashtable hashtable)
  106. {
  107. List<CardSource> selectedCards = new List<CardSource>();
  108. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  109. selectHandEffect.SetUp(
  110. selectPlayer: card.Owner,
  111. canTargetCondition: CanSelectDigimonCardCondition,
  112. canTargetCondition_ByPreSelecetedList: null,
  113. canEndSelectCondition: null,
  114. maxCount: 1,
  115. canNoSelect: true,
  116. canEndNotMax: false,
  117. isShowOpponent: true,
  118. selectCardCoroutine: SelectCardCoroutine,
  119. afterSelectCardCoroutine: null,
  120. mode: SelectHandEffect.Mode.Custom,
  121. cardEffect: activateClass);
  122. selectHandEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  123. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  124. yield return StartCoroutine(selectHandEffect.Activate());
  125. IEnumerator SelectCardCoroutine(CardSource cardSource)
  126. {
  127. selectedCards.Add(cardSource);
  128. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  129. cardSources: selectedCards, activateClass: activateClass, payCost: false, isTapped: false,
  130. root: SelectCardEffect.Root.Hand, activateETB: true));
  131. }
  132. }
  133. }
  134. #endregion
  135. #region When Attacking
  136. if (timing == EffectTiming.OnAllyAttack)
  137. {
  138. ActivateClass activateClass = new ActivateClass();
  139. activateClass.SetUpICardEffect("1 of your other Digimon digivolves without paying the cost", CanUseCondition, card);
  140. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDescription());
  141. activateClass.SetHashString("WA_BT21-039");
  142. cardEffects.Add(activateClass);
  143. string EffectDescription()
  144. {
  145. return
  146. "[When Attacking] (Once Per Turn) 1 of your other Digimon may digivolve into a Digimon card with the [WG] trait in the hand without paying the cost.";
  147. }
  148. bool CanUseCondition(Hashtable hashtable)
  149. {
  150. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  151. }
  152. bool DigivolveFromPermanentCondition(Permanent permanent)
  153. {
  154. return CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card) &&
  155. permanent.IsDigimon &&
  156. card.Owner.HandCards.Where(DigivolveToCardCondition).Any(cardSource =>
  157. cardSource.CanPlayCardTargetFrame(permanent.PermanentFrame, false, activateClass));
  158. }
  159. bool DigivolveToCardCondition(CardSource cardSource)
  160. {
  161. return cardSource.IsDigimon && cardSource.EqualsTraits("WG");
  162. }
  163. bool CanActivateCondition(Hashtable hashtable)
  164. {
  165. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  166. CardEffectCommons.HasMatchConditionPermanent(DigivolveFromPermanentCondition);
  167. }
  168. IEnumerator ActivateCoroutine(Hashtable hashtable)
  169. {
  170. Permanent selectedPermanent = null;
  171. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  172. selectPermanentEffect.SetUp(
  173. selectPlayer: card.Owner,
  174. canTargetCondition: DigivolveFromPermanentCondition,
  175. canTargetCondition_ByPreSelecetedList: null,
  176. canEndSelectCondition: null,
  177. maxCount: 1,
  178. canNoSelect: true,
  179. canEndNotMax: false,
  180. selectPermanentCoroutine: SelectPermanentCoroutine,
  181. afterSelectPermanentCoroutine: null,
  182. mode: SelectPermanentEffect.Mode.Custom,
  183. cardEffect: activateClass);
  184. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will digivolve.",
  185. "The opponent is selecting 1 Digimon that will digivolve.");
  186. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  187. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  188. {
  189. selectedPermanent = permanent;
  190. yield return null;
  191. }
  192. if (selectedPermanent != null)
  193. {
  194. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DigivolveIntoHandOrTrashCard(
  195. targetPermanent: selectedPermanent,
  196. cardCondition: DigivolveToCardCondition,
  197. payCost: false,
  198. reduceCostTuple: null,
  199. fixedCostTuple: null,
  200. ignoreDigivolutionRequirementFixedCost: -1,
  201. isHand: true,
  202. activateClass: activateClass,
  203. successProcess: null));
  204. }
  205. }
  206. }
  207. #endregion
  208. return cardEffects;
  209. }
  210. }
  211. }