BT11_029.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  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_029 : 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.OnDeclaration)
  13. {
  14. ActivateClass activateClass = new ActivateClass();
  15. activateClass.SetUpICardEffect("Reveal the top 3 cards of deck", CanUseCondition, card);
  16. activateClass.SetUpActivateClass(null, ActivateCoroutine, 1, false, EffectDiscription());
  17. activateClass.SetHashString("Reveal3_BT11_029");
  18. cardEffects.Add(activateClass);
  19. string EffectDiscription()
  20. {
  21. return "[Main][Once Per Turn] By suspending this Digimon, reveal the top 3 cards of your deck. Add all blue Tamer cards among them to your hand. Place the rest at the bottom of your deck in any order.";
  22. }
  23. bool CanSelectCardCondition(CardSource cardSource)
  24. {
  25. if (cardSource.IsTamer)
  26. {
  27. if (cardSource.HasCardColor(CardColor.Blue))
  28. {
  29. return true;
  30. }
  31. }
  32. return false;
  33. }
  34. bool CanUseCondition(Hashtable hashtable)
  35. {
  36. if (CardEffectCommons.IsExistOnBattleArea(card))
  37. {
  38. if (!card.PermanentOfThisCard().IsSuspended && card.PermanentOfThisCard().CanSuspend)
  39. {
  40. return true;
  41. }
  42. }
  43. return false;
  44. }
  45. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  46. {
  47. yield return ContinuousController.instance.StartCoroutine(new SuspendPermanentsClass(new List<Permanent>() { card.PermanentOfThisCard() }, CardEffectCommons.CardEffectHashtable(activateClass)).Tap());
  48. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.RevealDeckTopCardsAndProcessForAll(
  49. revealCount: 3,
  50. simplifiedSelectCardCondition:
  51. new SimplifiedSelectCardConditionClass(
  52. canTargetCondition: CanSelectCardCondition,
  53. message: "",
  54. mode: SelectCardEffect.Mode.AddHand,
  55. maxCount: -1,
  56. selectCardCoroutine: null),
  57. remainingCardsPlace: RemainingCardsPlace.DeckBottom,
  58. activateClass: activateClass
  59. ));
  60. }
  61. }
  62. if (timing == EffectTiming.OnAllyAttack)
  63. {
  64. ActivateClass activateClass = new ActivateClass();
  65. activateClass.SetUpICardEffect("Activate [On Play] effect", CanUseCondition, card);
  66. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDiscription());
  67. activateClass.SetIsInheritedEffect(true);
  68. activateClass.SetHashString("Activate_BT11_029");
  69. cardEffects.Add(activateClass);
  70. string EffectDiscription()
  71. {
  72. return "[When Attacking][Once Per Turn] Activate 1 of your [Rina Shinomiya]'s [On Play] effects.";
  73. }
  74. bool CanSelectPermanentCondition(Permanent permanent)
  75. {
  76. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card))
  77. {
  78. if (permanent.TopCard.CardNames.Contains("Rina Shinomiya") || permanent.TopCard.CardNames.Contains("RinaShinomiya"))
  79. {
  80. List<ICardEffect> candidateEffects = permanent.EffectList(EffectTiming.OnEnterFieldAnyone)
  81. .Clone()
  82. .Filter(cardEffect => cardEffect != null && cardEffect is ActivateICardEffect && !cardEffect.IsSecurityEffect && cardEffect.IsOnPlay);
  83. if (candidateEffects.Count >= 1)
  84. {
  85. return true;
  86. }
  87. }
  88. }
  89. return false;
  90. }
  91. bool CanUseCondition(Hashtable hashtable)
  92. {
  93. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  94. }
  95. bool CanActivateCondition(Hashtable hashtable)
  96. {
  97. if (CardEffectCommons.IsExistOnBattleArea(card))
  98. {
  99. return true;
  100. }
  101. return false;
  102. }
  103. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  104. {
  105. if (card.Owner.GetBattleAreaPermanents().Count(CanSelectPermanentCondition) >= 1)
  106. {
  107. Permanent selectedPermanent = null;
  108. int maxCount = Math.Min(1, card.Owner.GetBattleAreaPermanents().Count(CanSelectPermanentCondition));
  109. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  110. selectPermanentEffect.SetUp(
  111. selectPlayer: card.Owner,
  112. canTargetCondition: CanSelectPermanentCondition,
  113. canTargetCondition_ByPreSelecetedList: null,
  114. canEndSelectCondition: null,
  115. maxCount: maxCount,
  116. canNoSelect: false,
  117. canEndNotMax: false,
  118. selectPermanentCoroutine: null,
  119. afterSelectPermanentCoroutine: AfterSelectPermanentCoroutine,
  120. mode: SelectPermanentEffect.Mode.Custom,
  121. cardEffect: activateClass);
  122. selectPermanentEffect.SetUpCustomMessage("Select 1 [Rina Shinomiya].", "The opponent is selecting 1 [Rina Shinomiya].");
  123. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  124. IEnumerator AfterSelectPermanentCoroutine(List<Permanent> permanents)
  125. {
  126. foreach (Permanent permanent in permanents)
  127. {
  128. selectedPermanent = permanent;
  129. }
  130. yield return null;
  131. }
  132. if (selectedPermanent != null)
  133. {
  134. List<ICardEffect> candidateEffects = selectedPermanent.EffectList(EffectTiming.OnEnterFieldAnyone)
  135. .Clone()
  136. .Filter(cardEffect => cardEffect != null && cardEffect is ActivateICardEffect && !cardEffect.IsSecurityEffect && cardEffect.IsOnPlay);
  137. if (candidateEffects.Count >= 1)
  138. {
  139. ICardEffect selectedEffect = null;
  140. if (candidateEffects.Count == 1)
  141. {
  142. selectedEffect = candidateEffects[0];
  143. }
  144. else
  145. {
  146. List<SkillInfo> skillInfos = candidateEffects
  147. .Map(cardEffect => new SkillInfo(cardEffect, null, EffectTiming.None));
  148. List<CardSource> cardSources = candidateEffects
  149. .Map(cardEffect => cardEffect.EffectSourceCard);
  150. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  151. selectCardEffect.SetUp(
  152. canTargetCondition: (cardSource) => true,
  153. canTargetCondition_ByPreSelecetedList: null,
  154. canEndSelectCondition: null,
  155. canNoSelect: () => false,
  156. selectCardCoroutine: null,
  157. afterSelectCardCoroutine: null,
  158. message: "Select 1 effect to activate.",
  159. maxCount: 1,
  160. canEndNotMax: false,
  161. isShowOpponent: false,
  162. mode: SelectCardEffect.Mode.Custom,
  163. root: SelectCardEffect.Root.Custom,
  164. customRootCardList: cardSources,
  165. canLookReverseCard: true,
  166. selectPlayer: card.Owner,
  167. cardEffect: activateClass);
  168. selectCardEffect.SetNotShowCard();
  169. selectCardEffect.SetUpSkillInfos(skillInfos);
  170. selectCardEffect.SetUpAfterSelectIndexCoroutine(AfterSelectIndexCoroutine);
  171. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  172. IEnumerator AfterSelectIndexCoroutine(List<int> selectedIndexes)
  173. {
  174. if (selectedIndexes.Count == 1)
  175. {
  176. selectedEffect = candidateEffects[selectedIndexes[0]];
  177. yield return null;
  178. }
  179. }
  180. }
  181. if (selectedEffect != null)
  182. {
  183. if (selectedEffect.EffectSourceCard != null)
  184. {
  185. if (selectedEffect.EffectSourceCard.PermanentOfThisCard() != null)
  186. {
  187. Hashtable effectHashtable = CardEffectCommons.OnPlayCheckHashtableOfCard(selectedEffect.EffectSourceCard);
  188. if (selectedEffect.CanUse(effectHashtable))
  189. {
  190. yield return ContinuousController.instance.StartCoroutine(((ActivateICardEffect)selectedEffect).Activate_Optional_Effect_Execute(effectHashtable));
  191. }
  192. }
  193. }
  194. }
  195. }
  196. }
  197. }
  198. }
  199. }
  200. return cardEffects;
  201. }
  202. }
  203. }