BT17_028.cs 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467
  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).ReduceSecurity());
  242. }
  243. }
  244. }
  245. #endregion
  246. #region On Deletion
  247. if (timing == EffectTiming.OnDestroyedAnyone)
  248. {
  249. ActivateClass activateClass = new ActivateClass();
  250. activateClass.SetUpICardEffect(
  251. "Return 1 Tamer card and 1 Hybrid trait Digimon card from trash to hand, then play 1 Tamer from hand", CanUseCondition,
  252. card);
  253. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDescription());
  254. cardEffects.Add(activateClass);
  255. string EffectDescription()
  256. {
  257. return
  258. "[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.";
  259. }
  260. bool IsTamerCardCondition(CardSource cardSource)
  261. {
  262. return cardSource.IsTamer;
  263. }
  264. bool IsHybridDigimonCardCondition(CardSource cardSource)
  265. {
  266. return cardSource.IsDigimon && cardSource.ContainsTraits("Hybrid");
  267. }
  268. bool CanSelectHandTamerCardCondition(CardSource cardSource)
  269. {
  270. if (cardSource.IsTamer)
  271. {
  272. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  273. {
  274. return true;
  275. }
  276. }
  277. return false;
  278. }
  279. bool CanUseCondition(Hashtable hashtable)
  280. {
  281. return CardEffectCommons.CanTriggerOnDeletion(hashtable, card);
  282. }
  283. bool CanActivateCondition(Hashtable hashtable)
  284. {
  285. if (CardEffectCommons.IsExistOnTrash(card))
  286. {
  287. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, IsTamerCardCondition))
  288. {
  289. return true;
  290. }
  291. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, IsHybridDigimonCardCondition))
  292. {
  293. return true;
  294. }
  295. if (card.Owner.HandCards.Count(CanSelectHandTamerCardCondition) >= 1)
  296. {
  297. return true;
  298. }
  299. }
  300. return false;
  301. }
  302. IEnumerator ActivateCoroutine(Hashtable hashtable)
  303. {
  304. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, IsTamerCardCondition))
  305. {
  306. int maxCount = Math.Min(1, card.Owner.TrashCards.Count(IsTamerCardCondition));
  307. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  308. selectCardEffect.SetUp(
  309. canTargetCondition: IsTamerCardCondition,
  310. canTargetCondition_ByPreSelecetedList: null,
  311. canEndSelectCondition: null,
  312. canNoSelect: () => false,
  313. selectCardCoroutine: null,
  314. afterSelectCardCoroutine: null,
  315. message: "Select 1 Tamer card to add to your hand.",
  316. maxCount: maxCount,
  317. canEndNotMax: false,
  318. isShowOpponent: true,
  319. mode: SelectCardEffect.Mode.AddHand,
  320. root: SelectCardEffect.Root.Trash,
  321. customRootCardList: null,
  322. canLookReverseCard: true,
  323. selectPlayer: card.Owner,
  324. cardEffect: activateClass);
  325. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  326. }
  327. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, IsHybridDigimonCardCondition))
  328. {
  329. int maxCount = Math.Min(1, card.Owner.TrashCards.Count(IsHybridDigimonCardCondition));
  330. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  331. selectCardEffect.SetUp(
  332. canTargetCondition: IsHybridDigimonCardCondition,
  333. canTargetCondition_ByPreSelecetedList: null,
  334. canEndSelectCondition: null,
  335. canNoSelect: () => false,
  336. selectCardCoroutine: null,
  337. afterSelectCardCoroutine: null,
  338. message: "Select 1 Hybrid Digimon card to add to your hand.",
  339. maxCount: maxCount,
  340. canEndNotMax: false,
  341. isShowOpponent: true,
  342. mode: SelectCardEffect.Mode.AddHand,
  343. root: SelectCardEffect.Root.Trash,
  344. customRootCardList: null,
  345. canLookReverseCard: true,
  346. selectPlayer: card.Owner,
  347. cardEffect: activateClass);
  348. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  349. }
  350. if (card.Owner.HandCards.Count(CanSelectHandTamerCardCondition) >= 1)
  351. {
  352. List<CardSource> selectedCards = new List<CardSource>();
  353. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  354. selectHandEffect.SetUp(
  355. selectPlayer: card.Owner,
  356. canTargetCondition: CanSelectHandTamerCardCondition,
  357. canTargetCondition_ByPreSelecetedList: null,
  358. canEndSelectCondition: null,
  359. maxCount: 1,
  360. canNoSelect: true,
  361. canEndNotMax: false,
  362. isShowOpponent: true,
  363. selectCardCoroutine: SelectCardCoroutine,
  364. afterSelectCardCoroutine: null,
  365. mode: SelectHandEffect.Mode.Custom,
  366. cardEffect: activateClass);
  367. selectHandEffect.SetUpCustomMessage("Select 1 Tamer card to play.",
  368. "The opponent is selecting 1 Tamer card to play.");
  369. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  370. yield return StartCoroutine(selectHandEffect.Activate());
  371. IEnumerator SelectCardCoroutine(CardSource cardSource)
  372. {
  373. selectedCards.Add(cardSource);
  374. yield return null;
  375. }
  376. yield return ContinuousController.instance.StartCoroutine(
  377. CardEffectCommons.PlayPermanentCards(cardSources: selectedCards, activateClass: activateClass,
  378. payCost: false, isTapped: false, root: SelectCardEffect.Root.Hand, activateETB: true));
  379. }
  380. }
  381. }
  382. #endregion
  383. return cardEffects;
  384. }
  385. }
  386. }