Beetlemon_BT18_063.cs 13 KB

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