BT21_054.cs 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.BT21
  6. {
  7. //Shotmon
  8. public class BT21_054 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. int totalSourceCount = 0;
  14. #region Link Condition
  15. if (timing == EffectTiming.None)
  16. {
  17. static bool PermanentCondition(Permanent targetPermanent)
  18. {
  19. return targetPermanent.TopCard.HasAppmonTraits;
  20. }
  21. cardEffects.Add(CardEffectFactory.AddSelfLinkConditionStaticEffect(permanentCondition: PermanentCondition, linkCost: 1, card: card));
  22. }
  23. #endregion
  24. #region Alternative Digivolution Condition
  25. if (timing == EffectTiming.None)
  26. {
  27. bool PermanentCondition(Permanent targetPermanent)
  28. {
  29. return targetPermanent.TopCard.IsLevel2 && (targetPermanent.TopCard.EqualsTraits("Appmon") || targetPermanent.TopCard.HasText("Three Musketeers"));
  30. }
  31. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  32. permanentCondition: PermanentCondition,
  33. digivolutionCost: 0,
  34. ignoreDigivolutionRequirement: false,
  35. card: card,
  36. condition: null)
  37. );
  38. }
  39. #endregion
  40. #region On Play
  41. if (timing == EffectTiming.OnEnterFieldAnyone)
  42. {
  43. ActivateClass activateClass = new ActivateClass();
  44. activateClass.SetUpICardEffect("Trash 1 source and de-digivolve 1.", CanUseCondition, card);
  45. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDescription());
  46. cardEffects.Add(activateClass);
  47. string EffectDescription()
  48. {
  49. return "[On Play] By trashing 1 card with the [Appmon] or [Three Musketeers] trait from any of your Digimon's digivolution cards, <De-Digivolve 1> 1 of your opponent's Digimon.";
  50. }
  51. bool HasProperTrait(CardSource source)
  52. {
  53. return !source.CanNotTrashFromDigivolutionCards(activateClass) &&
  54. source.EqualsTraits("Appmon") || source.EqualsTraits("Three Musketeers");
  55. }
  56. bool CanSelectTrashTargetCondition(Permanent permanent)
  57. {
  58. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  59. {
  60. totalSourceCount = permanent.DigivolutionCards.Count(HasProperTrait);
  61. if (totalSourceCount >= 1)
  62. {
  63. return true;
  64. }
  65. }
  66. return false;
  67. }
  68. bool CanSelectPermanentCondition(Permanent permanent)
  69. {
  70. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  71. }
  72. bool CanUseCondition(Hashtable hashtable)
  73. {
  74. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  75. }
  76. bool CanActivateCondition(Hashtable hashtable)
  77. {
  78. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  79. CardEffectCommons.HasMatchConditionPermanent(CanSelectTrashTargetCondition) &&
  80. totalSourceCount >= 1;
  81. }
  82. IEnumerator ActivateCoroutine(Hashtable hashtable)
  83. {
  84. bool cardsTrashed = false;
  85. Permanent selectedPermanent = null;
  86. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.SelectTrashDigivolutionCards(
  87. permanentCondition: CanSelectTrashTargetCondition,
  88. cardCondition: HasProperTrait,
  89. maxCount: 1,
  90. canNoTrash: false,
  91. isFromOnly1Permanent: false,
  92. activateClass: activateClass,
  93. afterSelectionCoroutine: AfterTrashedCards
  94. ));
  95. IEnumerator AfterTrashedCards(Permanent permanent, List<CardSource> cards)
  96. {
  97. if (cards.Count == 1)
  98. cardsTrashed = true;
  99. selectedPermanent = permanent;
  100. yield return null;
  101. }
  102. if (cardsTrashed && CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  103. {
  104. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  105. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  106. selectPermanentEffect.SetUp(
  107. selectPlayer: card.Owner,
  108. canTargetCondition: CanSelectPermanentCondition,
  109. canTargetCondition_ByPreSelecetedList: null,
  110. canEndSelectCondition: CanEndSelectCondition,
  111. maxCount: maxCount,
  112. canNoSelect: false,
  113. canEndNotMax: false,
  114. selectPermanentCoroutine: SelectPermanentCoroutine,
  115. afterSelectPermanentCoroutine: null,
  116. mode: SelectPermanentEffect.Mode.Custom,
  117. cardEffect: activateClass);
  118. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to De-Digivolve.", "The opponent is selecting 1 Digimon to De-Digivolve.");
  119. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  120. bool CanEndSelectCondition(List<Permanent> permanents)
  121. {
  122. return permanents.Count > 0;
  123. }
  124. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  125. {
  126. Permanent selectedPermanent = permanent;
  127. if (selectedPermanent != null)
  128. {
  129. yield return ContinuousController.instance.StartCoroutine(new IDegeneration(selectedPermanent, 1, activateClass).Degeneration());
  130. }
  131. yield return null;
  132. }
  133. }
  134. }
  135. }
  136. #endregion
  137. #region Link
  138. if (timing == EffectTiming.OnDeclaration)
  139. {
  140. cardEffects.Add(CardEffectFactory.LinkEffect(card));
  141. }
  142. #endregion
  143. #region When Linking
  144. if (timing == EffectTiming.WhenLinked)
  145. {
  146. ActivateClass activateClass = new ActivateClass();
  147. activateClass.SetUpICardEffect("Delete 1 Digimon with 3 or less Cost", CanUseCondition, card);
  148. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  149. activateClass.SetIsLinkedEffect(true);
  150. cardEffects.Add(activateClass);
  151. string EffectDiscription()
  152. {
  153. return "[When Linking] Delete 1 of your opponent's Digimon with a play cost of 3 or less.";
  154. }
  155. bool CanSelectPermanentCondition(Permanent permanent)
  156. {
  157. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card) &&
  158. permanent.TopCard.HasPlayCost &&
  159. permanent.TopCard.GetCostItself <= 3;
  160. }
  161. bool CanUseCondition(Hashtable hashtable)
  162. {
  163. return CardEffectCommons.CanTriggerWhenLinking(hashtable, null, card);
  164. }
  165. bool CanActivateCondition(Hashtable hashtable)
  166. {
  167. return CardEffectCommons.IsExistOnBattleArea(card) &&
  168. CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition);
  169. }
  170. IEnumerator ActivateCoroutine(Hashtable hashtable)
  171. {
  172. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  173. {
  174. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  175. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  176. selectPermanentEffect.SetUp(
  177. selectPlayer: card.Owner,
  178. canTargetCondition: CanSelectPermanentCondition,
  179. canTargetCondition_ByPreSelecetedList: null,
  180. canEndSelectCondition: null,
  181. maxCount: maxCount,
  182. canNoSelect: false,
  183. canEndNotMax: false,
  184. selectPermanentCoroutine: null,
  185. afterSelectPermanentCoroutine: null,
  186. mode: SelectPermanentEffect.Mode.Destroy,
  187. cardEffect: activateClass);
  188. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  189. }
  190. }
  191. }
  192. #endregion
  193. return cardEffects;
  194. }
  195. }
  196. }