BT10_070.cs 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using System.Linq;
  5. using Photon;
  6. using System;
  7. using Photon.Pun;
  8. namespace DCGO.CardEffects.BT10
  9. {
  10. public class BT10_070 : CEntity_Effect
  11. {
  12. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  13. {
  14. List<ICardEffect> cardEffects = new List<ICardEffect>();
  15. if (timing == EffectTiming.None)
  16. {
  17. cardEffects.Add(CardEffectFactory.RushSelfStaticEffect(isInheritedEffect: false, card: card, condition: null));
  18. }
  19. if (timing == EffectTiming.OnEnterFieldAnyone)
  20. {
  21. bool Condition()
  22. {
  23. if (CardEffectCommons.IsExistOnBattleArea(card))
  24. {
  25. if (card.PermanentOfThisCard().DigivolutionCards.Count >= 3)
  26. {
  27. return true;
  28. }
  29. }
  30. return false;
  31. }
  32. cardEffects.Add(CardEffectFactory.BlitzSelfEffect(isInheritedEffect: false, card: card, condition: Condition, isWhenDigivolving: false));
  33. }
  34. if (timing == EffectTiming.OnAllyAttack)
  35. {
  36. ActivateClass activateClass = new ActivateClass();
  37. activateClass.SetUpICardEffect("Trash 1 digivolution card to delete 1 level4 or lower Digimon", CanUseCondition, card);
  38. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  39. cardEffects.Add(activateClass);
  40. string EffectDiscription()
  41. {
  42. return "[Opponent's Turn][Once Per Turn] When an opponent's Digimon attacks, by trashing 1 of this Digimon's digivolution cards, delete 1 of your opponent's level 4 or lower Digimon.";
  43. }
  44. bool PermanentCondition(Permanent permanent)
  45. {
  46. return CardEffectCommons.IsOpponentPermanent(permanent, card);
  47. }
  48. bool CanSelectCardCondition(CardSource cardSource)
  49. {
  50. return !cardSource.CanNotTrashFromDigivolutionCards(activateClass);
  51. }
  52. bool CanSelectPermanentCondition(Permanent permanent)
  53. {
  54. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  55. {
  56. if (permanent.Level <= 4)
  57. {
  58. if (permanent.TopCard.HasLevel)
  59. {
  60. return true;
  61. }
  62. }
  63. }
  64. return false;
  65. }
  66. bool CanUseCondition(Hashtable hashtable)
  67. {
  68. if (CardEffectCommons.IsExistOnBattleArea(card))
  69. {
  70. if (CardEffectCommons.IsOpponentTurn(card))
  71. {
  72. if (CardEffectCommons.CanTriggerOnPermanentAttack(hashtable, PermanentCondition))
  73. {
  74. return true;
  75. }
  76. }
  77. }
  78. return false;
  79. }
  80. bool CanActivateCondition(Hashtable hashtable)
  81. {
  82. if (CardEffectCommons.IsExistOnBattleArea(card))
  83. {
  84. if (card.PermanentOfThisCard().DigivolutionCards.Count(CanSelectCardCondition) >= 1)
  85. {
  86. return true;
  87. }
  88. }
  89. return false;
  90. }
  91. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  92. {
  93. bool trashed = false;
  94. List<CardSource> selectedCards = new List<CardSource>();
  95. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  96. selectCardEffect.SetUp(
  97. canTargetCondition: CanSelectCardCondition,
  98. canTargetCondition_ByPreSelecetedList: null,
  99. canEndSelectCondition: null,
  100. canNoSelect: () => false,
  101. selectCardCoroutine: SelectCardCoroutine,
  102. afterSelectCardCoroutine: null,
  103. message: "Select 1 digivolution card to discard.",
  104. maxCount: 1,
  105. canEndNotMax: false,
  106. isShowOpponent: true,
  107. mode: SelectCardEffect.Mode.Custom,
  108. root: SelectCardEffect.Root.Custom,
  109. customRootCardList: card.PermanentOfThisCard().DigivolutionCards,
  110. canLookReverseCard: true,
  111. selectPlayer: card.Owner,
  112. cardEffect: null);
  113. selectCardEffect.SetUpCustomMessage("Select 1 digivolution card to discard.", "The opponent is selecting 1 digivolution card to discard.");
  114. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  115. IEnumerator SelectCardCoroutine(CardSource cardSource)
  116. {
  117. selectedCards.Add(cardSource);
  118. yield return null;
  119. }
  120. if (selectedCards.Count >= 1)
  121. {
  122. yield return ContinuousController.instance.StartCoroutine(new ITrashDigivolutionCards(card.PermanentOfThisCard(), selectedCards, activateClass).TrashDigivolutionCards());
  123. trashed = true;
  124. }
  125. if (trashed)
  126. {
  127. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  128. {
  129. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  130. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  131. selectPermanentEffect.SetUp(
  132. selectPlayer: card.Owner,
  133. canTargetCondition: CanSelectPermanentCondition,
  134. canTargetCondition_ByPreSelecetedList: null,
  135. canEndSelectCondition: null,
  136. maxCount: maxCount,
  137. canNoSelect: false,
  138. canEndNotMax: false,
  139. selectPermanentCoroutine: null,
  140. afterSelectPermanentCoroutine: null,
  141. mode: SelectPermanentEffect.Mode.Destroy,
  142. cardEffect: activateClass);
  143. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  144. }
  145. }
  146. }
  147. }
  148. return cardEffects;
  149. }
  150. }
  151. }