Kumamon_BT18_022.cs 14 KB

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