ST14_09.cs 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  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 ST14_09 : 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 4 * (card.Owner.TrashCards.Count / 10);
  18. }
  19. ChangeCostClass changeCostClass = new ChangeCostClass();
  20. changeCostClass.SetUpICardEffect($"Reduce Play Cost", CanUseCondition, card);
  21. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => false, isChangePayingCost: () => true);
  22. cardEffects.Add(changeCostClass);
  23. bool CanUseCondition(Hashtable hashtable)
  24. {
  25. if (card.Owner.HandCards.Contains(card))
  26. {
  27. return true;
  28. }
  29. return false;
  30. }
  31. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  32. {
  33. if (CardSourceCondition(cardSource))
  34. {
  35. if (RootCondition(root))
  36. {
  37. if (PermanentsCondition(targetPermanents))
  38. {
  39. Cost -= count();
  40. }
  41. }
  42. }
  43. return Cost;
  44. }
  45. bool PermanentsCondition(List<Permanent> targetPermanents)
  46. {
  47. if (targetPermanents == null)
  48. {
  49. return true;
  50. }
  51. else
  52. {
  53. if (targetPermanents.Count((targetPermanent) => targetPermanent != null) == 0)
  54. {
  55. return true;
  56. }
  57. }
  58. return false;
  59. }
  60. bool CardSourceCondition(CardSource cardSource)
  61. {
  62. return cardSource == card;
  63. }
  64. bool RootCondition(SelectCardEffect.Root root)
  65. {
  66. if (root == SelectCardEffect.Root.Hand)
  67. {
  68. return true;
  69. }
  70. return false;
  71. }
  72. bool isUpDown()
  73. {
  74. return true;
  75. }
  76. }
  77. if (timing == EffectTiming.OnDiscardLibrary)
  78. {
  79. ActivateClass activateClass = new ActivateClass();
  80. activateClass.SetUpICardEffect("Play 1 [Impmon] from trash", CanUseCondition, card);
  81. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  82. activateClass.SetHashString("PlayImpmon_ST14_09");
  83. cardEffects.Add(activateClass);
  84. string EffectDiscription()
  85. {
  86. return "[All Turns][Once Per Turn] When a card is trashed from your deck, you may play 1 [Impmon] from your trash without paying the cost. The Digimon played by this effect gains <Rush> for the turn.";
  87. }
  88. bool CanSelectCardCondition(CardSource cardSource)
  89. {
  90. if (cardSource.CardNames.Contains("Impmon"))
  91. {
  92. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  93. {
  94. return true;
  95. }
  96. }
  97. return false;
  98. }
  99. bool CanUseCondition(Hashtable hashtable)
  100. {
  101. if (CardEffectCommons.IsExistOnBattleArea(card))
  102. {
  103. if (CardEffectCommons.CanTriggerWhenDiscardLibrary(hashtable, cardSource => cardSource.Owner == card.Owner))
  104. {
  105. return true;
  106. }
  107. }
  108. return false;
  109. }
  110. bool CanActivateCondition(Hashtable hashtable)
  111. {
  112. if (CardEffectCommons.IsExistOnBattleArea(card))
  113. {
  114. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, (cardSource) => CanSelectCardCondition(cardSource)))
  115. {
  116. return true;
  117. }
  118. }
  119. return false;
  120. }
  121. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  122. {
  123. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, (cardSource) => CanSelectCardCondition(cardSource)))
  124. {
  125. int maxCount = Math.Min(1, card.Owner.TrashCards.Count((cardSource) => CanSelectCardCondition(cardSource)));
  126. List<CardSource> selectedCards = new List<CardSource>();
  127. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  128. selectCardEffect.SetUp(
  129. canTargetCondition: CanSelectCardCondition,
  130. canTargetCondition_ByPreSelecetedList: null,
  131. canEndSelectCondition: null,
  132. canNoSelect: () => true,
  133. selectCardCoroutine: SelectCardCoroutine,
  134. afterSelectCardCoroutine: null,
  135. message: "Select 1 card to play.",
  136. maxCount: maxCount,
  137. canEndNotMax: false,
  138. isShowOpponent: true,
  139. mode: SelectCardEffect.Mode.Custom,
  140. root: SelectCardEffect.Root.Trash,
  141. customRootCardList: null,
  142. canLookReverseCard: true,
  143. selectPlayer: card.Owner,
  144. cardEffect: activateClass);
  145. selectCardEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  146. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  147. yield return StartCoroutine(selectCardEffect.Activate());
  148. IEnumerator SelectCardCoroutine(CardSource cardSource)
  149. {
  150. selectedCards.Add(cardSource);
  151. yield return null;
  152. }
  153. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(cardSources: selectedCards, activateClass: activateClass, payCost: false, isTapped: false, root: SelectCardEffect.Root.Trash, activateETB: true));
  154. foreach (CardSource cardSource in selectedCards)
  155. {
  156. if (CardEffectCommons.IsExistOnBattleArea(cardSource))
  157. {
  158. Permanent selectedPermanent = cardSource.PermanentOfThisCard();
  159. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainRush(
  160. targetPermanent: selectedPermanent,
  161. effectDuration: EffectDuration.UntilEachTurnEnd,
  162. activateClass: activateClass));
  163. }
  164. }
  165. }
  166. }
  167. }
  168. if (timing == EffectTiming.OnAllyAttack)
  169. {
  170. ActivateClass activateClass = new ActivateClass();
  171. activateClass.SetUpICardEffect("Trash 1 card from deck top", CanUseCondition, card);
  172. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  173. cardEffects.Add(activateClass);
  174. string EffectDiscription()
  175. {
  176. return "[Opponent's Turn] When an opponent's Digimon attacks, trash the top card of your deck.";
  177. }
  178. bool PermanentCondition(Permanent permanent)
  179. {
  180. return CardEffectCommons.IsOpponentPermanent(permanent, card);
  181. }
  182. bool CanUseCondition(Hashtable hashtable)
  183. {
  184. if (CardEffectCommons.IsExistOnBattleArea(card))
  185. {
  186. if (CardEffectCommons.IsOpponentTurn(card))
  187. {
  188. if (CardEffectCommons.CanTriggerOnPermanentAttack(hashtable, PermanentCondition))
  189. {
  190. return true;
  191. }
  192. }
  193. }
  194. return false;
  195. }
  196. bool CanActivateCondition(Hashtable hashtable)
  197. {
  198. if (CardEffectCommons.IsExistOnBattleArea(card))
  199. {
  200. if (card.Owner.LibraryCards.Count >= 1)
  201. {
  202. return true;
  203. }
  204. }
  205. return false;
  206. }
  207. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  208. {
  209. yield return ContinuousController.instance.StartCoroutine(new IAddTrashCardsFromLibraryTop(1, card.Owner, activateClass).AddTrashCardsFromLibraryTop());
  210. }
  211. }
  212. return cardEffects;
  213. }
  214. }