BT18_048.cs 13 KB

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