EX11_044.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. // Pyramidimon
  6. namespace DCGO.CardEffects.EX11
  7. {
  8. public class EX11_044 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region Reboot
  14. if (timing == EffectTiming.None)
  15. {
  16. cardEffects.Add(CardEffectFactory.RebootSelfStaticEffect(isInheritedEffect: false, card: card, condition: null));
  17. }
  18. #endregion
  19. #region Fragment
  20. if (timing == EffectTiming.WhenPermanentWouldBeDeleted)
  21. {
  22. string EffectDiscription()
  23. {
  24. return "<Fragment <3>> (When this Digimon would be deleted, by trashing any 3 of its digivolution cards, it isn't deleted.)";
  25. }
  26. cardEffects.Add(CardEffectFactory.FragmentSelfEffect(isInheritedEffect: false, card: card, condition: null, trashValue: 3, effectName: "Fragment <3>", effectDiscription: EffectDiscription()));
  27. }
  28. #endregion
  29. #region Shared OP/WD/WA
  30. string SharedEffectName()
  31. {
  32. return "By trashing 3 [Mineral]/[Rock] cards from Digimon digivolution cards delete opponent's highest play cost Digimon/Tamer.";
  33. }
  34. string SharedEffectDescription(string tag)
  35. {
  36. return $"[{tag}] [Once Per Turn] By trashing any 3 [Mineral] or [Rock] trait cards from your Digimon's digivolution cards, delete 1 of your opponent's highest play cost Digimon or Tamers.";
  37. }
  38. string SharedHashString = "EX11_044_OP_WD_WA";
  39. bool SharedCanActivateCondition(Hashtable hashtable)
  40. {
  41. return CardEffectCommons.IsExistOnBattleArea(card)
  42. && HasProperAmountOfSources();
  43. }
  44. bool CanSelectPermanentCondition(Permanent permanent)
  45. {
  46. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card)
  47. && permanent.DigivolutionCards.Count(HasProperTrait) >= 1;
  48. }
  49. bool CanSelectPermanentCondition1(Permanent permanent)
  50. {
  51. return CardEffectCommons.IsMaxCost(permanent, card.Owner.Enemy, false);
  52. }
  53. bool HasProperTrait(CardSource cardSource)
  54. {
  55. return cardSource.EqualsTraits("Mineral")
  56. || cardSource.EqualsTraits("Rock");
  57. }
  58. bool HasProperAmountOfSources()
  59. {
  60. int totalSourceCount = 0;
  61. foreach (Permanent permanent in card.Owner.GetBattleAreaDigimons())
  62. {
  63. totalSourceCount += permanent.DigivolutionCards.Count(HasProperTrait);
  64. }
  65. return totalSourceCount >= 3;
  66. }
  67. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  68. {
  69. int trashedCount = 0;
  70. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.SelectTrashDigivolutionCards(
  71. permanentCondition: CanSelectPermanentCondition,
  72. cardCondition: HasProperTrait,
  73. maxCount: 3,
  74. canNoTrash: false,
  75. isFromOnly1Permanent: false,
  76. activateClass: activateClass,
  77. afterSelectionCoroutine: AfterTrashedCards
  78. ));
  79. IEnumerator AfterTrashedCards(Permanent permanent, List<CardSource> cards)
  80. {
  81. trashedCount = cards.Count;
  82. yield return null;
  83. }
  84. if (trashedCount == 3)
  85. {
  86. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition1));
  87. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  88. selectPermanentEffect.SetUp(
  89. selectPlayer: card.Owner,
  90. canTargetCondition: CanSelectPermanentCondition1,
  91. canTargetCondition_ByPreSelecetedList: null,
  92. canEndSelectCondition: null,
  93. maxCount: maxCount,
  94. canNoSelect: false,
  95. canEndNotMax: false,
  96. selectPermanentCoroutine: null,
  97. afterSelectPermanentCoroutine: null,
  98. mode: SelectPermanentEffect.Mode.Destroy,
  99. cardEffect: activateClass);
  100. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  101. }
  102. }
  103. #endregion
  104. #region On Play
  105. if (timing == EffectTiming.OnEnterFieldAnyone)
  106. {
  107. ActivateClass activateClass = new ActivateClass();
  108. activateClass.SetUpICardEffect(SharedEffectName(), CanUseCondition, card);
  109. activateClass.SetUpActivateClass(SharedCanActivateCondition, (hash) => SharedActivateCoroutine(hash, activateClass), 1, true, SharedEffectDescription("On Play"));
  110. activateClass.SetHashString(SharedHashString);
  111. cardEffects.Add(activateClass);
  112. bool CanUseCondition(Hashtable hashtable)
  113. {
  114. return CardEffectCommons.CanTriggerOnPlay(hashtable, card)
  115. && CardEffectCommons.IsExistOnBattleArea(card);
  116. }
  117. }
  118. #endregion
  119. #region When Digivolving
  120. if (timing == EffectTiming.OnEnterFieldAnyone)
  121. {
  122. ActivateClass activateClass = new ActivateClass();
  123. activateClass.SetUpICardEffect(SharedEffectName(), CanUseCondition, card);
  124. activateClass.SetUpActivateClass(SharedCanActivateCondition, (hash) => SharedActivateCoroutine(hash, activateClass), 1, true, SharedEffectDescription("When Digivolving"));
  125. activateClass.SetHashString(SharedHashString);
  126. cardEffects.Add(activateClass);
  127. bool CanUseCondition(Hashtable hashtable)
  128. {
  129. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card)
  130. && CardEffectCommons.IsExistOnBattleArea(card);
  131. }
  132. }
  133. #endregion
  134. #region When Attacking
  135. if (timing == EffectTiming.OnAllyAttack)
  136. {
  137. ActivateClass activateClass = new ActivateClass();
  138. activateClass.SetUpICardEffect(SharedEffectName(), CanUseCondition, card);
  139. activateClass.SetUpActivateClass(SharedCanActivateCondition, hash => SharedActivateCoroutine(hash, activateClass), 1, true, SharedEffectDescription("When Attacking"));
  140. activateClass.SetHashString(SharedHashString);
  141. cardEffects.Add(activateClass);
  142. bool CanUseCondition(Hashtable hashtable)
  143. {
  144. return CardEffectCommons.CanTriggerOnAttack(hashtable, card) &&
  145. CardEffectCommons.IsExistOnBattleArea(card);
  146. }
  147. }
  148. #endregion
  149. #region All Turns
  150. if (timing == EffectTiming.OnDigivolutionCardDiscarded)
  151. {
  152. ActivateClass activateClass = new ActivateClass();
  153. activateClass.SetUpICardEffect("May place 3 [Mineral]/[Rock] trait cards from trash under this Digimon.", CanUseCondition, card);
  154. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  155. activateClass.SetHashString("EX10_044_AT");
  156. cardEffects.Add(activateClass);
  157. string EffectDiscription()
  158. {
  159. return "[All Turns] [Once Per Turn] When effects trash any of this Digimon's digivolution cards, you may place 3 [Mineral] or [Rock] trait cards from your trash as this Digimon's bottom digivolution cards.";
  160. }
  161. bool CanUseCondition(Hashtable hashtable)
  162. {
  163. return CardEffectCommons.IsExistOnBattleArea(card)
  164. && CardEffectCommons.CanTriggerOnTrashDigivolutionCard(hashtable, perm => perm == card.PermanentOfThisCard(), cardEffect => cardEffect != null, source => source != null);
  165. }
  166. bool CanActivateCondition(Hashtable hashtable)
  167. {
  168. return CardEffectCommons.IsExistOnBattleArea(card)
  169. && CardEffectCommons.MatchConditionOwnersCardCountInTrash(card, HasProperTrait) >= 1;
  170. }
  171. IEnumerator ActivateCoroutine(Hashtable hashtable)
  172. {
  173. List<CardSource> selectedCards = new List<CardSource>();
  174. int maxCount = Math.Min(3, CardEffectCommons.MatchConditionOwnersCardCountInTrash(card, HasProperTrait));
  175. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  176. selectCardEffect.SetUp(
  177. canTargetCondition: HasProperTrait,
  178. canTargetCondition_ByPreSelecetedList: null,
  179. canEndSelectCondition: null,
  180. canNoSelect: () => false,
  181. selectCardCoroutine: SelectCardCoroutine,
  182. afterSelectCardCoroutine: null,
  183. message: "Select [Mineral] or [Rock] to place on bottom of digivolution cards\n(cards will be placed so that cards with lower numbers are on top).",
  184. maxCount: maxCount,
  185. canEndNotMax: false,
  186. isShowOpponent: true,
  187. mode: SelectCardEffect.Mode.Custom,
  188. root: SelectCardEffect.Root.Trash,
  189. customRootCardList: null,
  190. canLookReverseCard: true,
  191. selectPlayer: card.Owner,
  192. cardEffect: activateClass);
  193. selectCardEffect.SetUpCustomMessage_ShowCard("Digivolution Card");
  194. selectCardEffect.SetUpCustomMessage("Select [Mineral] or [Rock] to place on bottom of digivolution cards.", "The opponent is selecting [Mineral] or [Rock] to place on bottom of digivolution cards.");
  195. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  196. IEnumerator SelectCardCoroutine(CardSource cardSource)
  197. {
  198. selectedCards.Add(cardSource);
  199. yield return null;
  200. }
  201. if (selectedCards.Count >= 1)
  202. {
  203. yield return ContinuousController.instance.StartCoroutine(card.PermanentOfThisCard().AddDigivolutionCardsBottom(selectedCards, activateClass));
  204. }
  205. }
  206. }
  207. #endregion
  208. return cardEffects;
  209. }
  210. }
  211. }