BT23_025.cs 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. // MarineAngemon
  5. namespace DCGO.CardEffects.BT23
  6. {
  7. public class BT23_025 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Alternative Digivolution Condition
  13. if (timing == EffectTiming.None)
  14. {
  15. bool PermanentCondition(Permanent targetPermanent)
  16. {
  17. return targetPermanent.TopCard.IsLevel5 && targetPermanent.TopCard.HasCSTraits;
  18. }
  19. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  20. permanentCondition: PermanentCondition,
  21. digivolutionCost: 3,
  22. ignoreDigivolutionRequirement: false,
  23. card: card,
  24. condition: null)
  25. );
  26. }
  27. #endregion
  28. #region Hand - Main
  29. if (timing == EffectTiming.OnDeclaration)
  30. {
  31. ActivateClass activateClass = new ActivateClass();
  32. activateClass.SetUpICardEffect("Give 3 Digimon Sec-1", CanUseCondition, card);
  33. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, true, EffectDescription());
  34. cardEffects.Add(activateClass);
  35. string EffectDescription()
  36. {
  37. return "[Hand] [Main] If you have a Digimon or Tamer with the [CS] trait, by paying 5 cost, give 3 of your opponent's Digimon <Security A. -1> until their turn ends. Then, place this card as the top security card.";
  38. }
  39. bool IsCSDigimonOrTamer(Permanent permanent)
  40. {
  41. bool isCSDigimon = CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card) &&
  42. permanent.TopCard.HasCSTraits;
  43. bool isCSTamer = CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card) &&
  44. permanent.TopCard.IsTamer &&
  45. permanent.TopCard.HasCSTraits;
  46. return isCSDigimon || isCSTamer;
  47. }
  48. bool IsOpponentDigimon(Permanent permanent)
  49. {
  50. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  51. {
  52. return true;
  53. }
  54. return false;
  55. }
  56. bool CanUseCondition(Hashtable hashtable)
  57. {
  58. // Can use from your hand, if you have a CS digimon or tamer
  59. return CardEffectCommons.IsExistOnHand(card)
  60. && CardEffectCommons.IsOwnerTurn(card)
  61. && CardEffectCommons.HasMatchConditionOwnersPermanent(card, IsCSDigimonOrTamer);
  62. }
  63. IEnumerator ActivateCoroutine(Hashtable hashtable)
  64. {
  65. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, IsCSDigimonOrTamer))
  66. {
  67. // First, select 3 opponent's digimon on the field
  68. int maxCount = Math.Min(3, CardEffectCommons.MatchConditionPermanentCount(IsOpponentDigimon));
  69. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  70. selectPermanentEffect.SetUp(
  71. selectPlayer: card.Owner,
  72. canTargetCondition: IsOpponentDigimon,
  73. canTargetCondition_ByPreSelecetedList: null,
  74. canEndSelectCondition: null,
  75. maxCount: maxCount,
  76. canNoSelect: false,
  77. canEndNotMax: false,
  78. selectPermanentCoroutine: SelectPermanentCoroutine,
  79. afterSelectPermanentCoroutine: null,
  80. mode: SelectPermanentEffect.Mode.Custom,
  81. cardEffect: activateClass);
  82. selectPermanentEffect.SetUpCustomMessage("Select 3 Digimon that will get Security Attack -1.", "The opponent is selecting 3 Digimon that will get Security Attack -1.");
  83. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  84. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  85. {
  86. // To the permanents selected, apply the Sec-1.
  87. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonSAttack(targetPermanent: permanent, changeValue: -1, effectDuration: EffectDuration.UntilOpponentTurnEnd, activateClass: activateClass));
  88. yield return null;
  89. }
  90. // Either way, pay the 5 cost, then place this card as the top security card.
  91. yield return ContinuousController.instance.StartCoroutine(card.Owner.AddMemory(-5, activateClass));
  92. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddSecurityCard(card, true, false));
  93. }
  94. }
  95. }
  96. #endregion
  97. #region On Play/When Digivolving Shared
  98. bool IsLowestLevelOpponentDigimon(Permanent permanent)
  99. {
  100. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  101. {
  102. if (CardEffectCommons.IsMinLevel(permanent, card.Owner.Enemy))
  103. {
  104. return true;
  105. }
  106. }
  107. return false;
  108. }
  109. #endregion
  110. #region On Play
  111. if (timing == EffectTiming.OnEnterFieldAnyone)
  112. {
  113. ActivateClass activateClass = new ActivateClass();
  114. activateClass.SetUpICardEffect("Return 1 of your opponent's Digimon to hand", CanUseCondition, card);
  115. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription());
  116. cardEffects.Add(activateClass);
  117. string EffectDescription()
  118. {
  119. return
  120. "[On Play] Return 1 of your opponent's Digimon with the lowest level to the hand.";
  121. }
  122. bool CanUseCondition(Hashtable hashtable)
  123. {
  124. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  125. }
  126. bool CanActivateCondition(Hashtable hashtable)
  127. {
  128. if (CardEffectCommons.IsExistOnBattleArea(card))
  129. {
  130. if (CardEffectCommons.HasMatchConditionPermanent(IsLowestLevelOpponentDigimon))
  131. {
  132. return true;
  133. }
  134. }
  135. return false;
  136. }
  137. IEnumerator ActivateCoroutine(Hashtable hashtable)
  138. {
  139. if (CardEffectCommons.HasMatchConditionPermanent(IsLowestLevelOpponentDigimon))
  140. {
  141. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(IsLowestLevelOpponentDigimon));
  142. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  143. selectPermanentEffect.SetUp(
  144. selectPlayer: card.Owner,
  145. canTargetCondition: IsLowestLevelOpponentDigimon,
  146. canTargetCondition_ByPreSelecetedList: null,
  147. canEndSelectCondition: null,
  148. maxCount: maxCount,
  149. canNoSelect: false,
  150. canEndNotMax: false,
  151. selectPermanentCoroutine: null,
  152. afterSelectPermanentCoroutine: null,
  153. mode: SelectPermanentEffect.Mode.Bounce,
  154. cardEffect: activateClass);
  155. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  156. }
  157. }
  158. }
  159. #endregion
  160. #region When Digivolving
  161. if (timing == EffectTiming.OnEnterFieldAnyone)
  162. {
  163. ActivateClass activateClass = new ActivateClass();
  164. activateClass.SetUpICardEffect("Return 1 of your opponent's Digimon to hand", CanUseCondition, card);
  165. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription());
  166. cardEffects.Add(activateClass);
  167. string EffectDescription()
  168. {
  169. return
  170. "[When Digivolving] Return 1 of your opponent's Digimon with the lowest level to the hand.";
  171. }
  172. bool CanUseCondition(Hashtable hashtable)
  173. {
  174. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  175. }
  176. bool CanActivateCondition(Hashtable hashtable)
  177. {
  178. if (CardEffectCommons.IsExistOnBattleArea(card))
  179. {
  180. if (CardEffectCommons.HasMatchConditionPermanent(IsLowestLevelOpponentDigimon))
  181. {
  182. return true;
  183. }
  184. }
  185. return false;
  186. }
  187. IEnumerator ActivateCoroutine(Hashtable hashtable)
  188. {
  189. if (CardEffectCommons.HasMatchConditionPermanent(IsLowestLevelOpponentDigimon))
  190. {
  191. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(IsLowestLevelOpponentDigimon));
  192. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  193. selectPermanentEffect.SetUp(
  194. selectPlayer: card.Owner,
  195. canTargetCondition: IsLowestLevelOpponentDigimon,
  196. canTargetCondition_ByPreSelecetedList: null,
  197. canEndSelectCondition: null,
  198. maxCount: maxCount,
  199. canNoSelect: false,
  200. canEndNotMax: false,
  201. selectPermanentCoroutine: null,
  202. afterSelectPermanentCoroutine: null,
  203. mode: SelectPermanentEffect.Mode.Bounce,
  204. cardEffect: activateClass);
  205. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  206. }
  207. }
  208. }
  209. #endregion
  210. #region Security
  211. if (timing == EffectTiming.SecuritySkill)
  212. {
  213. // Ugh, I don't like doing this, but I think in order to delete the digimon played after the security battle, I have to be able to
  214. // activate the deletion effect from within the ActivateCoroutine of the function. Instead of calling CardEffectFactory.PlaySelfDigimonAfterBattleSecurityEffect,
  215. // I need to copy the code from that function here, then modify the necessary sections...
  216. ActivateClass activateClass = new ActivateClass();
  217. activateClass.SetUpICardEffect("Play this card at the end of the battle", CanUseCondition, card);
  218. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  219. activateClass.SetIsSecurityEffect(true);
  220. string EffectDiscription()
  221. {
  222. return "[Security] At the end of the battle, play this card without paying its memory cost.";
  223. }
  224. bool CanUseCondition(Hashtable hashtable)
  225. {
  226. return CardEffectCommons.CanTriggerSecurityEffect(hashtable, card);
  227. }
  228. bool CanActivateCondition(Hashtable hashtable)
  229. {
  230. if (CardEffectCommons.IsExistOnExecutingArea(card))
  231. {
  232. return true;
  233. }
  234. return false;
  235. }
  236. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  237. {
  238. yield return null;
  239. ContinuousController.instance.PlaySE(GManager.instance.GetComponent<Effects>().BuffSE);
  240. ActivateClass activateClass1 = new ActivateClass();
  241. activateClass1.SetUpICardEffect("Play this card", CanUseCondition1, card);
  242. activateClass1.SetUpActivateClass(CanActivateCondition1, ActivateCoroutine1, -1, false, EffectDiscription1());
  243. card.Owner.UntilEndBattleEffects.Add(GetCardEffect1);
  244. string EffectDiscription1()
  245. {
  246. return "Play this card without paying its memory cost.";
  247. }
  248. bool CanUseCondition1(Hashtable hashtable)
  249. {
  250. return true;
  251. }
  252. bool CanActivateCondition1(Hashtable hashtable)
  253. {
  254. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: card, payCost: false, cardEffect: activateClass1, root: SelectCardEffect.Root.Security))
  255. {
  256. if (!card.Owner.LibraryCards.Contains(card) && !card.Owner.SecurityCards.Contains(card))
  257. {
  258. return true;
  259. }
  260. }
  261. return false;
  262. }
  263. ICardEffect GetCardEffect1(EffectTiming _timing)
  264. {
  265. if (_timing == EffectTiming.OnEndBattle)
  266. {
  267. return activateClass1;
  268. }
  269. return null;
  270. }
  271. IEnumerator ActivateCoroutine1(Hashtable _hashtable1)
  272. {
  273. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: card, payCost: false, cardEffect: activateClass1, root: SelectCardEffect.Root.Security))
  274. {
  275. if (!card.Owner.LibraryCards.Contains(card) && !card.Owner.SecurityCards.Contains(card))
  276. {
  277. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  278. cardSources: new List<CardSource>() { card },
  279. activateClass: activateClass1,
  280. payCost: false,
  281. isTapped: false,
  282. root: SelectCardEffect.Root.Security,
  283. activateETB: true));
  284. #region Delete Played Digimon
  285. Permanent selectedPermanent = card.PermanentOfThisCard();
  286. ActivateClass activateClassDeleteSelf = new ActivateClass();
  287. activateClassDeleteSelf.SetUpICardEffect("Delete this Digimon", CanUseDeleteSelfCondition, selectedPermanent.TopCard);
  288. activateClassDeleteSelf.SetUpActivateClass(CanActivateDeleteSelfCondition, ActivateDeleteSelfCoroutine, -1, false, EffectDiscription2());
  289. activateClassDeleteSelf.SetEffectSourcePermanent(selectedPermanent);
  290. selectedPermanent.UntilOwnerTurnEndEffects.Add(GetDeleteSelfCardEffect);
  291. if (!selectedPermanent.TopCard.CanNotBeAffected(activateClass1))
  292. {
  293. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().CreateDebuffEffect(selectedPermanent));
  294. }
  295. string EffectDiscription2()
  296. {
  297. return "[End of Your Turn] Delete this Digimon.";
  298. }
  299. bool CanUseDeleteSelfCondition(Hashtable hashtable2)
  300. {
  301. if (CardEffectCommons.IsOpponentTurn(card))
  302. {
  303. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(selectedPermanent, selectedPermanent.TopCard))
  304. {
  305. if (CardEffectCommons.CanTriggerOnEndAttack(hashtable2, selectedPermanent.TopCard))
  306. {
  307. return true;
  308. }
  309. }
  310. }
  311. return false;
  312. }
  313. bool CanActivateDeleteSelfCondition(Hashtable hashtable2)
  314. {
  315. if (CardEffectCommons.IsPermanentExistsOnBattleArea(selectedPermanent))
  316. {
  317. if (!selectedPermanent.TopCard.CanNotBeAffected(activateClass1))
  318. {
  319. return true;
  320. }
  321. }
  322. return false;
  323. }
  324. IEnumerator ActivateDeleteSelfCoroutine(Hashtable _hashtable2)
  325. {
  326. if (CardEffectCommons.IsPermanentExistsOnBattleArea(selectedPermanent))
  327. {
  328. yield return ContinuousController.instance.StartCoroutine(new DestroyPermanentsClass(
  329. new List<Permanent>() { selectedPermanent },
  330. CardEffectCommons.CardEffectHashtable(activateClassDeleteSelf)).Destroy());
  331. }
  332. }
  333. ICardEffect GetDeleteSelfCardEffect(EffectTiming _timing)
  334. {
  335. if (_timing == EffectTiming.OnEndTurn)
  336. {
  337. return activateClassDeleteSelf;
  338. }
  339. return null;
  340. }
  341. #endregion
  342. }
  343. }
  344. }
  345. }
  346. }
  347. #endregion
  348. return cardEffects;
  349. }
  350. }
  351. }