BT13_028.cs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.BT13
  6. {
  7. public class BT13_028 : 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("Your 1 [Jellymon] digivolves into this card", CanUseCondition, card);
  16. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDiscription());
  17. cardEffects.Add(activateClass);
  18. string EffectDiscription()
  19. {
  20. return "[Hand][Main] If you have [Kiyoshiro Higashimitarai], by placing 1 [TeslaJellymon] from your hand as 1 of your [Jellymon]'s bottom digivolution card, that Digimon digivolves into this card for a digivolution cost of 3, ignoring digivolution requirements.";
  21. }
  22. bool CanSelectCardCondition(CardSource cardSource)
  23. {
  24. return cardSource.CardNames.Contains("TeslaJellymon");
  25. }
  26. bool CanSelectPermanentCondition(Permanent permanent)
  27. {
  28. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card))
  29. {
  30. if (permanent.TopCard.CardNames.Contains("Jellymon"))
  31. {
  32. if (!permanent.IsToken)
  33. {
  34. return true;
  35. }
  36. }
  37. }
  38. return false;
  39. }
  40. bool CanUseCondition(Hashtable hashtable)
  41. {
  42. if (card.Owner.HandCards.Contains(card))
  43. {
  44. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, (permanent) => permanent.TopCard.CardNames.Contains("Kiyoshiro Higashimitarai") || permanent.TopCard.CardNames.Contains("KiyoshiroHigashimitarai")))
  45. {
  46. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  47. {
  48. if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  49. {
  50. return true;
  51. }
  52. }
  53. }
  54. }
  55. return false;
  56. }
  57. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  58. {
  59. if (card.Owner.HandCards.Contains(card))
  60. {
  61. bool added = false;
  62. Permanent selectedPermanent = null;
  63. if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  64. {
  65. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  66. {
  67. CardSource selectedCard = null;
  68. int maxCount = 1;
  69. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  70. selectHandEffect.SetUp(
  71. selectPlayer: card.Owner,
  72. canTargetCondition: CanSelectCardCondition,
  73. canTargetCondition_ByPreSelecetedList: null,
  74. canEndSelectCondition: null,
  75. maxCount: maxCount,
  76. canNoSelect: true,
  77. canEndNotMax: false,
  78. isShowOpponent: true,
  79. selectCardCoroutine: SelectCardCoroutine,
  80. afterSelectCardCoroutine: null,
  81. mode: SelectHandEffect.Mode.Custom,
  82. cardEffect: activateClass);
  83. selectHandEffect.SetUpCustomMessage("Select 1 card to place at the bottom of digivolution cards.", "The opponent is selecting 1 card to place at the bottom of digivolution cards.");
  84. yield return StartCoroutine(selectHandEffect.Activate());
  85. IEnumerator SelectCardCoroutine(CardSource cardSource)
  86. {
  87. selectedCard = cardSource;
  88. yield return null;
  89. }
  90. if (selectedCard != null)
  91. {
  92. maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  93. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  94. selectPermanentEffect.SetUp(
  95. selectPlayer: card.Owner,
  96. canTargetCondition: CanSelectPermanentCondition,
  97. canTargetCondition_ByPreSelecetedList: null,
  98. canEndSelectCondition: null,
  99. maxCount: maxCount,
  100. canNoSelect: true,
  101. canEndNotMax: false,
  102. selectPermanentCoroutine: SelectPermanentCoroutine,
  103. afterSelectPermanentCoroutine: null,
  104. mode: SelectPermanentEffect.Mode.Custom,
  105. cardEffect: activateClass);
  106. selectPermanentEffect.SetUpCustomMessage("Select 1 [Jellymon] that will get a digivolution card.", "The opponent is selecting 1 [Jellymon] that will get a digivolution card.");
  107. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  108. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  109. {
  110. selectedPermanent = permanent;
  111. if (selectedPermanent != null)
  112. {
  113. yield return ContinuousController.instance.StartCoroutine(selectedPermanent.AddDigivolutionCardsBottom(new List<CardSource>() { selectedCard }, activateClass));
  114. added = true;
  115. }
  116. }
  117. }
  118. }
  119. }
  120. if (added)
  121. {
  122. if (selectedPermanent != null)
  123. {
  124. if (card.Owner.HandCards.Contains(card))
  125. {
  126. #region ignore digivolution requirements
  127. AddDigivolutionRequirementClass addEvolutionConditionClass = new AddDigivolutionRequirementClass();
  128. addEvolutionConditionClass.SetUpICardEffect("Ignore Digivolution requirements", CanUseCondition1, card);
  129. addEvolutionConditionClass.SetUpAddDigivolutionRequirementClass(getEvoCost: GetEvoCost);
  130. Func<EffectTiming, ICardEffect> getCardEffect = GetCardEffect;
  131. card.Owner.UntilCalculateFixedCostEffect.Add(getCardEffect);
  132. ICardEffect GetCardEffect(EffectTiming _timing)
  133. {
  134. if (_timing == EffectTiming.None)
  135. {
  136. return addEvolutionConditionClass;
  137. }
  138. return null;
  139. }
  140. bool CanUseCondition1(Hashtable hashtable)
  141. {
  142. return true;
  143. }
  144. int GetEvoCost(Permanent permanent, CardSource cardSource, CardEffectCommons.IgnoreRequirement ignore, bool checkAvailability)
  145. {
  146. if (card.Owner.CanIgnoreDigivolutionRequirement(permanent, cardSource))
  147. {
  148. if (CardSourceCondition(cardSource) && PermanentCondition(permanent))
  149. {
  150. return 3;
  151. }
  152. }
  153. return -1;
  154. }
  155. bool PermanentCondition(Permanent targetPermanent)
  156. {
  157. return targetPermanent == selectedPermanent;
  158. }
  159. bool CardSourceCondition(CardSource cardSource)
  160. {
  161. return cardSource == card;
  162. }
  163. #endregion
  164. if (card.CanPlayCardTargetFrame(selectedPermanent.PermanentFrame, true, activateClass))
  165. {
  166. yield return ContinuousController.instance.StartCoroutine(new PlayCardClass(
  167. cardSources: new List<CardSource>() { card },
  168. hashtable: CardEffectCommons.CardEffectHashtable(activateClass),
  169. payCost: true,
  170. targetPermanent: selectedPermanent,
  171. isTapped: false,
  172. root: SelectCardEffect.Root.Hand,
  173. activateETB: true).PlayCard());
  174. }
  175. #region release ignore digivolution requirements
  176. card.Owner.UntilCalculateFixedCostEffect.Remove(getCardEffect);
  177. #endregion
  178. }
  179. }
  180. }
  181. }
  182. }
  183. }
  184. if (timing == EffectTiming.OnEndAttack)
  185. {
  186. ActivateClass activateClass = new ActivateClass();
  187. activateClass.SetUpICardEffect("Return cards from trash to the bottom of deck to unsuspend this Digimon", CanUseCondition, card);
  188. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  189. activateClass.SetIsInheritedEffect(true);
  190. activateClass.SetHashString("Unsuspend_BT13_028");
  191. cardEffects.Add(activateClass);
  192. string EffectDiscription()
  193. {
  194. return "[End of Attack][Once Per Turn] By returning 3 cards with [Jellymon] in their text from your trash at the bottom of the deck in any order, unsuspend this Digimon.";
  195. }
  196. bool CanSelectCardCondition(CardSource cardSource)
  197. {
  198. return cardSource.HasText("Jellymon");
  199. }
  200. bool CanUseCondition(Hashtable hashtable)
  201. {
  202. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  203. }
  204. bool CanActivateCondition(Hashtable hashtable)
  205. {
  206. if (CardEffectCommons.IsExistOnBattleArea(card))
  207. {
  208. if (card.Owner.TrashCards.Count(CanSelectCardCondition) >= 3)
  209. {
  210. return true;
  211. }
  212. }
  213. return false;
  214. }
  215. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  216. {
  217. if (card.Owner.TrashCards.Count(CanSelectCardCondition) >= 3)
  218. {
  219. int maxCount = 3;
  220. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  221. selectCardEffect.SetUp(
  222. canTargetCondition: (cardSource) => CanSelectCardCondition(cardSource),
  223. canTargetCondition_ByPreSelecetedList: null,
  224. canEndSelectCondition: null,
  225. canNoSelect: () => false,
  226. selectCardCoroutine: null,
  227. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  228. message: "Select cards to place at the bottom of the deck\n(cards will be placed back to the bottom of the deck so that cards with lower numbers are on top).",
  229. maxCount: maxCount,
  230. canEndNotMax: false,
  231. isShowOpponent: false,
  232. mode: SelectCardEffect.Mode.Custom,
  233. root: SelectCardEffect.Root.Trash,
  234. customRootCardList: null,
  235. canLookReverseCard: true,
  236. selectPlayer: card.Owner,
  237. cardEffect: activateClass);
  238. selectCardEffect.SetNotShowCard();
  239. selectCardEffect.SetNotAddLog();
  240. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  241. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  242. {
  243. if (cardSources.Count == 3)
  244. {
  245. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddLibraryBottomCards(cardSources));
  246. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().ShowCardEffect(cardSources, "Deck Bottom Cards", true, true));
  247. if (CardEffectCommons.IsExistOnBattleArea(card))
  248. {
  249. Permanent selectedPermanent = card.PermanentOfThisCard();
  250. yield return ContinuousController.instance.StartCoroutine(new IUnsuspendPermanents(new List<Permanent>() { selectedPermanent }, activateClass).Unsuspend());
  251. }
  252. }
  253. }
  254. }
  255. }
  256. }
  257. return cardEffects;
  258. }
  259. }
  260. }