EX9_029.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. namespace DCGO.CardEffects.EX9
  5. {
  6. public class EX9_029 : CEntity_Effect
  7. {
  8. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  9. {
  10. List<ICardEffect> cardEffects = new List<ICardEffect>();
  11. #region Alternate Digivolution Requirement
  12. if (timing == EffectTiming.None)
  13. {
  14. static bool PermanentCondition(Permanent targetPermanent)
  15. {
  16. return targetPermanent.TopCard.IsLevel3 &&
  17. targetPermanent.TopCard.EqualsTraits("DM");
  18. }
  19. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 2, ignoreDigivolutionRequirement: false, card: card, condition: null));
  20. }
  21. #endregion
  22. #region Training
  23. if (timing == EffectTiming.OnDeclaration)
  24. {
  25. cardEffects.Add(CardEffectFactory.TrainingEffect(card: card));
  26. }
  27. #endregion
  28. #region When Digivolving
  29. if (timing == EffectTiming.OnEnterFieldAnyone)
  30. {
  31. ActivateClass activateClass = new ActivateClass();
  32. activateClass.SetUpICardEffect("Place 1 digimon from hand as source for Recovery +1", CanUseCondition, card);
  33. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDescription());
  34. activateClass.SetHashString("Recover_EX9-029");
  35. cardEffects.Add(activateClass);
  36. string EffectDescription()
  37. {
  38. return "[When Digivolving] [Once Per Turn] By placing 1 card in your hand face down as this Digimon's bottom digivolution card, if you have as many or fewer security cards as this Digimon has face-down digivolution cards, <Recovery +1 (Deck)> (Place the top card of your deck on top of your security stack).";
  39. }
  40. bool CanUseCondition(Hashtable hashtable)
  41. {
  42. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  43. }
  44. bool CanActivateCondition(Hashtable hashtable)
  45. {
  46. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) && card.Owner.HandCards.Count >= 1;
  47. }
  48. bool CanSelectHandCardCondition(CardSource cardSource)
  49. {
  50. return true;
  51. }
  52. IEnumerator ActivateCoroutine(Hashtable hashtable)
  53. {
  54. CardSource selectedCard = null;
  55. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  56. selectHandEffect.SetUp(
  57. selectPlayer: card.Owner,
  58. canTargetCondition: CanSelectHandCardCondition,
  59. canTargetCondition_ByPreSelecetedList: null,
  60. canEndSelectCondition: null,
  61. maxCount: 1,
  62. canNoSelect: true,
  63. canEndNotMax: false,
  64. isShowOpponent: false,
  65. selectCardCoroutine: SelectCardCoroutine,
  66. afterSelectCardCoroutine: null,
  67. mode: SelectHandEffect.Mode.Custom,
  68. cardEffect: activateClass);
  69. selectHandEffect.SetUpCustomMessage("Select 1 card to place face-down on bottom of digivolution cards.", "The opponent is selecting 1 card to place face-down on bottom of digivolution cards.");
  70. yield return ContinuousController.instance.StartCoroutine(selectHandEffect.Activate());
  71. IEnumerator SelectCardCoroutine(CardSource cardSource)
  72. {
  73. selectedCard = cardSource;
  74. yield return null;
  75. }
  76. if(selectedCard != null)
  77. {
  78. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddExecutingCard(selectedCard));
  79. yield return ContinuousController.instance.StartCoroutine(card.PermanentOfThisCard().AddDigivolutionCardsBottom(new List<CardSource>() { selectedCard }, activateClass, isFacedown: true));
  80. if (card.Owner.SecurityCards.Count <= card.PermanentOfThisCard().DigivolutionCards.Filter(x => x.IsFlipped).Count)
  81. yield return ContinuousController.instance.StartCoroutine(new IRecovery(card.Owner, 1, activateClass).Recovery());
  82. }
  83. }
  84. }
  85. #endregion
  86. #region When Attacking
  87. if (timing == EffectTiming.OnAllyAttack)
  88. {
  89. ActivateClass activateClass = new ActivateClass();
  90. activateClass.SetUpICardEffect("Place 1 digimon from hand as source for Recovery +1", CanUseCondition, card);
  91. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDescription());
  92. activateClass.SetHashString("Recover_EX9-029");
  93. cardEffects.Add(activateClass);
  94. string EffectDescription()
  95. {
  96. return "[When Attacking] [Once Per Turn] By placing 1 card in your hand face down as this Digimon's bottom digivolution card, if you have as many or fewer security cards as this Digimon has face-down digivolution cards, <Recovery +1 (Deck)> (Place the top card of your deck on top of your security stack).";
  97. }
  98. bool CanUseCondition(Hashtable hashtable)
  99. {
  100. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  101. }
  102. bool CanActivateCondition(Hashtable hashtable)
  103. {
  104. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  105. card.Owner.HandCards.Count >= 1 &&
  106. CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectHandCardCondition);
  107. }
  108. bool CanSelectHandCardCondition(CardSource cardSource)
  109. {
  110. return true;
  111. }
  112. IEnumerator ActivateCoroutine(Hashtable hashtable)
  113. {
  114. CardSource selectedCard = null;
  115. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  116. selectHandEffect.SetUp(
  117. selectPlayer: card.Owner,
  118. canTargetCondition: CanSelectHandCardCondition,
  119. canTargetCondition_ByPreSelecetedList: null,
  120. canEndSelectCondition: null,
  121. maxCount: 1,
  122. canNoSelect: true,
  123. canEndNotMax: false,
  124. isShowOpponent: false,
  125. selectCardCoroutine: SelectCardCoroutine,
  126. afterSelectCardCoroutine: null,
  127. mode: SelectHandEffect.Mode.Custom,
  128. cardEffect: activateClass);
  129. selectHandEffect.SetUpCustomMessage("Select 1 card to place face-down on bottom of digivolution cards.",
  130. "The opponent is selecting 1 card to place face-down on bottom of digivolution cards.");
  131. yield return ContinuousController.instance.StartCoroutine(selectHandEffect.Activate());
  132. IEnumerator SelectCardCoroutine(CardSource cardSource)
  133. {
  134. selectedCard = cardSource;
  135. yield return null;
  136. }
  137. if (selectedCard != null)
  138. {
  139. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddExecutingCard(selectedCard));
  140. yield return ContinuousController.instance.StartCoroutine(card.PermanentOfThisCard().AddDigivolutionCardsBottom(new List<CardSource>() { selectedCard }, activateClass, isFacedown: true));
  141. if (card.Owner.SecurityCards.Count <= card.PermanentOfThisCard().DigivolutionCards.Filter(x => x.IsFlipped).Count)
  142. yield return ContinuousController.instance.StartCoroutine(new IRecovery(card.Owner, 1, activateClass).Recovery());
  143. }
  144. }
  145. }
  146. #endregion
  147. #region When Attacking - ESS
  148. if (timing == EffectTiming.OnAllyAttack)
  149. {
  150. ActivateClass activateClass = new ActivateClass();
  151. activateClass.SetUpICardEffect("DP -2000", CanUseCondition, card);
  152. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDescription());
  153. activateClass.SetIsInheritedEffect(true);
  154. activateClass.SetHashString("DP-2000_EX9-029");
  155. cardEffects.Add(activateClass);
  156. string EffectDescription()
  157. {
  158. return "[When Attacking][Once Per Turn] 1 of your opponent's Digimon gets -2000 DP for the turn.";
  159. }
  160. bool CanSelectPermanentCondition(Permanent permanent)
  161. {
  162. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  163. }
  164. bool CanUseCondition(Hashtable hashtable)
  165. {
  166. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  167. }
  168. bool CanActivateCondition(Hashtable hashtable)
  169. {
  170. return CardEffectCommons.IsExistOnBattleArea(card);
  171. }
  172. IEnumerator ActivateCoroutine(Hashtable hashtable)
  173. {
  174. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  175. {
  176. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  177. SelectPermanentEffect selectPermanentEffect =
  178. GManager.instance.GetComponent<SelectPermanentEffect>();
  179. selectPermanentEffect.SetUp(
  180. selectPlayer: card.Owner,
  181. canTargetCondition: CanSelectPermanentCondition,
  182. canTargetCondition_ByPreSelecetedList: null,
  183. canEndSelectCondition: null,
  184. maxCount: maxCount,
  185. canNoSelect: false,
  186. canEndNotMax: false,
  187. selectPermanentCoroutine: SelectPermanentCoroutine,
  188. afterSelectPermanentCoroutine: null,
  189. mode: SelectPermanentEffect.Mode.Custom,
  190. cardEffect: activateClass);
  191. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will get DP -2000.",
  192. "The opponent is selecting 1 Digimon that will get DP -2000.");
  193. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  194. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  195. {
  196. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDP(
  197. targetPermanent: permanent,
  198. changeValue: -2000,
  199. effectDuration: EffectDuration.UntilEachTurnEnd,
  200. activateClass: activateClass));
  201. }
  202. }
  203. }
  204. }
  205. #endregion
  206. return cardEffects;
  207. }
  208. }
  209. }