BT20_015.cs 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. namespace DCGO.CardEffects.BT20
  4. {
  5. public class BT20_015 : CEntity_Effect
  6. {
  7. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  8. {
  9. List<ICardEffect> cardEffects = new List<ICardEffect>();
  10. #region Alternate Digivolution
  11. if (timing == EffectTiming.None)
  12. {
  13. bool PermanentCondition(Permanent targetPermanent)
  14. {
  15. return (targetPermanent.TopCard.EqualsCardName("Ginryumon")) ||
  16. (targetPermanent.TopCard.IsLevel4 && targetPermanent.TopCard.EqualsTraits("Chronicle"));
  17. }
  18. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  19. permanentCondition: PermanentCondition,
  20. digivolutionCost: 3,
  21. ignoreDigivolutionRequirement: false,
  22. card: card,
  23. condition: null));
  24. }
  25. #endregion
  26. #region On Play
  27. if (timing == EffectTiming.OnEnterFieldAnyone)
  28. {
  29. ActivateClass activateClass = new ActivateClass();
  30. activateClass.SetUpICardEffect("Play 1 Digimon from your hand to your empty breeding area", CanUseCondition, card);
  31. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription());
  32. cardEffects.Add(activateClass);
  33. string EffectDescription()
  34. {
  35. return
  36. "[On Play] You may play 1 [Dorumon]/[Ryudamon] from your hand to your empty breeding area without paying the cost. Then if during an attack, until the end of your opponent's turn, 1 of your Digimon gains <Security Attack +1> and gets +5000 DP.";
  37. }
  38. bool CanUseCondition(Hashtable hashtable)
  39. {
  40. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  41. }
  42. bool IsCorrectRookieCardCondition(CardSource cardSource)
  43. {
  44. return cardSource.IsDigimon &&
  45. (cardSource.EqualsCardName("Dorumon") || cardSource.EqualsCardName("Ryudamon")) &&
  46. CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass,
  47. isBreedingArea: true);
  48. }
  49. bool CanSelectPermanentCondition(Permanent permanent)
  50. {
  51. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card);
  52. }
  53. bool PlayBreedingAreaCondition()
  54. {
  55. return CardEffectCommons.HasMatchConditionOwnersHand(card, IsCorrectRookieCardCondition) &&
  56. card.Owner.GetBreedingAreaPermanents().Count == 0;
  57. }
  58. bool IsAttackingCondition()
  59. {
  60. return GManager.instance.attackProcess.IsAttacking;
  61. }
  62. bool CanActivateCondition(Hashtable hashtable)
  63. {
  64. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  65. (PlayBreedingAreaCondition() || IsAttackingCondition());
  66. }
  67. IEnumerator ActivateCoroutine(Hashtable hashtable)
  68. {
  69. if (PlayBreedingAreaCondition())
  70. {
  71. List<CardSource> selectedCards = new List<CardSource>();
  72. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  73. selectHandEffect.SetUp(
  74. selectPlayer: card.Owner,
  75. canTargetCondition: IsCorrectRookieCardCondition,
  76. canTargetCondition_ByPreSelecetedList: null,
  77. canEndSelectCondition: null,
  78. maxCount: 1,
  79. canNoSelect: true,
  80. canEndNotMax: false,
  81. isShowOpponent: true,
  82. selectCardCoroutine: SelectCardCoroutine,
  83. afterSelectCardCoroutine: null,
  84. mode: SelectHandEffect.Mode.Custom,
  85. cardEffect: activateClass);
  86. selectHandEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  87. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  88. yield return StartCoroutine(selectHandEffect.Activate());
  89. IEnumerator SelectCardCoroutine(CardSource cardSource)
  90. {
  91. selectedCards.Add(cardSource);
  92. yield return null;
  93. }
  94. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  95. cardSources: selectedCards,
  96. activateClass: activateClass,
  97. payCost: false,
  98. isTapped: false,
  99. root: SelectCardEffect.Root.Hand,
  100. activateETB: true,
  101. isBreedingArea: true));
  102. }
  103. if (IsAttackingCondition())
  104. {
  105. Permanent selectedPermanent = null;
  106. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  107. selectPermanentEffect.SetUp(
  108. selectPlayer: card.Owner,
  109. canTargetCondition: CanSelectPermanentCondition,
  110. canTargetCondition_ByPreSelecetedList: null,
  111. canEndSelectCondition: null,
  112. maxCount: 1,
  113. canNoSelect: false,
  114. canEndNotMax: false,
  115. selectPermanentCoroutine: SelectPermanentCoroutine,
  116. afterSelectPermanentCoroutine: null,
  117. mode: SelectPermanentEffect.Mode.Custom,
  118. cardEffect: activateClass);
  119. selectPermanentEffect.SetUpCustomMessage(
  120. "Select 1 Digimon that will get <Security Attack +1> and DP +5000.",
  121. "The opponent is selecting 1 Digimon that will get <Security Attack +1> and DP +5000.");
  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.ChangeDigimonSAttack(
  131. targetPermanent: selectedPermanent,
  132. changeValue: 1,
  133. effectDuration: EffectDuration.UntilOpponentTurnEnd,
  134. activateClass: activateClass));
  135. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDP(
  136. targetPermanent: selectedPermanent,
  137. changeValue: 5000,
  138. effectDuration: EffectDuration.UntilOpponentTurnEnd,
  139. activateClass: activateClass));
  140. }
  141. }
  142. }
  143. }
  144. #endregion
  145. #region When Digivolving
  146. if (timing == EffectTiming.OnEnterFieldAnyone)
  147. {
  148. ActivateClass activateClass = new ActivateClass();
  149. activateClass.SetUpICardEffect("Play 1 Digimon from your hand to your empty breeding area", CanUseCondition, card);
  150. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription());
  151. cardEffects.Add(activateClass);
  152. string EffectDescription()
  153. {
  154. return
  155. "[When Digivolving] You may play 1 [Dorumon]/[Ryudamon] from your hand to your empty breeding area without paying the cost. Then if during an attack, until the end of your opponent's turn, 1 of your Digimon gains <Security Attack +1> and gets +5000 DP.";
  156. }
  157. bool CanUseCondition(Hashtable hashtable)
  158. {
  159. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  160. }
  161. bool IsCorrectRookieCardCondition(CardSource cardSource)
  162. {
  163. return cardSource.IsDigimon &&
  164. (cardSource.EqualsCardName("Dorumon") || cardSource.EqualsCardName("Ryudamon")) &&
  165. CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass,
  166. isBreedingArea: true);
  167. }
  168. bool CanSelectPermanentCondition(Permanent permanent)
  169. {
  170. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card);
  171. }
  172. bool PlayBreedingAreaCondition()
  173. {
  174. return CardEffectCommons.HasMatchConditionOwnersHand(card, IsCorrectRookieCardCondition) &&
  175. card.Owner.GetBreedingAreaPermanents().Count == 0;
  176. }
  177. bool IsAttackingCondition()
  178. {
  179. return GManager.instance.attackProcess.IsAttacking;
  180. }
  181. bool CanActivateCondition(Hashtable hashtable)
  182. {
  183. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  184. (PlayBreedingAreaCondition() || IsAttackingCondition());
  185. }
  186. IEnumerator ActivateCoroutine(Hashtable hashtable)
  187. {
  188. if (PlayBreedingAreaCondition())
  189. {
  190. List<CardSource> selectedCards = new List<CardSource>();
  191. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  192. selectHandEffect.SetUp(
  193. selectPlayer: card.Owner,
  194. canTargetCondition: IsCorrectRookieCardCondition,
  195. canTargetCondition_ByPreSelecetedList: null,
  196. canEndSelectCondition: null,
  197. maxCount: 1,
  198. canNoSelect: true,
  199. canEndNotMax: false,
  200. isShowOpponent: true,
  201. selectCardCoroutine: SelectCardCoroutine,
  202. afterSelectCardCoroutine: null,
  203. mode: SelectHandEffect.Mode.Custom,
  204. cardEffect: activateClass);
  205. selectHandEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  206. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  207. yield return StartCoroutine(selectHandEffect.Activate());
  208. IEnumerator SelectCardCoroutine(CardSource cardSource)
  209. {
  210. selectedCards.Add(cardSource);
  211. yield return null;
  212. }
  213. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  214. cardSources: selectedCards,
  215. activateClass: activateClass,
  216. payCost: false,
  217. isTapped: false,
  218. root: SelectCardEffect.Root.Hand,
  219. activateETB: true,
  220. isBreedingArea: true));
  221. }
  222. if (IsAttackingCondition())
  223. {
  224. Permanent selectedPermanent = null;
  225. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  226. selectPermanentEffect.SetUp(
  227. selectPlayer: card.Owner,
  228. canTargetCondition: CanSelectPermanentCondition,
  229. canTargetCondition_ByPreSelecetedList: null,
  230. canEndSelectCondition: null,
  231. maxCount: 1,
  232. canNoSelect: false,
  233. canEndNotMax: false,
  234. selectPermanentCoroutine: SelectPermanentCoroutine,
  235. afterSelectPermanentCoroutine: null,
  236. mode: SelectPermanentEffect.Mode.Custom,
  237. cardEffect: activateClass);
  238. selectPermanentEffect.SetUpCustomMessage(
  239. "Select 1 Digimon that will get <Security Attack +1> and DP +5000.",
  240. "The opponent is selecting 1 Digimon that will get <Security Attack +1> and DP +5000.");
  241. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  242. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  243. {
  244. selectedPermanent = permanent;
  245. yield return null;
  246. }
  247. if (selectedPermanent != null)
  248. {
  249. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonSAttack(
  250. targetPermanent: selectedPermanent,
  251. changeValue: 1,
  252. effectDuration: EffectDuration.UntilOpponentTurnEnd,
  253. activateClass: activateClass));
  254. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDP(
  255. targetPermanent: selectedPermanent,
  256. changeValue: 5000,
  257. effectDuration: EffectDuration.UntilOpponentTurnEnd,
  258. activateClass: activateClass));
  259. }
  260. }
  261. }
  262. }
  263. #endregion
  264. #region Your Turn - ESS
  265. if (timing == EffectTiming.None)
  266. {
  267. DisableEffectClass invalidationClass = new DisableEffectClass();
  268. invalidationClass.SetUpICardEffect("Ignore Security Effect", CanUseCondition, card);
  269. invalidationClass.SetUpDisableEffectClass(DisableCondition: InvalidateCondition);
  270. invalidationClass.SetIsInheritedEffect(true);
  271. cardEffects.Add(invalidationClass);
  272. bool CanUseCondition(Hashtable hashtable)
  273. {
  274. return true;
  275. }
  276. bool InvalidateCondition(ICardEffect cardEffect)
  277. {
  278. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  279. CardEffectCommons.IsOwnerTurn(card) &&
  280. cardEffect != null &&
  281. cardEffect.EffectSourceCard &&
  282. cardEffect.EffectSourceCard.IsOption &&
  283. cardEffect.IsSecurityEffect &&
  284. GManager.instance.attackProcess.AttackingPermanent == card.PermanentOfThisCard();
  285. }
  286. }
  287. #endregion
  288. return cardEffects;
  289. }
  290. }
  291. }