BT7_015.cs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328
  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_015 : 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.None)
  14. {
  15. int count()
  16. {
  17. int count = 0;
  18. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  19. {
  20. count += player.TrashCards.Count((cardSource) => cardSource.IsOption);
  21. }
  22. return count;
  23. }
  24. ChangeCostClass changeCostClass = new ChangeCostClass();
  25. changeCostClass.SetUpICardEffect($"Reduce Play Cost", CanUseCondition, card);
  26. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => false, isChangePayingCost: () => true);
  27. cardEffects.Add(changeCostClass);
  28. bool CanUseCondition(Hashtable hashtable)
  29. {
  30. if (card.Owner.HandCards.Contains(card))
  31. {
  32. return true;
  33. }
  34. return false;
  35. }
  36. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  37. {
  38. if (CardSourceCondition(cardSource))
  39. {
  40. if (RootCondition(root))
  41. {
  42. if (PermanentsCondition(targetPermanents))
  43. {
  44. Cost -= count();
  45. }
  46. }
  47. }
  48. return Cost;
  49. }
  50. bool PermanentsCondition(List<Permanent> targetPermanents)
  51. {
  52. if (targetPermanents == null)
  53. {
  54. return true;
  55. }
  56. else
  57. {
  58. if (targetPermanents.Count((targetPermanent) => targetPermanent != null) == 0)
  59. {
  60. return true;
  61. }
  62. }
  63. return false;
  64. }
  65. bool CardSourceCondition(CardSource cardSource)
  66. {
  67. return cardSource == card;
  68. }
  69. bool RootCondition(SelectCardEffect.Root root)
  70. {
  71. if (root == SelectCardEffect.Root.Hand)
  72. {
  73. return true;
  74. }
  75. return false;
  76. }
  77. bool isUpDown()
  78. {
  79. return true;
  80. }
  81. }
  82. if (timing == EffectTiming.OnEnterFieldAnyone)
  83. {
  84. ActivateClass activateClass = new ActivateClass();
  85. activateClass.SetUpICardEffect("Return cards from trash to deck and delete 1 Digimon", CanUseCondition, card);
  86. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  87. cardEffects.Add(activateClass);
  88. string EffectDiscription()
  89. {
  90. return "[On Play] Return all cards with [Three Musketeers] in their traits and all Option cards from both players' trashes to the bottom of their owners' decks. If 7 or more cards were returned using this effect, delete 1 of your opponent's Digimon with [Three Musketeers] in its traits or 8000 DP or less.";
  91. }
  92. bool CanSelectCardCondition(CardSource cardSource)
  93. {
  94. if (cardSource != null)
  95. {
  96. if (cardSource.IsOption)
  97. {
  98. return true;
  99. }
  100. if (cardSource.CardTraits.Contains("Three Musketeers"))
  101. {
  102. return true;
  103. }
  104. if (cardSource.CardTraits.Contains("ThreeMusketeers"))
  105. {
  106. return true;
  107. }
  108. }
  109. return false;
  110. }
  111. bool CanSelectPermanentCondition(Permanent permanent)
  112. {
  113. if (permanent != null)
  114. {
  115. if (permanent.TopCard != null)
  116. {
  117. if (permanent.IsDigimon)
  118. {
  119. if (permanent.TopCard.Owner == card.Owner.Enemy)
  120. {
  121. if (permanent.TopCard.Owner.GetBattleAreaPermanents().Contains(permanent))
  122. {
  123. if (permanent.DP <= card.Owner.MaxDP_DeleteEffect(8000, activateClass))
  124. {
  125. return true;
  126. }
  127. if (permanent.TopCard.CardTraits.Contains("ThreeMusketeers"))
  128. {
  129. return true;
  130. }
  131. if (permanent.TopCard.CardTraits.Contains("Three Musketeers"))
  132. {
  133. return true;
  134. }
  135. }
  136. }
  137. }
  138. }
  139. }
  140. return false;
  141. }
  142. bool CanUseCondition(Hashtable hashtable)
  143. {
  144. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  145. }
  146. bool CanActivateCondition(Hashtable hashtable)
  147. {
  148. if (isExistOnField(card))
  149. {
  150. if (card.Owner.GetBattleAreaDigimons().Contains(card.PermanentOfThisCard()))
  151. {
  152. int count = 0;
  153. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  154. {
  155. count += player.TrashCards.Count(CanSelectCardCondition);
  156. }
  157. if (count >= 1)
  158. {
  159. return true;
  160. }
  161. }
  162. }
  163. return false;
  164. }
  165. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  166. {
  167. if (isExistOnField(card))
  168. {
  169. if (card.Owner.GetBattleAreaDigimons().Contains(card.PermanentOfThisCard()))
  170. {
  171. int count = 0;
  172. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  173. {
  174. count += player.TrashCards.Count(CanSelectCardCondition);
  175. }
  176. if (count >= 1)
  177. {
  178. yield return ContinuousController.instance.StartCoroutine(PutLibraryBottom(card.Owner));
  179. yield return ContinuousController.instance.StartCoroutine(PutLibraryBottom(card.Owner.Enemy));
  180. IEnumerator PutLibraryBottom(Player player)
  181. {
  182. if (player.TrashCards.Count(CanSelectCardCondition) >= 1)
  183. {
  184. List<CardSource> selectedCards = new List<CardSource>();
  185. foreach (CardSource cardSource in player.TrashCards)
  186. {
  187. if (CanSelectCardCondition(cardSource))
  188. {
  189. selectedCards.Add(cardSource);
  190. }
  191. }
  192. if (selectedCards.Count >= 1)
  193. {
  194. List<CardSource> libraryBottomCards = new List<CardSource>();
  195. if (selectedCards.Count == 1)
  196. {
  197. foreach (CardSource cardSource in selectedCards)
  198. {
  199. libraryBottomCards.Add(cardSource);
  200. }
  201. }
  202. else
  203. {
  204. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  205. selectCardEffect.SetUp(
  206. canTargetCondition: (cardSource) => true,
  207. canTargetCondition_ByPreSelecetedList: null,
  208. canEndSelectCondition: null,
  209. canNoSelect: () => false,
  210. selectCardCoroutine: null,
  211. afterSelectCardCoroutine: AfterSelectCardCoroutine1,
  212. message: "Specify the order to place the card in the deck bottom\n(cards will be placed so that cards with lower numbers are on top).",
  213. maxCount: selectedCards.Count,
  214. canEndNotMax: false,
  215. isShowOpponent: false,
  216. mode: SelectCardEffect.Mode.Custom,
  217. root: SelectCardEffect.Root.Custom,
  218. customRootCardList: selectedCards,
  219. canLookReverseCard: true,
  220. selectPlayer: card.Owner,
  221. cardEffect: activateClass);
  222. selectCardEffect.SetNotShowCard();
  223. selectCardEffect.SetNotAddLog();
  224. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  225. IEnumerator AfterSelectCardCoroutine1(List<CardSource> cardSources)
  226. {
  227. foreach (CardSource cardSource in cardSources)
  228. {
  229. libraryBottomCards.Add(cardSource);
  230. }
  231. yield return null;
  232. }
  233. }
  234. if (libraryBottomCards.Count >= 1)
  235. {
  236. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddLibraryBottomCards(libraryBottomCards));
  237. if (!player.isYou)
  238. {
  239. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().ShowCardEffect(libraryBottomCards, "Deck Bottom Cards", true, true));
  240. }
  241. else
  242. {
  243. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().ShowCardEffect2(libraryBottomCards, "Deck Bottom Cards", true, true));
  244. }
  245. }
  246. }
  247. }
  248. }
  249. if (count >= 7)
  250. {
  251. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  252. {
  253. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  254. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  255. selectPermanentEffect.SetUp(
  256. selectPlayer: card.Owner,
  257. canTargetCondition: CanSelectPermanentCondition,
  258. canTargetCondition_ByPreSelecetedList: null,
  259. canEndSelectCondition: null,
  260. maxCount: maxCount,
  261. canNoSelect: false,
  262. canEndNotMax: false,
  263. selectPermanentCoroutine: null,
  264. afterSelectPermanentCoroutine: null,
  265. mode: SelectPermanentEffect.Mode.Destroy,
  266. cardEffect: activateClass);
  267. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  268. }
  269. }
  270. }
  271. }
  272. }
  273. }
  274. }
  275. return cardEffects;
  276. }
  277. }