EX2_041.cs 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.EX2
  6. {
  7. public class EX2_041 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. if (timing == EffectTiming.None)
  13. {
  14. ChangeCostClass changeCostClass = new ChangeCostClass();
  15. changeCostClass.SetUpICardEffect($"Play Cost -2", CanUseCondition, card);
  16. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => false, isChangePayingCost: () => true);
  17. cardEffects.Add(changeCostClass);
  18. bool CanUseCondition(Hashtable hashtable)
  19. {
  20. if (card.Owner.HandCards.Contains(card))
  21. {
  22. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, (permanent) => permanent.TopCard.CardNames.Contains("Alice McCoy")))
  23. {
  24. return true;
  25. }
  26. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, (permanent) => permanent.TopCard.CardNames.Contains("AliceMcCoy")))
  27. {
  28. return true;
  29. }
  30. }
  31. return false;
  32. }
  33. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  34. {
  35. if (CardSourceCondition(cardSource))
  36. {
  37. if (RootCondition(root))
  38. {
  39. if (PermanentsCondition(targetPermanents))
  40. {
  41. Cost -= 2;
  42. }
  43. }
  44. }
  45. return Cost;
  46. }
  47. bool PermanentsCondition(List<Permanent> targetPermanents)
  48. {
  49. if (targetPermanents == null)
  50. {
  51. return true;
  52. }
  53. else
  54. {
  55. if (targetPermanents.Count((targetPermanent) => targetPermanent != null) == 0)
  56. {
  57. return true;
  58. }
  59. }
  60. return false;
  61. }
  62. bool CardSourceCondition(CardSource cardSource)
  63. {
  64. return cardSource == card;
  65. }
  66. bool RootCondition(SelectCardEffect.Root root)
  67. {
  68. if (root == SelectCardEffect.Root.Hand)
  69. {
  70. return true;
  71. }
  72. return false;
  73. }
  74. bool isUpDown()
  75. {
  76. return true;
  77. }
  78. }
  79. if (timing == EffectTiming.OnDestroyedAnyone)
  80. {
  81. ActivateClass activateClass = new ActivateClass();
  82. activateClass.SetUpICardEffect("Trash 3 cards from deck top and return 1 card from trash to hand", CanUseCondition, card);
  83. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  84. cardEffects.Add(activateClass);
  85. string EffectDiscription()
  86. {
  87. return "[On Deletion] Trash the top 3 cards of your deck. Then, return 1 purple Digimon card or 1 purple Tamer card from your trash to your hand.";
  88. }
  89. bool CanSelectCardCondition(CardSource cardSource)
  90. {
  91. if (cardSource != null)
  92. {
  93. if (cardSource.Owner == card.Owner)
  94. {
  95. if (cardSource.HasCardColor(CardColor.Purple))
  96. {
  97. if (cardSource.IsDigimon)
  98. {
  99. return true;
  100. }
  101. if (cardSource.IsTamer)
  102. {
  103. return true;
  104. }
  105. }
  106. }
  107. }
  108. return false;
  109. }
  110. bool CanUseCondition(Hashtable hashtable)
  111. {
  112. return CardEffectCommons.CanTriggerOnDeletion(hashtable, card, activateClass);
  113. }
  114. bool CanActivateCondition(Hashtable hashtable)
  115. {
  116. if (CardEffectCommons.IsExistOnTrash(card))
  117. {
  118. return true;
  119. }
  120. return false;
  121. }
  122. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  123. {
  124. yield return ContinuousController.instance.StartCoroutine(new IAddTrashCardsFromLibraryTop(3, card.Owner, activateClass).AddTrashCardsFromLibraryTop());
  125. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  126. {
  127. int maxCount = Math.Min(1, card.Owner.TrashCards.Count(CanSelectCardCondition));
  128. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  129. selectCardEffect.SetUp(
  130. canTargetCondition: CanSelectCardCondition,
  131. canTargetCondition_ByPreSelecetedList: null,
  132. canEndSelectCondition: null,
  133. canNoSelect: () => false,
  134. selectCardCoroutine: null,
  135. afterSelectCardCoroutine: null,
  136. message: "Select 1 card to add to your hand.",
  137. maxCount: maxCount,
  138. canEndNotMax: false,
  139. isShowOpponent: true,
  140. mode: SelectCardEffect.Mode.AddHand,
  141. root: SelectCardEffect.Root.Trash,
  142. customRootCardList: null,
  143. canLookReverseCard: true,
  144. selectPlayer: card.Owner,
  145. cardEffect: activateClass);
  146. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  147. }
  148. }
  149. }
  150. return cardEffects;
  151. }
  152. }
  153. }