BT4_095.cs 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  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 BT4_095 : 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("Return a Digi-egg card from trash to the bottom of Digi-Egg deck ", CanUseCondition, card);
  17. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  18. cardEffects.Add(activateClass);
  19. string EffectDiscription()
  20. {
  21. return "[On Play] Return 1 Digi-Egg card from your trash to the bottom of your Digi-Egg deck.";
  22. }
  23. bool CanSelectCardCondition(CardSource cardSource)
  24. {
  25. return cardSource.IsDigiEgg;
  26. }
  27. bool CanUseCondition(Hashtable hashtable)
  28. {
  29. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  30. }
  31. bool CanActivateCondition(Hashtable hashtable)
  32. {
  33. if (CardEffectCommons.IsExistOnBattleArea(card))
  34. {
  35. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  36. {
  37. return true;
  38. }
  39. }
  40. return false;
  41. }
  42. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  43. {
  44. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  45. {
  46. int maxCount = Math.Min(1, card.Owner.TrashCards.Count(CanSelectCardCondition));
  47. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  48. selectCardEffect.SetUp(
  49. canTargetCondition: CanSelectCardCondition,
  50. canTargetCondition_ByPreSelecetedList: null,
  51. canEndSelectCondition: null,
  52. canNoSelect: () => false,
  53. selectCardCoroutine: SelectCardCoroutine,
  54. afterSelectCardCoroutine: null,
  55. message: "Select 1 card to return to the bottom of your Digi-Egg deck.",
  56. maxCount: maxCount,
  57. canEndNotMax: false,
  58. isShowOpponent: true,
  59. mode: SelectCardEffect.Mode.Custom,
  60. root: SelectCardEffect.Root.Trash,
  61. customRootCardList: null,
  62. canLookReverseCard: true,
  63. selectPlayer: card.Owner,
  64. cardEffect: activateClass);
  65. selectCardEffect.SetNotAddLog();
  66. selectCardEffect.SetUpCustomMessage_ShowCard("Digiegg Deck Bottom Card");
  67. selectCardEffect.SetUpCustomMessage(
  68. "Select 1 card to put on bottom of the deck.",
  69. "The opponent is selecting 1 card to put on bottom of the deck.");
  70. yield return StartCoroutine(selectCardEffect.Activate());
  71. IEnumerator SelectCardCoroutine(CardSource cardSource)
  72. {
  73. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddLibraryBottomCards(
  74. new List<CardSource>() { cardSource }));
  75. }
  76. }
  77. }
  78. }
  79. if (timing == EffectTiming.BeforePayCost)
  80. {
  81. ActivateClass activateClass = new ActivateClass();
  82. activateClass.SetUpICardEffect("Digivolution Cost -1", CanUseCondition, card);
  83. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  84. activateClass.SetHashString("Digisorption-1_BT4_095");
  85. cardEffects.Add(activateClass);
  86. string EffectDiscription()
  87. {
  88. return "[Your Turn] When digivolving one of your Digimon into a Digimon card in your hand with <Digi-Burst>, you may suspend this Tamer to reduce the digivolution cost by 1.";
  89. }
  90. bool PermanentCondition(Permanent permanent)
  91. {
  92. return CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card);
  93. }
  94. bool CardCondition(CardSource cardSource)
  95. {
  96. if (cardSource.IsDigimon)
  97. {
  98. if (cardSource.HasDigiBurst)
  99. {
  100. if (CardEffectCommons.IsExistOnHand(cardSource))
  101. {
  102. return true;
  103. }
  104. }
  105. }
  106. return false;
  107. }
  108. bool CanUseCondition(Hashtable hashtable)
  109. {
  110. if (CardEffectCommons.IsExistOnBattleArea(card))
  111. {
  112. if (CardEffectCommons.IsOwnerTurn(card))
  113. {
  114. if (CardEffectCommons.CanTriggerWhenPermanentWouldDigivolve(hashtable, PermanentCondition, CardCondition))
  115. {
  116. return true;
  117. }
  118. }
  119. }
  120. return false;
  121. }
  122. bool CanActivateCondition(Hashtable hashtable)
  123. {
  124. if (CardEffectCommons.IsExistOnBattleArea(card))
  125. {
  126. if (CardEffectCommons.CanActivateSuspendCostEffect(card))
  127. {
  128. return true;
  129. }
  130. }
  131. return false;
  132. }
  133. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  134. {
  135. yield return ContinuousController.instance.StartCoroutine(new SuspendPermanentsClass(
  136. new List<Permanent>() { card.PermanentOfThisCard() },
  137. CardEffectCommons.CardEffectHashtable(activateClass)).Tap());
  138. ContinuousController.instance.PlaySE(GManager.instance.GetComponent<Effects>().BuffSE);
  139. ChangeCostClass changeCostClass = new ChangeCostClass();
  140. changeCostClass.SetUpICardEffect("Digivolution Cost -1", CanUseCondition1, card);
  141. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => false, isChangePayingCost: () => true);
  142. card.Owner.UntilCalculateFixedCostEffect.Add((_timing) => changeCostClass);
  143. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ShowReducedCost(_hashtable));
  144. bool CanUseCondition1(Hashtable hashtable)
  145. {
  146. return true;
  147. }
  148. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  149. {
  150. if (CardSourceCondition(cardSource))
  151. {
  152. if (RootCondition(root))
  153. {
  154. if (PermanentsCondition(targetPermanents))
  155. {
  156. Cost -= 1;
  157. }
  158. }
  159. }
  160. return Cost;
  161. }
  162. bool PermanentsCondition(List<Permanent> targetPermanents)
  163. {
  164. if (targetPermanents != null)
  165. {
  166. if (targetPermanents.Count(PermanentCondition) >= 1)
  167. {
  168. return true;
  169. }
  170. }
  171. return false;
  172. }
  173. bool PermanentCondition(Permanent targetPermanent)
  174. {
  175. if (targetPermanent.TopCard != null)
  176. {
  177. if (targetPermanent.TopCard.Owner == card.Owner)
  178. {
  179. if (targetPermanent.TopCard.Owner.GetBattleAreaPermanents().Contains(targetPermanent))
  180. {
  181. return true;
  182. }
  183. }
  184. }
  185. return false;
  186. }
  187. bool CardSourceCondition(CardSource cardSource)
  188. {
  189. if (cardSource != null)
  190. {
  191. if (cardSource.Owner == card.Owner)
  192. {
  193. if (cardSource.HasDigiBurst)
  194. {
  195. return true;
  196. }
  197. }
  198. }
  199. return false;
  200. }
  201. bool RootCondition(SelectCardEffect.Root root)
  202. {
  203. return true;
  204. }
  205. bool isUpDown()
  206. {
  207. return true;
  208. }
  209. }
  210. }
  211. if (timing == EffectTiming.SecuritySkill)
  212. {
  213. cardEffects.Add(CardEffectFactory.PlaySelfTamerSecurityEffect(card));
  214. }
  215. return cardEffects;
  216. }
  217. }