Loweemon_BT18_076.cs 13 KB

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