BT17_028.cs 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468
  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_028 : 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 elementLobomon =
  29. new DigiXrosConditionElement(CanSelectCardConditionLobomon, "Lobomon");
  30. bool CanSelectCardConditionLobomon(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("Lobomon"))
  39. {
  40. return true;
  41. }
  42. }
  43. }
  44. }
  45. return false;
  46. }
  47. DigiXrosConditionElement elementKendoGarurumon =
  48. new DigiXrosConditionElement(CanSelectCardConditionKendoGarurumon, "KendoGarurumon");
  49. bool CanSelectCardConditionKendoGarurumon(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("KendoGarurumon"))
  58. {
  59. return true;
  60. }
  61. }
  62. }
  63. }
  64. return false;
  65. }
  66. List<DigiXrosConditionElement> elements = new List<DigiXrosConditionElement>()
  67. { elementLobomon, elementKendoGarurumon };
  68. DigiXrosCondition digiXrosCondition = new DigiXrosCondition(elements, null, 3);
  69. return digiXrosCondition;
  70. }
  71. return null;
  72. }
  73. }
  74. #endregion
  75. #region On Play
  76. if (timing == EffectTiming.OnEnterFieldAnyone)
  77. {
  78. ActivateClass activateClass = new ActivateClass();
  79. activateClass.SetUpICardEffect("Return 1 of your opponent's Digimon to hand", CanUseCondition, card);
  80. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription());
  81. cardEffects.Add(activateClass);
  82. string EffectDescription()
  83. {
  84. return
  85. "[On Play] Return 1 of your opponent's Digimon with the lowest level to the hand.";
  86. }
  87. bool CanUseCondition(Hashtable hashtable)
  88. {
  89. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  90. }
  91. bool CanSelectPermanentCondition(Permanent permanent)
  92. {
  93. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  94. {
  95. if (CardEffectCommons.IsMinLevel(permanent, card.Owner.Enemy))
  96. {
  97. return true;
  98. }
  99. }
  100. return false;
  101. }
  102. bool CanActivateCondition(Hashtable hashtable)
  103. {
  104. if (CardEffectCommons.IsExistOnBattleArea(card))
  105. {
  106. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  107. {
  108. return true;
  109. }
  110. }
  111. return false;
  112. }
  113. IEnumerator ActivateCoroutine(Hashtable hashtable)
  114. {
  115. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  116. {
  117. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  118. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  119. selectPermanentEffect.SetUp(
  120. selectPlayer: card.Owner,
  121. canTargetCondition: CanSelectPermanentCondition,
  122. canTargetCondition_ByPreSelecetedList: null,
  123. canEndSelectCondition: null,
  124. maxCount: maxCount,
  125. canNoSelect: false,
  126. canEndNotMax: false,
  127. selectPermanentCoroutine: null,
  128. afterSelectPermanentCoroutine: null,
  129. mode: SelectPermanentEffect.Mode.Bounce,
  130. cardEffect: activateClass);
  131. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  132. }
  133. }
  134. }
  135. #endregion
  136. #region When Digivolving
  137. if (timing == EffectTiming.OnEnterFieldAnyone)
  138. {
  139. ActivateClass activateClass = new ActivateClass();
  140. activateClass.SetUpICardEffect("Return 1 of your opponent's Digimon to hand", CanUseCondition, card);
  141. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription());
  142. cardEffects.Add(activateClass);
  143. string EffectDescription()
  144. {
  145. return
  146. "[When Digivolving] Return 1 of your opponent's Digimon with the lowest level to the hand.";
  147. }
  148. bool CanUseCondition(Hashtable hashtable)
  149. {
  150. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  151. }
  152. bool CanSelectPermanentCondition(Permanent permanent)
  153. {
  154. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  155. {
  156. if (CardEffectCommons.IsMinLevel(permanent, card.Owner.Enemy))
  157. {
  158. return true;
  159. }
  160. }
  161. return false;
  162. }
  163. bool CanActivateCondition(Hashtable hashtable)
  164. {
  165. if (CardEffectCommons.IsExistOnBattleArea(card))
  166. {
  167. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  168. {
  169. return true;
  170. }
  171. }
  172. return false;
  173. }
  174. IEnumerator ActivateCoroutine(Hashtable hashtable)
  175. {
  176. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  177. {
  178. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  179. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  180. selectPermanentEffect.SetUp(
  181. selectPlayer: card.Owner,
  182. canTargetCondition: CanSelectPermanentCondition,
  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.Bounce,
  191. cardEffect: activateClass);
  192. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  193. }
  194. }
  195. }
  196. #endregion
  197. #region Your Turn
  198. if (timing == EffectTiming.OnAddHand)
  199. {
  200. ActivateClass activateClass = new ActivateClass();
  201. activateClass.SetUpICardEffect("Your opponent adds the top card of their security stack to the hand", CanUseCondition,
  202. card);
  203. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDescription());
  204. activateClass.SetHashString("AddOpponentSecurityToHand_BT17_028");
  205. cardEffects.Add(activateClass);
  206. string EffectDescription()
  207. {
  208. return
  209. "[Your Turn] [Once Per Turn] When an effect adds cards to your or your opponent's hand, your opponent adds the top card of their security stack to the hand.";
  210. }
  211. bool CanUseCondition(Hashtable hashtable)
  212. {
  213. if (CardEffectCommons.IsExistOnBattleArea(card))
  214. {
  215. if (CardEffectCommons.IsOwnerTurn(card))
  216. {
  217. return CardEffectCommons.CanTriggerWhenAddHand(hashtable,
  218. player => player == card.Owner || player == card.Owner.Enemy,
  219. cardEffect => cardEffect != null);
  220. }
  221. }
  222. return false;
  223. }
  224. bool CanActivateCondition(Hashtable hashtable)
  225. {
  226. if (CardEffectCommons.IsExistOnBattleArea(card))
  227. {
  228. return card.Owner.Enemy.SecurityCards.Count >= 1;
  229. }
  230. return false;
  231. }
  232. IEnumerator ActivateCoroutine(Hashtable hashtable)
  233. {
  234. if (card.Owner.Enemy.SecurityCards.Count >= 1)
  235. {
  236. CardSource topCard = card.Owner.Enemy.SecurityCards[0];
  237. yield return ContinuousController.instance.StartCoroutine(
  238. CardObjectController.AddHandCards(new List<CardSource>() { topCard }, false, activateClass));
  239. yield return ContinuousController.instance.StartCoroutine(new IReduceSecurity(
  240. player: card.Owner.Enemy,
  241. refSkillInfos: ref ContinuousController.instance.nullSkillInfos,
  242. activateClass).ReduceSecurity());
  243. }
  244. }
  245. }
  246. #endregion
  247. #region On Deletion
  248. if (timing == EffectTiming.OnDestroyedAnyone)
  249. {
  250. ActivateClass activateClass = new ActivateClass();
  251. activateClass.SetUpICardEffect(
  252. "Return 1 Tamer card and 1 Hybrid trait Digimon card from trash to hand, then play 1 Tamer from hand", CanUseCondition,
  253. card);
  254. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription());
  255. cardEffects.Add(activateClass);
  256. string EffectDescription()
  257. {
  258. return
  259. "[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.";
  260. }
  261. bool IsTamerCardCondition(CardSource cardSource)
  262. {
  263. return cardSource.IsTamer;
  264. }
  265. bool IsHybridDigimonCardCondition(CardSource cardSource)
  266. {
  267. return cardSource.IsDigimon && cardSource.ContainsTraits("Hybrid");
  268. }
  269. bool CanSelectHandTamerCardCondition(CardSource cardSource)
  270. {
  271. if (cardSource.IsTamer)
  272. {
  273. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  274. {
  275. return true;
  276. }
  277. }
  278. return false;
  279. }
  280. bool CanUseCondition(Hashtable hashtable)
  281. {
  282. return CardEffectCommons.CanTriggerOnDeletion(hashtable, card, activateClass);
  283. }
  284. bool CanActivateCondition(Hashtable hashtable)
  285. {
  286. if (CardEffectCommons.IsExistOnTrash(card))
  287. {
  288. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, IsTamerCardCondition))
  289. {
  290. return true;
  291. }
  292. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, IsHybridDigimonCardCondition))
  293. {
  294. return true;
  295. }
  296. if (card.Owner.HandCards.Count(CanSelectHandTamerCardCondition) >= 1)
  297. {
  298. return true;
  299. }
  300. }
  301. return false;
  302. }
  303. IEnumerator ActivateCoroutine(Hashtable hashtable)
  304. {
  305. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, IsTamerCardCondition))
  306. {
  307. int maxCount = Math.Min(1, card.Owner.TrashCards.Count(IsTamerCardCondition));
  308. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  309. selectCardEffect.SetUp(
  310. canTargetCondition: IsTamerCardCondition,
  311. canTargetCondition_ByPreSelecetedList: null,
  312. canEndSelectCondition: null,
  313. canNoSelect: () => true,
  314. selectCardCoroutine: null,
  315. afterSelectCardCoroutine: null,
  316. message: "Select 1 Tamer card to add to your hand.",
  317. maxCount: maxCount,
  318. canEndNotMax: false,
  319. isShowOpponent: true,
  320. mode: SelectCardEffect.Mode.AddHand,
  321. root: SelectCardEffect.Root.Trash,
  322. customRootCardList: null,
  323. canLookReverseCard: true,
  324. selectPlayer: card.Owner,
  325. cardEffect: activateClass);
  326. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  327. }
  328. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, IsHybridDigimonCardCondition))
  329. {
  330. int maxCount = Math.Min(1, card.Owner.TrashCards.Count(IsHybridDigimonCardCondition));
  331. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  332. selectCardEffect.SetUp(
  333. canTargetCondition: IsHybridDigimonCardCondition,
  334. canTargetCondition_ByPreSelecetedList: null,
  335. canEndSelectCondition: null,
  336. canNoSelect: () => true,
  337. selectCardCoroutine: null,
  338. afterSelectCardCoroutine: null,
  339. message: "Select 1 Hybrid Digimon card to add to your hand.",
  340. maxCount: maxCount,
  341. canEndNotMax: false,
  342. isShowOpponent: true,
  343. mode: SelectCardEffect.Mode.AddHand,
  344. root: SelectCardEffect.Root.Trash,
  345. customRootCardList: null,
  346. canLookReverseCard: true,
  347. selectPlayer: card.Owner,
  348. cardEffect: activateClass);
  349. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  350. }
  351. if (card.Owner.HandCards.Count(CanSelectHandTamerCardCondition) >= 1)
  352. {
  353. List<CardSource> selectedCards = new List<CardSource>();
  354. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  355. selectHandEffect.SetUp(
  356. selectPlayer: card.Owner,
  357. canTargetCondition: CanSelectHandTamerCardCondition,
  358. canTargetCondition_ByPreSelecetedList: null,
  359. canEndSelectCondition: null,
  360. maxCount: 1,
  361. canNoSelect: true,
  362. canEndNotMax: false,
  363. isShowOpponent: true,
  364. selectCardCoroutine: SelectCardCoroutine,
  365. afterSelectCardCoroutine: null,
  366. mode: SelectHandEffect.Mode.Custom,
  367. cardEffect: activateClass);
  368. selectHandEffect.SetUpCustomMessage("Select 1 Tamer card to play.",
  369. "The opponent is selecting 1 Tamer card to play.");
  370. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  371. yield return StartCoroutine(selectHandEffect.Activate());
  372. IEnumerator SelectCardCoroutine(CardSource cardSource)
  373. {
  374. selectedCards.Add(cardSource);
  375. yield return null;
  376. }
  377. yield return ContinuousController.instance.StartCoroutine(
  378. CardEffectCommons.PlayPermanentCards(cardSources: selectedCards, activateClass: activateClass,
  379. payCost: false, isTapped: false, root: SelectCardEffect.Root.Hand, activateETB: true));
  380. }
  381. }
  382. }
  383. #endregion
  384. return cardEffects;
  385. }
  386. }
  387. }