BT4_087.cs 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. public class BT4_087 : CEntity_Effect
  6. {
  7. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  8. {
  9. List<ICardEffect> cardEffects = new List<ICardEffect>();
  10. if (timing == EffectTiming.OnEnterFieldAnyone)
  11. {
  12. ActivateClass activateClass = new ActivateClass();
  13. activateClass.SetUpICardEffect("Play 1 level 3 Digimon from trash", CanUseCondition, card);
  14. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  15. cardEffects.Add(activateClass);
  16. string EffectDiscription()
  17. {
  18. return "[When Digivolving] You may play 1 level 3 Digimon card from your trash without paying its memory cost.";
  19. }
  20. bool CanSelectCardCondition(CardSource cardSource)
  21. {
  22. if (cardSource.IsDigimon)
  23. {
  24. if (cardSource.Level == 3)
  25. {
  26. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  27. {
  28. if (cardSource.HasLevel)
  29. {
  30. return true;
  31. }
  32. }
  33. }
  34. }
  35. return false;
  36. }
  37. bool CanUseCondition(Hashtable hashtable)
  38. {
  39. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  40. }
  41. bool CanActivateCondition(Hashtable hashtable)
  42. {
  43. if (CardEffectCommons.IsExistOnBattleArea(card))
  44. {
  45. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  46. {
  47. return true;
  48. }
  49. }
  50. return false;
  51. }
  52. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  53. {
  54. int maxCount = Math.Min(1, card.Owner.TrashCards.Count((cardSource) => CanSelectCardCondition(cardSource)));
  55. List<CardSource> selectedCards = new List<CardSource>();
  56. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  57. selectCardEffect.SetUp(
  58. canTargetCondition: CanSelectCardCondition,
  59. canTargetCondition_ByPreSelecetedList: null,
  60. canEndSelectCondition: null,
  61. canNoSelect: () => true,
  62. selectCardCoroutine: SelectCardCoroutine,
  63. afterSelectCardCoroutine: null,
  64. message: "Select 1 card to play.",
  65. maxCount: maxCount,
  66. canEndNotMax: false,
  67. isShowOpponent: true,
  68. mode: SelectCardEffect.Mode.Custom,
  69. root: SelectCardEffect.Root.Trash,
  70. customRootCardList: null,
  71. canLookReverseCard: true,
  72. selectPlayer: card.Owner,
  73. cardEffect: activateClass);
  74. selectCardEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  75. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  76. yield return StartCoroutine(selectCardEffect.Activate());
  77. IEnumerator SelectCardCoroutine(CardSource cardSource)
  78. {
  79. selectedCards.Add(cardSource);
  80. yield return null;
  81. }
  82. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(cardSources: selectedCards, activateClass: activateClass, payCost: false, isTapped: false, root: SelectCardEffect.Root.Trash, activateETB: true));
  83. }
  84. }
  85. if (timing == EffectTiming.OnEnterFieldAnyone)
  86. {
  87. ActivateClass activateClass = new ActivateClass();
  88. activateClass.SetUpICardEffect("The played Digimon gains Rush", CanUseCondition, card);
  89. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  90. cardEffects.Add(activateClass);
  91. string EffectDiscription()
  92. {
  93. return "[Your Turn] When you play a Digimon from your trash, that Digimon gains <Rush> for the turn. (This Digimon can attack the turn it comes into play.)";
  94. }
  95. bool PermanentCondition(Permanent permanent)
  96. {
  97. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card);
  98. }
  99. bool RootCondition(SelectCardEffect.Root root)
  100. {
  101. return root == SelectCardEffect.Root.Trash;
  102. }
  103. bool CanUseCondition(Hashtable hashtable)
  104. {
  105. if (CardEffectCommons.IsExistOnBattleArea(card))
  106. {
  107. if (CardEffectCommons.IsOwnerTurn(card))
  108. {
  109. if (CardEffectCommons.CanTriggerOnPermanentPlay(hashtable, PermanentCondition, RootCondition))
  110. {
  111. return true;
  112. }
  113. }
  114. }
  115. return false;
  116. }
  117. bool CanActivateCondition(Hashtable hashtable)
  118. {
  119. if (CardEffectCommons.IsExistOnBattleArea(card))
  120. {
  121. List<Permanent> permanents = CardEffectCommons.GetPlayedPermanentsFromEnterFieldHashtable(
  122. hashtable: hashtable,
  123. rootCondition: RootCondition);
  124. if (permanents != null)
  125. {
  126. if (permanents.Count(CardEffectCommons.IsPermanentExistsOnBattleArea) >= 1)
  127. {
  128. return true;
  129. }
  130. }
  131. }
  132. return false;
  133. }
  134. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  135. {
  136. List<Permanent> permanents = CardEffectCommons.GetPlayedPermanentsFromEnterFieldHashtable(
  137. hashtable: _hashtable,
  138. rootCondition: RootCondition);
  139. if (permanents != null)
  140. {
  141. foreach (Permanent permanent in permanents.Filter(CardEffectCommons.IsPermanentExistsOnBattleArea).Clone())
  142. {
  143. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainRush(
  144. targetPermanent: permanent,
  145. effectDuration: EffectDuration.UntilEachTurnEnd,
  146. activateClass: activateClass));
  147. }
  148. }
  149. }
  150. }
  151. return cardEffects;
  152. }
  153. }