BT22_074.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. // SkullMeramon
  5. namespace DCGO.CardEffects.BT22
  6. {
  7. public class BT22_074 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Alternative Digivolution Condition
  13. if (timing == EffectTiming.None)
  14. {
  15. bool PermanentCondition(Permanent targetPermanent)
  16. {
  17. return targetPermanent.TopCard.IsLevel4 && (targetPermanent.TopCard.HasFlameTraits || targetPermanent.TopCard.HasCSTraits);
  18. }
  19. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  20. permanentCondition: PermanentCondition,
  21. digivolutionCost: 3,
  22. ignoreDigivolutionRequirement: false,
  23. card: card,
  24. condition: null)
  25. );
  26. }
  27. #endregion
  28. #region Main
  29. if (timing == EffectTiming.OnDeclaration)
  30. {
  31. ActivateClass activateClass = new ActivateClass();
  32. activateClass.SetUpICardEffect("Pay 3, Delete 1 level 5 or lower digimon, if it didn't Sec +1. then it may attack", CanUseCondition, card);
  33. activateClass.SetUpActivateClass(null, ActivateCoroutine, 1, false, EffectDiscription());
  34. activateClass.SetHashString("BT22_074_Main");
  35. cardEffects.Add(activateClass);
  36. string EffectDiscription()
  37. {
  38. return "[Main] [Once Per Turn] By paying 3 cost, delete 1 of your opponent's level 5 or lower Digimon. If this effect didn't delete, this Digimon gains <Security A. +1> (This Digimon checks 1 additional security card) for the turn. Then, this Digimon may attack.";
  39. }
  40. bool CanUseCondition(Hashtable hashtable)
  41. {
  42. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) && CardEffectCommons.IsOwnerTurn(card);
  43. }
  44. bool CanSelectPermamentCondition(Permanent permanent)
  45. {
  46. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card) &&
  47. permanent.TopCard.HasLevel && permanent.TopCard.Level <= 5;
  48. }
  49. IEnumerator ActivateCoroutine(Hashtable hashtable)
  50. {
  51. yield return ContinuousController.instance.StartCoroutine(card.Owner.AddMemory(-3, activateClass));
  52. if (CardEffectCommons.HasMatchConditionOpponentsPermanent(card, CanSelectPermamentCondition))
  53. {
  54. Permanent selectedPermanent = null;
  55. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  56. selectPermanentEffect.SetUp(
  57. selectPlayer: card.Owner,
  58. canTargetCondition: CanSelectPermamentCondition,
  59. canTargetCondition_ByPreSelecetedList: null,
  60. canEndSelectCondition: null,
  61. maxCount: 1,
  62. canNoSelect: false,
  63. canEndNotMax: false,
  64. selectPermanentCoroutine: SelectPermanentCoroutine,
  65. afterSelectPermanentCoroutine: null,
  66. mode: SelectPermanentEffect.Mode.Custom,
  67. cardEffect: activateClass);
  68. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  69. {
  70. selectedPermanent = permanent;
  71. yield return null;
  72. }
  73. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to destroy", "The opponent is selecting 1 Digimon to destroy");
  74. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  75. if (selectedPermanent != null)
  76. {
  77. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DeletePeremanentAndProcessAccordingToResult
  78. (new List<Permanent>() { selectedPermanent },
  79. activateClass,
  80. null,
  81. FailureProcess
  82. ));
  83. IEnumerator FailureProcess()
  84. {
  85. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonSAttack(card.PermanentOfThisCard(), 1, EffectDuration.UntilEachTurnEnd, activateClass));
  86. }
  87. }
  88. }
  89. else
  90. {
  91. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonSAttack(card.PermanentOfThisCard(), 1, EffectDuration.UntilEachTurnEnd, activateClass));
  92. }
  93. if (card.PermanentOfThisCard().CanAttack(activateClass))
  94. {
  95. SelectAttackEffect selectAttackEffect = GManager.instance.GetComponent<SelectAttackEffect>();
  96. selectAttackEffect.SetUp(
  97. attacker: card.PermanentOfThisCard(),
  98. canAttackPlayerCondition: () => true,
  99. defenderCondition: _ => true,
  100. cardEffect: activateClass);
  101. yield return ContinuousController.instance.StartCoroutine(selectAttackEffect.Activate());
  102. }
  103. }
  104. }
  105. #endregion
  106. #region On Deletion
  107. if (timing == EffectTiming.OnDestroyedAnyone)
  108. {
  109. ActivateClass activateClass = new ActivateClass();
  110. activateClass.SetUpICardEffect("Draw 2 and trash 1 card from hand", CanUseCondition, card);
  111. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  112. cardEffects.Add(activateClass);
  113. string EffectDiscription()
  114. {
  115. return "[On Deletion] <Draw 2> (Draw 2 cards from your deck) and trash 1 card in your hand.";
  116. }
  117. bool CanUseCondition(Hashtable hashtable)
  118. {
  119. return CardEffectCommons.CanTriggerOnDeletion(hashtable, card, activateClass);
  120. }
  121. bool CanActivateCondition(Hashtable hashtable)
  122. {
  123. return CardEffectCommons.CanActivateOnDeletion(card, activateClass);
  124. }
  125. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  126. {
  127. yield return ContinuousController.instance.StartCoroutine(new DrawClass(card.Owner, 2, activateClass).Draw());
  128. if (card.Owner.HandCards.Count >= 1)
  129. {
  130. int discardCount = 1;
  131. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  132. selectHandEffect.SetUp(
  133. selectPlayer: card.Owner,
  134. canTargetCondition: (cardSource) => true,
  135. canTargetCondition_ByPreSelecetedList: null,
  136. canEndSelectCondition: null,
  137. maxCount: discardCount,
  138. canNoSelect: false,
  139. canEndNotMax: false,
  140. isShowOpponent: true,
  141. selectCardCoroutine: null,
  142. afterSelectCardCoroutine: null,
  143. mode: SelectHandEffect.Mode.Discard,
  144. cardEffect: activateClass);
  145. yield return StartCoroutine(selectHandEffect.Activate());
  146. }
  147. }
  148. }
  149. #endregion
  150. #region ESS
  151. if (timing == EffectTiming.OnDestroyedAnyone)
  152. {
  153. ActivateClass activateClass = new ActivateClass();
  154. activateClass.SetUpICardEffect("Play 1 level 4 or lower [Flame]/[CS] Digimon", CanUseCondition, card);
  155. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  156. activateClass.SetIsInheritedEffect(true);
  157. cardEffects.Add(activateClass);
  158. string EffectDiscription()
  159. {
  160. return "[On Deletion] You may play 1 level 4 or lower Digimon card with the [Flame] or [CS] trait from your trash without paying the cost.";
  161. }
  162. bool CanUseCondition(Hashtable hashtable)
  163. {
  164. return CardEffectCommons.CanTriggerOnDeletion(hashtable, card, activateClass);
  165. }
  166. bool CanActivateCondition(Hashtable hashtable)
  167. {
  168. return CardEffectCommons.CanActivateOnDeletion(card, activateClass)
  169. && CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition);
  170. }
  171. bool CanSelectCardCondition(CardSource cardSource)
  172. {
  173. return cardSource.IsDigimon
  174. && (cardSource.HasFlameTraits || cardSource.HasCSTraits)
  175. && cardSource.HasLevel && cardSource.Level <= 4
  176. && CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass);
  177. }
  178. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  179. {
  180. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  181. {
  182. CardSource selectedCard = null;
  183. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionOwnersCardCountInTrash(card, CanSelectCardCondition));
  184. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  185. selectCardEffect.SetUp(
  186. canTargetCondition: CanSelectCardCondition,
  187. canTargetCondition_ByPreSelecetedList: null,
  188. canEndSelectCondition: null,
  189. canNoSelect: () => true,
  190. selectCardCoroutine: SelectCardCoroutine,
  191. afterSelectCardCoroutine: null,
  192. message: "Select 1 digimon card to play.",
  193. maxCount: maxCount,
  194. canEndNotMax: false,
  195. isShowOpponent: true,
  196. mode: SelectCardEffect.Mode.Custom,
  197. root: SelectCardEffect.Root.Trash,
  198. customRootCardList: null,
  199. canLookReverseCard: true,
  200. selectPlayer: card.Owner,
  201. cardEffect: activateClass);
  202. IEnumerator SelectCardCoroutine(CardSource cardSource)
  203. {
  204. selectedCard = cardSource;
  205. yield return null;
  206. }
  207. selectCardEffect.SetUpCustomMessage("Select 1 digimon card to play.", "The opponent is selecting 1 digimon card to play.");
  208. selectCardEffect.SetUpCustomMessage_ShowCard("Selected Card");
  209. yield return StartCoroutine(selectCardEffect.Activate());
  210. if (selectedCard) yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(cardSources: new List<CardSource>() { selectedCard }, activateClass: activateClass, payCost: false, isTapped: false, root: SelectCardEffect.Root.Trash, activateETB: true));
  211. }
  212. }
  213. }
  214. #endregion
  215. return cardEffects;
  216. }
  217. }
  218. }