BT18_081.cs 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. namespace DCGO.CardEffects.BT18
  5. {
  6. public class BT18_081 : CEntity_Effect
  7. {
  8. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  9. {
  10. List<ICardEffect> cardEffects = new List<ICardEffect>();
  11. #region Alternate Digivolution
  12. if (timing == EffectTiming.None)
  13. {
  14. bool PermanentCondition(Permanent targetPermanent)
  15. {
  16. return targetPermanent.TopCard.IsLevel4 && targetPermanent.TopCard.EqualsTraits("Hybrid")
  17. && (targetPermanent.TopCard.CardColors.Contains(CardColor.Purple) ||
  18. targetPermanent.TopCard.CardColors.Contains(CardColor.Yellow));
  19. }
  20. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  21. permanentCondition: PermanentCondition,
  22. digivolutionCost: 3,
  23. ignoreDigivolutionRequirement: false,
  24. card: card,
  25. condition: null)
  26. );
  27. }
  28. #endregion
  29. #region Hand - Main
  30. if (timing == EffectTiming.OnDeclaration)
  31. {
  32. ActivateClass activateClass = new ActivateClass();
  33. activateClass.SetUpICardEffect("Your purple or yellow tamer digivolves into this card", CanUseCondition,
  34. card);
  35. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDescription());
  36. cardEffects.Add(activateClass);
  37. string EffectDescription()
  38. {
  39. return
  40. "[Hand] [Main] By placing 1 [Loweemon] and [KaiserLeomon] from your trash under 1 of your purple or yellow Tamers, that Tamer digivolves into this card for digivolution cost of 3, ignoring its digivolution requirements.";
  41. }
  42. bool CanSelectHumanSpiritCardCondition(CardSource cardSource)
  43. {
  44. return cardSource.EqualsCardName("Loweemon");
  45. }
  46. bool CanSelectBeastSpiritCardCondition(CardSource cardSource)
  47. {
  48. return cardSource.EqualsCardName("KaiserLeomon");
  49. }
  50. bool CanSelectTamerPermanentCondition(Permanent permanent)
  51. {
  52. return permanent != null && CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card) &&
  53. permanent.IsTamer &&
  54. (permanent.TopCard.CardColors.Contains(CardColor.Purple) ||
  55. permanent.TopCard.CardColors.Contains(CardColor.Yellow));
  56. }
  57. bool CanUseCondition(Hashtable hashtable)
  58. {
  59. return card.Owner.HandCards.Contains(card) &&
  60. CardEffectCommons.HasMatchConditionPermanent(CanSelectTamerPermanentCondition) &&
  61. CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectHumanSpiritCardCondition) &&
  62. CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectBeastSpiritCardCondition);
  63. }
  64. IEnumerator ActivateCoroutine(Hashtable hashtable)
  65. {
  66. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectTamerPermanentCondition))
  67. {
  68. Permanent selectedPermanent = null;
  69. SelectPermanentEffect selectPermanentEffect =
  70. GManager.instance.GetComponent<SelectPermanentEffect>();
  71. selectPermanentEffect.SetUp(
  72. selectPlayer: card.Owner,
  73. canTargetCondition: CanSelectTamerPermanentCondition,
  74. canTargetCondition_ByPreSelecetedList: null,
  75. canEndSelectCondition: null,
  76. maxCount: 1,
  77. canNoSelect: false,
  78. canEndNotMax: false,
  79. selectPermanentCoroutine: SelectPermanentCoroutine,
  80. afterSelectPermanentCoroutine: null,
  81. mode: SelectPermanentEffect.Mode.Custom,
  82. cardEffect: activateClass);
  83. selectPermanentEffect.SetUpCustomMessage("Select 1 tamer to digivolve.",
  84. "The opponent is selecting 1 tamer to digivolve.");
  85. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  86. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  87. {
  88. selectedPermanent = permanent;
  89. yield return null;
  90. }
  91. if (selectedPermanent != null &&
  92. CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectHumanSpiritCardCondition) &&
  93. CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectBeastSpiritCardCondition))
  94. {
  95. bool digivolve = false;
  96. List<CardSource> selectedCards = new List<CardSource>();
  97. SelectCardEffect selectCardEffect =
  98. GManager.instance.GetComponent<SelectCardEffect>();
  99. selectCardEffect.SetUp(
  100. canTargetCondition: (cardSource) =>
  101. CanSelectHumanSpiritCardCondition(cardSource) ||
  102. CanSelectBeastSpiritCardCondition(cardSource),
  103. canTargetCondition_ByPreSelecetedList: CanTargetConditionByPreSelectedList,
  104. canEndSelectCondition: CanEndSelectCondition,
  105. canNoSelect: () => false,
  106. selectCardCoroutine: SelectCardCoroutine,
  107. afterSelectCardCoroutine: null,
  108. message:
  109. "Select cards to place on the bottom of Digivolution cards\n(cards will be placed in the digivolution cards so that cards with lower numbers are on top).",
  110. maxCount: 2,
  111. canEndNotMax: false,
  112. isShowOpponent: true,
  113. mode: SelectCardEffect.Mode.Custom,
  114. root: SelectCardEffect.Root.Trash,
  115. customRootCardList: null,
  116. canLookReverseCard: true,
  117. selectPlayer: card.Owner,
  118. cardEffect: activateClass);
  119. yield return ContinuousController.instance.StartCoroutine(
  120. selectCardEffect.Activate());
  121. bool CanTargetConditionByPreSelectedList(List<CardSource> cardSources,
  122. CardSource cardSource)
  123. {
  124. if (cardSources.Count(CanSelectHumanSpiritCardCondition) >= 1)
  125. {
  126. if (CanSelectHumanSpiritCardCondition(cardSource))
  127. {
  128. return false;
  129. }
  130. }
  131. if (cardSources.Count(CanSelectBeastSpiritCardCondition) >= 1)
  132. {
  133. if (CanSelectBeastSpiritCardCondition(cardSource))
  134. {
  135. return false;
  136. }
  137. }
  138. return true;
  139. }
  140. bool CanEndSelectCondition(List<CardSource> cardSources)
  141. {
  142. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card,
  143. CanSelectHumanSpiritCardCondition))
  144. {
  145. if (cardSources.Count(CanSelectHumanSpiritCardCondition) == 0)
  146. {
  147. return false;
  148. }
  149. }
  150. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card,
  151. CanSelectBeastSpiritCardCondition))
  152. {
  153. if (cardSources.Count(CanSelectBeastSpiritCardCondition) == 0)
  154. {
  155. return false;
  156. }
  157. }
  158. if (cardSources.Count(CanSelectHumanSpiritCardCondition) >= 2)
  159. {
  160. return false;
  161. }
  162. if (cardSources.Count(CanSelectBeastSpiritCardCondition) >= 2)
  163. {
  164. return false;
  165. }
  166. return true;
  167. }
  168. IEnumerator SelectCardCoroutine(CardSource cardSource)
  169. {
  170. selectedCards.Add(cardSource);
  171. yield return null;
  172. }
  173. if (selectedCards.Count >= 1)
  174. {
  175. yield return ContinuousController.instance.StartCoroutine(
  176. selectedPermanent.AddDigivolutionCardsBottom(selectedCards, activateClass));
  177. if (selectedCards.Count == 2)
  178. {
  179. digivolve = true;
  180. }
  181. }
  182. if (digivolve)
  183. {
  184. yield return ContinuousController.instance.StartCoroutine(
  185. CardEffectCommons.DigivolveIntoHandOrTrashCard(
  186. targetPermanent: selectedPermanent,
  187. cardCondition: source => source == card,
  188. payCost: true,
  189. reduceCostTuple: null,
  190. fixedCostTuple: null,
  191. ignoreDigivolutionRequirementFixedCost: 3,
  192. isHand: true,
  193. activateClass: activateClass,
  194. successProcess: null,
  195. failedProcess: DigivolvedFailed()));
  196. }
  197. IEnumerator DigivolvedFailed()
  198. {
  199. IDiscardHand discard = new IDiscardHand(card, hashtable);
  200. discard.Discard();
  201. yield return null;
  202. }
  203. }
  204. }
  205. }
  206. }
  207. #endregion
  208. #region Jamming
  209. if (timing == EffectTiming.None)
  210. {
  211. cardEffects.Add(CardEffectFactory.JammingSelfStaticEffect(isInheritedEffect: false, card: card, condition: null));
  212. }
  213. #endregion
  214. #region When Digivolving
  215. if (timing == EffectTiming.OnEnterFieldAnyone)
  216. {
  217. ActivateClass activateClass = new ActivateClass();
  218. activateClass.SetUpICardEffect("Play 1 Tamer card from trash", CanUseCondition, card);
  219. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDescription());
  220. cardEffects.Add(activateClass);
  221. string EffectDescription()
  222. {
  223. return
  224. "[When Digivolving] You may play 1 Tamer card with inherited effects from your trash without paying the cost.";
  225. }
  226. bool CanUseCondition(Hashtable hashtable)
  227. {
  228. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  229. }
  230. bool CanSelectCardCondition(CardSource cardSource)
  231. {
  232. return cardSource.IsTamer && cardSource.HasInheritedEffect &&
  233. CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass);
  234. }
  235. bool CanActivateCondition(Hashtable hashtable)
  236. {
  237. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  238. CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition);
  239. }
  240. IEnumerator ActivateCoroutine(Hashtable hashtable)
  241. {
  242. List<CardSource> selectedCards = new List<CardSource>();
  243. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  244. selectCardEffect.SetUp(
  245. canTargetCondition: CanSelectCardCondition,
  246. canTargetCondition_ByPreSelecetedList: null,
  247. canEndSelectCondition: null,
  248. canNoSelect: () => true,
  249. selectCardCoroutine: SelectCardCoroutine,
  250. afterSelectCardCoroutine: null,
  251. message: "Select 1 Tamer card to play.",
  252. maxCount: 1,
  253. canEndNotMax: false,
  254. isShowOpponent: true,
  255. mode: SelectCardEffect.Mode.Custom,
  256. root: SelectCardEffect.Root.Trash,
  257. customRootCardList: null,
  258. canLookReverseCard: true,
  259. selectPlayer: card.Owner,
  260. cardEffect: activateClass);
  261. selectCardEffect.SetUpCustomMessage("Select 1 Tamer card to play.", "The opponent is selecting 1 Tamer card to play.");
  262. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  263. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  264. IEnumerator SelectCardCoroutine(CardSource cardSource)
  265. {
  266. selectedCards.Add(cardSource);
  267. yield return null;
  268. }
  269. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  270. cardSources: selectedCards,
  271. activateClass: activateClass,
  272. payCost: false,
  273. isTapped: false,
  274. root: SelectCardEffect.Root.Trash,
  275. activateETB: true));
  276. }
  277. }
  278. #endregion
  279. #region When Attacking - ESS
  280. if (timing == EffectTiming.OnAllyAttack)
  281. {
  282. ActivateClass activateClass = new ActivateClass();
  283. activateClass.SetUpICardEffect("DP -4000", CanUseCondition, card);
  284. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false,
  285. EffectDescription());
  286. activateClass.SetIsInheritedEffect(true);
  287. activateClass.SetHashString("-4000DP_BT18_81");
  288. cardEffects.Add(activateClass);
  289. string EffectDescription()
  290. {
  291. return "[When Attacking] (Once Per Turn) 1 of your opponent's Digimon gets -4000 DP for the turn.";
  292. }
  293. bool CanUseCondition(Hashtable hashtable)
  294. {
  295. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  296. }
  297. bool CanSelectPermanentCondition(Permanent permanent)
  298. {
  299. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  300. }
  301. bool CanActivateCondition(Hashtable hashtable)
  302. {
  303. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  304. }
  305. IEnumerator ActivateCoroutine(Hashtable hashtable)
  306. {
  307. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  308. {
  309. SelectPermanentEffect selectPermanentEffect =
  310. GManager.instance.GetComponent<SelectPermanentEffect>();
  311. selectPermanentEffect.SetUp(
  312. selectPlayer: card.Owner,
  313. canTargetCondition: CanSelectPermanentCondition,
  314. canTargetCondition_ByPreSelecetedList: null,
  315. canEndSelectCondition: null,
  316. maxCount: 1,
  317. canNoSelect: false,
  318. canEndNotMax: false,
  319. selectPermanentCoroutine: SelectPermanentCoroutine,
  320. afterSelectPermanentCoroutine: null,
  321. mode: SelectPermanentEffect.Mode.Custom,
  322. cardEffect: activateClass);
  323. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will get DP -4000.",
  324. "The opponent is selecting 1 Digimon that will get DP -4000.");
  325. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  326. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  327. {
  328. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDP(
  329. targetPermanent: permanent,
  330. changeValue: -4000,
  331. effectDuration: EffectDuration.UntilEachTurnEnd,
  332. activateClass: activateClass));
  333. }
  334. }
  335. }
  336. }
  337. #endregion
  338. return cardEffects;
  339. }
  340. }
  341. }