BT18_076.cs 13 KB

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