BT9_107.cs 7.7 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. public class BT9_107 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. if (timing == EffectTiming.OptionSkill)
  14. {
  15. ActivateClass activateClass = new ActivateClass();
  16. activateClass.SetUpICardEffect(card.BaseENGCardNameFromEntity, CanUseCondition, card);
  17. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDiscription());
  18. cardEffects.Add(activateClass);
  19. string EffectDiscription()
  20. {
  21. return "[Main] Trash up to 3 cards in your hand. For each card trashed by this effect, <De-Digivolve 1> 1 of your opponent's Digimon. (Trash 1 card from the top of one of your opponent's Digimon. If it has no digivolution cards, or becomes a level 3 Digimon, you can't trash any more cards.) Then, delete 1 of your opponent's level 4 or lower Digimon.";
  22. }
  23. bool CanSelectPermanentCondition(Permanent permanent)
  24. {
  25. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  26. }
  27. bool CanSelectPermanentCondition1(Permanent permanent)
  28. {
  29. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  30. {
  31. if (permanent.Level <= 4)
  32. {
  33. if (permanent.TopCard.HasLevel)
  34. {
  35. return true;
  36. }
  37. }
  38. }
  39. return false;
  40. }
  41. bool CanUseCondition(Hashtable hashtable)
  42. {
  43. return CardEffectCommons.CanTriggerOptionMainEffect(hashtable, card);
  44. }
  45. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  46. {
  47. int De_DigivolveCount = 0;
  48. if (card.Owner.HandCards.Count >= 1)
  49. {
  50. int discardCount = 3;
  51. if (card.Owner.HandCards.Count < discardCount)
  52. {
  53. discardCount = card.Owner.HandCards.Count;
  54. }
  55. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  56. selectHandEffect.SetUp(
  57. selectPlayer: card.Owner,
  58. canTargetCondition: (cardSource) => true,
  59. canTargetCondition_ByPreSelecetedList: null,
  60. canEndSelectCondition: CanEndSelectCondition,
  61. maxCount: discardCount,
  62. canNoSelect: false,
  63. canEndNotMax: true,
  64. isShowOpponent: true,
  65. selectCardCoroutine: null,
  66. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  67. mode: SelectHandEffect.Mode.Discard,
  68. cardEffect: activateClass);
  69. yield return StartCoroutine(selectHandEffect.Activate());
  70. bool CanEndSelectCondition(List<CardSource> cardSources)
  71. {
  72. if (discardCount >= 1)
  73. {
  74. if (cardSources.Count <= 0)
  75. {
  76. return false;
  77. }
  78. }
  79. return true;
  80. }
  81. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  82. {
  83. De_DigivolveCount = cardSources.Count;
  84. yield return null;
  85. }
  86. }
  87. if (De_DigivolveCount >= 1)
  88. {
  89. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  90. {
  91. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  92. List<Permanent> selectedPermanents = new List<Permanent>();
  93. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  94. selectPermanentEffect.SetUp(
  95. selectPlayer: card.Owner,
  96. canTargetCondition: CanSelectPermanentCondition,
  97. canTargetCondition_ByPreSelecetedList: null,
  98. canEndSelectCondition: null,
  99. maxCount: maxCount,
  100. canNoSelect: false,
  101. canEndNotMax: false,
  102. selectPermanentCoroutine: SelectPermanentCoroutine,
  103. afterSelectPermanentCoroutine: null,
  104. mode: SelectPermanentEffect.Mode.Custom,
  105. cardEffect: activateClass);
  106. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to De-Digivolve.", "The opponent is selecting 1 Digimon to De-Digivolve.");
  107. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  108. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  109. {
  110. selectedPermanents.Add(permanent);
  111. yield return null;
  112. }
  113. if (selectedPermanents.Count >= 1)
  114. {
  115. foreach (Permanent selectedPermanent in selectedPermanents)
  116. {
  117. if (selectedPermanent != null)
  118. {
  119. yield return ContinuousController.instance.StartCoroutine(new IDegeneration(selectedPermanent, De_DigivolveCount, activateClass).Degeneration());
  120. }
  121. }
  122. }
  123. }
  124. }
  125. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition1))
  126. {
  127. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition1));
  128. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  129. selectPermanentEffect.SetUp(
  130. selectPlayer: card.Owner,
  131. canTargetCondition: CanSelectPermanentCondition1,
  132. canTargetCondition_ByPreSelecetedList: null,
  133. canEndSelectCondition: null,
  134. maxCount: maxCount,
  135. canNoSelect: false,
  136. canEndNotMax: false,
  137. selectPermanentCoroutine: null,
  138. afterSelectPermanentCoroutine: null,
  139. mode: SelectPermanentEffect.Mode.Destroy,
  140. cardEffect: activateClass);
  141. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  142. }
  143. }
  144. }
  145. if (timing == EffectTiming.SecuritySkill)
  146. {
  147. CardEffectCommons.AddActivateMainOptionSecurityEffect(card: card, cardEffects: ref cardEffects, effectName: $"Trash cards from hand to De-Digivolve to 1 Digimon and delete 1 level 4 or lower Digimon");
  148. }
  149. return cardEffects;
  150. }
  151. }