EX3_057.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.EX3
  6. {
  7. public class EX3_057 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. if (timing == EffectTiming.None)
  13. {
  14. bool PermanentCondition(Permanent targetPermanent)
  15. {
  16. return targetPermanent.TopCard.ContainsCardName("Guilmon");
  17. }
  18. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 2, ignoreDigivolutionRequirement: false, card: card, condition: null));
  19. }
  20. if (timing == EffectTiming.OnEnterFieldAnyone)
  21. {
  22. ActivateClass activateClass = new ActivateClass();
  23. activateClass.SetUpICardEffect("Delete 1 Digimon with 3000 DP or less or both players trash the top 2 cards of their decks", CanUseCondition, card);
  24. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  25. cardEffects.Add(activateClass);
  26. string EffectDiscription()
  27. {
  28. return "[When Digivolving] Delete 1 of your opponent's Digimon with 3000 DP or less. If no Digimon is deleted by this effect, trash the top 2 cards of both players' decks.";
  29. }
  30. bool CanSelectPermanentCondition(Permanent permanent)
  31. {
  32. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  33. {
  34. if (permanent.DP <= card.Owner.MaxDP_DeleteEffect(3000, activateClass))
  35. {
  36. return true;
  37. }
  38. }
  39. return false;
  40. }
  41. bool CanUseCondition(Hashtable hashtable)
  42. {
  43. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  44. }
  45. bool CanActivateCondition(Hashtable hashtable)
  46. {
  47. if (CardEffectCommons.IsExistOnBattleArea(card))
  48. {
  49. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  50. {
  51. return true;
  52. }
  53. else
  54. {
  55. if (GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer.Count((player) => player.LibraryCards.Count >= 1) >= 1)
  56. {
  57. return true;
  58. }
  59. }
  60. }
  61. return false;
  62. }
  63. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  64. {
  65. List<Permanent> deleteTargetPermanents = new List<Permanent>();
  66. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  67. {
  68. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  69. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  70. selectPermanentEffect.SetUp(
  71. selectPlayer: card.Owner,
  72. canTargetCondition: CanSelectPermanentCondition,
  73. canTargetCondition_ByPreSelecetedList: null,
  74. canEndSelectCondition: null,
  75. maxCount: maxCount,
  76. canNoSelect: false,
  77. canEndNotMax: false,
  78. selectPermanentCoroutine: null,
  79. afterSelectPermanentCoroutine: AfterSelectPermanentCoroutine,
  80. mode: SelectPermanentEffect.Mode.Custom,
  81. cardEffect: activateClass);
  82. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to delete.", "The opponent is selecting 1 Digimon to delete.");
  83. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  84. IEnumerator AfterSelectPermanentCoroutine(List<Permanent> permanents)
  85. {
  86. foreach (Permanent permanent in permanents)
  87. {
  88. deleteTargetPermanents.Add(permanent);
  89. }
  90. yield return null;
  91. }
  92. }
  93. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DeletePeremanentAndProcessAccordingToResult(targetPermanents: deleteTargetPermanents, activateClass: activateClass, successProcess: null, failureProcess: FailureProcess));
  94. IEnumerator FailureProcess()
  95. {
  96. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  97. {
  98. if (player.LibraryCards.Count >= 1)
  99. {
  100. IAddTrashCardsFromLibraryTop addTrashCard = new IAddTrashCardsFromLibraryTop(2, player, activateClass);
  101. addTrashCard.SetNotShowCards();
  102. yield return ContinuousController.instance.StartCoroutine(addTrashCard.AddTrashCardsFromLibraryTop());
  103. if (player.isYou)
  104. {
  105. ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().ShowCardEffect2(addTrashCard.discardedCards, "Your Discarded Cards", true, true));
  106. }
  107. else
  108. {
  109. ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().ShowCardEffect(addTrashCard.discardedCards, "Opponent's Discarded Cards", true, true));
  110. }
  111. }
  112. }
  113. }
  114. }
  115. }
  116. if (timing == EffectTiming.OnAllyAttack)
  117. {
  118. ActivateClass activateClass = new ActivateClass();
  119. activateClass.SetUpICardEffect("Delete your Digimon to gain Security Attack +1", CanUseCondition, card);
  120. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  121. activateClass.SetIsInheritedEffect(true);
  122. activateClass.SetHashString("SecurityAttack+1_EX3_057");
  123. cardEffects.Add(activateClass);
  124. string EffectDiscription()
  125. {
  126. return "[When Attacking][Once Per Turn] By deleting 1 of your other Digimon, this Digimon gains <Security Attack +1> for the turn. (This Digimon checks 1 additional security card.)";
  127. }
  128. bool CanSelectPermanentCondition(Permanent permanent)
  129. {
  130. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  131. {
  132. if (permanent != card.PermanentOfThisCard())
  133. {
  134. return true;
  135. }
  136. }
  137. return false;
  138. }
  139. bool CanUseCondition(Hashtable hashtable)
  140. {
  141. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  142. }
  143. bool CanActivateCondition(Hashtable hashtable)
  144. {
  145. if (CardEffectCommons.IsExistOnBattleArea(card))
  146. {
  147. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  148. {
  149. return true;
  150. }
  151. }
  152. return false;
  153. }
  154. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  155. {
  156. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  157. {
  158. int maxCount = Math.Min(1, card.Owner.GetBattleAreaDigimons().Count(CanSelectPermanentCondition));
  159. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  160. selectPermanentEffect.SetUp(
  161. selectPlayer: card.Owner,
  162. canTargetCondition: CanSelectPermanentCondition,
  163. canTargetCondition_ByPreSelecetedList: null,
  164. canEndSelectCondition: null,
  165. maxCount: maxCount,
  166. canNoSelect: true,
  167. canEndNotMax: false,
  168. selectPermanentCoroutine: SelectPermanentCoroutine,
  169. afterSelectPermanentCoroutine: null,
  170. mode: SelectPermanentEffect.Mode.Custom,
  171. cardEffect: activateClass);
  172. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to delete.", "The opponent is selecting 1 Digimon to delete.");
  173. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  174. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  175. {
  176. Permanent thisCardPermanent = card.PermanentOfThisCard();
  177. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DeletePeremanentAndProcessAccordingToResult(targetPermanents: new List<Permanent>() { permanent }, activateClass: activateClass, successProcess: permanents => SuccessProcess(), failureProcess: null));
  178. IEnumerator SuccessProcess()
  179. {
  180. if (thisCardPermanent.TopCard != null)
  181. {
  182. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonSAttack(targetPermanent: thisCardPermanent, changeValue: 1, effectDuration: EffectDuration.UntilEachTurnEnd, activateClass: activateClass));
  183. }
  184. }
  185. }
  186. }
  187. }
  188. }
  189. return cardEffects;
  190. }
  191. }
  192. }