BT7_079.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  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_079 : 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("Play 1 Tamer from trash and delete Digimon", CanUseCondition, card);
  17. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  18. cardEffects.Add(activateClass);
  19. string EffectDiscription()
  20. {
  21. return "[When Digivolving] You may play 1 purple Tamer card from your trash without paying its memory cost. Then, for each Tamer you have in play, delete 1 of your opponent's level 4 or lower Digimon.";
  22. }
  23. bool CanSelectCardCondition(CardSource cardSource)
  24. {
  25. if (cardSource != null)
  26. {
  27. if (cardSource.IsTamer)
  28. {
  29. if (cardSource.Owner == card.Owner)
  30. {
  31. if (cardSource.HasCardColor(CardColor.Purple))
  32. {
  33. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  34. {
  35. return true;
  36. }
  37. }
  38. }
  39. }
  40. }
  41. return false;
  42. }
  43. bool CanSelectPermanentCondition(Permanent permanent)
  44. {
  45. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  46. {
  47. if (permanent.Level <= 4)
  48. {
  49. if (permanent.CanSelectBySkill(activateClass))
  50. {
  51. if (permanent.TopCard.HasLevel)
  52. {
  53. return true;
  54. }
  55. }
  56. }
  57. }
  58. return false;
  59. }
  60. bool CanUseCondition(Hashtable hashtable)
  61. {
  62. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  63. }
  64. bool CanActivateCondition(Hashtable hashtable)
  65. {
  66. if (CardEffectCommons.IsExistOnBattleArea(card))
  67. {
  68. return true;
  69. }
  70. return false;
  71. }
  72. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  73. {
  74. if (isExistOnField(card))
  75. {
  76. if (card.Owner.GetBattleAreaDigimons().Contains(card.PermanentOfThisCard()))
  77. {
  78. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  79. {
  80. List<CardSource> selectedCards = new List<CardSource>();
  81. int maxCount = 1;
  82. if (card.Owner.TrashCards.Count(CanSelectCardCondition) <= maxCount)
  83. {
  84. maxCount = card.Owner.TrashCards.Count(CanSelectCardCondition);
  85. }
  86. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  87. selectCardEffect.SetUp(
  88. canTargetCondition: CanSelectCardCondition,
  89. canTargetCondition_ByPreSelecetedList: null,
  90. canEndSelectCondition: null,
  91. canNoSelect: () => true,
  92. selectCardCoroutine: SelectCardCoroutine,
  93. afterSelectCardCoroutine: null,
  94. message: "Select 1 card to play.",
  95. maxCount: maxCount,
  96. canEndNotMax: false,
  97. isShowOpponent: true,
  98. mode: SelectCardEffect.Mode.Custom,
  99. root: SelectCardEffect.Root.Trash,
  100. customRootCardList: null,
  101. canLookReverseCard: true,
  102. selectPlayer: card.Owner,
  103. cardEffect: activateClass);
  104. selectCardEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  105. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  106. yield return StartCoroutine(selectCardEffect.Activate());
  107. IEnumerator SelectCardCoroutine(CardSource cardSource)
  108. {
  109. selectedCards.Add(cardSource);
  110. yield return null;
  111. }
  112. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(cardSources: selectedCards, activateClass: activateClass, payCost: false, isTapped: false, root: SelectCardEffect.Root.Trash, activateETB: true));
  113. }
  114. int tamerCount = card.Owner.GetBattleAreaPermanents().Count((permanent) => permanent.IsTamer);
  115. if (tamerCount >= 1)
  116. {
  117. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  118. {
  119. int maxCount = Math.Min(tamerCount, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  120. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  121. selectPermanentEffect.SetUp(
  122. selectPlayer: card.Owner,
  123. canTargetCondition: CanSelectPermanentCondition,
  124. canTargetCondition_ByPreSelecetedList: null,
  125. canEndSelectCondition: null,
  126. maxCount: maxCount,
  127. canNoSelect: false,
  128. canEndNotMax: false,
  129. selectPermanentCoroutine: null,
  130. afterSelectPermanentCoroutine: null,
  131. mode: SelectPermanentEffect.Mode.Destroy,
  132. cardEffect: activateClass);
  133. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  134. }
  135. }
  136. }
  137. }
  138. }
  139. }
  140. if (timing == EffectTiming.OnDestroyedAnyone)
  141. {
  142. ActivateClass activateClass = new ActivateClass();
  143. activateClass.SetUpICardEffect("Play level 3 Digimon from trash", CanUseCondition, card);
  144. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  145. cardEffects.Add(activateClass);
  146. string EffectDiscription()
  147. {
  148. return "[On Deletion] For each Tamer you have in play, you may play 1 level 3 Digimon card from your trash without paying its memory cost.";
  149. }
  150. bool CanSelectCardCondition(CardSource cardSource)
  151. {
  152. if (cardSource.IsDigimon)
  153. {
  154. if (cardSource.Level == 3)
  155. {
  156. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  157. {
  158. if (cardSource.HasLevel)
  159. {
  160. return true;
  161. }
  162. }
  163. }
  164. }
  165. return false;
  166. }
  167. bool CanUseCondition(Hashtable hashtable)
  168. {
  169. return CardEffectCommons.CanTriggerOnDeletion(hashtable, card, activateClass);
  170. }
  171. bool CanActivateCondition(Hashtable hashtable)
  172. {
  173. if (CardEffectCommons.IsExistOnTrash(card))
  174. {
  175. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, (cardSource) => CanSelectCardCondition(cardSource)))
  176. {
  177. int tamerCount = card.Owner.GetBattleAreaPermanents().Count((permanent) => permanent.IsTamer);
  178. if (tamerCount >= 1)
  179. {
  180. return true;
  181. }
  182. }
  183. }
  184. return false;
  185. }
  186. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  187. {
  188. int tamerCount = card.Owner.GetBattleAreaPermanents().Count((permanent) => permanent.IsTamer);
  189. if (tamerCount >= 1)
  190. {
  191. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, (cardSource) => CanSelectCardCondition(cardSource)))
  192. {
  193. int maxCount = Math.Min(tamerCount, card.Owner.TrashCards.Count((cardSource) => CanSelectCardCondition(cardSource)));
  194. List<CardSource> selectedCards = new List<CardSource>();
  195. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  196. selectCardEffect.SetUp(
  197. canTargetCondition: CanSelectCardCondition,
  198. canTargetCondition_ByPreSelecetedList: null,
  199. canEndSelectCondition: null,
  200. canNoSelect: () => true,
  201. selectCardCoroutine: SelectCardCoroutine,
  202. afterSelectCardCoroutine: null,
  203. message: "Select cards to play.",
  204. maxCount: maxCount,
  205. canEndNotMax: false,
  206. isShowOpponent: true,
  207. mode: SelectCardEffect.Mode.Custom,
  208. root: SelectCardEffect.Root.Trash,
  209. customRootCardList: null,
  210. canLookReverseCard: true,
  211. selectPlayer: card.Owner,
  212. cardEffect: activateClass);
  213. selectCardEffect.SetUpCustomMessage("Select cards to play.", "The opponent is selecting cards to play.");
  214. selectCardEffect.SetUpCustomMessage_ShowCard("Played Cards");
  215. yield return StartCoroutine(selectCardEffect.Activate());
  216. IEnumerator SelectCardCoroutine(CardSource cardSource)
  217. {
  218. selectedCards.Add(cardSource);
  219. yield return null;
  220. }
  221. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(cardSources: selectedCards, activateClass: activateClass, payCost: false, isTapped: false, root: SelectCardEffect.Root.Trash, activateETB: true));
  222. }
  223. }
  224. }
  225. }
  226. return cardEffects;
  227. }
  228. }