P_089.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using System.Linq;
  5. using Photon;
  6. using System;
  7. using Photon.Pun;
  8. public class P_089 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. if (timing == EffectTiming.OnEnterFieldAnyone)
  14. {
  15. ActivateClass activateClass = new ActivateClass();
  16. activateClass.SetUpICardEffect("Trash cards from hand to trash digivolution cards, and opponent's 1 Digimon or Tamer can't suspend", CanUseCondition, card);
  17. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  18. cardEffects.Add(activateClass);
  19. string EffectDiscription()
  20. {
  21. return "[When Digivolving] You may trash up to 3 blue cards from your hand. For each card trashed by this effect, you may trash 1 card under 1 of your opponent's Digimon or Tamers. Then, 1 of your opponent's Digimon or Tamers without cards under it can't suspend until the end of your opponent's turn.";
  22. }
  23. bool CanSelectCardCondition(CardSource cardSource)
  24. {
  25. return cardSource.HasCardColor(CardColor.Blue);
  26. }
  27. bool CanSelectPermanentCondition(Permanent permanent)
  28. {
  29. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleArea(permanent, card))
  30. {
  31. if (permanent.IsDigimon || permanent.IsTamer)
  32. {
  33. if (permanent.DigivolutionCards.Count(CanSelectCardCondition1) >= 1)
  34. {
  35. if (!permanent.TopCard.CanNotBeAffected(activateClass))
  36. {
  37. return true;
  38. }
  39. }
  40. }
  41. }
  42. return false;
  43. }
  44. bool CanSelectCardCondition1(CardSource cardSource)
  45. {
  46. return !cardSource.CanNotTrashFromDigivolutionCards(activateClass);
  47. }
  48. bool CanSelectPermanentCondition1(Permanent permanent)
  49. {
  50. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleArea(permanent, card))
  51. {
  52. if (permanent.IsDigimon || permanent.IsTamer)
  53. {
  54. if (permanent.HasNoDigivolutionCards)
  55. {
  56. return true;
  57. }
  58. }
  59. }
  60. return false;
  61. }
  62. bool CanUseCondition(Hashtable hashtable)
  63. {
  64. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  65. }
  66. bool CanActivateCondition(Hashtable hashtable)
  67. {
  68. if (CardEffectCommons.IsExistOnBattleArea(card))
  69. {
  70. if (card.Owner.HandCards.Count >= 1)
  71. {
  72. return true;
  73. }
  74. if (card.Owner.Enemy.GetBattleAreaPermanents().Count(CanSelectPermanentCondition1) >= 1)
  75. {
  76. return true;
  77. }
  78. }
  79. return false;
  80. }
  81. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  82. {
  83. if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  84. {
  85. List<CardSource> discardCards = new List<CardSource>();
  86. int maxCount = Math.Min(3, card.Owner.HandCards.Count(CanSelectCardCondition));
  87. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  88. selectHandEffect.SetUp(
  89. selectPlayer: card.Owner,
  90. canTargetCondition: CanSelectCardCondition,
  91. canTargetCondition_ByPreSelecetedList: null,
  92. canEndSelectCondition: null,
  93. maxCount: maxCount,
  94. canNoSelect: true,
  95. canEndNotMax: true,
  96. isShowOpponent: true,
  97. selectCardCoroutine: null,
  98. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  99. mode: SelectHandEffect.Mode.Discard,
  100. cardEffect: activateClass);
  101. yield return StartCoroutine(selectHandEffect.Activate());
  102. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  103. {
  104. if (cardSources.Count >= 1)
  105. {
  106. discardCards = cardSources.Clone();
  107. yield return null;
  108. }
  109. }
  110. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.SelectTrashDigivolutionCards(
  111. permanentCondition: CanSelectPermanentCondition,
  112. cardCondition: CanSelectCardCondition1,
  113. maxCount: discardCards.Count,
  114. canNoTrash: true,
  115. isFromOnly1Permanent: false,
  116. activateClass: activateClass,
  117. selectString: "Digimon or Tamer"
  118. ));
  119. }
  120. if (card.Owner.Enemy.GetBattleAreaPermanents().Count(CanSelectPermanentCondition1) >= 1)
  121. {
  122. int maxCount = Math.Min(1, card.Owner.Enemy.GetBattleAreaPermanents().Count(CanSelectPermanentCondition1));
  123. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  124. selectPermanentEffect.SetUp(
  125. selectPlayer: card.Owner,
  126. canTargetCondition: CanSelectPermanentCondition1,
  127. canTargetCondition_ByPreSelecetedList: null,
  128. canEndSelectCondition: null,
  129. maxCount: maxCount,
  130. canNoSelect: false,
  131. canEndNotMax: false,
  132. selectPermanentCoroutine: SelectPermanentCoroutine,
  133. afterSelectPermanentCoroutine: null,
  134. mode: SelectPermanentEffect.Mode.Custom,
  135. cardEffect: activateClass);
  136. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon or Tamer that will get unable to suspend.", "The opponent is selecting 1 Digimon or Tamer that will get unable to suspend.");
  137. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  138. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  139. {
  140. Permanent selectedPermanent = permanent;
  141. if (selectedPermanent != null)
  142. {
  143. CanNotSuspendClass canNotSuspendClass = new CanNotSuspendClass();
  144. canNotSuspendClass.SetUpICardEffect("Can't Suspend", CanUseCondition1, card);
  145. canNotSuspendClass.SetUpCanNotSuspendClass(PermanentCondition: PermanentCondition);
  146. selectedPermanent.UntilOwnerTurnEndEffects.Add((_timing) => canNotSuspendClass);
  147. if (!selectedPermanent.TopCard.CanNotBeAffected(activateClass))
  148. {
  149. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().CreateDebuffEffect(selectedPermanent));
  150. }
  151. bool CanUseCondition1(Hashtable hashtable)
  152. {
  153. if (selectedPermanent.TopCard != null)
  154. {
  155. if (!selectedPermanent.TopCard.CanNotBeAffected(activateClass))
  156. {
  157. return true;
  158. }
  159. }
  160. return false;
  161. }
  162. bool PermanentCondition(Permanent permanent)
  163. {
  164. if (permanent == selectedPermanent)
  165. {
  166. return true;
  167. }
  168. return false;
  169. }
  170. }
  171. }
  172. }
  173. }
  174. }
  175. if (timing == EffectTiming.OnAllyAttack)
  176. {
  177. ActivateClass activateClass = new ActivateClass();
  178. activateClass.SetUpICardEffect("Return cards from trash to the bottom of deck to end the attack", CanUseCondition, card);
  179. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  180. activateClass.SetHashString("EndAttack_P_089");
  181. cardEffects.Add(activateClass);
  182. string EffectDiscription()
  183. {
  184. return "[Opponent's Turn] [Once Per Turn] When an opponent's Digimon attacks, end that attack by returning 3 cards with [Jellymon] in their text from your trash to the bottom of your deck.";
  185. }
  186. bool CanSelectCardCondition(CardSource cardSource)
  187. {
  188. return cardSource.HasText("Jellymon");
  189. }
  190. bool PermanentCondition(Permanent permanent)
  191. {
  192. return CardEffectCommons.IsOpponentPermanent(permanent, card);
  193. }
  194. bool CanUseCondition(Hashtable hashtable)
  195. {
  196. if (CardEffectCommons.IsExistOnBattleArea(card))
  197. {
  198. if (CardEffectCommons.IsOpponentTurn(card))
  199. {
  200. if (CardEffectCommons.CanTriggerOnPermanentAttack(hashtable, PermanentCondition))
  201. {
  202. return true;
  203. }
  204. }
  205. }
  206. return false;
  207. }
  208. bool CanActivateCondition(Hashtable hashtable)
  209. {
  210. if (CardEffectCommons.IsExistOnBattleArea(card))
  211. {
  212. if (card.Owner.TrashCards.Count(CanSelectCardCondition) >= 3)
  213. {
  214. return true;
  215. }
  216. }
  217. return false;
  218. }
  219. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  220. {
  221. if (card.Owner.TrashCards.Count(CanSelectCardCondition) >= 3)
  222. {
  223. int maxCount = 3;
  224. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  225. selectCardEffect.SetUp(
  226. canTargetCondition: (cardSource) => CanSelectCardCondition(cardSource),
  227. canTargetCondition_ByPreSelecetedList: null,
  228. canEndSelectCondition: null,
  229. canNoSelect: () => false,
  230. selectCardCoroutine: null,
  231. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  232. 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).",
  233. maxCount: maxCount,
  234. canEndNotMax: false,
  235. isShowOpponent: false,
  236. mode: SelectCardEffect.Mode.Custom,
  237. root: SelectCardEffect.Root.Trash,
  238. customRootCardList: null,
  239. canLookReverseCard: true,
  240. selectPlayer: card.Owner,
  241. cardEffect: activateClass);
  242. selectCardEffect.SetNotShowCard();
  243. selectCardEffect.SetNotAddLog();
  244. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  245. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  246. {
  247. if (cardSources.Count == 3)
  248. {
  249. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddLibraryBottomCards(cardSources));
  250. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().ShowCardEffect(cardSources, "Deck Bottom Cards", true, true));
  251. yield return ContinuousController.instance.StartCoroutine(GManager.instance.attackProcess.EndAttack());
  252. }
  253. }
  254. }
  255. }
  256. }
  257. return cardEffects;
  258. }
  259. }