BT16_011.cs 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.BT16
  6. {
  7. public class BT16_011 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. # region Alternate Digivolution Requirement
  13. if (timing == EffectTiming.None)
  14. {
  15. bool PermanentCondition(Permanent targetPermanent)
  16. {
  17. if (targetPermanent.TopCard.CardNames.Contains("Garudamon"))
  18. {
  19. return true;
  20. }
  21. return false;
  22. }
  23. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  24. permanentCondition: PermanentCondition,
  25. digivolutionCost: 0,
  26. ignoreDigivolutionRequirement: false,
  27. card: card,
  28. condition: null));
  29. }
  30. #endregion
  31. #region On Play
  32. if (timing == EffectTiming.OnEnterFieldAnyone)
  33. {
  34. ActivateClass activateClass = new ActivateClass();
  35. activateClass.SetUpICardEffect("Return 1 red Digimon card from the trash to your hand and delete a Digimon.", CanUseCondition, card);
  36. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  37. cardEffects.Add(activateClass);
  38. string EffectDiscription()
  39. {
  40. return "[On Play] You may return 1 red Digimon card from your trash to the hand. Then, if [Garudamon] or [X-Antibody] is in this Digimon's digivolution cards, delete 1 of your opponent's Digimon with DP less than or equal to this Digimon's DP.";
  41. }
  42. bool CanSelectCardCondition(CardSource cardSource)
  43. {
  44. if (cardSource.IsDigimon)
  45. {
  46. if (cardSource.HasCardColor(CardColor.Red))
  47. {
  48. return true;
  49. }
  50. }
  51. return false;
  52. }
  53. bool CanUseCondition(Hashtable hashtable)
  54. {
  55. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  56. }
  57. bool CanActivateCondition(Hashtable hashtable)
  58. {
  59. return CardEffectCommons.IsExistOnBattleArea(card);
  60. }
  61. bool CanSelectPermanentCondition(Permanent permanent)
  62. {
  63. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  64. {
  65. if (CardEffectCommons.IsExistOnBattleArea(card))
  66. {
  67. if (card.PermanentOfThisCard().HasDP)
  68. {
  69. if (permanent.TopCard.HasDP)
  70. {
  71. if (permanent.DP <= card.PermanentOfThisCard().DP)
  72. {
  73. return true;
  74. }
  75. }
  76. }
  77. }
  78. }
  79. return false;
  80. }
  81. IEnumerator ActivateCoroutine(Hashtable hashtable)
  82. {
  83. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  84. {
  85. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  86. {
  87. new SelectionElement<bool>(message: $"Yes", value : true, spriteIndex: 0),
  88. new SelectionElement<bool>(message: $"No", value : false, spriteIndex: 1),
  89. };
  90. string selectPlayerMessage = "Will you return a Digimon from your trash to your hand?";
  91. string notSelectPlayerMessage = "The opponent is choosing whether or not to return a card to their hand.";
  92. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  93. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  94. bool willReturn = GManager.instance.userSelectionManager.SelectedBoolValue;
  95. if (willReturn)
  96. {
  97. int maxCount = Math.Min(1, card.Owner.TrashCards.Count(CanSelectCardCondition));
  98. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  99. selectCardEffect.SetUp(
  100. canTargetCondition: CanSelectCardCondition,
  101. canTargetCondition_ByPreSelecetedList: null,
  102. canEndSelectCondition: null,
  103. canNoSelect: () => false,
  104. selectCardCoroutine: null,
  105. afterSelectCardCoroutine: null,
  106. message: "Select 1 card to add to your hand.",
  107. maxCount: maxCount,
  108. canEndNotMax: false,
  109. isShowOpponent: true,
  110. mode: SelectCardEffect.Mode.AddHand,
  111. root: SelectCardEffect.Root.Trash,
  112. customRootCardList: null,
  113. canLookReverseCard: true,
  114. selectPlayer: card.Owner,
  115. cardEffect: activateClass);
  116. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  117. }
  118. }
  119. if (CardEffectCommons.IsExistOnBattleArea(card) && card.PermanentOfThisCard().DigivolutionCards.Count((cardSource) => cardSource.CardNames.Contains("Garudamon") || cardSource.CardNames.Contains("X Antibody") || cardSource.CardNames.Contains("XAntibody")) >= 1)
  120. {
  121. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  122. {
  123. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  124. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  125. selectPermanentEffect.SetUp(
  126. selectPlayer: card.Owner,
  127. canTargetCondition: CanSelectPermanentCondition,
  128. canTargetCondition_ByPreSelecetedList: null,
  129. canEndSelectCondition: null,
  130. maxCount: maxCount,
  131. canNoSelect: false,
  132. canEndNotMax: false,
  133. selectPermanentCoroutine: null,
  134. afterSelectPermanentCoroutine: null,
  135. mode: SelectPermanentEffect.Mode.Destroy,
  136. cardEffect: activateClass);
  137. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  138. }
  139. }
  140. }
  141. }
  142. #endregion
  143. #region When Digivolving
  144. if (timing == EffectTiming.OnEnterFieldAnyone)
  145. {
  146. ActivateClass activateClass = new ActivateClass();
  147. activateClass.SetUpICardEffect("Return 1 red Digimon card from the trash to your hand and delete a Digimon.", CanUseCondition, card);
  148. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  149. cardEffects.Add(activateClass);
  150. string EffectDiscription()
  151. {
  152. return "[When Digivolving] You may return 1 red Digimon card from your trash to the hand. Then, if [Garudamon] or [X-Antibody] is in this Digimon's digivolution cards, delete 1 of your opponent's Digimon with DP less than or equal to this Digimon's DP.";
  153. }
  154. bool CanSelectCardCondition(CardSource cardSource)
  155. {
  156. if (cardSource.IsDigimon)
  157. {
  158. if (cardSource.HasCardColor(CardColor.Red))
  159. {
  160. return true;
  161. }
  162. }
  163. return false;
  164. }
  165. bool CanUseCondition(Hashtable hashtable)
  166. {
  167. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  168. }
  169. bool CanActivateCondition(Hashtable hashtable)
  170. {
  171. return CardEffectCommons.IsExistOnBattleArea(card);
  172. }
  173. bool CanSelectPermanentCondition(Permanent permanent)
  174. {
  175. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  176. {
  177. if (CardEffectCommons.IsExistOnBattleArea(card))
  178. {
  179. if (card.PermanentOfThisCard().HasDP)
  180. {
  181. if (permanent.TopCard.HasDP)
  182. {
  183. if (permanent.DP <= card.PermanentOfThisCard().DP)
  184. {
  185. return true;
  186. }
  187. }
  188. }
  189. }
  190. }
  191. return false;
  192. }
  193. IEnumerator ActivateCoroutine(Hashtable hashtable)
  194. {
  195. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  196. {
  197. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  198. {
  199. new SelectionElement<bool>(message: $"Yes", value : true, spriteIndex: 0),
  200. new SelectionElement<bool>(message: $"No", value : false, spriteIndex: 1),
  201. };
  202. string selectPlayerMessage = "Will you return a Digimon from your trash to your hand?";
  203. string notSelectPlayerMessage = "The opponent is choosing whether or not to return a card to their hand.";
  204. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  205. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  206. bool willReturn = GManager.instance.userSelectionManager.SelectedBoolValue;
  207. if (willReturn)
  208. {
  209. int maxCount = Math.Min(1, card.Owner.TrashCards.Count(CanSelectCardCondition));
  210. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  211. selectCardEffect.SetUp(
  212. canTargetCondition: CanSelectCardCondition,
  213. canTargetCondition_ByPreSelecetedList: null,
  214. canEndSelectCondition: null,
  215. canNoSelect: () => false,
  216. selectCardCoroutine: null,
  217. afterSelectCardCoroutine: null,
  218. message: "Select 1 card to add to your hand.",
  219. maxCount: maxCount,
  220. canEndNotMax: false,
  221. isShowOpponent: true,
  222. mode: SelectCardEffect.Mode.AddHand,
  223. root: SelectCardEffect.Root.Trash,
  224. customRootCardList: null,
  225. canLookReverseCard: true,
  226. selectPlayer: card.Owner,
  227. cardEffect: activateClass);
  228. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  229. }
  230. }
  231. if (CardEffectCommons.IsExistOnBattleArea(card) && card.PermanentOfThisCard().DigivolutionCards.Count((cardSource) => cardSource.CardNames.Contains("Garudamon") || cardSource.CardNames.Contains("X Antibody") || cardSource.CardNames.Contains("XAntibody")) >= 1)
  232. {
  233. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  234. {
  235. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  236. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  237. selectPermanentEffect.SetUp(
  238. selectPlayer: card.Owner,
  239. canTargetCondition: CanSelectPermanentCondition,
  240. canTargetCondition_ByPreSelecetedList: null,
  241. canEndSelectCondition: null,
  242. maxCount: maxCount,
  243. canNoSelect: false,
  244. canEndNotMax: false,
  245. selectPermanentCoroutine: null,
  246. afterSelectPermanentCoroutine: null,
  247. mode: SelectPermanentEffect.Mode.Destroy,
  248. cardEffect: activateClass);
  249. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  250. }
  251. }
  252. }
  253. }
  254. #endregion
  255. #region Inherit
  256. if (timing == EffectTiming.OnDestroyedAnyone)
  257. {
  258. ActivateClass activateClass = new ActivateClass();
  259. activateClass.SetUpICardEffect("Trash the top card of your opponent's security stack.", CanUseCondition, card);
  260. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  261. activateClass.SetIsInheritedEffect(true);
  262. cardEffects.Add(activateClass);
  263. string EffectDiscription()
  264. {
  265. return "[On Deletion] Trash the top card of your opponent's security stack.";
  266. }
  267. bool CanUseCondition(Hashtable hashtable)
  268. {
  269. return CardEffectCommons.CanTriggerOnDeletion(hashtable, card, activateClass);
  270. }
  271. bool CanActivateCondition(Hashtable hashtable)
  272. {
  273. if (CardEffectCommons.CanActivateOnDeletion(card, activateClass))
  274. {
  275. if (card.Owner.Enemy.SecurityCards.Count >= 1)
  276. {
  277. return true;
  278. }
  279. }
  280. return false;
  281. }
  282. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  283. {
  284. yield return ContinuousController.instance.StartCoroutine(new IDestroySecurity(
  285. player: card.Owner.Enemy,
  286. destroySecurityCount: 1,
  287. cardEffect: activateClass,
  288. fromTop: true).DestroySecurity());
  289. }
  290. }
  291. #endregion
  292. #region Your Turn
  293. if (timing == EffectTiming.OnReturnCardsToHandFromTrash)
  294. {
  295. ActivateClass activateClass = new ActivateClass();
  296. activateClass.SetUpICardEffect("1 of your Digimon gains <Rush>.", CanUseCondition, card);
  297. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDiscription());
  298. activateClass.SetHashString("GainRush_BT16_011");
  299. cardEffects.Add(activateClass);
  300. string EffectDiscription()
  301. {
  302. return "[Your Turn] [Once Per Turn] When a red Digimon card returns from your trash to the hand, 1 of your Digimon gains <Rush> for the turn.";
  303. }
  304. bool CanSelectPermanentCondition(Permanent permanent)
  305. {
  306. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  307. {
  308. return true;
  309. }
  310. return false;
  311. }
  312. bool CardReturnedCondition(CardSource cardSource)
  313. {
  314. if (cardSource.Owner == card.Owner)
  315. {
  316. if (cardSource.IsDigimon)
  317. {
  318. if (cardSource.HasCardColor(CardColor.Red))
  319. {
  320. return true;
  321. }
  322. }
  323. }
  324. return false;
  325. }
  326. bool CanUseCondition(Hashtable hashtable)
  327. {
  328. if (CardEffectCommons.IsExistOnBattleArea(card))
  329. {
  330. if (CardEffectCommons.CanTriggerWhenCardsReturnToHandFromTrash(hashtable, CardReturnedCondition, card))
  331. {
  332. if (CardEffectCommons.IsOwnerTurn(card))
  333. {
  334. return true;
  335. }
  336. }
  337. }
  338. return false;
  339. }
  340. bool CanActivateCondition(Hashtable hashtable)
  341. {
  342. if (CardEffectCommons.IsExistOnBattleArea(card))
  343. {
  344. return true;
  345. }
  346. return false;
  347. }
  348. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  349. {
  350. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  351. {
  352. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  353. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  354. selectPermanentEffect.SetUp(
  355. selectPlayer: card.Owner,
  356. canTargetCondition: CanSelectPermanentCondition,
  357. canTargetCondition_ByPreSelecetedList: null,
  358. canEndSelectCondition: null,
  359. maxCount: maxCount,
  360. canNoSelect: false,
  361. canEndNotMax: false,
  362. selectPermanentCoroutine: SelectPermanentCoroutine,
  363. afterSelectPermanentCoroutine: null,
  364. mode: SelectPermanentEffect.Mode.Custom,
  365. cardEffect: activateClass);
  366. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to gain Rush.", "The opponent is selecting 1 Digimon to gain Rush.");
  367. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  368. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  369. {
  370. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainRush(targetPermanent: permanent, effectDuration: EffectDuration.UntilEachTurnEnd, activateClass: activateClass));
  371. }
  372. }
  373. }
  374. }
  375. #endregion
  376. return cardEffects;
  377. }
  378. }
  379. }