BT5_081.cs 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  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 BT5_081 : 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("Delete Digimon", CanUseCondition, card);
  17. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  18. cardEffects.Add(activateClass);
  19. string EffectDiscription()
  20. {
  21. return "[When Digivolving] You may delete 1 of your other Digimon to delete 1 of your opponent's level 5 or lower Digimon.";
  22. }
  23. bool CanSelectPermanentCondition(Permanent permanent)
  24. {
  25. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  26. {
  27. if (permanent != card.PermanentOfThisCard())
  28. {
  29. return true;
  30. }
  31. }
  32. return false;
  33. }
  34. bool CanSelectPermanentCondition1(Permanent permanent)
  35. {
  36. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  37. {
  38. if (permanent.Level <= 5)
  39. {
  40. if (permanent.TopCard.HasLevel)
  41. {
  42. return true;
  43. }
  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. }
  61. return false;
  62. }
  63. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  64. {
  65. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  66. {
  67. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  68. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  69. selectPermanentEffect.SetUp(
  70. selectPlayer: card.Owner,
  71. canTargetCondition: CanSelectPermanentCondition,
  72. canTargetCondition_ByPreSelecetedList: null,
  73. canEndSelectCondition: null,
  74. maxCount: maxCount,
  75. canNoSelect: true,
  76. canEndNotMax: false,
  77. selectPermanentCoroutine: SelectPermanentCoroutine,
  78. afterSelectPermanentCoroutine: null,
  79. mode: SelectPermanentEffect.Mode.Custom,
  80. cardEffect: activateClass);
  81. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to delete.", "The opponent is selecting 1 Digimon to delete.");
  82. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  83. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  84. {
  85. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DeletePeremanentAndProcessAccordingToResult(targetPermanents: new List<Permanent>() { permanent }, activateClass: activateClass, successProcess: permanents => SuccessProcess(), failureProcess: null));
  86. IEnumerator SuccessProcess()
  87. {
  88. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition1))
  89. {
  90. maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition1));
  91. selectPermanentEffect.SetUp(
  92. selectPlayer: card.Owner,
  93. canTargetCondition: CanSelectPermanentCondition1,
  94. canTargetCondition_ByPreSelecetedList: null,
  95. canEndSelectCondition: null,
  96. maxCount: maxCount,
  97. canNoSelect: false,
  98. canEndNotMax: false,
  99. selectPermanentCoroutine: null,
  100. afterSelectPermanentCoroutine: null,
  101. mode: SelectPermanentEffect.Mode.Destroy,
  102. cardEffect: activateClass);
  103. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  104. }
  105. }
  106. }
  107. }
  108. }
  109. }
  110. if (timing == EffectTiming.OnDestroyedAnyone)
  111. {
  112. ActivateClass activateClass = new ActivateClass();
  113. activateClass.SetUpICardEffect("Play 1 level 3 Digimon from trash", CanUseCondition, card);
  114. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  115. activateClass.SetHashString("PlayDigimon_BT5_081");
  116. cardEffects.Add(activateClass);
  117. string EffectDiscription()
  118. {
  119. return "[Your Turn][Once Per Turn] When one of your other Digimon is deleted, you may play 1 level 3 purple Digimon card from your trash without paying its memory cost. Any [On Play] effects on Digimon played with this effect don't activate.";
  120. }
  121. bool CanSelectCardCondition(CardSource cardSource)
  122. {
  123. if (cardSource.IsDigimon)
  124. {
  125. if (cardSource.HasCardColor(CardColor.Purple))
  126. {
  127. if (cardSource.Level == 3)
  128. {
  129. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  130. {
  131. if (cardSource.HasLevel)
  132. {
  133. return true;
  134. }
  135. }
  136. }
  137. }
  138. }
  139. return false;
  140. }
  141. bool PermanentCondition(Permanent permanent)
  142. {
  143. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  144. {
  145. if (permanent != card.PermanentOfThisCard())
  146. {
  147. return true;
  148. }
  149. }
  150. return false;
  151. }
  152. bool CanUseCondition(Hashtable hashtable)
  153. {
  154. if (CardEffectCommons.IsExistOnBattleArea(card))
  155. {
  156. if (CardEffectCommons.CanTriggerOnPermanentDeleted(hashtable, PermanentCondition, activateClass))
  157. {
  158. if (CardEffectCommons.IsOwnerTurn(card))
  159. {
  160. return true;
  161. }
  162. }
  163. }
  164. return false;
  165. }
  166. bool CanActivateCondition(Hashtable hashtable)
  167. {
  168. if (CardEffectCommons.IsExistOnBattleArea(card))
  169. {
  170. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, (cardSource) => CanSelectCardCondition(cardSource)))
  171. {
  172. return true;
  173. }
  174. }
  175. return false;
  176. }
  177. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  178. {
  179. int maxCount = Math.Min(1, card.Owner.TrashCards.Count((cardSource) => CanSelectCardCondition(cardSource)));
  180. List<CardSource> selectedCards = new List<CardSource>();
  181. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  182. selectCardEffect.SetUp(
  183. canTargetCondition: CanSelectCardCondition,
  184. canTargetCondition_ByPreSelecetedList: null,
  185. canEndSelectCondition: null,
  186. canNoSelect: () => true,
  187. selectCardCoroutine: SelectCardCoroutine,
  188. afterSelectCardCoroutine: null,
  189. message: "Select 1 card to play.",
  190. maxCount: maxCount,
  191. canEndNotMax: false,
  192. isShowOpponent: true,
  193. mode: SelectCardEffect.Mode.Custom,
  194. root: SelectCardEffect.Root.Trash,
  195. customRootCardList: null,
  196. canLookReverseCard: true,
  197. selectPlayer: card.Owner,
  198. cardEffect: activateClass);
  199. selectCardEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  200. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  201. yield return StartCoroutine(selectCardEffect.Activate());
  202. IEnumerator SelectCardCoroutine(CardSource cardSource)
  203. {
  204. selectedCards.Add(cardSource);
  205. yield return null;
  206. }
  207. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(cardSources: selectedCards, activateClass: activateClass, payCost: false, isTapped: false, root: SelectCardEffect.Root.Trash, activateETB: false));
  208. }
  209. }
  210. return cardEffects;
  211. }
  212. }