EX6_037.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5. using System.Linq;
  6. namespace DCGO.CardEffects.EX6
  7. {
  8. public class EX6_037 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region Alternate Digivolution
  14. if (timing == EffectTiming.None)
  15. {
  16. static bool PermanentCondition(Permanent targetPermanent)
  17. {
  18. return targetPermanent.TopCard.ContainsCardName("Sakuttomon") || targetPermanent.TopCard.ContainsCardName("Kakkinmon");
  19. }
  20. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  21. permanentCondition: PermanentCondition,
  22. digivolutionCost: 0,
  23. ignoreDigivolutionRequirement: false,
  24. card: card,
  25. condition: null));
  26. }
  27. #endregion
  28. #region Hand - Main
  29. if (timing == EffectTiming.OnDeclaration)
  30. {
  31. ActivateClass activateClass = new ActivateClass();
  32. activateClass.SetUpICardEffect("Pay 1 Memory, Place as bottom Digivolution source to Draw 1", CanUseCondition, card);
  33. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, true, EffectDiscription());
  34. cardEffects.Add(activateClass);
  35. string EffectDiscription()
  36. {
  37. return "[Hand] [Main] By paying 1 cost and placing this card as the bottom digivolution card of 1 of your Digimon that's level 3 or has the [Legend-Arms] trait, <Draw 1>.";
  38. }
  39. bool IsLevel3OrHasLegendArmsTrait(Permanent targetPermanent)
  40. {
  41. if(CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(targetPermanent, card))
  42. {
  43. if (targetPermanent.TopCard.HasLevel && targetPermanent.Level == 3)
  44. return true;
  45. if (targetPermanent.TopCard.ContainsTraits("Legend-Arms"))
  46. return true;
  47. }
  48. return false;
  49. }
  50. bool CanUseCondition(Hashtable hashtable)
  51. {
  52. if (CardEffectCommons.IsExistOnHand(card))
  53. {
  54. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, IsLevel3OrHasLegendArmsTrait))
  55. {
  56. return true;
  57. }
  58. }
  59. return false;
  60. }
  61. IEnumerator ActivateCoroutine(Hashtable hashtable)
  62. {
  63. if (CardEffectCommons.HasMatchConditionPermanent(IsLevel3OrHasLegendArmsTrait))
  64. {
  65. Permanent selectedPermanent = null;
  66. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(IsLevel3OrHasLegendArmsTrait));
  67. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  68. selectPermanentEffect.SetUp(
  69. selectPlayer: card.Owner,
  70. canTargetCondition: IsLevel3OrHasLegendArmsTrait,
  71. canTargetCondition_ByPreSelecetedList: null,
  72. canEndSelectCondition: null,
  73. maxCount: maxCount,
  74. canNoSelect: false,
  75. canEndNotMax: false,
  76. selectPermanentCoroutine: SelectPermanentCoroutine,
  77. afterSelectPermanentCoroutine: null,
  78. mode: SelectPermanentEffect.Mode.Custom,
  79. cardEffect: activateClass);
  80. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to add bottom digivolution source.", "The opponent is selecting 1 Digimon to add bottom digivolution source.");
  81. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  82. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  83. {
  84. selectedPermanent = permanent;
  85. yield return null;
  86. }
  87. if(selectedPermanent != null)
  88. {
  89. yield return ContinuousController.instance.StartCoroutine(selectedPermanent.AddDigivolutionCardsBottom(
  90. new List<CardSource>() { card },
  91. activateClass));
  92. yield return ContinuousController.instance.StartCoroutine(card.Owner.AddMemory(-1, activateClass));
  93. yield return ContinuousController.instance.StartCoroutine(new DrawClass(card.Owner, 1, activateClass).Draw());
  94. }
  95. }
  96. }
  97. }
  98. #endregion
  99. #region On Play
  100. if (timing == EffectTiming.OnEnterFieldAnyone)
  101. {
  102. ActivateClass activateClass = new ActivateClass();
  103. activateClass.SetUpICardEffect("Trash 1 [Legend-Arms], <Draw 2>", CanUseCondition, card);
  104. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  105. cardEffects.Add(activateClass);
  106. string EffectDiscription()
  107. {
  108. return "[On Play] By trashing 1 card with the [Legend-Arms] trait in your hand, <Draw 2>.";
  109. }
  110. bool HasLegendArmInTrait(CardSource cardSource)
  111. {
  112. return cardSource.ContainsTraits("Legend-Arms");
  113. }
  114. bool CanUseCondition(Hashtable hashtable)
  115. {
  116. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  117. }
  118. bool CanActivateCondition(Hashtable hashtable)
  119. {
  120. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  121. }
  122. IEnumerator ActivateCoroutine(Hashtable hashtable)
  123. {
  124. if (card.Owner.HandCards.Count(HasLegendArmInTrait) > 0)
  125. {
  126. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  127. selectHandEffect.SetUp(
  128. canTargetCondition: HasLegendArmInTrait,
  129. canTargetCondition_ByPreSelecetedList: null,
  130. canEndSelectCondition: null,
  131. canNoSelect: true,
  132. selectCardCoroutine: null,
  133. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  134. maxCount: 1,
  135. canEndNotMax: false,
  136. isShowOpponent: true,
  137. mode: SelectHandEffect.Mode.Discard,
  138. selectPlayer: card.Owner,
  139. cardEffect: activateClass);
  140. selectHandEffect.SetUpCustomMessage("Select 1 card with [Legend-Arms] trait to discard.", "The opponent is selecting 1 card with [Legend-Arms] trait to discard.");
  141. yield return ContinuousController.instance.StartCoroutine(selectHandEffect.Activate());
  142. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  143. {
  144. if (cardSources.Count > 0)
  145. yield return ContinuousController.instance.StartCoroutine(new DrawClass(card.Owner, 2, activateClass).Draw());
  146. yield return null;
  147. }
  148. }
  149. }
  150. }
  151. #endregion
  152. #region When Attacking
  153. if (timing == EffectTiming.OnAllyAttack)
  154. {
  155. ActivateClass activateClass = new ActivateClass();
  156. activateClass.SetUpICardEffect("Delete 1 3000 DP or less Digimon", CanUseCondition, card);
  157. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDiscription());
  158. activateClass.SetIsInheritedEffect(true);
  159. activateClass.SetHashString("WhenAttacking_EX6_037");
  160. cardEffects.Add(activateClass);
  161. string EffectDiscription()
  162. {
  163. return "[When Attacking] [Once Per Turn] Delete 1 of your opponent's Digimon with 3000 DP or less.";
  164. }
  165. bool DigimonTarget(Permanent permanent)
  166. {
  167. if(CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  168. {
  169. if(permanent.HasDP && permanent.DP <= card.Owner.MaxDP_DeleteEffect(3000, activateClass))
  170. {
  171. return true;
  172. }
  173. }
  174. return false;
  175. }
  176. bool CanUseCondition(Hashtable hashtable)
  177. {
  178. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  179. }
  180. bool CanActivateCondition(Hashtable hashtable)
  181. {
  182. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  183. }
  184. IEnumerator ActivateCoroutine(Hashtable hashtable)
  185. {
  186. if (CardEffectCommons.HasMatchConditionPermanent(DigimonTarget))
  187. {
  188. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(DigimonTarget));
  189. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  190. selectPermanentEffect.SetUp(
  191. selectPlayer: card.Owner,
  192. canTargetCondition: DigimonTarget,
  193. canTargetCondition_ByPreSelecetedList: null,
  194. canEndSelectCondition: null,
  195. maxCount: maxCount,
  196. canNoSelect: false,
  197. canEndNotMax: false,
  198. selectPermanentCoroutine: null,
  199. afterSelectPermanentCoroutine: null,
  200. mode: SelectPermanentEffect.Mode.Destroy,
  201. cardEffect: activateClass);
  202. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to delete.", "The opponent is selecting 1 Digimon to delete.");
  203. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  204. }
  205. }
  206. }
  207. #endregion
  208. return cardEffects;
  209. }
  210. }
  211. }