BT23_017.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using UnityEngine;
  6. // Betamon
  7. namespace DCGO.CardEffects.BT23
  8. {
  9. public class BT23_017 : CEntity_Effect
  10. {
  11. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  12. {
  13. List<ICardEffect> cardEffects = new List<ICardEffect>();
  14. #region Alternative Digivolution Condition
  15. if (timing == EffectTiming.None)
  16. {
  17. bool PermanentCondition(Permanent targetPermanent)
  18. {
  19. return targetPermanent.TopCard.HasCSTraits
  20. && targetPermanent.TopCard.HasLevel
  21. && targetPermanent.TopCard.IsLevel2;
  22. }
  23. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  24. permanentCondition: PermanentCondition,
  25. digivolutionCost: 0,
  26. ignoreDigivolutionRequirement: false,
  27. card: card,
  28. condition: null)
  29. );
  30. }
  31. #endregion
  32. #region On Play
  33. if (timing == EffectTiming.OnEnterFieldAnyone)
  34. {
  35. ActivateClass activateClass = new ActivateClass();
  36. activateClass.SetUpICardEffect("Trash 1 card, return 1 non digi-egg [CS] card from trash to hand", CanUseCondition, card);
  37. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  38. cardEffects.Add(activateClass);
  39. string EffectDiscription()
  40. {
  41. return "[On Play] By trashing 1 card in your hand, you may return 1 non-Digi-Egg card with the [CS] trait from your trash to the hand.";
  42. }
  43. bool CanUseCondition(Hashtable hashtable)
  44. {
  45. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  46. && CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  47. }
  48. bool CanActivateCondition(Hashtable hashtable)
  49. {
  50. return CardEffectCommons.IsExistOnBattleArea(card);
  51. }
  52. bool CanSelectCardCondition(CardSource cardSource)
  53. {
  54. return !cardSource.IsDigiEgg
  55. && cardSource.HasCSTraits;
  56. }
  57. IEnumerator ActivateCoroutine(Hashtable hashtable)
  58. {
  59. bool trashed = false;
  60. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  61. selectHandEffect.SetUp(
  62. selectPlayer: card.Owner,
  63. canTargetCondition: (cardSource) => true,
  64. canTargetCondition_ByPreSelecetedList: null,
  65. canEndSelectCondition: null,
  66. maxCount: 1,
  67. canNoSelect: true,
  68. canEndNotMax: false,
  69. isShowOpponent: true,
  70. selectCardCoroutine: null,
  71. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  72. mode: SelectHandEffect.Mode.Discard,
  73. cardEffect: activateClass);
  74. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  75. {
  76. if (cardSources.Any()) trashed = true;
  77. yield return null;
  78. }
  79. selectHandEffect.SetUpCustomMessage("Select 1 card to trash", "Your opponent is selecting 1 card to trash");
  80. selectHandEffect.SetUpCustomMessage_ShowCard("Selected Card");
  81. yield return ContinuousController.instance.StartCoroutine(selectHandEffect.Activate());
  82. if (trashed && CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  83. {
  84. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionOwnersCardCountInTrash(card, CanSelectCardCondition));
  85. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  86. selectCardEffect.SetUp(
  87. canTargetCondition: CanSelectCardCondition,
  88. canTargetCondition_ByPreSelecetedList: null,
  89. canEndSelectCondition: null,
  90. canNoSelect: () => true,
  91. selectCardCoroutine: null,
  92. afterSelectCardCoroutine: null,
  93. message: "Select 1 [CS] card to add to hand.",
  94. maxCount: maxCount,
  95. canEndNotMax: false,
  96. isShowOpponent: true,
  97. mode: SelectCardEffect.Mode.AddHand,
  98. root: SelectCardEffect.Root.Trash,
  99. customRootCardList: null,
  100. canLookReverseCard: true,
  101. selectPlayer: card.Owner,
  102. cardEffect: activateClass);
  103. selectCardEffect.SetUpCustomMessage("Select 1 [CS] card to add to hand.", "The opponent is selecting 1 card to add to hand.");
  104. selectCardEffect.SetUpCustomMessage_ShowCard("Selected Card");
  105. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  106. }
  107. }
  108. }
  109. #endregion
  110. #region ESS - When Attacking
  111. if (timing == EffectTiming.OnAllyAttack)
  112. {
  113. ActivateClass activateClass = new ActivateClass();
  114. activateClass.SetUpICardEffect("Play 1 5 cost or less [Hudie] digimon from hand", CanUseCondition, card);
  115. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  116. activateClass.SetIsInheritedEffect(true);
  117. activateClass.SetHashString("BT23_017_WA");
  118. cardEffects.Add(activateClass);
  119. string EffectDiscription()
  120. {
  121. return "[When Attacking] [Once Per Turn] You may play 1 play cost 5 or lower Digimon card with the [Hudie] trait from your hand without paying the cost. The Digimon this effect played can't digivolve and is deleted at the end of your opponent's turn.";
  122. }
  123. bool CanUseCondition(Hashtable hashtable)
  124. {
  125. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  126. && CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  127. }
  128. bool CanActivateCondition(Hashtable hashtable)
  129. {
  130. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  131. }
  132. bool CanSelectCardCondition(CardSource cardSource)
  133. {
  134. return cardSource.IsDigimon
  135. && cardSource.HasPlayCost && cardSource.BasePlayCostFromEntity <= 5
  136. && cardSource.HasHudieTraits
  137. && CardEffectCommons.CanPlayAsNewPermanent(cardSource, false, activateClass);
  138. }
  139. IEnumerator ActivateCoroutine(Hashtable hashtable)
  140. {
  141. if (CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectCardCondition))
  142. {
  143. CardSource selectedCard = null;
  144. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  145. selectHandEffect.SetUp(
  146. selectPlayer: card.Owner,
  147. canTargetCondition: CanSelectCardCondition,
  148. canTargetCondition_ByPreSelecetedList: null,
  149. canEndSelectCondition: null,
  150. maxCount: 1,
  151. canNoSelect: true,
  152. canEndNotMax: false,
  153. isShowOpponent: true,
  154. selectCardCoroutine: SelectCardCoroutine,
  155. afterSelectCardCoroutine: null,
  156. mode: SelectHandEffect.Mode.Custom,
  157. cardEffect: activateClass);
  158. IEnumerator SelectCardCoroutine(CardSource cardSource)
  159. {
  160. selectedCard = cardSource;
  161. yield return null;
  162. }
  163. selectHandEffect.SetUpCustomMessage("Select 1 [Hudie] digimon to play", "Your opponent is selecting 1 card to play");
  164. selectHandEffect.SetUpCustomMessage_ShowCard("Selected Card");
  165. yield return ContinuousController.instance.StartCoroutine(selectHandEffect.Activate());
  166. if (selectedCard != null)
  167. {
  168. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  169. new List<CardSource>() { selectedCard },
  170. activateClass: activateClass,
  171. payCost: false,
  172. isTapped: false,
  173. root: SelectCardEffect.Root.Hand,
  174. activateETB: true));
  175. yield return new WaitForSeconds(0.2f);
  176. Permanent playedDigimon = selectedCard.PermanentOfThisCard();
  177. #region Can't Digivolve/Delete EoOT
  178. if (playedDigimon != null)
  179. {
  180. #region Can't Digivolve
  181. CanNotDigivolveClass canNotEvolveClass = new CanNotDigivolveClass();
  182. canNotEvolveClass.SetUpICardEffect("Can't digivolve", CanUseCantEvoCondition, card);
  183. canNotEvolveClass.SetUpCanNotEvolveClass(permanentCondition: PermanentCondition, cardCondition: CardCondition);
  184. playedDigimon.PermanentEffects.Add((_timing) => canNotEvolveClass);
  185. bool CanUseCantEvoCondition(Hashtable hashtable)
  186. {
  187. return CardEffectCommons.IsPermanentExistsOnBattleArea(playedDigimon);
  188. }
  189. bool PermanentCondition(Permanent permanent)
  190. {
  191. return permanent == playedDigimon;
  192. }
  193. bool CardCondition(CardSource cardSource)
  194. {
  195. return true;
  196. }
  197. #endregion
  198. #region Delete Digimon Played
  199. yield return ContinuousController.instance.StartCoroutine(
  200. CardEffectCommons.AddSelfDeleteEffect(playedDigimon, CardEffectCommons.DeleteTiming.AtOpponentTurnEnd, activateClass));
  201. #endregion
  202. }
  203. #endregion
  204. }
  205. }
  206. }
  207. }
  208. #endregion
  209. return cardEffects;
  210. }
  211. }
  212. }