AD1_013.cs 9.7 KB

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