EX5_070.cs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. public class EX5_070 : 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.None)
  11. {
  12. ChangeCardNamesClass changeCardNamesClass = new ChangeCardNamesClass();
  13. changeCardNamesClass.SetUpICardEffect("Also treated as [X Antibody]", CanUseCondition, card);
  14. changeCardNamesClass.SetUpChangeCardNamesClass(changeCardNames: changeCardNames);
  15. cardEffects.Add(changeCardNamesClass);
  16. bool CanUseCondition(Hashtable hashtable)
  17. {
  18. return true;
  19. }
  20. List<string> changeCardNames(CardSource cardSource, List<string> CardNames)
  21. {
  22. if (cardSource == card)
  23. {
  24. CardNames.Add("X Antibody");
  25. }
  26. return CardNames;
  27. }
  28. }
  29. if (timing == EffectTiming.None)
  30. {
  31. IgnoreColorConditionClass ignoreColorConditionClass = new IgnoreColorConditionClass();
  32. ignoreColorConditionClass.SetUpICardEffect("Ignore color requirements", CanUseCondition, card);
  33. ignoreColorConditionClass.SetUpIgnoreColorConditionClass(cardCondition: CardCondition);
  34. cardEffects.Add(ignoreColorConditionClass);
  35. bool CanUseCondition(Hashtable hashtable)
  36. {
  37. return card.Owner.GetBattleAreaDigimons().Count >= 1;
  38. }
  39. bool CardCondition(CardSource cardSource)
  40. {
  41. return cardSource == card;
  42. }
  43. }
  44. if (timing == EffectTiming.SecuritySkill)
  45. {
  46. ActivateClass activateClass = new ActivateClass();
  47. activateClass.SetUpICardEffect($"Add this card to hand", CanUseCondition, card);
  48. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDiscription());
  49. activateClass.SetIsSecurityEffect(true);
  50. cardEffects.Add(activateClass);
  51. string EffectDiscription()
  52. {
  53. return "[Security] Add this card to its owner's hand.";
  54. }
  55. bool CanUseCondition(Hashtable hashtable)
  56. {
  57. return CardEffectCommons.CanTriggerSecurityEffect(hashtable, card);
  58. }
  59. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  60. {
  61. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.AddThisCardToHand(card, activateClass));
  62. }
  63. }
  64. if (timing == EffectTiming.OptionSkill)
  65. {
  66. ActivateClass activateClass = new ActivateClass();
  67. activateClass.SetUpICardEffect(card.BaseENGCardNameFromEntity, CanUseCondition, card);
  68. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDiscription());
  69. cardEffects.Add(activateClass);
  70. string EffectDiscription()
  71. {
  72. return "[Main] 1 of your Digimon without [X Antibody] in its digivolution cards may digivolve into a Digimon card with the [X Antibody] trait in your hand with the digivolution cost reduced by 1. If it did, place this card as its bottom digivolution card.";
  73. }
  74. bool CanSelectPermanentCondition(Permanent permanent)
  75. {
  76. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  77. {
  78. foreach (CardSource cardSource in card.Owner.HandCards)
  79. {
  80. if (CanSelectCardCondition(cardSource))
  81. {
  82. if (cardSource.CanPlayCardTargetFrame(permanent.PermanentFrame, false, activateClass))
  83. {
  84. if (permanent.DigivolutionCards.Count((cardSource) => cardSource.CardNames.Contains("X Antibody") || cardSource.CardNames.Contains("XAntibody")) == 0)
  85. {
  86. return true;
  87. }
  88. }
  89. }
  90. }
  91. }
  92. return false;
  93. }
  94. bool CanSelectCardCondition(CardSource cardSource)
  95. {
  96. return cardSource.IsDigimon && cardSource.HasXAntibodyTraits;
  97. }
  98. bool CanUseCondition(Hashtable hashtable)
  99. {
  100. return CardEffectCommons.CanTriggerOptionMainEffect(hashtable, card);
  101. }
  102. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  103. {
  104. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  105. {
  106. Permanent selectedPermanent = null;
  107. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  108. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  109. selectPermanentEffect.SetUp(
  110. selectPlayer: card.Owner,
  111. canTargetCondition: CanSelectPermanentCondition,
  112. canTargetCondition_ByPreSelecetedList: null,
  113. canEndSelectCondition: null,
  114. maxCount: maxCount,
  115. canNoSelect: true,
  116. canEndNotMax: false,
  117. selectPermanentCoroutine: SelectPermanentCoroutine,
  118. afterSelectPermanentCoroutine: null,
  119. mode: SelectPermanentEffect.Mode.Custom,
  120. cardEffect: activateClass);
  121. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will digivolve.", "The opponent is selecting 1 Digimon that will digivolve.");
  122. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  123. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  124. {
  125. selectedPermanent = permanent;
  126. yield return null;
  127. }
  128. if (selectedPermanent != null)
  129. {
  130. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DigivolveIntoHandOrTrashCard(
  131. targetPermanent: selectedPermanent,
  132. cardCondition: CanSelectCardCondition,
  133. payCost: true,
  134. reduceCostTuple: (reduceCost: 1, reduceCostCardCondition: null),
  135. fixedCostTuple: null,
  136. ignoreDigivolutionRequirementFixedCost: -1,
  137. isHand: true,
  138. activateClass: activateClass,
  139. successProcess: SuccessProcess()));
  140. IEnumerator SuccessProcess()
  141. {
  142. yield return ContinuousController.instance.StartCoroutine(selectedPermanent.AddDigivolutionCardsBottom(
  143. new List<CardSource>() { card },
  144. activateClass));
  145. }
  146. }
  147. }
  148. }
  149. }
  150. if (timing == EffectTiming.WhenRemoveField)
  151. {
  152. ActivateClass activateClass = new ActivateClass();
  153. activateClass.SetUpICardEffect("Return 1 card from digivolution cards and place 1 [XAntibody] to the top of security", CanUseCondition, card);
  154. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  155. activateClass.SetIsInheritedEffect(true);
  156. activateClass.SetHashString("ReturnCard_EX5_070");
  157. cardEffects.Add(activateClass);
  158. string EffectDiscription()
  159. {
  160. return "[All Turns] When this Digimon would leave the battle area other than by one of your effects, from this Digimon's digivolution cards, return 1 Digimon card to the hand and place 1 [X Antibody] on top of your security stack.";
  161. }
  162. bool CanSelectCardCondition(CardSource cardSource)
  163. {
  164. return cardSource.IsDigimon;
  165. }
  166. bool CanSelectCardCondition1(CardSource cardSource)
  167. {
  168. return cardSource.CardNames.Contains("X Antibody") || cardSource.CardNames.Contains("XAntibody");
  169. }
  170. bool CanUseCondition(Hashtable hashtable)
  171. {
  172. if (CardEffectCommons.IsExistOnBattleArea(card))
  173. {
  174. if (CardEffectCommons.CanTriggerWhenRemoveField(hashtable, card))
  175. {
  176. if (!CardEffectCommons.IsByEffect(hashtable, cardEffect => CardEffectCommons.IsOwnerEffect(cardEffect, card)))
  177. {
  178. return true;
  179. }
  180. }
  181. }
  182. return false;
  183. }
  184. bool CanActivateCondition(Hashtable hashtable)
  185. {
  186. if (CardEffectCommons.IsExistOnBattleArea(card))
  187. {
  188. if (card.PermanentOfThisCard().DigivolutionCards.Some(CanSelectCardCondition))
  189. {
  190. return true;
  191. }
  192. if (card.PermanentOfThisCard().DigivolutionCards.Some(CanSelectCardCondition1))
  193. {
  194. if (card.Owner.CanAddSecurity(activateClass))
  195. {
  196. return true;
  197. }
  198. }
  199. }
  200. return false;
  201. }
  202. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  203. {
  204. if (CardEffectCommons.IsExistOnBattleArea(card))
  205. {
  206. if (card.PermanentOfThisCard().DigivolutionCards.Some(CanSelectCardCondition))
  207. {
  208. int maxCount = Math.Min(1, card.PermanentOfThisCard().DigivolutionCards.Count((cardSource) => CanSelectCardCondition(cardSource)));
  209. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  210. selectCardEffect.SetUp(
  211. canTargetCondition: CanSelectCardCondition,
  212. canTargetCondition_ByPreSelecetedList: null,
  213. canEndSelectCondition: null,
  214. canNoSelect: () => false,
  215. selectCardCoroutine: null,
  216. afterSelectCardCoroutine: null,
  217. message: "Select 1 digivolution card to add to your hand.",
  218. maxCount: maxCount,
  219. canEndNotMax: false,
  220. isShowOpponent: true,
  221. mode: SelectCardEffect.Mode.AddHand,
  222. root: SelectCardEffect.Root.DigivolutionCards,
  223. customRootCardList: card.PermanentOfThisCard().DigivolutionCards,
  224. canLookReverseCard: true,
  225. selectPlayer: card.Owner,
  226. cardEffect: activateClass);
  227. yield return StartCoroutine(selectCardEffect.Activate());
  228. }
  229. }
  230. if (CardEffectCommons.IsExistOnBattleArea(card))
  231. {
  232. if (card.PermanentOfThisCard().DigivolutionCards.Some(CanSelectCardCondition1))
  233. {
  234. List<CardSource> selectedCards = new List<CardSource>();
  235. int maxCount = Math.Min(1, card.PermanentOfThisCard().DigivolutionCards.Count((cardSource) => CanSelectCardCondition1(cardSource)));
  236. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  237. selectCardEffect.SetUp(
  238. canTargetCondition: CanSelectCardCondition1,
  239. canTargetCondition_ByPreSelecetedList: null,
  240. canEndSelectCondition: null,
  241. canNoSelect: () => false,
  242. selectCardCoroutine: SelectCardCoroutine,
  243. afterSelectCardCoroutine: null,
  244. message: "Select 1 [X Antibody] from digivolution cards to place at the top of security.",
  245. maxCount: maxCount,
  246. canEndNotMax: false,
  247. isShowOpponent: true,
  248. mode: SelectCardEffect.Mode.Custom,
  249. root: SelectCardEffect.Root.DigivolutionCards,
  250. customRootCardList: card.PermanentOfThisCard().DigivolutionCards,
  251. canLookReverseCard: true,
  252. selectPlayer: card.Owner,
  253. cardEffect: activateClass);
  254. yield return StartCoroutine(selectCardEffect.Activate());
  255. IEnumerator SelectCardCoroutine(CardSource cardSource)
  256. {
  257. selectedCards.Add(cardSource);
  258. yield return null;
  259. }
  260. foreach (CardSource cardSource in selectedCards)
  261. {
  262. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().RemoveDigivolveRootEffect(cardSource, cardSource.PermanentOfThisCard()));
  263. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddSecurityCard(cardSource, toTop: true));
  264. }
  265. }
  266. }
  267. }
  268. }
  269. return cardEffects;
  270. }
  271. }