BT21_039.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  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. permanent != card.PermanentOfThisCard() &&
  157. card.Owner.HandCards.Where(DigivolveToCardCondition).Any(cardSource =>
  158. cardSource.CanPlayCardTargetFrame(permanent.PermanentFrame, false, activateClass));
  159. }
  160. bool DigivolveToCardCondition(CardSource cardSource)
  161. {
  162. return cardSource.IsDigimon && cardSource.EqualsTraits("WG");
  163. }
  164. bool CanActivateCondition(Hashtable hashtable)
  165. {
  166. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  167. CardEffectCommons.HasMatchConditionPermanent(DigivolveFromPermanentCondition);
  168. }
  169. IEnumerator ActivateCoroutine(Hashtable hashtable)
  170. {
  171. Permanent selectedPermanent = null;
  172. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  173. selectPermanentEffect.SetUp(
  174. selectPlayer: card.Owner,
  175. canTargetCondition: DigivolveFromPermanentCondition,
  176. canTargetCondition_ByPreSelecetedList: null,
  177. canEndSelectCondition: null,
  178. maxCount: 1,
  179. canNoSelect: true,
  180. canEndNotMax: false,
  181. selectPermanentCoroutine: SelectPermanentCoroutine,
  182. afterSelectPermanentCoroutine: null,
  183. mode: SelectPermanentEffect.Mode.Custom,
  184. cardEffect: activateClass);
  185. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will digivolve.",
  186. "The opponent is selecting 1 Digimon that will digivolve.");
  187. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  188. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  189. {
  190. selectedPermanent = permanent;
  191. yield return null;
  192. }
  193. if (selectedPermanent != null)
  194. {
  195. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DigivolveIntoHandOrTrashCard(
  196. targetPermanent: selectedPermanent,
  197. cardCondition: DigivolveToCardCondition,
  198. payCost: false,
  199. reduceCostTuple: null,
  200. fixedCostTuple: null,
  201. ignoreDigivolutionRequirementFixedCost: -1,
  202. isHand: true,
  203. activateClass: activateClass,
  204. successProcess: null));
  205. }
  206. }
  207. }
  208. #endregion
  209. return cardEffects;
  210. }
  211. }
  212. }