BT20_018.cs 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. namespace DCGO.CardEffects.BT20
  4. {
  5. public class BT20_018 : CEntity_Effect
  6. {
  7. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  8. {
  9. List<ICardEffect> cardEffects = new List<ICardEffect>();
  10. #region Piercing
  11. if (timing == EffectTiming.OnDetermineDoSecurityCheck)
  12. {
  13. cardEffects.Add(CardEffectFactory.PierceSelfEffect(
  14. isInheritedEffect: false,
  15. card: card,
  16. condition: null));
  17. }
  18. #endregion
  19. #region On Play
  20. if (timing == EffectTiming.OnEnterFieldAnyone)
  21. {
  22. ActivateClass activateClass = new ActivateClass();
  23. activateClass.SetUpICardEffect("<De-Digivolve 2> 1 of your opponent's Digimon", CanUseCondition, card);
  24. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription());
  25. cardEffects.Add(activateClass);
  26. string EffectDescription()
  27. {
  28. return
  29. "[On Play] <De-Digivolve 2> 1 of your opponent's Digimon. Then, if during an attack, 1 of your Digimon in the breeding area may digivolve into a level 6 or lower [Chronicle] trait Digimon card in the hand or trash without paying the cost.";
  30. }
  31. bool CanUseCondition(Hashtable hashtable)
  32. {
  33. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  34. }
  35. bool CanSelectDeDigiPermanentCondition(Permanent permanent)
  36. {
  37. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  38. }
  39. bool CanSelectDigivolveCardCondition(CardSource cardSource)
  40. {
  41. return cardSource.IsDigimon && cardSource.HasLevel && cardSource.Level <= 6 &&
  42. cardSource.EqualsTraits("Chronicle") &&
  43. cardSource.CanPlayCardTargetFrame(
  44. card.Owner.GetBreedingAreaPermanents()[0].PermanentFrame,
  45. false, activateClass, isBreedingArea: true);
  46. }
  47. bool IsAttackingCondition()
  48. {
  49. return GManager.instance.attackProcess.IsAttacking &&
  50. card.Owner.GetBreedingAreaPermanents().Count > 0 &&
  51. (CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectDigivolveCardCondition) ||
  52. CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectDigivolveCardCondition));
  53. }
  54. bool CanActivateCondition(Hashtable hashtable)
  55. {
  56. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  57. (CardEffectCommons.HasMatchConditionPermanent(CanSelectDeDigiPermanentCondition) ||
  58. IsAttackingCondition());
  59. }
  60. IEnumerator ActivateCoroutine(Hashtable hashtable)
  61. {
  62. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectDeDigiPermanentCondition))
  63. {
  64. Permanent selectedPermanent = null;
  65. SelectPermanentEffect selectPermanentEffect =
  66. GManager.instance.GetComponent<SelectPermanentEffect>();
  67. selectPermanentEffect.SetUp(
  68. selectPlayer: card.Owner,
  69. canTargetCondition: CanSelectDeDigiPermanentCondition,
  70. canTargetCondition_ByPreSelecetedList: null,
  71. canEndSelectCondition: null,
  72. maxCount: 1,
  73. canNoSelect: false,
  74. canEndNotMax: false,
  75. selectPermanentCoroutine: SelectPermanentCoroutine,
  76. afterSelectPermanentCoroutine: null,
  77. mode: SelectPermanentEffect.Mode.Custom,
  78. cardEffect: activateClass);
  79. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to De-Digivolve.",
  80. "The opponent is selecting 1 Digimon to De-Digivolve.");
  81. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  82. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  83. {
  84. selectedPermanent = permanent;
  85. yield return null;
  86. }
  87. if (selectedPermanent != null)
  88. {
  89. yield return ContinuousController.instance.StartCoroutine(
  90. new IDegeneration(selectedPermanent, 2, activateClass).Degeneration());
  91. }
  92. }
  93. if (IsAttackingCondition())
  94. {
  95. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  96. {
  97. new(message: "Digivolve in the breeding area", value: true, spriteIndex: 0),
  98. new(message: "Do not digivolve", value: false, spriteIndex: 1),
  99. };
  100. string selectPlayerMessage = "Digivolve in the breeding area?";
  101. string notSelectPlayerMessage = "The opponent is choosing whether to digivolve in the breeding area or not.";
  102. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements,
  103. selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage,
  104. notSelectPlayerMessage: notSelectPlayerMessage);
  105. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager
  106. .WaitForEndSelect());
  107. if (GManager.instance.userSelectionManager.SelectedBoolValue)
  108. {
  109. bool canSelectHand = CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectDigivolveCardCondition);
  110. bool canSelectTrash =
  111. CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectDigivolveCardCondition);
  112. if (canSelectHand || canSelectTrash)
  113. {
  114. if (canSelectHand && canSelectTrash)
  115. {
  116. selectionElements = new List<SelectionElement<bool>>()
  117. {
  118. new(message: "From hand", value: true, spriteIndex: 0),
  119. new(message: "From trash", value: false, spriteIndex: 1),
  120. };
  121. selectPlayerMessage = "From which area do you play a card?";
  122. notSelectPlayerMessage = "The opponent is choosing from which area to play a card.";
  123. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements,
  124. selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage,
  125. notSelectPlayerMessage: notSelectPlayerMessage);
  126. }
  127. else
  128. {
  129. GManager.instance.userSelectionManager.SetBool(canSelectHand);
  130. }
  131. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager
  132. .WaitForEndSelect());
  133. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DigivolveIntoHandOrTrashCard(
  134. targetPermanent: card.Owner.GetBreedingAreaPermanents()[0],
  135. cardCondition: CanSelectDigivolveCardCondition,
  136. payCost: false,
  137. reduceCostTuple: null,
  138. fixedCostTuple: null,
  139. ignoreDigivolutionRequirementFixedCost: -1,
  140. isHand: GManager.instance.userSelectionManager.SelectedBoolValue,
  141. activateClass: activateClass,
  142. successProcess: null));
  143. }
  144. }
  145. }
  146. }
  147. }
  148. #endregion
  149. #region When Digivolving
  150. if (timing == EffectTiming.OnEnterFieldAnyone)
  151. {
  152. ActivateClass activateClass = new ActivateClass();
  153. activateClass.SetUpICardEffect("<De-Digivolve 2> 1 of your opponent's Digimon", CanUseCondition, card);
  154. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription());
  155. cardEffects.Add(activateClass);
  156. string EffectDescription()
  157. {
  158. return
  159. "[When Digivolving] <De-Digivolve 2> 1 of your opponent's Digimon. Then, if during an attack, 1 of your Digimon in the breeding area may digivolve into a level 6 or lower [Chronicle] trait Digimon card in the hand or trash without paying the cost.";
  160. }
  161. bool CanUseCondition(Hashtable hashtable)
  162. {
  163. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  164. }
  165. bool CanSelectDeDigiPermanentCondition(Permanent permanent)
  166. {
  167. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  168. }
  169. bool CanSelectDigivolveCardCondition(CardSource cardSource)
  170. {
  171. return cardSource.IsDigimon && cardSource.HasLevel && cardSource.Level <= 6 &&
  172. cardSource.EqualsTraits("Chronicle") &&
  173. cardSource.CanPlayCardTargetFrame(
  174. card.Owner.GetBreedingAreaPermanents()[0].PermanentFrame,
  175. false, activateClass, isBreedingArea: true);
  176. }
  177. bool IsAttackingCondition()
  178. {
  179. return GManager.instance.attackProcess.IsAttacking &&
  180. card.Owner.GetBreedingAreaPermanents().Count > 0 &&
  181. (CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectDigivolveCardCondition) ||
  182. CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectDigivolveCardCondition));
  183. }
  184. bool CanActivateCondition(Hashtable hashtable)
  185. {
  186. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  187. (CardEffectCommons.HasMatchConditionPermanent(CanSelectDeDigiPermanentCondition) ||
  188. IsAttackingCondition());
  189. }
  190. IEnumerator ActivateCoroutine(Hashtable hashtable)
  191. {
  192. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectDeDigiPermanentCondition))
  193. {
  194. Permanent selectedPermanent = null;
  195. SelectPermanentEffect selectPermanentEffect =
  196. GManager.instance.GetComponent<SelectPermanentEffect>();
  197. selectPermanentEffect.SetUp(
  198. selectPlayer: card.Owner,
  199. canTargetCondition: CanSelectDeDigiPermanentCondition,
  200. canTargetCondition_ByPreSelecetedList: null,
  201. canEndSelectCondition: null,
  202. maxCount: 1,
  203. canNoSelect: false,
  204. canEndNotMax: false,
  205. selectPermanentCoroutine: SelectPermanentCoroutine,
  206. afterSelectPermanentCoroutine: null,
  207. mode: SelectPermanentEffect.Mode.Custom,
  208. cardEffect: activateClass);
  209. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to De-Digivolve.",
  210. "The opponent is selecting 1 Digimon to De-Digivolve.");
  211. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  212. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  213. {
  214. selectedPermanent = permanent;
  215. yield return null;
  216. }
  217. if (selectedPermanent != null)
  218. {
  219. yield return ContinuousController.instance.StartCoroutine(
  220. new IDegeneration(selectedPermanent, 2, activateClass).Degeneration());
  221. }
  222. }
  223. if (IsAttackingCondition())
  224. {
  225. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  226. {
  227. new(message: "Digivolve in the breeding area", value: true, spriteIndex: 0),
  228. new(message: "Do not digivolve", value: false, spriteIndex: 1),
  229. };
  230. string selectPlayerMessage = "Digivolve in the breeding area?";
  231. string notSelectPlayerMessage = "The opponent is choosing whether to digivolve in the breeding area or not.";
  232. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements,
  233. selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage,
  234. notSelectPlayerMessage: notSelectPlayerMessage);
  235. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager
  236. .WaitForEndSelect());
  237. if (GManager.instance.userSelectionManager.SelectedBoolValue)
  238. {
  239. bool canSelectHand = CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectDigivolveCardCondition);
  240. bool canSelectTrash =
  241. CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectDigivolveCardCondition);
  242. if (canSelectHand || canSelectTrash)
  243. {
  244. if (canSelectHand && canSelectTrash)
  245. {
  246. selectionElements = new List<SelectionElement<bool>>()
  247. {
  248. new(message: "From hand", value: true, spriteIndex: 0),
  249. new(message: "From trash", value: false, spriteIndex: 1),
  250. };
  251. selectPlayerMessage = "From which area do you play a card?";
  252. notSelectPlayerMessage = "The opponent is choosing from which area to play a card.";
  253. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements,
  254. selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage,
  255. notSelectPlayerMessage: notSelectPlayerMessage);
  256. }
  257. else
  258. {
  259. GManager.instance.userSelectionManager.SetBool(canSelectHand);
  260. }
  261. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager
  262. .WaitForEndSelect());
  263. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DigivolveIntoHandOrTrashCard(
  264. targetPermanent: card.Owner.GetBreedingAreaPermanents()[0],
  265. cardCondition: CanSelectDigivolveCardCondition,
  266. payCost: false,
  267. reduceCostTuple: null,
  268. fixedCostTuple: null,
  269. ignoreDigivolutionRequirementFixedCost: -1,
  270. isHand: GManager.instance.userSelectionManager.SelectedBoolValue,
  271. activateClass: activateClass,
  272. successProcess: null));
  273. }
  274. }
  275. }
  276. }
  277. }
  278. #endregion
  279. #region All Turns
  280. if (timing == EffectTiming.OnLoseSecurity)
  281. {
  282. ActivateClass activateClass = new ActivateClass();
  283. activateClass.SetUpICardEffect("Delete 1 of your opponent's Digimon", CanUseCondition, card);
  284. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDescription());
  285. activateClass.SetHashString("RemovedSec_BT20_018");
  286. cardEffects.Add(activateClass);
  287. string EffectDescription()
  288. {
  289. return
  290. "[All Turns] (Once Per Turn) When security stacks are removed from, delete 1 of your opponent's Digimon with the lowest DP.";
  291. }
  292. bool CanUseCondition(Hashtable hashtable)
  293. {
  294. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  295. CardEffectCommons.CanTriggerWhenLoseSecurity(hashtable, _ => true);
  296. }
  297. bool CanSelectPermanentCondition(Permanent permanent)
  298. {
  299. return CardEffectCommons.IsMinDP(permanent, card.Owner.Enemy);
  300. }
  301. bool CanActivateCondition(Hashtable hashtable)
  302. {
  303. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  304. }
  305. IEnumerator ActivateCoroutine(Hashtable hashtable)
  306. {
  307. if(CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  308. {
  309. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  310. selectPermanentEffect.SetUp(
  311. selectPlayer: card.Owner,
  312. canTargetCondition: CanSelectPermanentCondition,
  313. canTargetCondition_ByPreSelecetedList: null,
  314. canEndSelectCondition: null,
  315. maxCount: 1,
  316. canNoSelect: false,
  317. canEndNotMax: false,
  318. selectPermanentCoroutine: null,
  319. afterSelectPermanentCoroutine: null,
  320. mode: SelectPermanentEffect.Mode.Destroy,
  321. cardEffect: activateClass);
  322. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  323. }
  324. }
  325. }
  326. #endregion
  327. #region When Attacking - ESS
  328. if (timing == EffectTiming.OnAllyAttack)
  329. {
  330. ActivateClass activateClass = new ActivateClass();
  331. activateClass.SetUpICardEffect("Trash your opponent's top security card", CanUseCondition, card);
  332. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDescription());
  333. activateClass.SetIsInheritedEffect(true);
  334. activateClass.SetHashString("WhenAttacking_BT20_018");
  335. cardEffects.Add(activateClass);
  336. string EffectDescription()
  337. {
  338. return
  339. "[When Attacking] (Once Per Turn) If this Digimon is [Alphamon: Ouryuken], trash your opponent's top security card.";
  340. }
  341. bool CanUseCondition(Hashtable hashtable)
  342. {
  343. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  344. }
  345. bool CanActivateCondition(Hashtable hashtable)
  346. {
  347. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  348. card.PermanentOfThisCard().TopCard.EqualsCardName("Alphamon: Ouryuken") &&
  349. card.Owner.Enemy.SecurityCards.Count > 0;
  350. }
  351. IEnumerator ActivateCoroutine(Hashtable hashtable)
  352. {
  353. yield return ContinuousController.instance.StartCoroutine(new IDestroySecurity(
  354. player: card.Owner.Enemy,
  355. destroySecurityCount: 1,
  356. cardEffect: activateClass,
  357. fromTop: true).DestroySecurity());
  358. }
  359. }
  360. #endregion
  361. return cardEffects;
  362. }
  363. }
  364. }