BT18_063.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. namespace DCGO.CardEffects.BT18
  5. {
  6. public class BT18_063 : 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 black or yellow tamer
  13. if (timing == EffectTiming.None)
  14. {
  15. bool PermanentCondition(Permanent targetPermanent)
  16. {
  17. return targetPermanent.IsTamer && (targetPermanent.TopCard.CardColors.Contains(CardColor.Black) ||
  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. // J.P. Shibayama
  25. if (timing == EffectTiming.None)
  26. {
  27. bool PermanentCondition(Permanent targetPermanent)
  28. {
  29. return targetPermanent.TopCard.EqualsCardName("J.P. Shibayama");
  30. }
  31. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  32. permanentCondition: PermanentCondition, digivolutionCost: 2, ignoreDigivolutionRequirement: false,
  33. card: card, condition: null));
  34. }
  35. // MetalKabuterimon
  36. if (timing == EffectTiming.None)
  37. {
  38. bool PermanentCondition(Permanent targetPermanent)
  39. {
  40. return targetPermanent.TopCard.EqualsCardName("MetalKabuterimon");
  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("This Digimon can't be deleted by opponent's effects", CanUseCondition, card);
  52. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription());
  53. cardEffects.Add(activateClass);
  54. string EffectDescription()
  55. {
  56. return
  57. "[When Digivolving] Until the end of your opponent's turn, this Digimon can't be deleted by your opponent's effects.";
  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. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainCanNotBeDeletedByEffect(
  70. targetPermanent: card.PermanentOfThisCard(),
  71. cardEffectCondition: cardEffect => CardEffectCommons.IsOpponentEffect(cardEffect, card),
  72. effectDuration: EffectDuration.UntilOpponentTurnEnd,
  73. activateClass: activateClass,
  74. effectName: "Can't be deleted by opponent's effects"));
  75. }
  76. }
  77. #endregion
  78. #region When Attacking
  79. if (timing == EffectTiming.OnAllyAttack)
  80. {
  81. ActivateClass activateClass = new ActivateClass();
  82. activateClass.SetUpICardEffect("1 of your Digimon or Tamers digivolves", CanUseCondition, card);
  83. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true,
  84. EffectDescription());
  85. cardEffects.Add(activateClass);
  86. string EffectDescription()
  87. {
  88. return
  89. "[When Attacking] 1 of your Digimon or Tamers may digivolve into a black or yellow Digimon card with the [Hybrid] trait in the hand with the digivolution cost reduced by 1.";
  90. }
  91. bool CanUseCondition(Hashtable hashtable)
  92. {
  93. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  94. }
  95. bool DigivolveFromPermanentCondition(Permanent permanent)
  96. {
  97. return CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card) &&
  98. (permanent.IsDigimon || permanent.IsTamer) &&
  99. card.Owner.HandCards.Where(DigivolveToCardCondition).Any(cardSource =>
  100. cardSource.CanPlayCardTargetFrame(permanent.PermanentFrame, false, activateClass));
  101. }
  102. bool DigivolveToCardCondition(CardSource cardSource)
  103. {
  104. return cardSource.IsDigimon && cardSource.ContainsTraits("Hybrid") &&
  105. (cardSource.CardColors.Contains(CardColor.Black) || cardSource.CardColors.Contains(CardColor.Yellow));
  106. }
  107. bool CanActivateCondition(Hashtable hashtable)
  108. {
  109. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  110. CardEffectCommons.HasMatchConditionPermanent(DigivolveFromPermanentCondition);
  111. }
  112. IEnumerator ActivateCoroutine(Hashtable hashtable)
  113. {
  114. Permanent selectedPermanent = null;
  115. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  116. selectPermanentEffect.SetUp(
  117. selectPlayer: card.Owner,
  118. canTargetCondition: DigivolveFromPermanentCondition,
  119. canTargetCondition_ByPreSelecetedList: null,
  120. canEndSelectCondition: null,
  121. maxCount: 1,
  122. canNoSelect: true,
  123. canEndNotMax: false,
  124. selectPermanentCoroutine: SelectPermanentCoroutine,
  125. afterSelectPermanentCoroutine: null,
  126. mode: SelectPermanentEffect.Mode.Custom,
  127. cardEffect: activateClass);
  128. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will digivolve.",
  129. "The opponent is selecting 1 Digimon that will digivolve.");
  130. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  131. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  132. {
  133. selectedPermanent = permanent;
  134. yield return null;
  135. }
  136. if (selectedPermanent != null)
  137. {
  138. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DigivolveIntoHandOrTrashCard(
  139. targetPermanent: selectedPermanent,
  140. cardCondition: DigivolveToCardCondition,
  141. payCost: true,
  142. reduceCostTuple: (reduceCost: 1, reduceCostCardCondition: null),
  143. fixedCostTuple: null,
  144. ignoreDigivolutionRequirementFixedCost: -1,
  145. isHand: true,
  146. activateClass: activateClass,
  147. successProcess: null));
  148. }
  149. }
  150. }
  151. #endregion
  152. #region All Turns - ESS
  153. if (timing == EffectTiming.WhenRemoveField)
  154. {
  155. ActivateClass activateClass = new ActivateClass();
  156. activateClass.SetUpICardEffect("Play 1 Tamer card with inherited effects from this Digimon's digivolution cards",
  157. CanUseCondition, card);
  158. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDescription());
  159. activateClass.SetIsInheritedEffect(true);
  160. activateClass.SetHashString("PlayTamer_BT18_63");
  161. cardEffects.Add(activateClass);
  162. string EffectDescription()
  163. {
  164. return
  165. "[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.";
  166. }
  167. bool CanUseCondition(Hashtable hashtable)
  168. {
  169. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  170. CardEffectCommons.CanTriggerWhenRemoveField(hashtable, card) &&
  171. !CardEffectCommons.IsByEffect(hashtable, cardEffect => CardEffectCommons.IsOwnerEffect(cardEffect, card));
  172. }
  173. bool CanSelectTamerSourceCardCondition(CardSource cardSource)
  174. {
  175. return cardSource.IsTamer && cardSource.HasInheritedEffect &&
  176. CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass);
  177. }
  178. bool CanActivateCondition(Hashtable hashtable)
  179. {
  180. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  181. card.PermanentOfThisCard().DigivolutionCards.Some(CanSelectTamerSourceCardCondition);
  182. }
  183. IEnumerator ActivateCoroutine(Hashtable hashtable)
  184. {
  185. List<CardSource> selectedCards = new List<CardSource>();
  186. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  187. selectCardEffect.SetUp(
  188. canTargetCondition: CanSelectTamerSourceCardCondition,
  189. canTargetCondition_ByPreSelecetedList: null,
  190. canEndSelectCondition: null,
  191. canNoSelect: () => true,
  192. selectCardCoroutine: SelectCardCoroutine,
  193. afterSelectCardCoroutine: null,
  194. message: "Select 1 digivolution card to play.",
  195. maxCount: 1,
  196. canEndNotMax: false,
  197. isShowOpponent: true,
  198. mode: SelectCardEffect.Mode.Custom,
  199. root: SelectCardEffect.Root.Custom,
  200. customRootCardList: card.PermanentOfThisCard().DigivolutionCards,
  201. canLookReverseCard: true,
  202. selectPlayer: card.Owner,
  203. cardEffect: activateClass);
  204. selectCardEffect.SetUpCustomMessage(
  205. "Select 1 digivolution card to play.",
  206. "The opponent is selecting 1 digivolution card to play.");
  207. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  208. yield return StartCoroutine(selectCardEffect.Activate());
  209. IEnumerator SelectCardCoroutine(CardSource cardSource)
  210. {
  211. selectedCards.Add(cardSource);
  212. yield return null;
  213. }
  214. yield return ContinuousController.instance.StartCoroutine(
  215. CardEffectCommons.PlayPermanentCards(
  216. cardSources: selectedCards,
  217. activateClass: activateClass,
  218. payCost: false,
  219. isTapped: false,
  220. root: SelectCardEffect.Root.DigivolutionCards,
  221. activateETB: true));
  222. }
  223. }
  224. #endregion
  225. return cardEffects;
  226. }
  227. }
  228. }