BT9_104.cs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322
  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 BT9_104 : 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.None)
  14. {
  15. IgnoreColorConditionClass ignoreColorConditionClass = new IgnoreColorConditionClass();
  16. ignoreColorConditionClass.SetUpICardEffect("Ignore color requirements", CanUseCondition, card);
  17. ignoreColorConditionClass.SetUpIgnoreColorConditionClass(cardCondition: CardCondition);
  18. cardEffects.Add(ignoreColorConditionClass);
  19. bool CanUseCondition(Hashtable hashtable)
  20. {
  21. if (card.Owner.GetBattleAreaDigimons().Count((permanet) => permanet.TopCard.HasXAntibodyTraits) >= 1)
  22. {
  23. return true;
  24. }
  25. return false;
  26. }
  27. bool CardCondition(CardSource cardSource)
  28. {
  29. if (cardSource == card)
  30. {
  31. return true;
  32. }
  33. return false;
  34. }
  35. }
  36. if (timing == EffectTiming.OptionSkill)
  37. {
  38. ActivateClass activateClass = new ActivateClass();
  39. activateClass.SetUpICardEffect(card.BaseENGCardNameFromEntity, CanUseCondition, card);
  40. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDiscription());
  41. cardEffects.Add(activateClass);
  42. string EffectDiscription()
  43. {
  44. return "[Main] Reveal the top 3 cards of your deck. You may digivolve 1 of your Digimon into a Digimon card with [X Antibody] in its traits among them without paying its memory cost. Trash the rest. Then, place 1 card with [X Antibody] in its traits from your trash under 1 of your Digimon with [X Antibody] in its traits as its bottom digivolution card.";
  45. }
  46. bool CanSelectCardCondition(CardSource cardSource)
  47. {
  48. if (cardSource.HasXAntibodyTraits)
  49. {
  50. if (cardSource.IsDigimon)
  51. {
  52. foreach (Permanent permanent in card.Owner.GetBattleAreaDigimons())
  53. {
  54. if (cardSource.CanPlayCardTargetFrame(permanent.PermanentFrame, false, activateClass))
  55. {
  56. return true;
  57. }
  58. }
  59. }
  60. }
  61. return false;
  62. }
  63. bool CanSelectCardCondition1(CardSource cardSource)
  64. {
  65. return cardSource.HasXAntibodyTraits;
  66. }
  67. bool CanSelectPermanentCondition1(Permanent permanent)
  68. {
  69. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  70. {
  71. if (permanent.TopCard.HasXAntibodyTraits)
  72. {
  73. if (!permanent.IsToken)
  74. {
  75. return true;
  76. }
  77. }
  78. }
  79. return false;
  80. }
  81. bool CanUseCondition(Hashtable hashtable)
  82. {
  83. return CardEffectCommons.CanTriggerOptionMainEffect(hashtable, card);
  84. }
  85. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  86. {
  87. CardSource selectedCard = null;
  88. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.SimplifiedRevealDeckTopCardsAndSelect(
  89. revealCount: 3,
  90. simplifiedSelectCardConditions:
  91. new SimplifiedSelectCardConditionClass[]
  92. {
  93. new SimplifiedSelectCardConditionClass(
  94. canTargetCondition:CanSelectCardCondition,
  95. message: "Select 1 Digimon card with [X Antibody] in its traits to digivolve.",
  96. mode: SelectCardEffect.Mode.Custom,
  97. maxCount: 1,
  98. selectCardCoroutine: SelectCardCoroutine),
  99. },
  100. remainingCardsPlace: RemainingCardsPlace.Trash,
  101. activateClass: activateClass,
  102. canNoSelect: true
  103. ));
  104. IEnumerator SelectCardCoroutine(CardSource cardSource)
  105. {
  106. selectedCard = cardSource;
  107. yield return null;
  108. }
  109. if (selectedCard != null)
  110. {
  111. bool CanSelectPermanentCondition(Permanent permanent)
  112. {
  113. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  114. {
  115. if (selectedCard.CanPlayCardTargetFrame(permanent.PermanentFrame, false, activateClass))
  116. {
  117. return true;
  118. }
  119. }
  120. return false;
  121. }
  122. Permanent selectedPermanent = null;
  123. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  124. {
  125. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  126. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  127. selectPermanentEffect.SetUp(
  128. selectPlayer: card.Owner,
  129. canTargetCondition: CanSelectPermanentCondition,
  130. canTargetCondition_ByPreSelecetedList: null,
  131. canEndSelectCondition: null,
  132. maxCount: maxCount,
  133. canNoSelect: true,
  134. canEndNotMax: false,
  135. selectPermanentCoroutine: SelectPermanentCoroutine,
  136. afterSelectPermanentCoroutine: null,
  137. mode: SelectPermanentEffect.Mode.Custom,
  138. cardEffect: activateClass);
  139. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will digivolve.", "The opponent is selecting 1 Digimon that will digivolve.");
  140. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  141. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  142. {
  143. selectedPermanent = permanent;
  144. yield return null;
  145. }
  146. }
  147. if (selectedPermanent != null)
  148. {
  149. if (selectedCard.CanPlayCardTargetFrame(selectedPermanent.PermanentFrame, false, activateClass))
  150. {
  151. yield return ContinuousController.instance.StartCoroutine(new PlayCardClass(
  152. cardSources: new List<CardSource>() { selectedCard },
  153. hashtable: CardEffectCommons.CardEffectHashtable(activateClass),
  154. payCost: false,
  155. targetPermanent: selectedPermanent,
  156. isTapped: false,
  157. root: SelectCardEffect.Root.Library,
  158. activateETB: true).PlayCard());
  159. }
  160. }
  161. else
  162. {
  163. yield return ContinuousController.instance.StartCoroutine(new ITrashDeckCards(new List<CardSource>() { selectedCard }, activateClass).TrashDeckCards());
  164. }
  165. }
  166. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition1) && card.Owner.GetBattleAreaDigimons().Count(CanSelectPermanentCondition1) >= 1)
  167. {
  168. List<CardSource> selectedCards = new List<CardSource>();
  169. int maxCount = 1;
  170. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  171. selectCardEffect.SetUp(
  172. canTargetCondition: CanSelectCardCondition1,
  173. canTargetCondition_ByPreSelecetedList: null,
  174. canEndSelectCondition: null,
  175. canNoSelect: () => false,
  176. selectCardCoroutine: SelectCardCoroutine1,
  177. afterSelectCardCoroutine: null,
  178. message: "Select 1 card to place on bottom of digivolution cards.",
  179. maxCount: maxCount,
  180. canEndNotMax: false,
  181. isShowOpponent: true,
  182. mode: SelectCardEffect.Mode.Custom,
  183. root: SelectCardEffect.Root.Trash,
  184. customRootCardList: null,
  185. canLookReverseCard: true,
  186. selectPlayer: card.Owner,
  187. cardEffect: activateClass);
  188. selectCardEffect.SetUpCustomMessage_ShowCard("Digivolution Card");
  189. selectCardEffect.SetUpCustomMessage("Select 1 card to place on bottom of digivolution cards.", "The opponent is selecting 1 card to place on bottom of digivolution cards.");
  190. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  191. IEnumerator SelectCardCoroutine1(CardSource cardSource)
  192. {
  193. selectedCards.Add(cardSource);
  194. yield return null;
  195. }
  196. if (selectedCards.Count >= 1)
  197. {
  198. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition1))
  199. {
  200. maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition1));
  201. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  202. selectPermanentEffect.SetUp(
  203. selectPlayer: card.Owner,
  204. canTargetCondition: CanSelectPermanentCondition1,
  205. canTargetCondition_ByPreSelecetedList: null,
  206. canEndSelectCondition: null,
  207. maxCount: maxCount,
  208. canNoSelect: false,
  209. canEndNotMax: false,
  210. selectPermanentCoroutine: SelectPermanentCoroutine,
  211. afterSelectPermanentCoroutine: null,
  212. mode: SelectPermanentEffect.Mode.Custom,
  213. cardEffect: activateClass);
  214. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will get a digivolution card.", "The opponent is selecting 1 Digimon that will get a digivolution card.");
  215. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  216. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  217. {
  218. Permanent selectedPermanent = permanent;
  219. if (selectedPermanent != null)
  220. {
  221. yield return ContinuousController.instance.StartCoroutine(selectedPermanent.AddDigivolutionCardsBottom(selectedCards, activateClass));
  222. }
  223. }
  224. }
  225. }
  226. }
  227. }
  228. }
  229. if (timing == EffectTiming.SecuritySkill)
  230. {
  231. ActivateClass activateClass = new ActivateClass();
  232. activateClass.SetUpICardEffect($"Reveal the top 3 cards of deck", CanUseCondition, card);
  233. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, true, EffectDiscription());
  234. activateClass.SetIsSecurityEffect(true);
  235. cardEffects.Add(activateClass);
  236. string EffectDiscription()
  237. {
  238. return "[Security] You may reveal the top 3 cards of your deck. Add 1 card with [X Antibody] in its traits among them to your hand. Trash the rest.";
  239. }
  240. bool CanSelectCardCondition(CardSource cardSource)
  241. {
  242. return cardSource.HasXAntibodyTraits;
  243. }
  244. bool CanUseCondition(Hashtable hashtable)
  245. {
  246. return CardEffectCommons.CanTriggerSecurityEffect(hashtable, card);
  247. }
  248. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  249. {
  250. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.SimplifiedRevealDeckTopCardsAndSelect(
  251. revealCount: 3,
  252. simplifiedSelectCardConditions:
  253. new SimplifiedSelectCardConditionClass[]
  254. {
  255. new SimplifiedSelectCardConditionClass(
  256. canTargetCondition:CanSelectCardCondition,
  257. message: "Select 1 card with [X Antibody] in its traits.",
  258. mode: SelectCardEffect.Mode.AddHand,
  259. maxCount: 1,
  260. selectCardCoroutine: null),
  261. },
  262. remainingCardsPlace: RemainingCardsPlace.Trash,
  263. activateClass: activateClass
  264. ));
  265. }
  266. }
  267. return cardEffects;
  268. }
  269. }