BT7_066.cs 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  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 BT7_066 : 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.OnEnterFieldAnyone)
  14. {
  15. ActivateClass activateClass = new ActivateClass();
  16. activateClass.SetUpICardEffect("De-Digivolve 3 to 1 Digimon", CanUseCondition, card);
  17. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  18. cardEffects.Add(activateClass);
  19. string EffectDiscription()
  20. {
  21. return "[When Digivolving] Trigger <De-Digivolve 3> on 1 of your opponent's Digimon. (Trash up to 3 cards 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.)";
  22. }
  23. bool CanSelectPermanentCondition(Permanent permanent)
  24. {
  25. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  26. }
  27. bool CanUseCondition(Hashtable hashtable)
  28. {
  29. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  30. }
  31. bool CanActivateCondition(Hashtable hashtable)
  32. {
  33. if (CardEffectCommons.IsExistOnBattleArea(card))
  34. {
  35. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  36. {
  37. return true;
  38. }
  39. }
  40. return false;
  41. }
  42. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  43. {
  44. if (isExistOnField(card))
  45. {
  46. if (card.Owner.GetBattleAreaDigimons().Contains(card.PermanentOfThisCard()))
  47. {
  48. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  49. {
  50. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  51. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  52. selectPermanentEffect.SetUp(
  53. selectPlayer: card.Owner,
  54. canTargetCondition: CanSelectPermanentCondition,
  55. canTargetCondition_ByPreSelecetedList: null,
  56. canEndSelectCondition: CanEndSelectCondition,
  57. maxCount: maxCount,
  58. canNoSelect: false,
  59. canEndNotMax: false,
  60. selectPermanentCoroutine: SelectPermanentCoroutine,
  61. afterSelectPermanentCoroutine: null,
  62. mode: SelectPermanentEffect.Mode.Custom,
  63. cardEffect: activateClass);
  64. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to De-Digivolve.", "The opponent is selecting 1 Digimon to De-Digivolve.");
  65. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  66. bool CanEndSelectCondition(List<Permanent> permanents)
  67. {
  68. if (permanents.Count <= 0)
  69. {
  70. return false;
  71. }
  72. return true;
  73. }
  74. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  75. {
  76. Permanent selectedPermanent = permanent;
  77. if (selectedPermanent != null)
  78. {
  79. yield return ContinuousController.instance.StartCoroutine(new IDegeneration(selectedPermanent, 3, activateClass).Degeneration());
  80. }
  81. yield return null;
  82. }
  83. }
  84. }
  85. }
  86. }
  87. }
  88. if (timing == EffectTiming.OnDestroyedAnyone)
  89. {
  90. ActivateClass activateClass = new ActivateClass();
  91. activateClass.SetUpICardEffect("Play 1 Digimon from hand", CanUseCondition, card);
  92. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  93. cardEffects.Add(activateClass);
  94. string EffectDiscription()
  95. {
  96. return "[On Deletion] You may play 1 black level 4 or lower Digimon card with [Hybrid] in its form from your hand without paying its memory cost.";
  97. }
  98. bool CanSelectCardCondition(CardSource cardSource)
  99. {
  100. if (cardSource != null)
  101. {
  102. if (cardSource.IsDigimon)
  103. {
  104. if (cardSource.Owner == card.Owner)
  105. {
  106. if (cardSource.HasCardColor(CardColor.Black))
  107. {
  108. if (cardSource.Level <= 4)
  109. {
  110. if (cardSource.CardTraits.Contains("Hybrid"))
  111. {
  112. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  113. {
  114. if (cardSource.HasLevel)
  115. {
  116. return true;
  117. }
  118. }
  119. }
  120. }
  121. }
  122. }
  123. }
  124. }
  125. return false;
  126. }
  127. bool CanUseCondition(Hashtable hashtable)
  128. {
  129. return CardEffectCommons.CanTriggerOnDeletion(hashtable, card, activateClass);
  130. }
  131. bool CanActivateCondition(Hashtable hashtable)
  132. {
  133. if (CardEffectCommons.IsExistOnTrash(card))
  134. {
  135. if (card.Owner.HandCards.Count >= 1)
  136. {
  137. return true;
  138. }
  139. }
  140. return false;
  141. }
  142. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  143. {
  144. if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  145. {
  146. List<CardSource> selectedCards = new List<CardSource>();
  147. int maxCount = 1;
  148. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  149. selectHandEffect.SetUp(
  150. selectPlayer: card.Owner,
  151. canTargetCondition: CanSelectCardCondition,
  152. canTargetCondition_ByPreSelecetedList: null,
  153. canEndSelectCondition: null,
  154. maxCount: maxCount,
  155. canNoSelect: true,
  156. canEndNotMax: false,
  157. isShowOpponent: true,
  158. selectCardCoroutine: SelectCardCoroutine,
  159. afterSelectCardCoroutine: null,
  160. mode: SelectHandEffect.Mode.Custom,
  161. cardEffect: activateClass);
  162. selectHandEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  163. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  164. yield return StartCoroutine(selectHandEffect.Activate());
  165. IEnumerator SelectCardCoroutine(CardSource cardSource)
  166. {
  167. selectedCards.Add(cardSource);
  168. yield return null;
  169. }
  170. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(cardSources: selectedCards, activateClass: activateClass, payCost: false, isTapped: false, root: SelectCardEffect.Root.Hand, activateETB: true));
  171. }
  172. }
  173. }
  174. return cardEffects;
  175. }
  176. }