EX8_027.cs 9.4 KB

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