BT24_072.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System;
  4. using System.Linq;
  5. // SkullGreymon
  6. namespace DCGO.CardEffects.BT24
  7. {
  8. public class BT24_072 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region Alt Digivolution Condition
  14. if (timing == EffectTiming.None)
  15. {
  16. static bool PermanentCondition(Permanent targetPermanent)
  17. {
  18. return targetPermanent.TopCard.IsLevel4
  19. && (targetPermanent.TopCard.EqualsTraits("Demon")
  20. || targetPermanent.TopCard.HasTSTraits);
  21. }
  22. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 3, ignoreDigivolutionRequirement: false, card: card, condition: null));
  23. }
  24. #endregion
  25. #region Shared OP/WD
  26. string SharedEffectName() => "By trashing 1, give 1 digimon Blocker and Retaliation";
  27. string SharedEffectDescription(string tag) => $"[{tag}] By trashing 1 card in your hand, until your opponent's turn ends, 1 of your Digimon with the [Demon], [Shaman] or [Titan] trait gains <Blocker> and <Retaliation>.";
  28. bool SharedCanActivateCondition(Hashtable hashtable)
  29. {
  30. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  31. && card.Owner.HandCards.Count >= 1;
  32. }
  33. bool CanSelectCondition(Permanent permanent)
  34. {
  35. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card)
  36. && (permanent.TopCard.EqualsTraits("Demon")
  37. || permanent.TopCard.EqualsTraits("Shaman")
  38. || permanent.TopCard.EqualsTraits("Titan"));
  39. }
  40. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  41. {
  42. bool discarded = false;
  43. int discardCount = 1;
  44. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  45. selectHandEffect.SetUp(
  46. selectPlayer: card.Owner,
  47. canTargetCondition: (cardSource) => true,
  48. canTargetCondition_ByPreSelecetedList: null,
  49. canEndSelectCondition: null,
  50. maxCount: discardCount,
  51. canNoSelect: true,
  52. canEndNotMax: false,
  53. isShowOpponent: true,
  54. selectCardCoroutine: null,
  55. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  56. mode: SelectHandEffect.Mode.Discard,
  57. cardEffect: activateClass);
  58. selectHandEffect.SetUpCustomMessage("Select 1 Card to trash.", "The opponent is selecting 1 card to trash from their hand.");
  59. yield return StartCoroutine(selectHandEffect.Activate());
  60. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  61. {
  62. if (cardSources.Count >= 1)
  63. {
  64. discarded = true;
  65. yield return null;
  66. }
  67. }
  68. if (discarded)
  69. {
  70. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectCondition))
  71. {
  72. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectCondition));
  73. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  74. selectPermanentEffect.SetUp(
  75. selectPlayer: card.Owner,
  76. canTargetCondition: CanSelectCondition,
  77. canTargetCondition_ByPreSelecetedList: null,
  78. canEndSelectCondition: null,
  79. maxCount: maxCount,
  80. canNoSelect: false,
  81. canEndNotMax: false,
  82. selectPermanentCoroutine: SelectPermanentCoroutine,
  83. afterSelectPermanentCoroutine: null,
  84. mode: SelectPermanentEffect.Mode.Custom,
  85. cardEffect: activateClass);
  86. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to give Blocker and Retaliation.", "The opponent is selecting 1 Digimon to give Blocker and Retaliation.");
  87. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  88. }
  89. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  90. {
  91. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainBlocker(targetPermanent: permanent, effectDuration: EffectDuration.UntilOpponentTurnEnd, activateClass: activateClass));
  92. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainRetaliation(targetPermanent: permanent, effectDuration: EffectDuration.UntilOpponentTurnEnd, activateClass: activateClass));
  93. }
  94. }
  95. }
  96. #endregion
  97. #region On Play
  98. if (timing == EffectTiming.OnEnterFieldAnyone)
  99. {
  100. ActivateClass activateClass = new ActivateClass();
  101. activateClass.SetUpICardEffect(SharedEffectName(), CanUseCondition, card);
  102. activateClass.SetUpActivateClass(SharedCanActivateCondition, hash => SharedActivateCoroutine(hash, activateClass), -1, true, SharedEffectDescription("On Play"));
  103. cardEffects.Add(activateClass);
  104. bool CanUseCondition(Hashtable hashtable)
  105. {
  106. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  107. && CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  108. }
  109. }
  110. #endregion
  111. #region When Digivolving
  112. if (timing == EffectTiming.OnEnterFieldAnyone)
  113. {
  114. ActivateClass activateClass = new ActivateClass();
  115. activateClass.SetUpICardEffect(SharedEffectName(), CanUseCondition, card);
  116. activateClass.SetUpActivateClass(SharedCanActivateCondition, hash => SharedActivateCoroutine(hash, activateClass), -1, true, SharedEffectDescription("When Digivolving"));
  117. cardEffects.Add(activateClass);
  118. bool CanUseCondition(Hashtable hashtable)
  119. {
  120. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  121. && CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  122. }
  123. }
  124. #endregion
  125. #region On Deletion
  126. if (timing == EffectTiming.OnDestroyedAnyone)
  127. {
  128. ActivateClass activateClass = new ActivateClass();
  129. activateClass.SetUpICardEffect("Play 1 lvl 4- [Demon] or [Titan] from trash", CanUseCondition, card);
  130. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDescription());
  131. cardEffects.Add(activateClass);
  132. string EffectDescription() => "[On Deletion] You may play 1 level 4 or lower [Demon] or [Titan] trait Digimon card from your trash without paying the cost.";
  133. bool CanUseCondition(Hashtable hashtable)
  134. {
  135. return CardEffectCommons.CanTriggerOnDeletion(hashtable, card, activateClass);
  136. }
  137. bool CanActivateCondition(Hashtable hashtable)
  138. {
  139. return CardEffectCommons.CanActivateOnDeletion(card, activateClass);
  140. }
  141. bool CanPlayCardCondition(CardSource cardSource)
  142. {
  143. return cardSource.IsDigimon
  144. && cardSource.HasLevel
  145. && cardSource.Level <= 4
  146. && (cardSource.EqualsTraits("Demon")
  147. || cardSource.EqualsTraits("Titan"))
  148. && CardEffectCommons.CanPlayAsNewPermanent(cardSource, false, activateClass);
  149. }
  150. IEnumerator ActivateCoroutine(Hashtable hashtable)
  151. {
  152. int maxCount = Math.Min(1, card.Owner.TrashCards.Count(CanPlayCardCondition));
  153. List<CardSource> selectedCards = new List<CardSource>();
  154. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  155. selectCardEffect.SetUp(
  156. canTargetCondition: CanPlayCardCondition,
  157. canTargetCondition_ByPreSelecetedList: null,
  158. canEndSelectCondition: null,
  159. canNoSelect: () => true,
  160. selectCardCoroutine: SelectCardCoroutine,
  161. afterSelectCardCoroutine: null,
  162. message: "Select 1 card to play.",
  163. maxCount: maxCount,
  164. canEndNotMax: false,
  165. isShowOpponent: true,
  166. mode: SelectCardEffect.Mode.Custom,
  167. root: SelectCardEffect.Root.Trash,
  168. customRootCardList: null,
  169. canLookReverseCard: true,
  170. selectPlayer: card.Owner,
  171. cardEffect: activateClass);
  172. selectCardEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  173. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  174. yield return StartCoroutine(selectCardEffect.Activate());
  175. IEnumerator SelectCardCoroutine(CardSource cardSource)
  176. {
  177. selectedCards.Add(cardSource);
  178. yield return null;
  179. }
  180. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(cardSources: selectedCards, activateClass: activateClass, payCost: false, isTapped: false, root: SelectCardEffect.Root.Trash, activateETB: true));
  181. }
  182. }
  183. #endregion
  184. #region Inherited
  185. if (timing == EffectTiming.None)
  186. {
  187. bool Condition()
  188. {
  189. return CardEffectCommons.IsExistOnBattleArea(card)
  190. && CardEffectCommons.IsOwnerTurn(card)
  191. && (card.PermanentOfThisCard().TopCard.EqualsCardName("Titamon")
  192. || card.PermanentOfThisCard().TopCard.EqualsTraits("Titan"));
  193. }
  194. cardEffects.Add(CardEffectFactory.ChangeSelfSAttackStaticEffect(changeValue: 1, isInheritedEffect: true, card: card, condition: Condition));
  195. }
  196. #endregion
  197. return cardEffects;
  198. }
  199. }
  200. }