BT18_070.cs 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. namespace DCGO.CardEffects.BT18
  5. {
  6. public class BT18_070 : 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.Black) ||
  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 black 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 [Beetlemon] and [MetalKabuterimon] from your trash under 1 of your black 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("Beetlemon");
  45. }
  46. bool CanSelectBeastSpiritCardCondition(CardSource cardSource)
  47. {
  48. return cardSource.EqualsCardName("MetalKabuterimon");
  49. }
  50. bool CanSelectTamerPermanentCondition(Permanent permanent)
  51. {
  52. return permanent != null && CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card) &&
  53. permanent.IsTamer &&
  54. (permanent.TopCard.CardColors.Contains(CardColor.Black) ||
  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. }
  196. }
  197. }
  198. }
  199. }
  200. #endregion
  201. #region Collision
  202. if (timing == EffectTiming.OnCounterTiming)
  203. {
  204. cardEffects.Add(CardEffectFactory.CollisionSelfStaticEffect(false, card, null));
  205. }
  206. #endregion
  207. #region All Turns
  208. if (timing == EffectTiming.OnAttackTargetChanged)
  209. {
  210. ActivateClass activateClass = new ActivateClass();
  211. activateClass.SetUpICardEffect("Unsuspend this Digimon", CanUseCondition, card);
  212. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDescription());
  213. activateClass.SetHashString("Unsuspend_BT18_70");
  214. cardEffects.Add(activateClass);
  215. string EffectDescription()
  216. {
  217. return "[All Turns] (Once Per Turn) When an attack target is switched, you may unsuspend this Digimon.";
  218. }
  219. bool CanUseCondition(Hashtable hashtable)
  220. {
  221. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  222. CardEffectCommons.CanTriggerOnPermanentAttackTargetSwitch(hashtable, _ => true);
  223. }
  224. bool CanActivateCondition(Hashtable hashtable)
  225. {
  226. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  227. }
  228. IEnumerator ActivateCoroutine(Hashtable hashtable)
  229. {
  230. yield return ContinuousController.instance.StartCoroutine(
  231. new IUnsuspendPermanents(new List<Permanent>() { card.PermanentOfThisCard() }, activateClass).Unsuspend());
  232. }
  233. }
  234. #endregion
  235. #region When Attacking - ESS
  236. if (timing == EffectTiming.OnAllyAttack)
  237. {
  238. ActivateClass activateClass = new ActivateClass();
  239. activateClass.SetUpICardEffect("DP -4000", CanUseCondition, card);
  240. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false,
  241. EffectDescription());
  242. activateClass.SetIsInheritedEffect(true);
  243. activateClass.SetHashString("-4000DP_BT18_70");
  244. cardEffects.Add(activateClass);
  245. string EffectDescription()
  246. {
  247. return "[When Attacking] (Once Per Turn) 1 of your opponent's Digimon gets -4000 DP for the turn.";
  248. }
  249. bool CanUseCondition(Hashtable hashtable)
  250. {
  251. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  252. }
  253. bool CanSelectPermanentCondition(Permanent permanent)
  254. {
  255. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  256. }
  257. bool CanActivateCondition(Hashtable hashtable)
  258. {
  259. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  260. }
  261. IEnumerator ActivateCoroutine(Hashtable hashtable)
  262. {
  263. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  264. {
  265. SelectPermanentEffect selectPermanentEffect =
  266. GManager.instance.GetComponent<SelectPermanentEffect>();
  267. selectPermanentEffect.SetUp(
  268. selectPlayer: card.Owner,
  269. canTargetCondition: CanSelectPermanentCondition,
  270. canTargetCondition_ByPreSelecetedList: null,
  271. canEndSelectCondition: null,
  272. maxCount: 1,
  273. canNoSelect: false,
  274. canEndNotMax: false,
  275. selectPermanentCoroutine: SelectPermanentCoroutine,
  276. afterSelectPermanentCoroutine: null,
  277. mode: SelectPermanentEffect.Mode.Custom,
  278. cardEffect: activateClass);
  279. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will get DP -4000.",
  280. "The opponent is selecting 1 Digimon that will get DP -4000.");
  281. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  282. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  283. {
  284. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDP(
  285. targetPermanent: permanent,
  286. changeValue: -4000,
  287. effectDuration: EffectDuration.UntilEachTurnEnd,
  288. activateClass: activateClass));
  289. }
  290. }
  291. }
  292. }
  293. #endregion
  294. return cardEffects;
  295. }
  296. }
  297. }