EX8_027.cs 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. // Plesiomon
  4. namespace DCGO.CardEffects.EX8
  5. {
  6. public class EX8_027 : 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 Requirement
  12. if (timing == EffectTiming.None)
  13. {
  14. static bool PermanentCondition(Permanent targetPermanent)
  15. {
  16. return targetPermanent.TopCard.EqualsTraits("DS");
  17. }
  18. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 3, ignoreDigivolutionRequirement: false, card: card, condition: null, level: 5));
  19. }
  20. #endregion
  21. #region When Digivolving
  22. if (timing == EffectTiming.OnEnterFieldAnyone)
  23. {
  24. ActivateClass activateClass = new ActivateClass();
  25. activateClass.SetUpICardEffect("Play 1 digivolution card", CanUseCondition, card);
  26. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription());
  27. activateClass.SetIsSkippable(true);
  28. cardEffects.Add(activateClass);
  29. string EffectDescription()
  30. {
  31. return "[When Digivolving] You may play 1 level 4 or lower Digimon card from this Digimon's digivolution cards without paying the cost.";
  32. }
  33. bool CanSelectCardCondition(CardSource cardSource)
  34. {
  35. return cardSource.IsDigimon
  36. && cardSource.HasLevel
  37. && cardSource.Level <= 4
  38. && CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass);
  39. }
  40. bool CanUseCondition(Hashtable hashtable)
  41. {
  42. return CardEffectCommons.IsExistOnBattleAreaTrigger(card, activateClass)
  43. && CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  44. }
  45. bool CanActivateCondition(Hashtable hashtable)
  46. {
  47. return CardEffectCommons.IsExistOnBattleAreaActivate(card, activateClass)
  48. && card.PermanentOfThisCard().DigivolutionCards.Some(CanSelectCardCondition);
  49. }
  50. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  51. {
  52. List<CardSource> selectedCards = new List<CardSource>();
  53. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  54. selectCardEffect.SetUp(
  55. canTargetCondition: CanSelectCardCondition,
  56. canTargetCondition_ByPreSelecetedList: null,
  57. canEndSelectCondition: null,
  58. canNoSelect: () => true,
  59. selectCardCoroutine: SelectCardCoroutine,
  60. afterSelectCardCoroutine: null,
  61. message: "Select 1 digivolution card to play.",
  62. maxCount: 1,
  63. canEndNotMax: false,
  64. isShowOpponent: true,
  65. mode: SelectCardEffect.Mode.Custom,
  66. root: SelectCardEffect.Root.DigivolutionCards,
  67. customRootCardList: card.PermanentOfThisCard().DigivolutionCards,
  68. canLookReverseCard: true,
  69. selectPlayer: card.Owner,
  70. cardEffect: activateClass);
  71. selectCardEffect.SetUpCustomMessage("Select 1 digivolution card to play.", "The opponent is selecting 1 digivolution card to play.");
  72. yield return StartCoroutine(selectCardEffect.Activate());
  73. IEnumerator SelectCardCoroutine(CardSource cardSource)
  74. {
  75. selectedCards.Add(cardSource);
  76. yield return null;
  77. }
  78. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  79. cardSources: selectedCards,
  80. activateClass: activateClass,
  81. payCost: false,
  82. isTapped: false,
  83. root: SelectCardEffect.Root.DigivolutionCards,
  84. activateETB: true));
  85. }
  86. }
  87. #endregion
  88. #region Your Turn
  89. if (timing == EffectTiming.OnEnterFieldAnyone)
  90. {
  91. ActivateClass activateClass = new ActivateClass();
  92. activateClass.SetUpICardEffect("DNA Digivolve into [DS] trait, then attack", CanUseCondition, card);
  93. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDescription());
  94. activateClass.SetHashString("DNA_EX8-027");
  95. cardEffects.Add(activateClass);
  96. string EffectDescription()
  97. {
  98. return "[Your Turn] [Once Per Turn] When any of your Digimon are played or digivolve, if any of them have the [DS] trait, 2 of your Digimon may DNA digivolve into a Digimon card with the [DS] trait in the hand. Then, that DNA digivolved Digimon may attack.";
  99. }
  100. bool MyDigimonCondition(Permanent permanent)
  101. {
  102. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card)
  103. && permanent.TopCard.EqualsTraits("DS");
  104. }
  105. bool CanSelectDNACardCondition(CardSource cardSource)
  106. {
  107. return cardSource.IsDigimon
  108. && cardSource.EqualsTraits("DS")
  109. && cardSource.CanPlayJogress(true);
  110. }
  111. bool CanUseCondition(Hashtable hashtable)
  112. {
  113. return CardEffectCommons.IsExistOnBattleAreaTrigger(card, activateClass)
  114. && CardEffectCommons.IsOwnerTurn(card)
  115. && (CardEffectCommons.CanTriggerOnPermanentPlay(hashtable, MyDigimonCondition)
  116. || CardEffectCommons.CanTriggerWhenPermanentDigivolving(hashtable, MyDigimonCondition));
  117. }
  118. bool CanActivateCondition(Hashtable hashtable)
  119. {
  120. return CardEffectCommons.IsExistOnBattleAreaActivate(card, activateClass)
  121. && CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectDNACardCondition);
  122. }
  123. IEnumerator ActivateCoroutine(Hashtable hashtable)
  124. {
  125. // DNA digivolve
  126. yield return ContinuousController.instance.StartCoroutine(
  127. CardEffectCommons.DNADigivolvePermanentsIntoHandOrTrashCard(
  128. CanSelectDNACardCondition,
  129. payCost: true,
  130. isHand: true,
  131. activateClass,
  132. successProcess: OnDNASuccess
  133. ));
  134. IEnumerator OnDNASuccess(CardSource cardSource)
  135. {
  136. if (cardSource.PermanentOfThisCard().CanAttack(activateClass))
  137. {
  138. SelectAttackEffect selectAttackEffect =
  139. GManager.instance.GetComponent<SelectAttackEffect>();
  140. selectAttackEffect.SetUp(
  141. attacker: cardSource.PermanentOfThisCard(),
  142. canAttackPlayerCondition: () => true,
  143. defenderCondition: (permanent) => true,
  144. cardEffect: activateClass);
  145. yield return ContinuousController.instance.StartCoroutine(selectAttackEffect
  146. .Activate());
  147. }
  148. }
  149. }
  150. }
  151. #endregion
  152. return cardEffects;
  153. }
  154. }
  155. }