BT20_053.cs 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. namespace DCGO.CardEffects.BT20
  4. {
  5. public class BT20_053 : 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("Raptordramon")) ||
  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 isn't affected by your opponent's Digimon's effects 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 immunity to opponent's Digimon effects and DP +5000.",
  121. "The opponent is selecting 1 Digimon that will get immunity to opponent's Digimon effects 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. CanNotAffectedClass canNotAffectedClass = new CanNotAffectedClass();
  131. canNotAffectedClass.SetUpICardEffect("Isn't affected by opponent's Digimon's effects",
  132. CanUseConditionImmunity, card);
  133. canNotAffectedClass.SetUpCanNotAffectedClass(CardCondition: CardCondition,
  134. SkillCondition: SkillCondition);
  135. selectedPermanent.UntilOpponentTurnEndEffects.Add(GetCardEffect);
  136. bool CanUseConditionImmunity(Hashtable hashtableImmunity)
  137. {
  138. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(selectedPermanent, card);
  139. }
  140. bool CardCondition(CardSource cardSource)
  141. {
  142. return CardEffectCommons.IsPermanentExistsOnBattleArea(selectedPermanent) &&
  143. cardSource == selectedPermanent.TopCard;
  144. }
  145. bool SkillCondition(ICardEffect cardEffect)
  146. {
  147. return CardEffectCommons.IsOpponentEffect(cardEffect, card) &&
  148. cardEffect.IsDigimonEffect;
  149. }
  150. ICardEffect GetCardEffect(EffectTiming timingImmunity)
  151. {
  152. return timingImmunity == EffectTiming.None ? canNotAffectedClass : null;
  153. }
  154. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDP(
  155. targetPermanent: selectedPermanent,
  156. changeValue: 5000,
  157. effectDuration: EffectDuration.UntilOpponentTurnEnd,
  158. activateClass: activateClass));
  159. }
  160. }
  161. }
  162. }
  163. #endregion
  164. #region When Digivolving
  165. if (timing == EffectTiming.OnEnterFieldAnyone)
  166. {
  167. ActivateClass activateClass = new ActivateClass();
  168. activateClass.SetUpICardEffect("Play 1 Digimon from your hand to your empty breeding area", CanUseCondition, card);
  169. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription());
  170. cardEffects.Add(activateClass);
  171. string EffectDescription()
  172. {
  173. return
  174. "[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 isn't affected by your opponent's Digimon's effects and gets +5000 DP.";
  175. }
  176. bool CanUseCondition(Hashtable hashtable)
  177. {
  178. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  179. }
  180. bool IsCorrectRookieCardCondition(CardSource cardSource)
  181. {
  182. return cardSource.IsDigimon &&
  183. (cardSource.EqualsCardName("Dorumon") || cardSource.EqualsCardName("Ryudamon")) &&
  184. CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass,
  185. isBreedingArea: true);
  186. }
  187. bool CanSelectPermanentCondition(Permanent permanent)
  188. {
  189. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card);
  190. }
  191. bool PlayBreedingAreaCondition()
  192. {
  193. return CardEffectCommons.HasMatchConditionOwnersHand(card, IsCorrectRookieCardCondition) &&
  194. card.Owner.GetBreedingAreaPermanents().Count == 0;
  195. }
  196. bool IsAttackingCondition()
  197. {
  198. return GManager.instance.attackProcess.IsAttacking;
  199. }
  200. bool CanActivateCondition(Hashtable hashtable)
  201. {
  202. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  203. (PlayBreedingAreaCondition() || IsAttackingCondition());
  204. }
  205. IEnumerator ActivateCoroutine(Hashtable hashtable)
  206. {
  207. if (PlayBreedingAreaCondition())
  208. {
  209. List<CardSource> selectedCards = new List<CardSource>();
  210. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  211. selectHandEffect.SetUp(
  212. selectPlayer: card.Owner,
  213. canTargetCondition: IsCorrectRookieCardCondition,
  214. canTargetCondition_ByPreSelecetedList: null,
  215. canEndSelectCondition: null,
  216. maxCount: 1,
  217. canNoSelect: true,
  218. canEndNotMax: false,
  219. isShowOpponent: true,
  220. selectCardCoroutine: SelectCardCoroutine,
  221. afterSelectCardCoroutine: null,
  222. mode: SelectHandEffect.Mode.Custom,
  223. cardEffect: activateClass);
  224. selectHandEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  225. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  226. yield return StartCoroutine(selectHandEffect.Activate());
  227. IEnumerator SelectCardCoroutine(CardSource cardSource)
  228. {
  229. selectedCards.Add(cardSource);
  230. yield return null;
  231. }
  232. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  233. cardSources: selectedCards,
  234. activateClass: activateClass,
  235. payCost: false,
  236. isTapped: false,
  237. root: SelectCardEffect.Root.Hand,
  238. activateETB: true,
  239. isBreedingArea: true));
  240. }
  241. if (IsAttackingCondition())
  242. {
  243. Permanent selectedPermanent = null;
  244. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  245. selectPermanentEffect.SetUp(
  246. selectPlayer: card.Owner,
  247. canTargetCondition: CanSelectPermanentCondition,
  248. canTargetCondition_ByPreSelecetedList: null,
  249. canEndSelectCondition: null,
  250. maxCount: 1,
  251. canNoSelect: false,
  252. canEndNotMax: false,
  253. selectPermanentCoroutine: SelectPermanentCoroutine,
  254. afterSelectPermanentCoroutine: null,
  255. mode: SelectPermanentEffect.Mode.Custom,
  256. cardEffect: activateClass);
  257. selectPermanentEffect.SetUpCustomMessage(
  258. "Select 1 Digimon that will get immunity to opponent's Digimon effects and DP +5000.",
  259. "The opponent is selecting 1 Digimon that will get immunity to opponent's Digimon effects and DP +5000.");
  260. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  261. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  262. {
  263. selectedPermanent = permanent;
  264. yield return null;
  265. }
  266. if (selectedPermanent != null)
  267. {
  268. CanNotAffectedClass canNotAffectedClass = new CanNotAffectedClass();
  269. canNotAffectedClass.SetUpICardEffect("Isn't affected by opponent's Digimon's effects",
  270. CanUseConditionImmunity, card);
  271. canNotAffectedClass.SetUpCanNotAffectedClass(CardCondition: CardCondition,
  272. SkillCondition: SkillCondition);
  273. selectedPermanent.UntilOpponentTurnEndEffects.Add(GetCardEffect);
  274. bool CanUseConditionImmunity(Hashtable hashtableImmunity)
  275. {
  276. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(selectedPermanent, card);
  277. }
  278. bool CardCondition(CardSource cardSource)
  279. {
  280. return CardEffectCommons.IsPermanentExistsOnBattleArea(selectedPermanent) &&
  281. cardSource == selectedPermanent.TopCard;
  282. }
  283. bool SkillCondition(ICardEffect cardEffect)
  284. {
  285. return CardEffectCommons.IsOpponentEffect(cardEffect, card) &&
  286. cardEffect.IsDigimonEffect;
  287. }
  288. ICardEffect GetCardEffect(EffectTiming timingImmunity)
  289. {
  290. return timingImmunity == EffectTiming.None ? canNotAffectedClass : null;
  291. }
  292. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDP(
  293. targetPermanent: selectedPermanent,
  294. changeValue: 5000,
  295. effectDuration: EffectDuration.UntilOpponentTurnEnd,
  296. activateClass: activateClass));
  297. }
  298. }
  299. }
  300. }
  301. #endregion
  302. #region Opponent's Turn - ESS
  303. if (timing == EffectTiming.OnAllyAttack)
  304. {
  305. ActivateClass activateClass = new ActivateClass();
  306. activateClass.SetUpICardEffect("Switch attack target to this Digimon", CanUseCondition, card);
  307. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDescription());
  308. activateClass.SetIsInheritedEffect(true);
  309. activateClass.SetHashString("AttackSwitch_BT20_053");
  310. cardEffects.Add(activateClass);
  311. string EffectDescription()
  312. {
  313. return
  314. "[Opponent's Turn] [Once Per Turn] When one of your opponent's Digimon attacks, you may switch the attack target to this Digimon.";
  315. }
  316. bool AttackingPermanent(Permanent permanent)
  317. {
  318. return CardEffectCommons.IsOpponentPermanent(permanent, card);
  319. }
  320. bool CanUseCondition(Hashtable hashtable)
  321. {
  322. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  323. CardEffectCommons.IsOpponentTurn(card) &&
  324. CardEffectCommons.CanTriggerOnPermanentAttack(hashtable, AttackingPermanent);
  325. }
  326. bool CanActivateCondition(Hashtable hashtable)
  327. {
  328. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  329. GManager.instance.attackProcess.AttackingPermanent != null &&
  330. GManager.instance.attackProcess.AttackingPermanent.CanSwitchAttackTarget;
  331. }
  332. IEnumerator ActivateCoroutine(Hashtable hashtable)
  333. {
  334. yield return ContinuousController.instance.StartCoroutine(
  335. GManager.instance.attackProcess.SwitchDefender(activateClass, false, card.PermanentOfThisCard()));
  336. }
  337. }
  338. #endregion
  339. return cardEffects;
  340. }
  341. }
  342. }