BT10_084.cs 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using System.Linq;
  5. using System;
  6. namespace DCGO.CardEffects.BT10
  7. {
  8. public class BT10_084 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region On Play
  14. if (timing == EffectTiming.OnEnterFieldAnyone)
  15. {
  16. ActivateClass activateClass = new ActivateClass();
  17. activateClass.SetUpICardEffect("Play Digimon from trash", CanUseCondition, card);
  18. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  19. cardEffects.Add(activateClass);
  20. string EffectDiscription()
  21. {
  22. return "[On Play] Play 1 purple or yellow Digimon card with 6000 DP or less from your trash without paying its memory cost. If you have 1 or fewer security cards, you may play 1 level 6 or lower Digimon card with [Angel] or [Fallen Angel] in its traits from your trash without paying its memory cost instead.";
  23. }
  24. bool CanSelectCardCondition(CardSource cardSource)
  25. {
  26. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  27. {
  28. if (cardSource.IsDigimon)
  29. {
  30. if (cardSource.Level <= 4 && cardSource.HasLevel)
  31. {
  32. if (cardSource.CardTraits.Contains("BagraArmy"))
  33. {
  34. return true;
  35. }
  36. if (cardSource.CardTraits.Contains("Bagra Army"))
  37. {
  38. return true;
  39. }
  40. }
  41. }
  42. }
  43. return false;
  44. }
  45. bool CanUseCondition(Hashtable hashtable)
  46. {
  47. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  48. }
  49. bool CanActivateCondition(Hashtable hashtable)
  50. {
  51. if (CardEffectCommons.IsExistOnBattleArea(card))
  52. {
  53. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  54. {
  55. return true;
  56. }
  57. }
  58. return false;
  59. }
  60. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  61. {
  62. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  63. {
  64. List<CardSource> selectedCards = new List<CardSource>();
  65. int maxCount = Math.Min(2, card.Owner.TrashCards.Count(CanSelectCardCondition));
  66. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  67. selectCardEffect.SetUp(
  68. canTargetCondition: CanSelectCardCondition,
  69. canTargetCondition_ByPreSelecetedList: null,
  70. canEndSelectCondition: null,
  71. canNoSelect: () => true,
  72. selectCardCoroutine: SelectCardCoroutine,
  73. afterSelectCardCoroutine: null,
  74. message: "Select cards to play.",
  75. maxCount: maxCount,
  76. canEndNotMax: false,
  77. isShowOpponent: true,
  78. mode: SelectCardEffect.Mode.Custom,
  79. root: SelectCardEffect.Root.Trash,
  80. customRootCardList: null,
  81. canLookReverseCard: true,
  82. selectPlayer: card.Owner,
  83. cardEffect: activateClass);
  84. selectCardEffect.SetUpCustomMessage("Select cards to play.", "The opponent is selecting cards to play.");
  85. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  86. yield return StartCoroutine(selectCardEffect.Activate());
  87. IEnumerator SelectCardCoroutine(CardSource cardSource)
  88. {
  89. selectedCards.Add(cardSource);
  90. yield return null;
  91. }
  92. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  93. cardSources: selectedCards,
  94. activateClass: activateClass,
  95. payCost: false,
  96. isTapped: false,
  97. root: SelectCardEffect.Root.Trash,
  98. activateETB: true));
  99. foreach (CardSource selectedCard in selectedCards)
  100. {
  101. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainBlocker(
  102. targetPermanent: selectedCard.PermanentOfThisCard(),
  103. effectDuration: EffectDuration.UntilOpponentTurnEnd,
  104. activateClass: activateClass));
  105. }
  106. }
  107. }
  108. }
  109. #endregion
  110. #region Opponents Turn
  111. if (timing == EffectTiming.WhenWouldDigivolutionCardDiscarded)
  112. {
  113. ActivateClass activateClass = new ActivateClass();
  114. activateClass.SetUpICardEffect("Trash digivolution cards instead", CanUseCondition, card);
  115. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  116. cardEffects.Add(activateClass);
  117. string EffectDiscription()
  118. {
  119. return "[Opponent's Turn] When an effect would trash one of your other Digimon's digivolution cards, you may trash this Digimon's digivolution cards instead.";
  120. }
  121. bool PermanentCondition(Permanent permanent)
  122. {
  123. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  124. {
  125. if (permanent != card.PermanentOfThisCard())
  126. {
  127. return true;
  128. }
  129. }
  130. return false;
  131. }
  132. bool CanUseCondition(Hashtable hashtable)
  133. {
  134. if (CardEffectCommons.CanTriggerOnTrashDigivolutionCard(hashtable, PermanentCondition, cardEffect => true, cardSource => true))
  135. {
  136. return true;
  137. }
  138. return false;
  139. }
  140. bool CanActivateCondition(Hashtable hashtable)
  141. {
  142. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  143. {
  144. if (!CardEffectCommons.IsOwnerTurn(card))
  145. {
  146. return true;
  147. }
  148. }
  149. return false;
  150. }
  151. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  152. {
  153. List<CardSource> discardedCards = CardEffectCommons.GetDiscardedCardsFromHashtable(_hashtable);
  154. if (discardedCards.Count > 0)
  155. {
  156. if (card.PermanentOfThisCard().cardSources.Count >= discardedCards.Count)
  157. {
  158. discardedCards.ForEach(source => source.willBeRemoveSources = false);
  159. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  160. selectCardEffect.SetUp(
  161. canTargetCondition: (CardSource) => true,
  162. canTargetCondition_ByPreSelecetedList: null,
  163. canEndSelectCondition: null,
  164. canNoSelect: () => false,
  165. selectCardCoroutine: null,
  166. afterSelectCardCoroutine: null,
  167. message: "Select card(s) to trash.",
  168. maxCount: discardedCards.Count,
  169. canEndNotMax: false,
  170. isShowOpponent: true,
  171. mode: SelectCardEffect.Mode.Discard,
  172. root: SelectCardEffect.Root.Custom,
  173. customRootCardList: card.PermanentOfThisCard().DigivolutionCards,
  174. canLookReverseCard: true,
  175. selectPlayer: card.Owner,
  176. cardEffect: activateClass);
  177. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  178. }
  179. }
  180. }
  181. }
  182. #endregion
  183. return cardEffects;
  184. }
  185. }
  186. }