Dobelmon_EX2_041.cs 6.3 KB

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