BT19_025.cs 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. namespace DCGO.CardEffects.BT19
  5. {
  6. public class BT19_025 : CEntity_Effect
  7. {
  8. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  9. {
  10. List<ICardEffect> cardEffects = new List<ICardEffect>();
  11. #region Material Save
  12. if (timing == EffectTiming.WhenPermanentWouldBeDeleted)
  13. {
  14. cardEffects.Add(CardEffectFactory.MaterialSaveEffect(card: card, materialSaveCount: 2));
  15. }
  16. #endregion
  17. #region On Play
  18. if (timing == EffectTiming.OnEnterFieldAnyone)
  19. {
  20. ActivateClass activateClass = new ActivateClass();
  21. activateClass.SetUpICardEffect("This Digimon gains <Rush>", CanUseCondition, card);
  22. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription());
  23. cardEffects.Add(activateClass);
  24. string EffectDescription()
  25. {
  26. return
  27. "[On Play] This Digimon gains <Rush> for the turn.";
  28. }
  29. bool CanUseCondition(Hashtable hashtable)
  30. {
  31. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  32. }
  33. bool CanActivateCondition(Hashtable hashtable)
  34. {
  35. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  36. }
  37. IEnumerator ActivateCoroutine(Hashtable hashtable)
  38. {
  39. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainRush(
  40. targetPermanent: card.PermanentOfThisCard(),
  41. effectDuration: EffectDuration.UntilEachTurnEnd,
  42. activateClass: activateClass));
  43. }
  44. }
  45. #endregion
  46. #region When Attacking
  47. if (timing == EffectTiming.OnAllyAttack)
  48. {
  49. ActivateClass activateClass = new ActivateClass();
  50. activateClass.SetUpICardEffect("<De-Digivolve 1> and digivolve into a [Blue Flare] card", CanUseCondition, card);
  51. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription());
  52. cardEffects.Add(activateClass);
  53. string EffectDescription()
  54. {
  55. return
  56. "[When Attacking] <De-Digivolve 1> 1 of your opponent's Digimon. Then, this Digimon may digivolve into a Digimon card with the [Blue Flare] trait from under your Tamers without paying the cost.";
  57. }
  58. bool CanUseCondition(Hashtable hashtable)
  59. {
  60. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  61. }
  62. bool CanSelectPermanentCondition(Permanent permanent)
  63. {
  64. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  65. }
  66. bool HasBlueFlareTraitCondition(CardSource cardSource)
  67. {
  68. return cardSource.IsDigimon && cardSource.EqualsTraits("Blue Flare") &&
  69. cardSource.CanPlayCardTargetFrame(card.PermanentOfThisCard().PermanentFrame, false, activateClass);
  70. }
  71. bool TamerHasDigimonCondition(Permanent permanent)
  72. {
  73. return CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card) &&
  74. permanent.IsTamer && permanent.DigivolutionCards.Count(HasBlueFlareTraitCondition) >= 1;
  75. }
  76. bool CanActivateCondition(Hashtable hashtable)
  77. {
  78. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  79. (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition) ||
  80. CardEffectCommons.HasMatchConditionPermanent(TamerHasDigimonCondition));
  81. }
  82. IEnumerator ActivateCoroutine(Hashtable hashtable)
  83. {
  84. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  85. {
  86. SelectPermanentEffect selectPermanentEffect =
  87. GManager.instance.GetComponent<SelectPermanentEffect>();
  88. selectPermanentEffect.SetUp(
  89. selectPlayer: card.Owner,
  90. canTargetCondition: CanSelectPermanentCondition,
  91. canTargetCondition_ByPreSelecetedList: null,
  92. canEndSelectCondition: null,
  93. maxCount: 1,
  94. canNoSelect: false,
  95. canEndNotMax: false,
  96. selectPermanentCoroutine: SelectPermanentCoroutine,
  97. afterSelectPermanentCoroutine: null,
  98. mode: SelectPermanentEffect.Mode.Custom,
  99. cardEffect: activateClass);
  100. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to De-Digivolve.",
  101. "The opponent is selecting 1 Digimon to De-Digivolve.");
  102. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  103. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  104. {
  105. yield return ContinuousController.instance.StartCoroutine(
  106. new IDegeneration(permanent, 1, activateClass).Degeneration());
  107. }
  108. }
  109. if (CardEffectCommons.HasMatchConditionPermanent(TamerHasDigimonCondition))
  110. {
  111. Permanent selectedPermanent = null;
  112. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  113. selectPermanentEffect.SetUp(
  114. selectPlayer: card.Owner,
  115. canTargetCondition: TamerHasDigimonCondition,
  116. canTargetCondition_ByPreSelecetedList: null,
  117. canEndSelectCondition: null,
  118. maxCount: 1,
  119. canNoSelect: true,
  120. canEndNotMax: false,
  121. selectPermanentCoroutine: SelectPermanentCoroutine,
  122. afterSelectPermanentCoroutine: null,
  123. mode: SelectPermanentEffect.Mode.Custom,
  124. cardEffect: activateClass);
  125. selectPermanentEffect.SetUpCustomMessage("Select a Tamer.", "The opponent is selecting a Tamer.");
  126. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  127. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  128. {
  129. selectedPermanent = permanent;
  130. yield return null;
  131. }
  132. if (selectedPermanent != null)
  133. {
  134. List<CardSource> selectedCards = new List<CardSource>();
  135. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  136. selectCardEffect.SetUp(
  137. canTargetCondition: HasBlueFlareTraitCondition,
  138. canTargetCondition_ByPreSelecetedList: null,
  139. canEndSelectCondition: null,
  140. canNoSelect: () => true,
  141. selectCardCoroutine: SelectCardCoroutine,
  142. afterSelectCardCoroutine: null,
  143. message: "Select 1 card to digivolve into.",
  144. maxCount: 1,
  145. canEndNotMax: false,
  146. isShowOpponent: true,
  147. mode: SelectCardEffect.Mode.Custom,
  148. root: SelectCardEffect.Root.Custom,
  149. customRootCardList: selectedPermanent.DigivolutionCards,
  150. canLookReverseCard: true,
  151. selectPlayer: card.Owner,
  152. cardEffect: activateClass);
  153. selectCardEffect.SetUpCustomMessage("Select 1 card to digivolve into.",
  154. "The opponent is selecting 1 card to digivolve into.");
  155. selectCardEffect.SetUpCustomMessage_ShowCard("Digivolve Card");
  156. yield return StartCoroutine(selectCardEffect.Activate());
  157. IEnumerator SelectCardCoroutine(CardSource cardSource)
  158. {
  159. selectedCards.Add(cardSource);
  160. yield return null;
  161. }
  162. yield return ContinuousController.instance.StartCoroutine(new PlayCardClass(
  163. cardSources: selectedCards,
  164. hashtable: CardEffectCommons.CardEffectHashtable(activateClass),
  165. payCost: false,
  166. targetPermanent: card.PermanentOfThisCard(),
  167. isTapped: false,
  168. root: SelectCardEffect.Root.DigivolutionCards,
  169. activateETB: true).PlayCard());
  170. }
  171. }
  172. }
  173. }
  174. #endregion
  175. #region DigiXros
  176. if (timing == EffectTiming.None)
  177. {
  178. AddDigiXrosConditionClass addDigiXrosConditionClass = new AddDigiXrosConditionClass();
  179. addDigiXrosConditionClass.SetUpICardEffect($"DigiXros -2", CanUseCondition, card);
  180. addDigiXrosConditionClass.SetUpAddDigiXrosConditionClass(getDigiXrosCondition: GetDigiXros);
  181. addDigiXrosConditionClass.SetNotShowUI(true);
  182. cardEffects.Add(addDigiXrosConditionClass);
  183. bool CanUseCondition(Hashtable hashtable)
  184. {
  185. return true;
  186. }
  187. DigiXrosCondition GetDigiXros(CardSource cardSource)
  188. {
  189. if (cardSource == card)
  190. {
  191. DigiXrosConditionElement elementA = new DigiXrosConditionElement(CanSelectCardConditionA, "Blue Greymon");
  192. bool CanSelectCardConditionA(CardSource conditionCardSource)
  193. {
  194. if (conditionCardSource != null)
  195. {
  196. if (conditionCardSource.Owner == card.Owner)
  197. {
  198. if (conditionCardSource.IsDigimon)
  199. {
  200. if (conditionCardSource.CardNames_DigiXros.Contains("Greymon"))
  201. {
  202. if (conditionCardSource.HasCardColor(CardColor.Blue))
  203. {
  204. return true;
  205. }
  206. }
  207. }
  208. }
  209. }
  210. return false;
  211. }
  212. DigiXrosConditionElement elementB = new DigiXrosConditionElement(CanSelectCardConditionB, "MailBirdramon");
  213. bool CanSelectCardConditionB(CardSource conditionCardSource)
  214. {
  215. if (conditionCardSource != null)
  216. {
  217. if (conditionCardSource.Owner == card.Owner)
  218. {
  219. if (conditionCardSource.IsDigimon)
  220. {
  221. if (conditionCardSource.CardNames_DigiXros.Contains("MailBirdramon"))
  222. {
  223. return true;
  224. }
  225. }
  226. }
  227. }
  228. return false;
  229. }
  230. List<DigiXrosConditionElement> elements = new List<DigiXrosConditionElement>() { elementA, elementB };
  231. DigiXrosCondition digiXrosCondition = new DigiXrosCondition(elements, null, 2);
  232. return digiXrosCondition;
  233. }
  234. return null;
  235. }
  236. }
  237. #endregion
  238. #region End of Attack - ESS
  239. if (timing == EffectTiming.OnEndAttack)
  240. {
  241. ActivateClass activateClass = new ActivateClass();
  242. activateClass.SetUpICardEffect("Play 1 level 4 or lower [Blue Flare] Digimon", CanUseCondition, card);
  243. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDescription());
  244. activateClass.SetIsInheritedEffect(true);
  245. activateClass.SetHashString("PlayDigimon_BT19_025");
  246. cardEffects.Add(activateClass);
  247. string EffectDescription()
  248. {
  249. return
  250. "[End of Attack] (Once Per Turn) You may play 1 level 4 or lower Digimon card with the [Blue Flare] trait from under any of your Tamers without paying the cost.";
  251. }
  252. bool CanUseCondition(Hashtable hashtable)
  253. {
  254. return CardEffectCommons.CanTriggerOnEndAttack(hashtable, card);
  255. }
  256. bool HasBlueFlareTraitCondition(CardSource cardSource)
  257. {
  258. return cardSource.IsDigimon && cardSource.EqualsTraits("Blue Flare") &&
  259. cardSource.HasLevel && cardSource.Level <= 4 &&
  260. CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass);
  261. }
  262. bool TamerHasDigimonCondition(Permanent permanent)
  263. {
  264. return CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card) &&
  265. permanent.IsTamer && permanent.DigivolutionCards.Count(HasBlueFlareTraitCondition) >= 1;
  266. }
  267. bool CanActivateCondition(Hashtable hashtable)
  268. {
  269. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  270. CardEffectCommons.HasMatchConditionPermanent(TamerHasDigimonCondition);
  271. }
  272. IEnumerator ActivateCoroutine(Hashtable hashtable)
  273. {
  274. Permanent selectedPermanent = null;
  275. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  276. selectPermanentEffect.SetUp(
  277. selectPlayer: card.Owner,
  278. canTargetCondition: TamerHasDigimonCondition,
  279. canTargetCondition_ByPreSelecetedList: null,
  280. canEndSelectCondition: null,
  281. maxCount: 1,
  282. canNoSelect: true,
  283. canEndNotMax: false,
  284. selectPermanentCoroutine: SelectPermanentCoroutine,
  285. afterSelectPermanentCoroutine: null,
  286. mode: SelectPermanentEffect.Mode.Custom,
  287. cardEffect: activateClass);
  288. selectPermanentEffect.SetUpCustomMessage("Select a Tamer.", "The opponent is selecting a Tamer.");
  289. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  290. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  291. {
  292. selectedPermanent = permanent;
  293. yield return null;
  294. }
  295. if (selectedPermanent != null)
  296. {
  297. List<CardSource> selectedCards = new List<CardSource>();
  298. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  299. selectCardEffect.SetUp(
  300. canTargetCondition: HasBlueFlareTraitCondition,
  301. canTargetCondition_ByPreSelecetedList: null,
  302. canEndSelectCondition: null,
  303. canNoSelect: () => true,
  304. selectCardCoroutine: SelectCardCoroutine,
  305. afterSelectCardCoroutine: null,
  306. message: "Select 1 digivolution card to play.",
  307. maxCount: 1,
  308. canEndNotMax: false,
  309. isShowOpponent: true,
  310. mode: SelectCardEffect.Mode.Custom,
  311. root: SelectCardEffect.Root.Custom,
  312. customRootCardList: selectedPermanent.DigivolutionCards,
  313. canLookReverseCard: true,
  314. selectPlayer: card.Owner,
  315. cardEffect: activateClass);
  316. selectCardEffect.SetUpCustomMessage("Select 1 digivolution card to play.",
  317. "The opponent is selecting 1 digivolution card to play.");
  318. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  319. yield return StartCoroutine(selectCardEffect.Activate());
  320. IEnumerator SelectCardCoroutine(CardSource cardSource)
  321. {
  322. selectedCards.Add(cardSource);
  323. yield return null;
  324. }
  325. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  326. cardSources: selectedCards,
  327. activateClass: activateClass,
  328. payCost: false,
  329. isTapped: false,
  330. root: SelectCardEffect.Root.DigivolutionCards,
  331. activateETB: true));
  332. }
  333. }
  334. }
  335. #endregion
  336. return cardEffects;
  337. }
  338. }
  339. }