EX8_061.cs 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. namespace DCGO.CardEffects.EX8
  4. {
  5. public class EX8_061 : CEntity_Effect
  6. {
  7. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  8. {
  9. List<ICardEffect> cardEffects = new List<ICardEffect>();
  10. #region Alternate Digivolution
  11. if (timing == EffectTiming.None)
  12. {
  13. bool PermanentCondition(Permanent targetPermanent)
  14. {
  15. return targetPermanent.TopCard.IsLevel4 && targetPermanent.TopCard.EqualsTraits("DS");
  16. }
  17. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  18. permanentCondition: PermanentCondition,
  19. digivolutionCost: 3,
  20. ignoreDigivolutionRequirement: false,
  21. card: card,
  22. condition: null)
  23. );
  24. }
  25. #endregion
  26. #region Scapegoat
  27. if(timing == EffectTiming.WhenPermanentWouldBeDeleted)
  28. {
  29. string EffectDiscription()
  30. {
  31. return "<Scapegoat> (When this Digimon would be deleted other than by your own effects, by deleting 1 of your other Digimon, prevent that deletion.)";
  32. }
  33. cardEffects.Add(CardEffectFactory.ScapegoatSelfEffect(isInheritedEffect: false, card: card, condition: null, effectName: "<Scapegoat>", effectDiscription: EffectDiscription()));
  34. }
  35. #endregion
  36. #region When Attacking
  37. if (timing == EffectTiming.OnAllyAttack)
  38. {
  39. ActivateClass activateClass = new ActivateClass();
  40. activateClass.SetUpICardEffect("You may play 1 level 4 or lower Digimon", CanUseCondition, card);
  41. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDescription());
  42. activateClass.SetHashString("PlayDigimon_EX8_061");
  43. cardEffects.Add(activateClass);
  44. string EffectDescription()
  45. {
  46. return "[When Attacking] [Once Per Turn] If you have 1 or more memory, you may play 1 level 4 or lower Digimon card with the [DS], [Mollusk], or [Crustacean] trait from your trash without paying the cost.";
  47. }
  48. bool DigimonToPlay(CardSource cardSource)
  49. {
  50. return CardEffectCommons.CanPlayAsNewPermanent(cardSource, false, activateClass, SelectCardEffect.Root.Trash) &&
  51. cardSource.IsDigimon &&
  52. cardSource.HasLevel &&
  53. cardSource.Level <= 4 &&
  54. (cardSource.EqualsTraits("DS") || cardSource.EqualsTraits("Mollusk") || cardSource.EqualsTraits("Crustacean"));
  55. }
  56. bool CanUseCondition(Hashtable hashtable)
  57. {
  58. if(CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  59. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  60. return false;
  61. }
  62. bool CanActivateCondition(Hashtable hashtable)
  63. {
  64. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  65. CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, DigimonToPlay) &&
  66. card.Owner.MemoryForPlayer >= 1;
  67. }
  68. IEnumerator ActivateCoroutine(Hashtable hashtable)
  69. {
  70. List<CardSource> selectedCards = new List<CardSource>();
  71. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  72. selectCardEffect.SetUp(
  73. canTargetCondition: DigimonToPlay,
  74. canTargetCondition_ByPreSelecetedList: null,
  75. canEndSelectCondition: null,
  76. canNoSelect: () => true,
  77. selectCardCoroutine: null,
  78. afterSelectCardCoroutine: SelectCardCoroutine,
  79. message: "Select 1 level 4 or lower Digimon card to play.",
  80. maxCount: 1,
  81. canEndNotMax: false,
  82. isShowOpponent: true,
  83. mode: SelectCardEffect.Mode.Custom,
  84. root: SelectCardEffect.Root.Trash,
  85. customRootCardList: null,
  86. canLookReverseCard: true,
  87. selectPlayer: card.Owner,
  88. cardEffect: activateClass);
  89. selectCardEffect.SetUpCustomMessage(
  90. "Select 1 level 4 or lower Digimon card to play.",
  91. "The opponent is selecting 1 level 4 or lower Digimon card to play.");
  92. selectCardEffect.SetUpCustomMessage_ShowCard("Play Card");
  93. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  94. IEnumerator SelectCardCoroutine(List<CardSource> sources)
  95. {
  96. selectedCards = sources;
  97. yield return null;
  98. }
  99. if (selectedCards.Count > 0)
  100. {
  101. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  102. cardSources: selectedCards,
  103. activateClass: activateClass,
  104. payCost: false,
  105. isTapped: false,
  106. root: SelectCardEffect.Root.Trash,
  107. activateETB: true));
  108. }
  109. }
  110. }
  111. #endregion
  112. #region On Deletion - ESS
  113. if (timing == EffectTiming.OnDestroyedAnyone)
  114. {
  115. ActivateClass activateClass = new ActivateClass();
  116. activateClass.SetUpICardEffect("Play 1 level 4 or lower Digimon", CanUseCondition, card);
  117. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDescription());
  118. activateClass.SetIsInheritedEffect(true);
  119. cardEffects.Add(activateClass);
  120. string EffectDescription()
  121. {
  122. return "[On Deletion] You may play 1 level 4 or lower Digimon card with the [DS], [Mollusk], or [Crustacean] trait from your trash without paying the cost.";
  123. }
  124. bool HasCorrectTrait(CardSource cardSource)
  125. {
  126. if (cardSource.EqualsTraits("DS") || cardSource.EqualsTraits("Mollusk") || cardSource.EqualsTraits("Crustacean"))
  127. {
  128. if (cardSource.HasLevel && cardSource.Level <= 4)
  129. {
  130. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  131. {
  132. return true;
  133. }
  134. }
  135. }
  136. return false;
  137. }
  138. bool CanUseCondition(Hashtable hashtable)
  139. {
  140. return CardEffectCommons.CanTriggerOnDeletion(hashtable, card, activateClass);
  141. }
  142. bool CanActivateCondition(Hashtable hashtable)
  143. {
  144. return CardEffectCommons.CanActivateOnDeletion(card, activateClass) &&
  145. CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, HasCorrectTrait);
  146. }
  147. IEnumerator ActivateCoroutine(Hashtable hashtable)
  148. {
  149. List<CardSource> selectedCards = new List<CardSource>();
  150. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  151. selectCardEffect.SetUp(
  152. canTargetCondition: HasCorrectTrait,
  153. canTargetCondition_ByPreSelecetedList: null,
  154. canEndSelectCondition: null,
  155. canNoSelect: () => true,
  156. selectCardCoroutine: SelectCardCoroutine,
  157. afterSelectCardCoroutine: null,
  158. message: "Select 1 level 4 or lower Digimon card to play.",
  159. maxCount: 1,
  160. canEndNotMax: false,
  161. isShowOpponent: true,
  162. mode: SelectCardEffect.Mode.Custom,
  163. root: SelectCardEffect.Root.Trash,
  164. customRootCardList: null,
  165. canLookReverseCard: true,
  166. selectPlayer: card.Owner,
  167. cardEffect: activateClass);
  168. selectCardEffect.SetUpCustomMessage(
  169. "Select 1 level 4 or lower Digimon card to play.",
  170. "The opponent is selecting 1 level 4 or lower Digimon card to play.");
  171. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  172. yield return StartCoroutine(selectCardEffect.Activate());
  173. IEnumerator SelectCardCoroutine(CardSource cardSource)
  174. {
  175. selectedCards.Add(cardSource);
  176. yield return null;
  177. }
  178. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  179. cardSources: selectedCards,
  180. activateClass: activateClass,
  181. payCost: false,
  182. isTapped: false,
  183. root: SelectCardEffect.Root.Trash,
  184. activateETB: true));
  185. }
  186. }
  187. #endregion
  188. return cardEffects;
  189. }
  190. }
  191. }