BT21_022.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. //Canoweissmon
  6. namespace DCGO.CardEffects.BT21
  7. {
  8. public class BT21_022 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region Alternative Digivolution Condition
  14. if (timing == EffectTiming.None)
  15. {
  16. bool PermanentCondition(Permanent targetPermanent)
  17. {
  18. if (targetPermanent.TopCard.Level == 4)
  19. {
  20. if (targetPermanent.TopCard.HasText("Gammamon"))
  21. {
  22. return true;
  23. }
  24. }
  25. return false;
  26. }
  27. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  28. permanentCondition: PermanentCondition,
  29. digivolutionCost: 3,
  30. ignoreDigivolutionRequirement: false,
  31. card: card,
  32. condition: null)
  33. );
  34. }
  35. #endregion
  36. #region On Play / When Digivolving Shared
  37. bool CanSelectCardCondition(CardSource cardSource)
  38. {
  39. if (cardSource.IsDigimon)
  40. {
  41. if (cardSource.HasText("Gammamon"))
  42. {
  43. return true;
  44. }
  45. }
  46. return false;
  47. }
  48. bool SharedCanActivateCondition(Hashtable hashtable)
  49. {
  50. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  51. {
  52. if (CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectCardCondition))
  53. {
  54. return true;
  55. }
  56. }
  57. return false;
  58. }
  59. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  60. {
  61. bool CanSelectPermanentCondition(Permanent permanent)
  62. {
  63. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  64. {
  65. if (permanent.DP <= card.Owner.MaxDP_DeleteEffect(7000, activateClass))
  66. {
  67. return true;
  68. }
  69. }
  70. return false;
  71. }
  72. bool cardAdded = false;
  73. CardSource selectedCard = null;
  74. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  75. selectHandEffect.SetUp(
  76. selectPlayer: card.Owner,
  77. canTargetCondition: CanSelectCardCondition,
  78. canTargetCondition_ByPreSelecetedList: null,
  79. canEndSelectCondition: null,
  80. maxCount: 1,
  81. canNoSelect: true,
  82. canEndNotMax: false,
  83. isShowOpponent: true,
  84. selectCardCoroutine: SelectCardCoroutine,
  85. afterSelectCardCoroutine: null,
  86. mode: SelectHandEffect.Mode.Custom,
  87. cardEffect: activateClass);
  88. selectHandEffect.SetUpCustomMessage("Select 1 card.", "The opponent is selecting 1 card.");
  89. selectHandEffect.SetUpCustomMessage_ShowCard("Selected Card");
  90. yield return StartCoroutine(selectHandEffect.Activate());
  91. IEnumerator SelectCardCoroutine(CardSource cardSource)
  92. {
  93. selectedCard = cardSource;
  94. yield return null;
  95. }
  96. if (selectedCard != null)
  97. {
  98. yield return ContinuousController.instance.StartCoroutine(card.PermanentOfThisCard().AddDigivolutionCardsBottom(new List<CardSource>() { selectedCard }, activateClass));
  99. cardAdded = true;
  100. }
  101. if (cardAdded)
  102. {
  103. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  104. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  105. selectPermanentEffect.SetUp(
  106. selectPlayer: card.Owner,
  107. canTargetCondition: CanSelectPermanentCondition,
  108. canTargetCondition_ByPreSelecetedList: null,
  109. canEndSelectCondition: null,
  110. maxCount: maxCount,
  111. canNoSelect: false,
  112. canEndNotMax: false,
  113. selectPermanentCoroutine: null,
  114. afterSelectPermanentCoroutine: null,
  115. mode: SelectPermanentEffect.Mode.Destroy,
  116. cardEffect: activateClass);
  117. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  118. }
  119. }
  120. #endregion
  121. #region On Play
  122. if (timing == EffectTiming.OnEnterFieldAnyone)
  123. {
  124. ActivateClass activateClass = new ActivateClass();
  125. activateClass.SetUpICardEffect("Add card from hand as source, destroy a 7k or less digimon", CanUseCondition, card);
  126. activateClass.SetUpActivateClass(SharedCanActivateCondition, hashtable => SharedActivateCoroutine(hashtable, activateClass), -1, true, EffectDiscription());
  127. cardEffects.Add(activateClass);
  128. string EffectDiscription()
  129. => "[On Play] By placing 1 Digimon card with [Gammamon] in its text from your hand as this Digimon's bottom digivolution card, delete 1 of your opponent's Digimon with 7000 DP or less.";
  130. bool CanUseCondition(Hashtable hashtable)
  131. {
  132. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  133. {
  134. if (CardEffectCommons.CanTriggerOnPlay(hashtable, card))
  135. {
  136. return true;
  137. }
  138. }
  139. return false;
  140. }
  141. }
  142. #endregion
  143. #region When Digivolving
  144. if (timing == EffectTiming.OnEnterFieldAnyone)
  145. {
  146. ActivateClass activateClass = new ActivateClass();
  147. activateClass.SetUpICardEffect("Add card from hand as source, destroy a 7k or less digimon", CanUseCondition, card);
  148. activateClass.SetUpActivateClass(SharedCanActivateCondition, hashtable => SharedActivateCoroutine(hashtable, activateClass), -1, true, EffectDiscription());
  149. cardEffects.Add(activateClass);
  150. string EffectDiscription()
  151. => "[When Digivolving] By placing 1 Digimon card with [Gammamon] in its text from your hand as this Digimon's bottom digivolution card, delete 1 of your opponent's Digimon with 7000 DP or less.";
  152. bool CanUseCondition(Hashtable hashtable)
  153. {
  154. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  155. {
  156. if (CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card))
  157. {
  158. return true;
  159. }
  160. }
  161. return false;
  162. }
  163. }
  164. #endregion
  165. #region ESS
  166. if (timing == EffectTiming.WhenRemoveField)
  167. {
  168. ActivateClass activateClass = new ActivateClass();
  169. activateClass.SetUpICardEffect("Prevent from leaving", CanUseCondition, card);
  170. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  171. activateClass.SetIsInheritedEffect(true);
  172. activateClass.SetHashString("PreventLeaving_BT21_022");
  173. cardEffects.Add(activateClass);
  174. string EffectDiscription()
  175. => "[All Turns] [Once Per Turn] When this Digimon with [Gammamon] in its text would leave the battle area by your opponent's effects, by trashing 3 Digimon cards from its digivolution cards, it doesn't leave.";
  176. bool SourceCondition(CardSource source)
  177. {
  178. return source.IsDigimon;
  179. }
  180. bool CanUseCondition(Hashtable hashtable)
  181. {
  182. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  183. {
  184. if (CardEffectCommons.CanTriggerWhenRemoveField(hashtable, card))
  185. {
  186. if (CardEffectCommons.IsByEffect(hashtable, CardEffectCondition))
  187. {
  188. return true;
  189. }
  190. }
  191. }
  192. return false;
  193. }
  194. bool CanActivateCondition(Hashtable hashtable)
  195. {
  196. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  197. {
  198. if (card.PermanentOfThisCard().TopCard.HasText("Gammamon"))
  199. {
  200. if(card.PermanentOfThisCard().DigivolutionCards.Count(SourceCondition) >= 3)
  201. return true;
  202. }
  203. }
  204. return false;
  205. }
  206. bool CardEffectCondition(ICardEffect effect)
  207. {
  208. return CardEffectCommons.IsOpponentEffect(effect, card);
  209. }
  210. IEnumerator ActivateCoroutine(Hashtable hashtable)
  211. {
  212. Permanent permanent = card.PermanentOfThisCard();
  213. List<CardSource> selectedCards = new List<CardSource>();
  214. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  215. selectCardEffect.SetUp(
  216. canTargetCondition: SourceCondition,
  217. canTargetCondition_ByPreSelecetedList: null,
  218. canEndSelectCondition: null,
  219. canNoSelect: () => true,
  220. selectCardCoroutine: null,
  221. afterSelectCardCoroutine: SelectCardCoroutine,
  222. message: "Select digivolution cards to trash",
  223. maxCount: 3,
  224. canEndNotMax: false,
  225. isShowOpponent: true,
  226. mode: SelectCardEffect.Mode.Custom,
  227. root: SelectCardEffect.Root.DigivolutionCards,
  228. customRootCardList: permanent.DigivolutionCards,
  229. canLookReverseCard: false,
  230. selectPlayer: card.Owner,
  231. cardEffect: null);
  232. selectCardEffect.SetUpCustomMessage("Select digivolution cards to trash.", "The opponent is selecting digivolution cards to return to trash.");
  233. selectCardEffect.SetNotShowCard();
  234. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  235. IEnumerator SelectCardCoroutine(List<CardSource> cardSources)
  236. {
  237. selectedCards = cardSources;
  238. yield return null;
  239. }
  240. if (selectedCards.Count >= 3)
  241. {
  242. yield return ContinuousController.instance.StartCoroutine(new ITrashDigivolutionCards(permanent, selectedCards, activateClass).TrashDigivolutionCards());
  243. permanent.willBeRemoveField = false;
  244. permanent.HideDeleteEffect();
  245. permanent.HideHandBounceEffect();
  246. permanent.HideDeckBounceEffect();
  247. permanent.HideWillRemoveFieldEffect();
  248. }
  249. }
  250. }
  251. #endregion
  252. return cardEffects;
  253. }
  254. }
  255. }