BT18_022.cs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. namespace DCGO.CardEffects.BT18
  5. {
  6. public class BT18_022 : 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. // Any blue or red tamer
  13. if (timing == EffectTiming.None)
  14. {
  15. bool PermanentCondition(Permanent targetPermanent)
  16. {
  17. return targetPermanent.IsTamer && (targetPermanent.TopCard.CardColors.Contains(CardColor.Blue) ||
  18. targetPermanent.TopCard.CardColors.Contains(CardColor.Red));
  19. }
  20. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  21. permanentCondition: PermanentCondition, digivolutionCost: 3, ignoreDigivolutionRequirement: false,
  22. card: card, condition: null));
  23. }
  24. // Tommy Himi
  25. if (timing == EffectTiming.None)
  26. {
  27. bool Condition()
  28. {
  29. return true;
  30. }
  31. bool PermanentCondition(Permanent targetPermanent)
  32. {
  33. return targetPermanent.TopCard.EqualsCardName("Tommy Himi");
  34. }
  35. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  36. permanentCondition: PermanentCondition, digivolutionCost: 2, ignoreDigivolutionRequirement: false,
  37. card: card, condition: Condition));
  38. }
  39. // Korikakumon
  40. if (timing == EffectTiming.None)
  41. {
  42. bool PermanentCondition(Permanent targetPermanent)
  43. {
  44. return targetPermanent.TopCard.EqualsCardName("Korikakumon");
  45. }
  46. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  47. permanentCondition: PermanentCondition, digivolutionCost: 0, ignoreDigivolutionRequirement: false,
  48. card: card, condition: null));
  49. }
  50. #endregion
  51. #region When Digivolving
  52. if (timing == EffectTiming.OnEnterFieldAnyone)
  53. {
  54. ActivateClass activateClass = new ActivateClass();
  55. activateClass.SetUpICardEffect("Trash 2 bottom digivolution cards", CanUseCondition, card);
  56. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription());
  57. cardEffects.Add(activateClass);
  58. string EffectDescription()
  59. {
  60. return "[When Digivolving] Trash the bottom 2 digivolution cards of 1 of your opponent's Digimon.";
  61. }
  62. bool CanUseCondition(Hashtable hashtable)
  63. {
  64. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  65. }
  66. bool CanSelectPermanentCondition(Permanent permanent)
  67. {
  68. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  69. }
  70. bool CanActivateCondition(Hashtable hashtable)
  71. {
  72. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  73. CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition);
  74. }
  75. IEnumerator ActivateCoroutine(Hashtable hashtable)
  76. {
  77. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  78. selectPermanentEffect.SetUp(
  79. selectPlayer: card.Owner,
  80. canTargetCondition: CanSelectPermanentCondition,
  81. canTargetCondition_ByPreSelecetedList: null,
  82. canEndSelectCondition: null,
  83. maxCount: 1,
  84. canNoSelect: false,
  85. canEndNotMax: false,
  86. selectPermanentCoroutine: SelectPermanentCoroutine,
  87. afterSelectPermanentCoroutine: null,
  88. mode: SelectPermanentEffect.Mode.Custom,
  89. cardEffect: activateClass);
  90. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will trash digivolution cards.",
  91. "The opponent is selecting 1 Digimon that will trash digivolution cards.");
  92. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  93. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  94. {
  95. yield return ContinuousController.instance.StartCoroutine(
  96. CardEffectCommons.TrashDigivolutionCardsFromTopOrBottom(
  97. targetPermanent: permanent,
  98. trashCount: 2,
  99. isFromTop: false,
  100. activateClass: activateClass));
  101. }
  102. }
  103. }
  104. #endregion
  105. #region When Attacking
  106. if (timing == EffectTiming.OnAllyAttack)
  107. {
  108. ActivateClass activateClass = new ActivateClass();
  109. activateClass.SetUpICardEffect("1 of your Digimon or Tamers digivolves", CanUseCondition, card);
  110. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true,
  111. EffectDescription());
  112. activateClass.SetHashString("Digivolve_BT18-022");
  113. cardEffects.Add(activateClass);
  114. string EffectDescription()
  115. {
  116. return
  117. "[When Attacking] (Once Per Turn) 1 of your Digimon or Tamers may digivolve into a blue or red Digimon card with the [Hybrid] trait in the hand with the digivolution cost reduced by 1.";
  118. }
  119. bool CanUseCondition(Hashtable hashtable)
  120. {
  121. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  122. }
  123. bool DigivolveFromPermanentCondition(Permanent permanent)
  124. {
  125. return CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card) &&
  126. (permanent.IsDigimon || permanent.IsTamer) &&
  127. card.Owner.HandCards.Where(DigivolveToCardCondition).Any(cardSource =>
  128. cardSource.CanPlayCardTargetFrame(permanent.PermanentFrame, false, activateClass));
  129. }
  130. bool DigivolveToCardCondition(CardSource cardSource)
  131. {
  132. return cardSource.IsDigimon && cardSource.ContainsTraits("Hybrid") &&
  133. (cardSource.HasCardColor(CardColor.Blue) || cardSource.HasCardColor(CardColor.Red));
  134. }
  135. bool CanActivateCondition(Hashtable hashtable)
  136. {
  137. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  138. CardEffectCommons.HasMatchConditionPermanent(DigivolveFromPermanentCondition);
  139. }
  140. IEnumerator ActivateCoroutine(Hashtable hashtable)
  141. {
  142. Permanent selectedPermanent = null;
  143. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  144. selectPermanentEffect.SetUp(
  145. selectPlayer: card.Owner,
  146. canTargetCondition: DigivolveFromPermanentCondition,
  147. canTargetCondition_ByPreSelecetedList: null,
  148. canEndSelectCondition: null,
  149. maxCount: 1,
  150. canNoSelect: true,
  151. canEndNotMax: false,
  152. selectPermanentCoroutine: SelectPermanentCoroutine,
  153. afterSelectPermanentCoroutine: null,
  154. mode: SelectPermanentEffect.Mode.Custom,
  155. cardEffect: activateClass);
  156. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will digivolve.",
  157. "The opponent is selecting 1 Digimon that will digivolve.");
  158. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  159. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  160. {
  161. selectedPermanent = permanent;
  162. yield return null;
  163. }
  164. if (selectedPermanent != null)
  165. {
  166. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DigivolveIntoHandOrTrashCard(
  167. targetPermanent: selectedPermanent,
  168. cardCondition: DigivolveToCardCondition,
  169. payCost: true,
  170. reduceCostTuple: (reduceCost: 1, reduceCostCardCondition: null),
  171. fixedCostTuple: null,
  172. ignoreDigivolutionRequirementFixedCost: -1,
  173. isHand: true,
  174. activateClass: activateClass,
  175. successProcess: null));
  176. }
  177. }
  178. }
  179. #endregion
  180. #region All Turns - ESS
  181. if (timing == EffectTiming.WhenRemoveField)
  182. {
  183. ActivateClass activateClass = new ActivateClass();
  184. activateClass.SetUpICardEffect("Play 1 Tamer card with inherited effects from this Digimon's digivolution cards",
  185. CanUseCondition, card);
  186. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDescription());
  187. activateClass.SetIsInheritedEffect(true);
  188. activateClass.SetHashString("PlayTamer_BT18_022");
  189. cardEffects.Add(activateClass);
  190. string EffectDescription()
  191. {
  192. return
  193. "[All Turns] When this Digimon would leave the battle area other than by your effects, you may play 1 Tamer card with inherited effects from this Digimon's digivolution cards without paying the cost.";
  194. }
  195. bool CanUseCondition(Hashtable hashtable)
  196. {
  197. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  198. CardEffectCommons.CanTriggerWhenRemoveField(hashtable, card) &&
  199. !CardEffectCommons.IsByEffect(hashtable, cardEffect => CardEffectCommons.IsOwnerEffect(cardEffect, card));
  200. }
  201. bool CanSelectTamerSourceCardCondition(CardSource cardSource)
  202. {
  203. return cardSource.IsTamer && cardSource.HasInheritedEffect &&
  204. CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass);
  205. }
  206. bool CanActivateCondition(Hashtable hashtable)
  207. {
  208. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  209. card.PermanentOfThisCard().DigivolutionCards.Some(CanSelectTamerSourceCardCondition);
  210. }
  211. IEnumerator ActivateCoroutine(Hashtable hashtable)
  212. {
  213. List<CardSource> selectedCards = new List<CardSource>();
  214. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  215. selectCardEffect.SetUp(
  216. canTargetCondition: CanSelectTamerSourceCardCondition,
  217. canTargetCondition_ByPreSelecetedList: null,
  218. canEndSelectCondition: null,
  219. canNoSelect: () => true,
  220. selectCardCoroutine: SelectCardCoroutine,
  221. afterSelectCardCoroutine: null,
  222. message: "Select 1 digivolution card to play.",
  223. maxCount: 1,
  224. canEndNotMax: false,
  225. isShowOpponent: true,
  226. mode: SelectCardEffect.Mode.Custom,
  227. root: SelectCardEffect.Root.Custom,
  228. customRootCardList: card.PermanentOfThisCard().DigivolutionCards,
  229. canLookReverseCard: true,
  230. selectPlayer: card.Owner,
  231. cardEffect: activateClass);
  232. selectCardEffect.SetUpCustomMessage(
  233. "Select 1 digivolution card to play.",
  234. "The opponent is selecting 1 digivolution card to play.");
  235. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  236. yield return StartCoroutine(selectCardEffect.Activate());
  237. IEnumerator SelectCardCoroutine(CardSource cardSource)
  238. {
  239. selectedCards.Add(cardSource);
  240. yield return null;
  241. }
  242. yield return ContinuousController.instance.StartCoroutine(
  243. CardEffectCommons.PlayPermanentCards(
  244. cardSources: selectedCards,
  245. activateClass: activateClass,
  246. payCost: false,
  247. isTapped: false,
  248. root: SelectCardEffect.Root.DigivolutionCards,
  249. activateETB: true));
  250. }
  251. }
  252. #endregion
  253. return cardEffects;
  254. }
  255. }
  256. }