XAntibodyProtoForm_EX5_070.cs 15 KB

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