BT19_036.cs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. namespace DCGO.CardEffects.BT19
  5. {
  6. public class BT19_036 : CEntity_Effect
  7. {
  8. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  9. {
  10. List<ICardEffect> cardEffects = new List<ICardEffect>();
  11. #region Digivolution Condition
  12. if (timing == EffectTiming.None)
  13. {
  14. bool PermanentCondition(Permanent targetPermanent)
  15. {
  16. return targetPermanent.TopCard.EqualsCardName("Wizardmon");
  17. }
  18. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 0, ignoreDigivolutionRequirement: false, card: card, condition: null));
  19. }
  20. #endregion
  21. #region On Play
  22. if (timing == EffectTiming.OnEnterFieldAnyone)
  23. {
  24. ActivateClass activateClass = new ActivateClass();
  25. activateClass.SetUpICardEffect("Add top security card to hand and place 1 Option card as bottom security", CanUseCondition, card);
  26. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  27. cardEffects.Add(activateClass);
  28. string EffectDiscription()
  29. {
  30. return "[On Play] Add your top security card to the hand. Then, if [Wizardmon]/[X Antibody] is in this Digimon's digivolution cards, you may place 1 yellow or purple Option card with cost of 5 or less from your hand as your bottom security card.";
  31. }
  32. bool CanUseCondition(Hashtable hashtable)
  33. {
  34. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  35. }
  36. bool CanSelectCardCondition(CardSource cardSource)
  37. {
  38. if (cardSource.IsOption)
  39. {
  40. if (cardSource.HasCardColor(CardColor.Yellow) || cardSource.HasCardColor(CardColor.Purple))
  41. {
  42. if(cardSource.HasUseCost && cardSource.GetCostItself <= 5)
  43. {
  44. return true;
  45. }
  46. }
  47. }
  48. return false;
  49. }
  50. bool CanActivateCondition(Hashtable hashtable)
  51. {
  52. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  53. }
  54. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  55. {
  56. if (card.Owner.SecurityCards.Count >= 1)
  57. {
  58. CardSource topCard = card.Owner.SecurityCards[0];
  59. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddHandCards(new List<CardSource>() { topCard }, false, activateClass));
  60. yield return ContinuousController.instance.StartCoroutine(new IReduceSecurity(
  61. player: card.Owner,
  62. refSkillInfos: ref ContinuousController.instance.nullSkillInfos,
  63. activateClass).ReduceSecurity());
  64. }
  65. if (card.PermanentOfThisCard().DigivolutionCards.Count((cardSource) => cardSource.EqualsCardName("Wizardmon") || cardSource.EqualsCardName("X Antibody")) >= 1)
  66. {
  67. if (card.Owner.CanAddSecurity(activateClass))
  68. {
  69. if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  70. {
  71. List<CardSource> selectedCards = new List<CardSource>();
  72. int maxCount = 1;
  73. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  74. selectHandEffect.SetUp(
  75. selectPlayer: card.Owner,
  76. canTargetCondition: CanSelectCardCondition,
  77. canTargetCondition_ByPreSelecetedList: null,
  78. canEndSelectCondition: null,
  79. maxCount: maxCount,
  80. canNoSelect: true,
  81. canEndNotMax: false,
  82. isShowOpponent: true,
  83. selectCardCoroutine: SelectCardCoroutine,
  84. afterSelectCardCoroutine: null,
  85. mode: SelectHandEffect.Mode.Custom,
  86. cardEffect: activateClass);
  87. selectHandEffect.SetUpCustomMessage(
  88. "Select 1 card to place at the bottom of security.",
  89. "The opponent is selecting 1 card to place at the bottom of security.");
  90. selectHandEffect.SetUpCustomMessage_ShowCard("Security Bottom Card");
  91. yield return StartCoroutine(selectHandEffect.Activate());
  92. IEnumerator SelectCardCoroutine(CardSource cardSource)
  93. {
  94. selectedCards.Add(cardSource);
  95. yield return null;
  96. }
  97. foreach (CardSource cardSource in selectedCards)
  98. {
  99. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddSecurityCard(cardSource, toTop: false));
  100. }
  101. }
  102. }
  103. }
  104. }
  105. }
  106. #endregion
  107. #region When Digivolving
  108. if (timing == EffectTiming.OnEnterFieldAnyone)
  109. {
  110. ActivateClass activateClass = new ActivateClass();
  111. activateClass.SetUpICardEffect("Add top security card to hand and place 1 Option card as bottom security", CanUseCondition, card);
  112. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  113. cardEffects.Add(activateClass);
  114. string EffectDiscription()
  115. {
  116. return "[When Digivolving] Add your top security card to the hand. Then, if [Wizardmon]/[X Antibody] is in this Digimon's digivolution cards, you may place 1 yellow or purple Option card with cost of 5 or less from your hand as your bottom security card.";
  117. }
  118. bool CanUseCondition(Hashtable hashtable)
  119. {
  120. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  121. {
  122. if (CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card))
  123. {
  124. return true;
  125. }
  126. }
  127. return false;
  128. }
  129. bool CanSelectCardCondition(CardSource cardSource)
  130. {
  131. if (cardSource.IsOption)
  132. {
  133. if (cardSource.HasCardColor(CardColor.Yellow) || cardSource.HasCardColor(CardColor.Purple))
  134. {
  135. if (cardSource.HasUseCost && cardSource.GetCostItself <= 5)
  136. {
  137. return true;
  138. }
  139. }
  140. }
  141. return false;
  142. }
  143. bool CanActivateCondition(Hashtable hashtable)
  144. {
  145. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  146. }
  147. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  148. {
  149. if (card.Owner.SecurityCards.Count >= 1)
  150. {
  151. CardSource topCard = card.Owner.SecurityCards[0];
  152. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddHandCards(new List<CardSource>() { topCard }, false, activateClass));
  153. yield return ContinuousController.instance.StartCoroutine(new IReduceSecurity(
  154. player: card.Owner,
  155. refSkillInfos: ref ContinuousController.instance.nullSkillInfos,
  156. activateClass).ReduceSecurity());
  157. }
  158. if (card.PermanentOfThisCard().DigivolutionCards.Count((cardSource) => cardSource.EqualsCardName("Wizardmon") || cardSource.EqualsCardName("X Antibody")) >= 1)
  159. {
  160. if (card.Owner.CanAddSecurity(activateClass))
  161. {
  162. if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  163. {
  164. List<CardSource> selectedCards = new List<CardSource>();
  165. int maxCount = 1;
  166. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  167. selectHandEffect.SetUp(
  168. selectPlayer: card.Owner,
  169. canTargetCondition: CanSelectCardCondition,
  170. canTargetCondition_ByPreSelecetedList: null,
  171. canEndSelectCondition: null,
  172. maxCount: maxCount,
  173. canNoSelect: true,
  174. canEndNotMax: false,
  175. isShowOpponent: true,
  176. selectCardCoroutine: SelectCardCoroutine,
  177. afterSelectCardCoroutine: null,
  178. mode: SelectHandEffect.Mode.Custom,
  179. cardEffect: activateClass);
  180. selectHandEffect.SetUpCustomMessage(
  181. "Select 1 card to place at the bottom of security.",
  182. "The opponent is selecting 1 card to place at the bottom of security.");
  183. selectHandEffect.SetUpCustomMessage_ShowCard("Security Bottom Card");
  184. yield return StartCoroutine(selectHandEffect.Activate());
  185. IEnumerator SelectCardCoroutine(CardSource cardSource)
  186. {
  187. selectedCards.Add(cardSource);
  188. yield return null;
  189. }
  190. foreach (CardSource cardSource in selectedCards)
  191. {
  192. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddSecurityCard(cardSource, toTop: false));
  193. }
  194. }
  195. }
  196. }
  197. }
  198. }
  199. #endregion
  200. #region Inherit
  201. if (timing == EffectTiming.WhenRemoveField)
  202. {
  203. ActivateClass activateClass = new ActivateClass();
  204. activateClass.SetUpICardEffect("Trash 1 security to prevent this Digimon from leaving Battle Area", CanUseCondition, card);
  205. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  206. activateClass.SetHashString("TrashSecurityToStay_WizardmonXAntibody_BT19_036");
  207. activateClass.SetIsInheritedEffect(true);
  208. cardEffects.Add(activateClass);
  209. string EffectDiscription()
  210. {
  211. return "[All Turns][Once Per Turn] When this yellow Digimon with the [Data]/[Witchelny] trait would leave the battle area by your opponent's effects, by trashing your top security card, it doesn't leave.";
  212. }
  213. bool CanUseCondition(Hashtable hashtable)
  214. {
  215. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  216. {
  217. if (CardEffectCommons.CanTriggerWhenRemoveField(hashtable, card))
  218. {
  219. if (CardEffectCommons.IsByEffect(hashtable, cardEffect => CardEffectCommons.IsOpponentEffect(cardEffect, card)))
  220. return true;
  221. }
  222. }
  223. return false;
  224. }
  225. bool CanActivateCondition(Hashtable hashtable)
  226. {
  227. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  228. {
  229. Permanent thisPermanent = card.PermanentOfThisCard();
  230. if (thisPermanent.TopCard.CardColors.Contains(CardColor.Yellow) && (thisPermanent.TopCard.ContainsTraits("Data") || thisPermanent.TopCard.ContainsTraits("Witchelny")))
  231. {
  232. if (card.Owner.SecurityCards.Count >= 1)
  233. return true;
  234. }
  235. }
  236. return false;
  237. }
  238. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  239. {
  240. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card) || card.Owner.SecurityCards.Count >= 1)
  241. {
  242. yield return ContinuousController.instance.StartCoroutine(new IDestroySecurity(
  243. player: card.Owner,
  244. destroySecurityCount: 1,
  245. cardEffect: activateClass,
  246. fromTop: true).DestroySecurity());
  247. Permanent thisCardPermanent = card.PermanentOfThisCard();
  248. thisCardPermanent.willBeRemoveField = false;
  249. thisCardPermanent.HideDeleteEffect();
  250. thisCardPermanent.HideHandBounceEffect();
  251. thisCardPermanent.HideDeckBounceEffect();
  252. thisCardPermanent.HideWillRemoveFieldEffect();
  253. yield return null;
  254. }
  255. }
  256. }
  257. #endregion
  258. return cardEffects;
  259. }
  260. }
  261. }