AD1_013.cs 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System;
  5. // ZeigGreymon
  6. namespace DCGO.CardEffects.AD1
  7. {
  8. public class AD1_013 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region Alternative Digivolve Condition
  14. if (timing == EffectTiming.None)
  15. {
  16. static bool PermanentCondition(Permanent targetPermanent)
  17. {
  18. return targetPermanent.TopCard.EqualsTraits("Blue Flare")
  19. || targetPermanent.TopCard.EqualsTraits("Xros Heart");
  20. }
  21. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(level: 5, permanentCondition: PermanentCondition, digivolutionCost: 3, ignoreDigivolutionRequirement: false, card: card, condition: null));
  22. }
  23. #endregion
  24. #region Reboot
  25. if (timing == EffectTiming.None)
  26. {
  27. cardEffects.Add(CardEffectFactory.RebootSelfStaticEffect(isInheritedEffect: false, card: card, condition: null));
  28. }
  29. #endregion
  30. #region Blocker
  31. if (timing == EffectTiming.None)
  32. {
  33. cardEffects.Add(CardEffectFactory.BlockerSelfStaticEffect(isInheritedEffect: false, card: card, condition: null));
  34. }
  35. #endregion
  36. #region Shared OP / WD
  37. string SharedEffectName = "Delete an Opponent's Digimon with the fewest sources";
  38. string SharedEffectDescription(string tag) => $"[{tag}] Delete 1 of your opponent's Digimon with the fewest digivolution cards.";
  39. bool IsMinDigivolutionCards(Permanent permanent) => CardEffectCommons.IsMinDigivolutionCards(permanent, card.Owner.Enemy);
  40. bool SharedCanActivateCondition(Hashtable hashtable) => CardEffectCommons.IsExistOnBattleArea(card);
  41. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  42. {
  43. if (CardEffectCommons.HasMatchConditionOpponentsPermanent(card, IsMinDigivolutionCards))
  44. {
  45. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  46. selectPermanentEffect.SetUp(
  47. selectPlayer: card.Owner,
  48. canTargetCondition: IsMinDigivolutionCards,
  49. canTargetCondition_ByPreSelecetedList: null,
  50. canEndSelectCondition: null,
  51. maxCount: 1,
  52. canNoSelect: false,
  53. canEndNotMax: false,
  54. selectPermanentCoroutine: null,
  55. afterSelectPermanentCoroutine: null,
  56. mode: SelectPermanentEffect.Mode.Destroy,
  57. cardEffect: activateClass);
  58. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  59. }
  60. }
  61. #endregion
  62. #region On Play
  63. if (timing == EffectTiming.OnEnterFieldAnyone)
  64. {
  65. ActivateClass activateClass = new ActivateClass();
  66. activateClass.SetUpICardEffect(SharedEffectName, CanUseCondition, card);
  67. activateClass.SetUpActivateClass(SharedCanActivateCondition, hashtable => SharedActivateCoroutine(hashtable, activateClass), -1, false, SharedEffectDescription("On Play"));
  68. cardEffects.Add(activateClass);
  69. bool CanUseCondition(Hashtable hashtable)
  70. {
  71. return CardEffectCommons.IsExistOnBattleArea(card)
  72. && CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  73. }
  74. }
  75. #endregion
  76. #region When Digivolving
  77. if (timing == EffectTiming.OnEnterFieldAnyone)
  78. {
  79. ActivateClass activateClass = new ActivateClass();
  80. activateClass.SetUpICardEffect(SharedEffectName, CanUseCondition, card);
  81. activateClass.SetUpActivateClass(SharedCanActivateCondition, hashtable => SharedActivateCoroutine(hashtable, activateClass), -1, false, SharedEffectDescription("When Digivolving"));
  82. cardEffects.Add(activateClass);
  83. bool CanUseCondition(Hashtable hashtable)
  84. {
  85. return CardEffectCommons.IsExistOnBattleArea(card)
  86. && CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  87. }
  88. }
  89. #endregion
  90. #region All Turns
  91. if (timing == EffectTiming.WhenRemoveField)
  92. {
  93. ActivateClass activateClass = new ActivateClass();
  94. activateClass.SetUpICardEffect("Play 1 level 5 or lower [Blue Flare] or [Xros Heart] Digimon from this Digimon's digivolution cards", CanUseCondition, card);
  95. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription());
  96. cardEffects.Add(activateClass);
  97. string EffectDescription()
  98. => "[All Turns] When this Digimon would leave the battle area other than by DigiXros, you may play 1 level 5 or lower [Blue Flare] or [Xros Heart] trait Digimon card from its digivolution cards without paying the cost.";
  99. bool CanUseCondition(Hashtable hashtable)
  100. {
  101. return CardEffectCommons.IsExistOnBattleArea(card)
  102. && CardEffectCommons.CanTriggerWhenRemoveField(hashtable, card)
  103. && !CardEffectCommons.IsLeavingForDigiXros(hashtable);
  104. }
  105. bool CanSelectSourceCardCondition(CardSource cardSource)
  106. {
  107. return cardSource.IsDigimon
  108. && cardSource.HasLevel && cardSource.Level <= 5
  109. && (cardSource.EqualsTraits("Blue Flare") || cardSource.EqualsTraits("Xros Heart"))
  110. && CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass);
  111. }
  112. bool CanActivateCondition(Hashtable hashtable)
  113. {
  114. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  115. && card.PermanentOfThisCard().DigivolutionCards.Some(CanSelectSourceCardCondition);
  116. }
  117. IEnumerator ActivateCoroutine(Hashtable hashtable)
  118. {
  119. List<CardSource> selectedCards = new List<CardSource>();
  120. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  121. selectCardEffect.SetUp(
  122. canTargetCondition: CanSelectSourceCardCondition,
  123. canTargetCondition_ByPreSelecetedList: null,
  124. canEndSelectCondition: null,
  125. canNoSelect: () => true,
  126. selectCardCoroutine: SelectCardCoroutine,
  127. afterSelectCardCoroutine: null,
  128. message: "Select 1 digivolution card to play.",
  129. maxCount: 1,
  130. canEndNotMax: false,
  131. isShowOpponent: true,
  132. mode: SelectCardEffect.Mode.Custom,
  133. root: SelectCardEffect.Root.DigivolutionCards,
  134. customRootCardList: card.PermanentOfThisCard().DigivolutionCards,
  135. canLookReverseCard: true,
  136. selectPlayer: card.Owner,
  137. cardEffect: activateClass);
  138. selectCardEffect.SetUpCustomMessage(
  139. "Select 1 digivolution card to play.",
  140. "The opponent is selecting 1 digivolution card to play.");
  141. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  142. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  143. IEnumerator SelectCardCoroutine(CardSource cardSource)
  144. {
  145. selectedCards.Add(cardSource);
  146. yield return null;
  147. }
  148. if (selectedCards.Count > 0) yield return ContinuousController.instance.StartCoroutine(
  149. CardEffectCommons.PlayPermanentCards(
  150. cardSources: selectedCards,
  151. activateClass: activateClass,
  152. payCost: false,
  153. isTapped: false,
  154. root: SelectCardEffect.Root.DigivolutionCards,
  155. activateETB: true));
  156. }
  157. }
  158. #endregion
  159. #region All Turns - ESS
  160. if (timing == EffectTiming.None)
  161. {
  162. bool Condition()
  163. {
  164. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  165. && (card.PermanentOfThisCard().TopCard.EqualsTraits("Blue Flare")
  166. || card.PermanentOfThisCard().TopCard.EqualsTraits("Xros Heart"));
  167. }
  168. int changeDP()
  169. {
  170. return 1000 * card.PermanentOfThisCard().DigivolutionCardsColors.Count;
  171. }
  172. cardEffects.Add(CardEffectFactory.ChangeSelfDPStaticEffect(
  173. changeValue: (Func<int>)changeDP,
  174. isInheritedEffect: true,
  175. card: card,
  176. condition: Condition));
  177. }
  178. #endregion
  179. return cardEffects;
  180. }
  181. }
  182. }