BT21_056.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.BT21
  6. {
  7. //Vemmon
  8. public class BT21_056 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region On Play
  14. if (timing == EffectTiming.OnEnterFieldAnyone)
  15. {
  16. ActivateClass activateClass = new ActivateClass();
  17. activateClass.SetUpICardEffect("Trash 1 card with [Vemmon] in text from hand to return 1 non-Digi-Egg card with [Vemmon] in text from trash to hand", CanUseCondition, card);
  18. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  19. cardEffects.Add(activateClass);
  20. string EffectDiscription()
  21. {
  22. return "[On Play] By trashing 1 card with [Vemmon] in its text from your hand, you may return 1 non-Digi-Egg card with [Vemmon] in its text from your trash to the hand.";
  23. }
  24. bool CanSelectCardCondition(CardSource cardSource)
  25. {
  26. if (cardSource != null)
  27. {
  28. if (cardSource.Owner == card.Owner)
  29. {
  30. if (cardSource.HasText("Vemmon") && !cardSource.IsDigiEgg)
  31. {
  32. return true;
  33. }
  34. }
  35. }
  36. return false;
  37. }
  38. bool CanUseCondition(Hashtable hashtable)
  39. {
  40. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  41. }
  42. bool CanActivateCondition(Hashtable hashtable)
  43. {
  44. if (CardEffectCommons.IsExistOnBattleArea(card))
  45. {
  46. if (card.Owner.HandCards.Count >= 1)
  47. {
  48. return true;
  49. }
  50. }
  51. return false;
  52. }
  53. IEnumerator ActivateCoroutine(Hashtable hashtable)
  54. {
  55. if (isExistOnField(card))
  56. {
  57. if (card.Owner.GetBattleAreaDigimons().Contains(card.PermanentOfThisCard()))
  58. {
  59. if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  60. {
  61. bool discarded = false;
  62. int discardCount = 1;
  63. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  64. selectHandEffect.SetUp(
  65. selectPlayer: card.Owner,
  66. canTargetCondition: CanSelectCardCondition,
  67. canTargetCondition_ByPreSelecetedList: null,
  68. canEndSelectCondition: null,
  69. maxCount: discardCount,
  70. canNoSelect: true,
  71. canEndNotMax: false,
  72. isShowOpponent: true,
  73. selectCardCoroutine: null,
  74. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  75. mode: SelectHandEffect.Mode.Discard,
  76. cardEffect: activateClass);
  77. yield return StartCoroutine(selectHandEffect.Activate());
  78. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  79. {
  80. if (cardSources.Count >= 1)
  81. {
  82. discarded = true;
  83. yield return null;
  84. }
  85. }
  86. if (discarded)
  87. {
  88. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  89. {
  90. int maxCount = Math.Min(1, card.Owner.TrashCards.Count(CanSelectCardCondition));
  91. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  92. selectCardEffect.SetUp(
  93. canTargetCondition: CanSelectCardCondition,
  94. canTargetCondition_ByPreSelecetedList: null,
  95. canEndSelectCondition: null,
  96. canNoSelect: () => true,
  97. selectCardCoroutine: null,
  98. afterSelectCardCoroutine: null,
  99. message: "Select 1 card to add to your hand.",
  100. maxCount: maxCount,
  101. canEndNotMax: false,
  102. isShowOpponent: true,
  103. mode: SelectCardEffect.Mode.AddHand,
  104. root: SelectCardEffect.Root.Trash,
  105. customRootCardList: null,
  106. canLookReverseCard: true,
  107. selectPlayer: card.Owner,
  108. cardEffect: activateClass);
  109. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  110. }
  111. }
  112. }
  113. }
  114. }
  115. }
  116. }
  117. #endregion
  118. #region Your Turn - ESS
  119. ActivateClass activateClass2 = new ActivateClass();
  120. activateClass2.SetUpICardEffect("Digivolution Cost -1", CanUseCondition2, card);
  121. activateClass2.SetUpActivateClass(CanActivateCondition2, ActivateCoroutine2, 1, false, EffectDiscription2());
  122. activateClass2.SetIsInheritedEffect(true);
  123. activateClass2.SetNotShowUI(true);
  124. activateClass2.SetIsBackgroundProcess(true);
  125. activateClass2.SetHashString("DigivolutionCost-1_BT11_061");
  126. string EffectDiscription2()
  127. {
  128. return "";
  129. }
  130. bool CanUseCondition2(Hashtable hashtable)
  131. {
  132. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  133. {
  134. if (CardEffectCommons.IsOwnerTurn(card))
  135. {
  136. if (CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card))
  137. {
  138. List<CardSource> evoRootTops = CardEffectCommons.GetEvoRootTopsFromEnterFieldHashtable(
  139. hashtable,
  140. permanent => permanent.cardSources.Contains(card));
  141. if (evoRootTops != null)
  142. {
  143. if (!evoRootTops.Contains(card))
  144. {
  145. if (card.PermanentOfThisCard().TopCard.HasText("Vemmon"))
  146. {
  147. return true;
  148. }
  149. }
  150. }
  151. }
  152. }
  153. }
  154. return false;
  155. }
  156. bool CanActivateCondition2(Hashtable hashtable)
  157. {
  158. return CardEffectCommons.IsExistOnBattleArea(card);
  159. }
  160. IEnumerator ActivateCoroutine2(Hashtable _hashtable)
  161. {
  162. yield return null;
  163. }
  164. if (timing == EffectTiming.OnEnterFieldAnyone)
  165. {
  166. cardEffects.Add(activateClass2);
  167. }
  168. if (timing == EffectTiming.None)
  169. {
  170. ChangeCostClass changeCostClass = new ChangeCostClass();
  171. changeCostClass.SetUpICardEffect($"Digivolution Cost -1", CanUseCondition, card);
  172. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => false, isChangePayingCost: () => true);
  173. changeCostClass.SetIsInheritedEffect(true);
  174. cardEffects.Add(changeCostClass);
  175. bool CanUseCondition(Hashtable hashtable)
  176. {
  177. if (CardEffectCommons.IsExistOnBattleArea(card))
  178. {
  179. if (CardEffectCommons.IsOwnerTurn(card))
  180. {
  181. if (!card.cEntity_EffectController.isOverMaxCountPerTurn(activateClass2, activateClass2.MaxCountPerTurn))
  182. {
  183. return true;
  184. }
  185. }
  186. }
  187. return false;
  188. }
  189. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  190. {
  191. if (CardSourceCondition(cardSource))
  192. {
  193. if (RootCondition(root))
  194. {
  195. if (PermanentsCondition(targetPermanents))
  196. {
  197. Cost -= 1;
  198. }
  199. }
  200. }
  201. return Cost;
  202. }
  203. bool PermanentsCondition(List<Permanent> targetPermanents)
  204. {
  205. if (targetPermanents != null)
  206. {
  207. if (targetPermanents.Count(PermanentCondition) >= 1)
  208. {
  209. return true;
  210. }
  211. }
  212. return false;
  213. }
  214. bool PermanentCondition(Permanent targetPermanent)
  215. {
  216. return targetPermanent == card.PermanentOfThisCard();
  217. }
  218. bool CardSourceCondition(CardSource cardSource)
  219. {
  220. if (cardSource.HasText("Vemmon"))
  221. {
  222. return true;
  223. }
  224. return false;
  225. }
  226. bool RootCondition(SelectCardEffect.Root root)
  227. {
  228. return true;
  229. }
  230. bool isUpDown()
  231. {
  232. return true;
  233. }
  234. }
  235. #endregion
  236. return cardEffects;
  237. }
  238. }
  239. }