BT11_057.cs 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.BT11
  6. {
  7. public class BT11_057 : 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.OnDetermineDoSecurityCheck)
  13. {
  14. cardEffects.Add(CardEffectFactory.PierceSelfEffect(isInheritedEffect: false, card: card, condition: null));
  15. }
  16. if (timing == EffectTiming.OnEnterFieldAnyone)
  17. {
  18. ActivateClass activateClass = new ActivateClass();
  19. activateClass.SetUpICardEffect("Trash cards from hand to suspend opponent's Digimon and gain Memory", CanUseCondition, card);
  20. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  21. cardEffects.Add(activateClass);
  22. string EffectDiscription()
  23. {
  24. return "[When Digivolving] You may trash up to 3 cards in your hand. If you do, for each card trashed, suspend 1 of your opponent's Digimon. Then, for each suspended Digimon your opponent has in play, gain 1 memory.";
  25. }
  26. bool CanSelectPermanentCondition(Permanent permanent)
  27. {
  28. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  29. {
  30. if (permanent.CanSelectBySkill(activateClass))
  31. {
  32. return true;
  33. }
  34. }
  35. return false;
  36. }
  37. bool CanSelectPermanentCondition1(Permanent permanent)
  38. {
  39. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  40. {
  41. if (permanent.IsSuspended)
  42. {
  43. return true;
  44. }
  45. }
  46. return false;
  47. }
  48. bool CanUseCondition(Hashtable hashtable)
  49. {
  50. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  51. }
  52. bool CanActivateCondition(Hashtable hashtable)
  53. {
  54. if (isExistOnField(card))
  55. {
  56. if (card.Owner.GetBattleAreaDigimons().Contains(card.PermanentOfThisCard()))
  57. {
  58. if (card.Owner.HandCards.Count >= 1)
  59. {
  60. return true;
  61. }
  62. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition1))
  63. {
  64. if (card.Owner.CanAddMemory(activateClass))
  65. {
  66. return true;
  67. }
  68. }
  69. }
  70. }
  71. return false;
  72. }
  73. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  74. {
  75. if (isExistOnField(card))
  76. {
  77. if (card.Owner.GetBattleAreaDigimons().Contains(card.PermanentOfThisCard()))
  78. {
  79. if (card.Owner.HandCards.Count >= 1)
  80. {
  81. List<CardSource> discardedCards = new List<CardSource>();
  82. int discardCount = 3;
  83. if (card.Owner.HandCards.Count < discardCount)
  84. {
  85. discardCount = card.Owner.HandCards.Count;
  86. }
  87. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  88. selectHandEffect.SetUp(
  89. selectPlayer: card.Owner,
  90. canTargetCondition: (cardSource) => true,
  91. canTargetCondition_ByPreSelecetedList: null,
  92. canEndSelectCondition: null,
  93. maxCount: discardCount,
  94. canNoSelect: true,
  95. canEndNotMax: true,
  96. isShowOpponent: true,
  97. selectCardCoroutine: null,
  98. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  99. mode: SelectHandEffect.Mode.Discard,
  100. cardEffect: activateClass);
  101. yield return StartCoroutine(selectHandEffect.Activate());
  102. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  103. {
  104. if (cardSources.Count >= 1)
  105. {
  106. foreach (CardSource cardSource in cardSources)
  107. {
  108. discardedCards.Add(cardSource);
  109. }
  110. yield return null;
  111. }
  112. }
  113. if (discardedCards.Count >= 1)
  114. {
  115. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  116. {
  117. int maxCount = Math.Min(discardedCards.Count, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  118. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  119. selectPermanentEffect.SetUp(
  120. selectPlayer: card.Owner,
  121. canTargetCondition: CanSelectPermanentCondition,
  122. canTargetCondition_ByPreSelecetedList: null,
  123. canEndSelectCondition: CanEndSelectCondition,
  124. maxCount: maxCount,
  125. canNoSelect: false,
  126. canEndNotMax: false,
  127. selectPermanentCoroutine: null,
  128. afterSelectPermanentCoroutine: null,
  129. mode: SelectPermanentEffect.Mode.Tap,
  130. cardEffect: activateClass);
  131. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  132. bool CanEndSelectCondition(List<Permanent> permanents)
  133. {
  134. if (permanents.Count <= 0)
  135. {
  136. return false;
  137. }
  138. return true;
  139. }
  140. }
  141. }
  142. }
  143. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition1))
  144. {
  145. if (card.Owner.CanAddMemory(activateClass))
  146. {
  147. yield return ContinuousController.instance.StartCoroutine(card.Owner.AddMemory(card.Owner.Enemy.GetBattleAreaDigimons().Count(CanSelectPermanentCondition1), activateClass));
  148. }
  149. }
  150. }
  151. }
  152. }
  153. }
  154. return cardEffects;
  155. }
  156. }
  157. }