EX3_021.cs 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  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_021 : 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.OnEnterFieldAnyone)
  13. {
  14. ActivateClass activateClass = new ActivateClass();
  15. activateClass.SetUpICardEffect("Trash digivolution cards and opponent's 1 Digimon can't attack and block", CanUseCondition, card);
  16. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  17. cardEffects.Add(activateClass);
  18. string EffectDiscription()
  19. {
  20. return "[When Digivolving] Trash any 2 digivolution cards under 1 of your opponent's Digimon. Then, 1 of your opponent's Digimon with no digivolution cards can't attack or block until the end of your opponent's turn.";
  21. }
  22. bool CanSelectPermanentCondition(Permanent permanent)
  23. {
  24. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  25. {
  26. if (permanent.DigivolutionCards.Count(CanSelectCardCondition) >= 1)
  27. {
  28. return true;
  29. }
  30. }
  31. return false;
  32. }
  33. bool CanSelectCardCondition(CardSource cardSource)
  34. {
  35. return !cardSource.CanNotTrashFromDigivolutionCards(activateClass);
  36. }
  37. bool CanSelectPermanentCondition1(Permanent permanent)
  38. {
  39. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  40. {
  41. if (permanent.HasNoDigivolutionCards)
  42. {
  43. return true;
  44. }
  45. }
  46. return false;
  47. }
  48. bool CanUseCondition(Hashtable hashtable)
  49. {
  50. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  51. }
  52. bool CanActivateCondition(Hashtable hashtable)
  53. {
  54. if (CardEffectCommons.IsExistOnBattleArea(card))
  55. {
  56. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  57. {
  58. return true;
  59. }
  60. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition1))
  61. {
  62. return true;
  63. }
  64. }
  65. return false;
  66. }
  67. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  68. {
  69. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.SelectTrashDigivolutionCards(
  70. permanentCondition: CanSelectPermanentCondition,
  71. cardCondition: CanSelectCardCondition,
  72. maxCount: 2,
  73. canNoTrash: false,
  74. isFromOnly1Permanent: true,
  75. activateClass: activateClass
  76. ));
  77. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition1))
  78. {
  79. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition1));
  80. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  81. selectPermanentEffect.SetUp(
  82. selectPlayer: card.Owner,
  83. canTargetCondition: CanSelectPermanentCondition1,
  84. canTargetCondition_ByPreSelecetedList: null,
  85. canEndSelectCondition: null,
  86. maxCount: maxCount,
  87. canNoSelect: false,
  88. canEndNotMax: false,
  89. selectPermanentCoroutine: SelectPermanentCoroutine,
  90. afterSelectPermanentCoroutine: null,
  91. mode: SelectPermanentEffect.Mode.Custom,
  92. cardEffect: activateClass);
  93. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will get effects.", "The opponent is selecting 1 Digimon that will get effects.");
  94. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  95. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  96. {
  97. Permanent selectedPermanent = permanent;
  98. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainCanNotAttack(
  99. targetPermanent: selectedPermanent,
  100. defenderCondition: null,
  101. effectDuration: EffectDuration.UntilOpponentTurnEnd,
  102. activateClass: activateClass,
  103. effectName: "Can't Attack"));
  104. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainCanNotBlock(
  105. targetPermanent: selectedPermanent,
  106. attackerCondition: null,
  107. effectDuration: EffectDuration.UntilOpponentTurnEnd,
  108. activateClass: activateClass,
  109. effectName: "Can't Block"));
  110. }
  111. }
  112. }
  113. }
  114. return cardEffects;
  115. }
  116. }
  117. }