BT18_081.cs 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421
  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. if (!card.CanNotEvolve(selectedPermanent))
  185. {
  186. yield return ContinuousController.instance.StartCoroutine(
  187. CardEffectCommons.DigivolveIntoHandOrTrashCard(
  188. targetPermanent: selectedPermanent,
  189. cardCondition: source => source == card,
  190. payCost: true,
  191. reduceCostTuple: null,
  192. fixedCostTuple: null,
  193. ignoreDigivolutionRequirementFixedCost: 3,
  194. isHand: true,
  195. activateClass: activateClass,
  196. successProcess: null,
  197. failedProcess: DigivolvedFailed(),
  198. isOptional: false));
  199. }
  200. else
  201. {
  202. yield return ContinuousController.instance.StartCoroutine("DigivolvedFailed");
  203. }
  204. }
  205. IEnumerator DigivolvedFailed()
  206. {
  207. IDiscardHand discard = new IDiscardHand(card, hashtable);
  208. discard.Discard();
  209. yield return null;
  210. }
  211. }
  212. }
  213. }
  214. }
  215. #endregion
  216. #region Jamming
  217. if (timing == EffectTiming.None)
  218. {
  219. cardEffects.Add(CardEffectFactory.JammingSelfStaticEffect(isInheritedEffect: false, card: card, condition: null));
  220. }
  221. #endregion
  222. #region When Digivolving
  223. if (timing == EffectTiming.OnEnterFieldAnyone)
  224. {
  225. ActivateClass activateClass = new ActivateClass();
  226. activateClass.SetUpICardEffect("Play 1 Tamer card from trash", CanUseCondition, card);
  227. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDescription());
  228. cardEffects.Add(activateClass);
  229. string EffectDescription()
  230. {
  231. return
  232. "[When Digivolving] You may play 1 Tamer card with inherited effects from your trash without paying the cost.";
  233. }
  234. bool CanUseCondition(Hashtable hashtable)
  235. {
  236. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  237. }
  238. bool CanSelectCardCondition(CardSource cardSource)
  239. {
  240. return cardSource.IsTamer && cardSource.HasInheritedEffect &&
  241. CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass);
  242. }
  243. bool CanActivateCondition(Hashtable hashtable)
  244. {
  245. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  246. CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition);
  247. }
  248. IEnumerator ActivateCoroutine(Hashtable hashtable)
  249. {
  250. List<CardSource> selectedCards = new List<CardSource>();
  251. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  252. selectCardEffect.SetUp(
  253. canTargetCondition: CanSelectCardCondition,
  254. canTargetCondition_ByPreSelecetedList: null,
  255. canEndSelectCondition: null,
  256. canNoSelect: () => true,
  257. selectCardCoroutine: SelectCardCoroutine,
  258. afterSelectCardCoroutine: null,
  259. message: "Select 1 Tamer card to play.",
  260. maxCount: 1,
  261. canEndNotMax: false,
  262. isShowOpponent: true,
  263. mode: SelectCardEffect.Mode.Custom,
  264. root: SelectCardEffect.Root.Trash,
  265. customRootCardList: null,
  266. canLookReverseCard: true,
  267. selectPlayer: card.Owner,
  268. cardEffect: activateClass);
  269. selectCardEffect.SetUpCustomMessage("Select 1 Tamer card to play.", "The opponent is selecting 1 Tamer card to play.");
  270. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  271. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  272. IEnumerator SelectCardCoroutine(CardSource cardSource)
  273. {
  274. selectedCards.Add(cardSource);
  275. yield return null;
  276. }
  277. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  278. cardSources: selectedCards,
  279. activateClass: activateClass,
  280. payCost: false,
  281. isTapped: false,
  282. root: SelectCardEffect.Root.Trash,
  283. activateETB: true));
  284. }
  285. }
  286. #endregion
  287. #region When Attacking - ESS
  288. if (timing == EffectTiming.OnAllyAttack)
  289. {
  290. ActivateClass activateClass = new ActivateClass();
  291. activateClass.SetUpICardEffect("DP -4000", CanUseCondition, card);
  292. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false,
  293. EffectDescription());
  294. activateClass.SetIsInheritedEffect(true);
  295. activateClass.SetHashString("-4000DP_BT18_81");
  296. cardEffects.Add(activateClass);
  297. string EffectDescription()
  298. {
  299. return "[When Attacking] (Once Per Turn) 1 of your opponent's Digimon gets -4000 DP for the turn.";
  300. }
  301. bool CanUseCondition(Hashtable hashtable)
  302. {
  303. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  304. }
  305. bool CanSelectPermanentCondition(Permanent permanent)
  306. {
  307. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  308. }
  309. bool CanActivateCondition(Hashtable hashtable)
  310. {
  311. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  312. }
  313. IEnumerator ActivateCoroutine(Hashtable hashtable)
  314. {
  315. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  316. {
  317. SelectPermanentEffect selectPermanentEffect =
  318. GManager.instance.GetComponent<SelectPermanentEffect>();
  319. selectPermanentEffect.SetUp(
  320. selectPlayer: card.Owner,
  321. canTargetCondition: CanSelectPermanentCondition,
  322. canTargetCondition_ByPreSelecetedList: null,
  323. canEndSelectCondition: null,
  324. maxCount: 1,
  325. canNoSelect: false,
  326. canEndNotMax: false,
  327. selectPermanentCoroutine: SelectPermanentCoroutine,
  328. afterSelectPermanentCoroutine: null,
  329. mode: SelectPermanentEffect.Mode.Custom,
  330. cardEffect: activateClass);
  331. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will get DP -4000.",
  332. "The opponent is selecting 1 Digimon that will get DP -4000.");
  333. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  334. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  335. {
  336. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDP(
  337. targetPermanent: permanent,
  338. changeValue: -4000,
  339. effectDuration: EffectDuration.UntilEachTurnEnd,
  340. activateClass: activateClass));
  341. }
  342. }
  343. }
  344. }
  345. #endregion
  346. return cardEffects;
  347. }
  348. }
  349. }