BT20_019.cs 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.BT20
  6. {
  7. public class BT20_019 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Alternate Digivolution Requirement
  13. if (timing == EffectTiming.None)
  14. {
  15. bool PermanentCondition(Permanent targetPermanent)
  16. {
  17. return targetPermanent.TopCard.EqualsCardName("Jesmon");
  18. }
  19. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 1, ignoreDigivolutionRequirement: false, card: card, condition: null));
  20. }
  21. #endregion
  22. #region Alliance
  23. if (timing == EffectTiming.OnAllyAttack)
  24. {
  25. cardEffects.Add(CardEffectFactory.AllianceSelfEffect(isInheritedEffect: false, card: card, condition: null));
  26. }
  27. #endregion
  28. #region When Digivolving
  29. if (timing == EffectTiming.OnEnterFieldAnyone)
  30. {
  31. ActivateClass activateClass = new ActivateClass();
  32. activateClass.SetUpICardEffect("Become unaffected by opponents effects, then can attack", CanUseCondition, card);
  33. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  34. cardEffects.Add(activateClass);
  35. string EffectDiscription()
  36. {
  37. return "[When Digivolving] If [Jesmon] or [X Antibody] is in this Digimon's digivolution cards, for the turn, 1 of your Digimon isn't affected by your opponent's effects. Then, 1 of your Digimon may attack.";
  38. }
  39. bool SourceCondition(CardSource source)
  40. {
  41. return source.EqualsCardName("Jesmon") || source.EqualsCardName("X Antibody");
  42. }
  43. bool CanSelectCondition(Permanent permanent)
  44. {
  45. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card);
  46. }
  47. bool CanUseCondition(Hashtable hashtable)
  48. {
  49. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  50. CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  51. }
  52. bool CanActivateCondition(Hashtable hashtable)
  53. {
  54. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  55. }
  56. IEnumerator ActivateCoroutine(Hashtable hashtable)
  57. {
  58. Permanent this_card = card.PermanentOfThisCard();
  59. if (this_card != null)
  60. {
  61. if (card.PermanentOfThisCard().DigivolutionCards.Count(SourceCondition) >= 1)
  62. {
  63. #region select immunity recipient
  64. {
  65. Permanent immunityPermanent = null;
  66. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectCondition));
  67. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  68. selectPermanentEffect.SetUp(
  69. selectPlayer: card.Owner,
  70. canTargetCondition: CanSelectCondition,
  71. canTargetCondition_ByPreSelecetedList: null,
  72. canEndSelectCondition: null,
  73. maxCount: maxCount,
  74. canNoSelect: false,
  75. canEndNotMax: false,
  76. selectPermanentCoroutine: SelectPermanentCoroutine,
  77. afterSelectPermanentCoroutine: null,
  78. mode: SelectPermanentEffect.Mode.Custom,
  79. cardEffect: activateClass);
  80. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will be immune from your opponent's effects.", "Opponent is selecting 1 Digimon that will be immune from your effects.");
  81. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  82. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  83. {
  84. immunityPermanent = permanent;
  85. yield return null;
  86. }
  87. if(immunityPermanent != null)
  88. {
  89. CanNotAffectedClass canNotAffectedClass = new CanNotAffectedClass();
  90. canNotAffectedClass.SetUpICardEffect("Isn't affected by opponent's effects.", CanUseConditionImmunity, card);
  91. canNotAffectedClass.SetUpCanNotAffectedClass(CardCondition: CardCondition, SkillCondition: SkillCondition);
  92. immunityPermanent.UntilEachTurnEndEffects.Add((_timing) => canNotAffectedClass);
  93. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().CreateBuffEffect(immunityPermanent));
  94. bool CanUseConditionImmunity(Hashtable hashtable)
  95. {
  96. return true;
  97. }
  98. bool CardCondition(CardSource cardSource)
  99. {
  100. if (CardEffectCommons.IsExistOnBattleAreaDigimon(cardSource))
  101. {
  102. if (cardSource == immunityPermanent.TopCard)
  103. {
  104. return true;
  105. }
  106. }
  107. return false;
  108. }
  109. bool SkillCondition(ICardEffect cardEffect)
  110. {
  111. if (CardEffectCommons.IsOpponentEffect(cardEffect, card))
  112. {
  113. return true;
  114. }
  115. return false;
  116. }
  117. }
  118. }
  119. #endregion
  120. }
  121. #region Select attacker
  122. {
  123. bool CanSelectAttackPermanentCondition(Permanent permanent)
  124. {
  125. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  126. {
  127. if (permanent.CanAttack(activateClass))
  128. {
  129. return true;
  130. }
  131. }
  132. return false;
  133. }
  134. Permanent selectedAttacker = null;
  135. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectAttackPermanentCondition));
  136. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  137. selectPermanentEffect.SetUp(
  138. selectPlayer: card.Owner,
  139. canTargetCondition: CanSelectAttackPermanentCondition,
  140. canTargetCondition_ByPreSelecetedList: null,
  141. canEndSelectCondition: null,
  142. maxCount: maxCount,
  143. canNoSelect: true,
  144. canEndNotMax: false,
  145. selectPermanentCoroutine: SelectPermanentCoroutine,
  146. afterSelectPermanentCoroutine: null,
  147. mode: SelectPermanentEffect.Mode.Custom,
  148. cardEffect: activateClass);
  149. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will attack.", "Opponent is selecting 1 Digimon that will attack.");
  150. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  151. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  152. {
  153. selectedAttacker = permanent;
  154. yield return null;
  155. }
  156. if (selectedAttacker != null)
  157. {
  158. SelectAttackEffect selectAttackEffect = GManager.instance.GetComponent<SelectAttackEffect>();
  159. selectAttackEffect.SetUp(
  160. attacker: selectedAttacker,
  161. canAttackPlayerCondition: () => true,
  162. defenderCondition: (permanent) => true,
  163. cardEffect: activateClass);
  164. yield return ContinuousController.instance.StartCoroutine(selectAttackEffect.Activate());
  165. }
  166. }
  167. #endregion
  168. }
  169. }
  170. }
  171. #endregion
  172. #region Your Turn
  173. if (timing == EffectTiming.None)
  174. {
  175. AddSkillClass addSkillClass = new AddSkillClass();
  176. addSkillClass.SetUpICardEffect("Your Digimon with [Sistermon] in their names or the [Royal Knight] trait gain Pierce", CanUseCondition, card);
  177. addSkillClass.SetUpAddSkillClass(cardSourceCondition: CardSourceCondition, getEffects: GetEffects);
  178. cardEffects.Add(addSkillClass);
  179. bool CanUseCondition(Hashtable hashtable)
  180. {
  181. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  182. {
  183. if (CardEffectCommons.IsOwnerTurn(card))
  184. {
  185. return true;
  186. }
  187. }
  188. return false;
  189. }
  190. bool PermanentCondition(Permanent permanent)
  191. {
  192. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  193. {
  194. if (permanent.TopCard.ContainsCardName("Sistermon") || permanent.TopCard.HasRoyalKnightTraits)
  195. return true;
  196. }
  197. return false;
  198. }
  199. bool CardSourceCondition(CardSource cardSource)
  200. {
  201. if (PermanentCondition(cardSource.PermanentOfThisCard()))
  202. {
  203. if (cardSource == cardSource.PermanentOfThisCard().TopCard)
  204. {
  205. return true;
  206. }
  207. }
  208. return false;
  209. }
  210. List<ICardEffect> GetEffects(CardSource cardSource, List<ICardEffect> cardEffects, EffectTiming _timing)
  211. {
  212. if (_timing == EffectTiming.OnDetermineDoSecurityCheck)
  213. {
  214. bool Condition()
  215. {
  216. return CardSourceCondition(cardSource);
  217. }
  218. cardEffects.Add(CardEffectFactory.PierceSelfEffect(
  219. isInheritedEffect: false,
  220. card: cardSource,
  221. condition: Condition));
  222. }
  223. return cardEffects;
  224. }
  225. }
  226. if (timing == EffectTiming.None)
  227. {
  228. CanAttackTargetDefendingPermanentClass canAttackTargetDefendingPermanentClass = new CanAttackTargetDefendingPermanentClass();
  229. canAttackTargetDefendingPermanentClass.SetUpICardEffect($"Can attack to unsuspended Digimon", CanUseCondition, card);
  230. canAttackTargetDefendingPermanentClass.SetUpCanAttackTargetDefendingPermanentClass(attackerCondition: PermanentCondition, defenderCondition: DefenderCondition, cardEffectCondition: CardEffectCondition);
  231. cardEffects.Add(canAttackTargetDefendingPermanentClass);
  232. bool PermanentCondition(Permanent permanent)
  233. {
  234. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  235. {
  236. if (permanent.TopCard.ContainsCardName("Sistermon") || permanent.TopCard.HasRoyalKnightTraits)
  237. return true;
  238. }
  239. return false;
  240. }
  241. bool CanUseCondition(Hashtable hashtable)
  242. {
  243. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  244. {
  245. if (CardEffectCommons.IsOwnerTurn(card))
  246. {
  247. return true;
  248. }
  249. }
  250. return false;
  251. }
  252. bool DefenderCondition(Permanent permanent)
  253. {
  254. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  255. {
  256. if (!permanent.IsSuspended)
  257. {
  258. return true;
  259. }
  260. }
  261. return false;
  262. }
  263. bool CardEffectCondition(ICardEffect cardEffect)
  264. {
  265. return true;
  266. }
  267. }
  268. #endregion
  269. #region Your Turn - ESS
  270. if (timing == EffectTiming.None)
  271. {
  272. AddSkillClass addSkillClass = new AddSkillClass();
  273. addSkillClass.SetUpICardEffect("[Your Turn] While this Digimon is [Jesmon GX], all of your Digimon gain <Piercing> and can also attack your opponent's unsuspended Digimon.", CanUseCondition, card);
  274. addSkillClass.SetUpAddSkillClass(cardSourceCondition: CardSourceCondition, getEffects: GetEffects);
  275. addSkillClass.SetIsInheritedEffect(true);
  276. cardEffects.Add(addSkillClass);
  277. bool CanUseCondition(Hashtable hashtable)
  278. {
  279. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  280. {
  281. if (CardEffectCommons.IsOwnerTurn(card))
  282. {
  283. return true;
  284. }
  285. }
  286. return false;
  287. }
  288. bool PermanentCondition(Permanent permanent)
  289. {
  290. return card.PermanentOfThisCard().TopCard.EqualsCardName("Jesmon GX") &&
  291. CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card);
  292. }
  293. bool CardSourceCondition(CardSource cardSource)
  294. {
  295. return CardEffectCommons.IsExistOnBattleAreaDigimon(cardSource) &&
  296. CardEffectCommons.IsOwnerPermanent(cardSource.PermanentOfThisCard(), card);
  297. }
  298. List<ICardEffect> GetEffects(CardSource cardSource, List<ICardEffect> cardEffects, EffectTiming _timing)
  299. {
  300. if (_timing == EffectTiming.OnDetermineDoSecurityCheck)
  301. {
  302. bool Condition()
  303. {
  304. return card.PermanentOfThisCard().TopCard.EqualsCardName("Jesmon GX") &&
  305. CardSourceCondition(cardSource);
  306. }
  307. cardEffects.Add(CardEffectFactory.PierceSelfEffect(isInheritedEffect: false, card: card, condition: Condition));
  308. }
  309. return cardEffects;
  310. }
  311. CanAttackTargetDefendingPermanentClass canAttackTargetDefendingPermanentClass = new CanAttackTargetDefendingPermanentClass();
  312. canAttackTargetDefendingPermanentClass.SetUpICardEffect($"Can attack to unsuspended Digimon", CanUseCondition1, card);
  313. canAttackTargetDefendingPermanentClass.SetUpCanAttackTargetDefendingPermanentClass(attackerCondition: PermanentCondition, defenderCondition: DefenderCondition, cardEffectCondition: CardEffectCondition);
  314. canAttackTargetDefendingPermanentClass.SetIsInheritedEffect(true);
  315. cardEffects.Add(canAttackTargetDefendingPermanentClass);
  316. bool CanUseCondition1(Hashtable hashtable)
  317. {
  318. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  319. }
  320. bool DefenderCondition(Permanent permanent)
  321. {
  322. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  323. {
  324. if (!permanent.IsSuspended)
  325. {
  326. return true;
  327. }
  328. }
  329. return false;
  330. }
  331. bool CardEffectCondition(ICardEffect cardEffect)
  332. {
  333. return true;
  334. }
  335. }
  336. #endregion
  337. return cardEffects;
  338. }
  339. }
  340. }