BT14_081.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.BT14
  6. {
  7. public class BT14_081 : 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.OnEnterFieldAnyone)
  13. {
  14. ActivateClass activateClass = new ActivateClass();
  15. activateClass.SetUpICardEffect("Play Digimon cards from trash", CanUseCondition, card);
  16. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  17. cardEffects.Add(activateClass);
  18. string EffectDiscription()
  19. {
  20. return "[When Digivolving] You may play 1 level 4 or lower card with the [Dark Animal] or [SoC] trait from your trash without paying the cost. If [Eiji Nagasumi] is in this Digimon's digivolution cards, add 2 to the number of cards this effect may play.";
  21. }
  22. bool CanSelectCardCondition(CardSource cardSource)
  23. {
  24. if (cardSource.Level <= 4)
  25. {
  26. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  27. {
  28. if (cardSource.HasLevel && cardSource.HasPlayCost)
  29. {
  30. if (cardSource.CardTraits.Contains("Dark Animal"))
  31. {
  32. return true;
  33. }
  34. if (cardSource.CardTraits.Contains("DarkAnimal"))
  35. {
  36. return true;
  37. }
  38. if (cardSource.CardTraits.Contains("SoC"))
  39. {
  40. return true;
  41. }
  42. }
  43. }
  44. }
  45. return false;
  46. }
  47. bool CanUseCondition(Hashtable hashtable)
  48. {
  49. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  50. }
  51. bool CanActivateCondition(Hashtable hashtable)
  52. {
  53. if (CardEffectCommons.IsExistOnBattleArea(card))
  54. {
  55. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  56. {
  57. return true;
  58. }
  59. }
  60. return false;
  61. }
  62. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  63. {
  64. int maxCount = 1;
  65. if (CardEffectCommons.IsExistOnBattleArea(card))
  66. {
  67. if (card.PermanentOfThisCard().DigivolutionCards.Some(cardSource => cardSource.CardNames.Contains("Eiji Nagasumi")) || card.PermanentOfThisCard().DigivolutionCards.Some(cardSource => cardSource.CardNames.Contains("EijiNagasumi")))
  68. {
  69. maxCount += 2;
  70. }
  71. }
  72. maxCount = Math.Min(maxCount, card.Owner.TrashCards.Count((cardSource) => CanSelectCardCondition(cardSource)));
  73. maxCount = Math.Min(maxCount, card.Owner.fieldCardFrames.Count((frame) => frame.IsEmptyFrame() && frame.IsBattleAreaFrame()));
  74. List<CardSource> selectedCards = new List<CardSource>();
  75. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  76. selectCardEffect.SetUp(
  77. canTargetCondition: CanSelectCardCondition,
  78. canTargetCondition_ByPreSelecetedList: null,
  79. canEndSelectCondition: null,
  80. canNoSelect: () => true,
  81. selectCardCoroutine: SelectCardCoroutine,
  82. afterSelectCardCoroutine: null,
  83. message: "Select cards to play.",
  84. maxCount: maxCount,
  85. canEndNotMax: false,
  86. isShowOpponent: true,
  87. mode: SelectCardEffect.Mode.Custom,
  88. root: SelectCardEffect.Root.Trash,
  89. customRootCardList: null,
  90. canLookReverseCard: true,
  91. selectPlayer: card.Owner,
  92. cardEffect: activateClass);
  93. selectCardEffect.SetUpCustomMessage("Select cards to play.", "The opponent is selecting cards to play.");
  94. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  95. yield return StartCoroutine(selectCardEffect.Activate());
  96. IEnumerator SelectCardCoroutine(CardSource cardSource)
  97. {
  98. selectedCards.Add(cardSource);
  99. yield return null;
  100. }
  101. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(cardSources: selectedCards, activateClass: activateClass, payCost: false, isTapped: false, root: SelectCardEffect.Root.Trash, activateETB: true));
  102. }
  103. }
  104. if (timing == EffectTiming.OnAllyAttack)
  105. {
  106. ActivateClass activateClass = new ActivateClass();
  107. activateClass.SetUpICardEffect("Delete 1 opponent's Digimon to unsuspend this Digimon", CanUseCondition, card);
  108. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  109. activateClass.SetHashString("Delete_BT14_081");
  110. cardEffects.Add(activateClass);
  111. string EffectDiscription()
  112. {
  113. return "[When Attacking][Once Per Turn] By deleting 1 of your opponent's level 3 or lower Digimon, unsuspend this Digimon. For each of your Digimon, add 1 to the level this effect may choose.";
  114. }
  115. bool CanSelectPermanentCondition(Permanent permanent)
  116. {
  117. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  118. {
  119. int maxLevel = 3;
  120. maxLevel += card.Owner.GetBattleAreaDigimons().Count;
  121. if (permanent.Level <= maxLevel)
  122. {
  123. if (permanent.TopCard.HasLevel)
  124. {
  125. return true;
  126. }
  127. }
  128. }
  129. return false;
  130. }
  131. bool CanUseCondition(Hashtable hashtable)
  132. {
  133. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  134. }
  135. bool CanActivateCondition(Hashtable hashtable)
  136. {
  137. if (CardEffectCommons.IsExistOnBattleArea(card))
  138. {
  139. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  140. {
  141. return true;
  142. }
  143. }
  144. return false;
  145. }
  146. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  147. {
  148. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  149. {
  150. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  151. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  152. selectPermanentEffect.SetUp(
  153. selectPlayer: card.Owner,
  154. canTargetCondition: CanSelectPermanentCondition,
  155. canTargetCondition_ByPreSelecetedList: null,
  156. canEndSelectCondition: null,
  157. maxCount: maxCount,
  158. canNoSelect: true,
  159. canEndNotMax: false,
  160. selectPermanentCoroutine: SelectPermanentCoroutine,
  161. afterSelectPermanentCoroutine: null,
  162. mode: SelectPermanentEffect.Mode.Custom,
  163. cardEffect: activateClass);
  164. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to delete.", "The opponent is selecting 1 Digimon to delete.");
  165. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  166. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  167. {
  168. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DeletePeremanentAndProcessAccordingToResult(
  169. targetPermanents: new List<Permanent>() { permanent },
  170. activateClass: activateClass,
  171. successProcess: permanents => SuccessProcess(),
  172. failureProcess: null));
  173. IEnumerator SuccessProcess()
  174. {
  175. Permanent selectedPermanent = card.PermanentOfThisCard();
  176. yield return ContinuousController.instance.StartCoroutine(new IUnsuspendPermanents(new List<Permanent>() { selectedPermanent }, activateClass).Unsuspend());
  177. }
  178. }
  179. }
  180. }
  181. }
  182. if (timing == EffectTiming.None)
  183. {
  184. ChangeEndTurnMinMemoryClass changeEndTurnMinMemoryClass = new ChangeEndTurnMinMemoryClass();
  185. changeEndTurnMinMemoryClass.SetUpICardEffect("The turn end condition is the opponent having 3 or more memory.", CanUseCondition, card);
  186. changeEndTurnMinMemoryClass.SetUpChangeEndTurnMinMemoryClass(minMemory => 3);
  187. cardEffects.Add(changeEndTurnMinMemoryClass);
  188. bool CanUseCondition(Hashtable hashtable)
  189. {
  190. if (CardEffectCommons.IsExistOnBattleArea(card))
  191. {
  192. if (CardEffectCommons.IsOwnerTurn(card))
  193. {
  194. return true;
  195. }
  196. }
  197. return false;
  198. }
  199. }
  200. return cardEffects;
  201. }
  202. }
  203. }