BT17_017.cs 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.BT17
  6. {
  7. public class BT17_017 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region DigiXros
  13. if (timing == EffectTiming.None)
  14. {
  15. AddDigiXrosConditionClass addDigiXrosConditionClass = new AddDigiXrosConditionClass();
  16. addDigiXrosConditionClass.SetUpICardEffect($"DigiXros -3", CanUseCondition, card);
  17. addDigiXrosConditionClass.SetUpAddDigiXrosConditionClass(getDigiXrosCondition: GetDigiXros);
  18. addDigiXrosConditionClass.SetNotShowUI(true);
  19. cardEffects.Add(addDigiXrosConditionClass);
  20. bool CanUseCondition(Hashtable hashtable)
  21. {
  22. return true;
  23. }
  24. DigiXrosCondition GetDigiXros(CardSource cardSource)
  25. {
  26. if (cardSource == card)
  27. {
  28. DigiXrosConditionElement elementAgunimon =
  29. new DigiXrosConditionElement(CanSelectCardConditionAgunimon, "Agunimon");
  30. bool CanSelectCardConditionAgunimon(CardSource conditionCardSource)
  31. {
  32. if (conditionCardSource != null)
  33. {
  34. if (conditionCardSource.Owner == card.Owner)
  35. {
  36. if (conditionCardSource.IsDigimon)
  37. {
  38. if (conditionCardSource.CardNames_DigiXros.Contains("Agunimon"))
  39. {
  40. return true;
  41. }
  42. }
  43. }
  44. }
  45. return false;
  46. }
  47. DigiXrosConditionElement elementBurningGreymon =
  48. new DigiXrosConditionElement(CanSelectCardConditionBurningGreymon, "BurningGreymon");
  49. bool CanSelectCardConditionBurningGreymon(CardSource conditionCardSource)
  50. {
  51. if (conditionCardSource != null)
  52. {
  53. if (conditionCardSource.Owner == card.Owner)
  54. {
  55. if (conditionCardSource.IsDigimon)
  56. {
  57. if (conditionCardSource.CardNames_DigiXros.Contains("BurningGreymon"))
  58. {
  59. return true;
  60. }
  61. }
  62. }
  63. }
  64. return false;
  65. }
  66. List<DigiXrosConditionElement> elements = new List<DigiXrosConditionElement>()
  67. { elementAgunimon, elementBurningGreymon };
  68. DigiXrosCondition digiXrosCondition = new DigiXrosCondition(elements, null, 3);
  69. return digiXrosCondition;
  70. }
  71. return null;
  72. }
  73. }
  74. #endregion
  75. #region Security Attack +1
  76. if (timing == EffectTiming.None)
  77. {
  78. cardEffects.Add(CardEffectFactory.ChangeSelfSAttackStaticEffect(changeValue: 1, isInheritedEffect: false, card: card,
  79. condition: null));
  80. }
  81. #endregion
  82. #region On Play/ When Digivolving Shared
  83. bool IsEnemyPermanentWithAsMuchOrLessDpSharedCondition(Permanent permanent)
  84. {
  85. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  86. {
  87. if (permanent.DP <= card.PermanentOfThisCard().DP)
  88. {
  89. return true;
  90. }
  91. }
  92. return false;
  93. }
  94. #endregion
  95. #region On Play
  96. if (timing == EffectTiming.OnEnterFieldAnyone)
  97. {
  98. ActivateClass activateClass = new ActivateClass();
  99. activateClass.SetUpICardEffect("Delete 1 Digimon", CanUseCondition, card);
  100. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription());
  101. cardEffects.Add(activateClass);
  102. string EffectDescription()
  103. {
  104. return
  105. "[On Play] Delete 1 of your opponent's Digimon with as much or less DP than this Digimon.";
  106. }
  107. bool CanUseCondition(Hashtable hashtable)
  108. {
  109. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  110. }
  111. bool CanActivateCondition(Hashtable hashtable)
  112. {
  113. if (CardEffectCommons.IsExistOnBattleArea(card))
  114. {
  115. if (CardEffectCommons.HasMatchConditionPermanent(IsEnemyPermanentWithAsMuchOrLessDpSharedCondition))
  116. {
  117. return true;
  118. }
  119. }
  120. return false;
  121. }
  122. IEnumerator ActivateCoroutine(Hashtable hashtable)
  123. {
  124. if (CardEffectCommons.HasMatchConditionPermanent(IsEnemyPermanentWithAsMuchOrLessDpSharedCondition))
  125. {
  126. int maxCount = Math.Min(1,
  127. CardEffectCommons.MatchConditionPermanentCount(IsEnemyPermanentWithAsMuchOrLessDpSharedCondition));
  128. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  129. selectPermanentEffect.SetUp(
  130. selectPlayer: card.Owner,
  131. canTargetCondition: IsEnemyPermanentWithAsMuchOrLessDpSharedCondition,
  132. canTargetCondition_ByPreSelecetedList: null,
  133. canEndSelectCondition: null,
  134. maxCount: maxCount,
  135. canNoSelect: false,
  136. canEndNotMax: false,
  137. selectPermanentCoroutine: null,
  138. afterSelectPermanentCoroutine: null,
  139. mode: SelectPermanentEffect.Mode.Destroy,
  140. cardEffect: activateClass);
  141. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  142. }
  143. }
  144. }
  145. #endregion
  146. #region When Digivolving
  147. if (timing == EffectTiming.OnEnterFieldAnyone)
  148. {
  149. ActivateClass activateClass = new ActivateClass();
  150. activateClass.SetUpICardEffect("Delete 1 Digimon", CanUseCondition, card);
  151. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription());
  152. cardEffects.Add(activateClass);
  153. string EffectDescription()
  154. {
  155. return
  156. "[When Digivolving] Delete 1 of your opponent's Digimon with as much or less DP than this Digimon.";
  157. }
  158. bool CanUseCondition(Hashtable hashtable)
  159. {
  160. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  161. }
  162. bool CanActivateCondition(Hashtable hashtable)
  163. {
  164. if (CardEffectCommons.IsExistOnBattleArea(card))
  165. {
  166. if (CardEffectCommons.HasMatchConditionPermanent(IsEnemyPermanentWithAsMuchOrLessDpSharedCondition))
  167. {
  168. return true;
  169. }
  170. }
  171. return false;
  172. }
  173. IEnumerator ActivateCoroutine(Hashtable hashtable)
  174. {
  175. if (CardEffectCommons.HasMatchConditionPermanent(IsEnemyPermanentWithAsMuchOrLessDpSharedCondition))
  176. {
  177. int maxCount = Math.Min(1,
  178. CardEffectCommons.MatchConditionPermanentCount(IsEnemyPermanentWithAsMuchOrLessDpSharedCondition));
  179. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  180. selectPermanentEffect.SetUp(
  181. selectPlayer: card.Owner,
  182. canTargetCondition: IsEnemyPermanentWithAsMuchOrLessDpSharedCondition,
  183. canTargetCondition_ByPreSelecetedList: null,
  184. canEndSelectCondition: null,
  185. maxCount: maxCount,
  186. canNoSelect: false,
  187. canEndNotMax: false,
  188. selectPermanentCoroutine: null,
  189. afterSelectPermanentCoroutine: null,
  190. mode: SelectPermanentEffect.Mode.Destroy,
  191. cardEffect: activateClass);
  192. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  193. }
  194. }
  195. }
  196. #endregion
  197. #region On Deletion
  198. if (timing == EffectTiming.OnDestroyedAnyone)
  199. {
  200. ActivateClass activateClass = new ActivateClass();
  201. activateClass.SetUpICardEffect(
  202. "Return 1 Tamer card and 1 Hybrid trait Digimon card from trash to hand, then play 1 Tamer from hand", CanUseCondition,
  203. card);
  204. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDescription());
  205. cardEffects.Add(activateClass);
  206. string EffectDescription()
  207. {
  208. return
  209. "[On Deletion] You may return 1 Tamer card and 1 [Hybrid] trait Digimon card from your trash to the hand. Then, you may play 1 Tamer card from your hand without paying the cost.";
  210. }
  211. bool IsTamerCardCondition(CardSource cardSource)
  212. {
  213. return cardSource.IsTamer;
  214. }
  215. bool IsHybridDigimonCardCondition(CardSource cardSource)
  216. {
  217. return cardSource.IsDigimon && cardSource.ContainsTraits("Hybrid");
  218. }
  219. bool CanSelectHandTamerCardCondition(CardSource cardSource)
  220. {
  221. if (cardSource.IsTamer)
  222. {
  223. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  224. {
  225. return true;
  226. }
  227. }
  228. return false;
  229. }
  230. bool CanUseCondition(Hashtable hashtable)
  231. {
  232. return CardEffectCommons.CanTriggerOnDeletion(hashtable, card, activateClass);
  233. }
  234. bool CanActivateCondition(Hashtable hashtable)
  235. {
  236. if (CardEffectCommons.IsExistOnTrash(card))
  237. {
  238. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, IsTamerCardCondition))
  239. {
  240. return true;
  241. }
  242. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, IsHybridDigimonCardCondition))
  243. {
  244. return true;
  245. }
  246. if (card.Owner.HandCards.Count(CanSelectHandTamerCardCondition) >= 1)
  247. {
  248. return true;
  249. }
  250. }
  251. return false;
  252. }
  253. IEnumerator ActivateCoroutine(Hashtable hashtable)
  254. {
  255. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, IsTamerCardCondition))
  256. {
  257. int maxCount = Math.Min(1, card.Owner.TrashCards.Count(IsTamerCardCondition));
  258. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  259. selectCardEffect.SetUp(
  260. canTargetCondition: IsTamerCardCondition,
  261. canTargetCondition_ByPreSelecetedList: null,
  262. canEndSelectCondition: null,
  263. canNoSelect: () => false,
  264. selectCardCoroutine: null,
  265. afterSelectCardCoroutine: null,
  266. message: "Select 1 Tamer card to add to your hand.",
  267. maxCount: maxCount,
  268. canEndNotMax: false,
  269. isShowOpponent: true,
  270. mode: SelectCardEffect.Mode.AddHand,
  271. root: SelectCardEffect.Root.Trash,
  272. customRootCardList: null,
  273. canLookReverseCard: true,
  274. selectPlayer: card.Owner,
  275. cardEffect: activateClass);
  276. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  277. }
  278. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, IsHybridDigimonCardCondition))
  279. {
  280. int maxCount = Math.Min(1, card.Owner.TrashCards.Count(IsHybridDigimonCardCondition));
  281. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  282. selectCardEffect.SetUp(
  283. canTargetCondition: IsHybridDigimonCardCondition,
  284. canTargetCondition_ByPreSelecetedList: null,
  285. canEndSelectCondition: null,
  286. canNoSelect: () => false,
  287. selectCardCoroutine: null,
  288. afterSelectCardCoroutine: null,
  289. message: "Select 1 Hybrid Digimon card to add to your hand.",
  290. maxCount: maxCount,
  291. canEndNotMax: false,
  292. isShowOpponent: true,
  293. mode: SelectCardEffect.Mode.AddHand,
  294. root: SelectCardEffect.Root.Trash,
  295. customRootCardList: null,
  296. canLookReverseCard: true,
  297. selectPlayer: card.Owner,
  298. cardEffect: activateClass);
  299. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  300. }
  301. if (card.Owner.HandCards.Count(CanSelectHandTamerCardCondition) >= 1)
  302. {
  303. List<CardSource> selectedCards = new List<CardSource>();
  304. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  305. selectHandEffect.SetUp(
  306. selectPlayer: card.Owner,
  307. canTargetCondition: CanSelectHandTamerCardCondition,
  308. canTargetCondition_ByPreSelecetedList: null,
  309. canEndSelectCondition: null,
  310. maxCount: 1,
  311. canNoSelect: true,
  312. canEndNotMax: false,
  313. isShowOpponent: true,
  314. selectCardCoroutine: SelectCardCoroutine,
  315. afterSelectCardCoroutine: null,
  316. mode: SelectHandEffect.Mode.Custom,
  317. cardEffect: activateClass);
  318. selectHandEffect.SetUpCustomMessage("Select 1 Tamer card to play.",
  319. "The opponent is selecting 1 Tamer card to play.");
  320. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  321. yield return StartCoroutine(selectHandEffect.Activate());
  322. IEnumerator SelectCardCoroutine(CardSource cardSource)
  323. {
  324. selectedCards.Add(cardSource);
  325. yield return null;
  326. }
  327. yield return ContinuousController.instance.StartCoroutine(
  328. CardEffectCommons.PlayPermanentCards(cardSources: selectedCards, activateClass: activateClass,
  329. payCost: false, isTapped: false, root: SelectCardEffect.Root.Hand, activateETB: true));
  330. }
  331. }
  332. }
  333. #endregion
  334. return cardEffects;
  335. }
  336. }
  337. }