BT6_112.cs 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  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 BT6_112 : 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. return card.Owner.TrashCards.Count(cardSource =>
  18. (cardSource.IsDigimon && (cardSource.CardTraits.Contains("Three Musketeers") || cardSource.CardTraits.Contains("ThreeMusketeers")))
  19. || (cardSource.IsOption && cardSource.GetCostItself == 7 && cardSource.HasUseCost));
  20. }
  21. ChangeCostClass changeCostClass = new ChangeCostClass();
  22. changeCostClass.SetUpICardEffect($"Reduce Play Cost", CanUseCondition, card);
  23. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => false, isChangePayingCost: () => true);
  24. cardEffects.Add(changeCostClass);
  25. bool CanUseCondition(Hashtable hashtable)
  26. {
  27. if (card.Owner.HandCards.Contains(card))
  28. {
  29. changeCostClass.SetEffectName($"Play Cost -{count()}");
  30. return true;
  31. }
  32. return false;
  33. }
  34. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  35. {
  36. if (CardSourceCondition(cardSource))
  37. {
  38. if (RootCondition(root))
  39. {
  40. if (PermanentsCondition(targetPermanents))
  41. {
  42. Cost -= count();
  43. }
  44. }
  45. }
  46. return Cost;
  47. }
  48. bool PermanentsCondition(List<Permanent> targetPermanents)
  49. {
  50. if (targetPermanents == null)
  51. {
  52. return true;
  53. }
  54. else
  55. {
  56. if (targetPermanents.Count((targetPermanent) => targetPermanent != null) == 0)
  57. {
  58. return true;
  59. }
  60. }
  61. return false;
  62. }
  63. bool CardSourceCondition(CardSource cardSource)
  64. {
  65. return cardSource == card;
  66. }
  67. bool RootCondition(SelectCardEffect.Root root)
  68. {
  69. return root == SelectCardEffect.Root.Hand;
  70. }
  71. bool isUpDown()
  72. {
  73. return true;
  74. }
  75. }
  76. if (timing == EffectTiming.OnEnterFieldAnyone)
  77. {
  78. ActivateClass activateClass = new ActivateClass();
  79. activateClass.SetUpICardEffect("Return 1 Option from trash to hand and play 1 Option from hand", CanUseCondition, card);
  80. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  81. cardEffects.Add(activateClass);
  82. string EffectDiscription()
  83. {
  84. return "[On Play] Return 1 Option card with a memory cost of 7 from your trash to your hand. Then, use 1 Option card with a memory cost of 7 in your hand without paying its memory cost.";
  85. }
  86. bool CanSelectCardCondition(CardSource cardSource)
  87. {
  88. if (cardSource.IsOption)
  89. {
  90. if (cardSource.GetCostItself == 7)
  91. {
  92. if (cardSource.HasUseCost)
  93. {
  94. return true;
  95. }
  96. }
  97. }
  98. return false;
  99. }
  100. bool CanSelectCardCondition1(CardSource cardSource)
  101. {
  102. if (cardSource.IsOption)
  103. {
  104. if (cardSource.GetCostItself == 7)
  105. {
  106. if (cardSource.HasUseCost)
  107. {
  108. if (!cardSource.CanNotPlayThisOption)
  109. {
  110. return true;
  111. }
  112. }
  113. }
  114. }
  115. return false;
  116. }
  117. bool CanUseCondition(Hashtable hashtable)
  118. {
  119. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  120. }
  121. bool CanActivateCondition(Hashtable hashtable)
  122. {
  123. if (CardEffectCommons.IsExistOnBattleArea(card))
  124. {
  125. return true;
  126. }
  127. return false;
  128. }
  129. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  130. {
  131. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  132. {
  133. int maxCount = Math.Min(1, card.Owner.TrashCards.Count(CanSelectCardCondition));
  134. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  135. selectCardEffect.SetUp(
  136. canTargetCondition: CanSelectCardCondition,
  137. canTargetCondition_ByPreSelecetedList: null,
  138. canEndSelectCondition: null,
  139. canNoSelect: () => false,
  140. selectCardCoroutine: null,
  141. afterSelectCardCoroutine: null,
  142. message: "Select 1 card to add to your hand.",
  143. maxCount: maxCount,
  144. canEndNotMax: false,
  145. isShowOpponent: true,
  146. mode: SelectCardEffect.Mode.AddHand,
  147. root: SelectCardEffect.Root.Trash,
  148. customRootCardList: null,
  149. canLookReverseCard: true,
  150. selectPlayer: card.Owner,
  151. cardEffect: activateClass);
  152. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  153. }
  154. if (card.Owner.HandCards.Count(CanSelectCardCondition1) >= 1)
  155. {
  156. List<CardSource> selectedCards = new List<CardSource>();
  157. int maxCount = 1;
  158. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  159. selectHandEffect.SetUp(
  160. selectPlayer: card.Owner,
  161. canTargetCondition: CanSelectCardCondition1,
  162. canTargetCondition_ByPreSelecetedList: null,
  163. canEndSelectCondition: null,
  164. maxCount: maxCount,
  165. canNoSelect: true,
  166. canEndNotMax: false,
  167. isShowOpponent: true,
  168. selectCardCoroutine: SelectCardCoroutine,
  169. afterSelectCardCoroutine: null,
  170. mode: SelectHandEffect.Mode.Custom,
  171. cardEffect: activateClass);
  172. selectHandEffect.SetUpCustomMessage(
  173. "Select 1 option card to use.",
  174. "The opponent is selecting 1 option card to use.");
  175. selectHandEffect.SetUpCustomMessage_ShowCard("Used Card");
  176. yield return StartCoroutine(selectHandEffect.Activate());
  177. IEnumerator SelectCardCoroutine(CardSource cardSource)
  178. {
  179. selectedCards.Add(cardSource);
  180. yield return null;
  181. }
  182. yield return ContinuousController.instance.StartCoroutine(
  183. CardEffectCommons.PlayOptionCards(
  184. cardSources: selectedCards,
  185. activateClass: activateClass,
  186. payCost: false,
  187. root: SelectCardEffect.Root.Hand));
  188. }
  189. }
  190. }
  191. return cardEffects;
  192. }
  193. }