BT20_056.cs 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. namespace DCGO.CardEffects.BT20
  4. {
  5. public class BT20_056 : CEntity_Effect
  6. {
  7. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  8. {
  9. List<ICardEffect> cardEffects = new List<ICardEffect>();
  10. #region Barrier
  11. if (timing == EffectTiming.WhenPermanentWouldBeDeleted)
  12. {
  13. cardEffects.Add(CardEffectFactory.BarrierSelfEffect(
  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("<Recovery +1 (Deck)>", CanUseCondition, card);
  24. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription());
  25. cardEffects.Add(activateClass);
  26. string EffectDescription()
  27. {
  28. return
  29. "[On Play] <Recovery +1 (Deck)>. 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 CanSelectDigivolveCardCondition(CardSource cardSource)
  36. {
  37. return cardSource.IsDigimon && cardSource.HasLevel && cardSource.Level <= 6 &&
  38. cardSource.EqualsTraits("Chronicle") &&
  39. cardSource.CanPlayCardTargetFrame(
  40. card.Owner.GetBreedingAreaPermanents()[0].PermanentFrame,
  41. false, activateClass, isBreedingArea: true);
  42. }
  43. bool IsAttackingCondition()
  44. {
  45. return GManager.instance.attackProcess.IsAttacking &&
  46. card.Owner.GetBreedingAreaPermanents().Count > 0 &&
  47. (CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectDigivolveCardCondition) ||
  48. CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectDigivolveCardCondition));
  49. }
  50. bool CanActivateCondition(Hashtable hashtable)
  51. {
  52. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  53. (card.Owner.LibraryCards.Count >= 1 || IsAttackingCondition());
  54. }
  55. IEnumerator ActivateCoroutine(Hashtable hashtable)
  56. {
  57. if (card.Owner.LibraryCards.Count >= 1)
  58. {
  59. yield return ContinuousController.instance.StartCoroutine(new IRecovery(card.Owner, 1, activateClass).Recovery());
  60. }
  61. if (IsAttackingCondition())
  62. {
  63. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  64. {
  65. new(message: "Digivolve in the breeding area", value: true, spriteIndex: 0),
  66. new(message: "Do not digivolve", value: false, spriteIndex: 1),
  67. };
  68. string selectPlayerMessage = "Digivolve in the breeding area?";
  69. string notSelectPlayerMessage = "The opponent is choosing whether to digivolve in the breeding area or not.";
  70. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements,
  71. selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage,
  72. notSelectPlayerMessage: notSelectPlayerMessage);
  73. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager
  74. .WaitForEndSelect());
  75. if (GManager.instance.userSelectionManager.SelectedBoolValue)
  76. {
  77. bool canSelectHand = CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectDigivolveCardCondition);
  78. bool canSelectTrash =
  79. CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectDigivolveCardCondition);
  80. if (canSelectHand || canSelectTrash)
  81. {
  82. if (canSelectHand && canSelectTrash)
  83. {
  84. selectionElements = new List<SelectionElement<bool>>()
  85. {
  86. new(message: "From hand", value: true, spriteIndex: 0),
  87. new(message: "From trash", value: false, spriteIndex: 1),
  88. };
  89. selectPlayerMessage = "From which area do you play a card?";
  90. notSelectPlayerMessage = "The opponent is choosing from which area to play a card.";
  91. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements,
  92. selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage,
  93. notSelectPlayerMessage: notSelectPlayerMessage);
  94. }
  95. else
  96. {
  97. GManager.instance.userSelectionManager.SetBool(canSelectHand);
  98. }
  99. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager
  100. .WaitForEndSelect());
  101. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DigivolveIntoHandOrTrashCard(
  102. targetPermanent: card.Owner.GetBreedingAreaPermanents()[0],
  103. cardCondition: CanSelectDigivolveCardCondition,
  104. payCost: false,
  105. reduceCostTuple: null,
  106. fixedCostTuple: null,
  107. ignoreDigivolutionRequirementFixedCost: -1,
  108. isHand: GManager.instance.userSelectionManager.SelectedBoolValue,
  109. activateClass: activateClass,
  110. successProcess: null));
  111. }
  112. }
  113. }
  114. }
  115. }
  116. #endregion
  117. #region When Digivolving
  118. if (timing == EffectTiming.OnEnterFieldAnyone)
  119. {
  120. ActivateClass activateClass = new ActivateClass();
  121. activateClass.SetUpICardEffect("<Recovery +1 (Deck)>", CanUseCondition, card);
  122. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription());
  123. cardEffects.Add(activateClass);
  124. string EffectDescription()
  125. {
  126. return
  127. "[When Digivolving] <Recovery +1 (Deck)>. 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.";
  128. }
  129. bool CanUseCondition(Hashtable hashtable)
  130. {
  131. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  132. }
  133. bool CanSelectDigivolveCardCondition(CardSource cardSource)
  134. {
  135. return cardSource.IsDigimon && cardSource.HasLevel && cardSource.Level <= 6 &&
  136. cardSource.EqualsTraits("Chronicle") &&
  137. cardSource.CanPlayCardTargetFrame(
  138. card.Owner.GetBreedingAreaPermanents()[0].PermanentFrame,
  139. false, activateClass, isBreedingArea: true);
  140. }
  141. bool IsAttackingCondition()
  142. {
  143. return GManager.instance.attackProcess.IsAttacking &&
  144. card.Owner.GetBreedingAreaPermanents().Count > 0 &&
  145. (CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectDigivolveCardCondition) ||
  146. CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectDigivolveCardCondition));
  147. }
  148. bool CanActivateCondition(Hashtable hashtable)
  149. {
  150. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  151. (card.Owner.LibraryCards.Count >= 1 || IsAttackingCondition());
  152. }
  153. IEnumerator ActivateCoroutine(Hashtable hashtable)
  154. {
  155. if (card.Owner.LibraryCards.Count >= 1)
  156. {
  157. yield return ContinuousController.instance.StartCoroutine(new IRecovery(card.Owner, 1, activateClass).Recovery());
  158. }
  159. if (IsAttackingCondition())
  160. {
  161. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  162. {
  163. new(message: "Digivolve in the breeding area", value: true, spriteIndex: 0),
  164. new(message: "Do not digivolve", value: false, spriteIndex: 1),
  165. };
  166. string selectPlayerMessage = "Digivolve in the breeding area?";
  167. string notSelectPlayerMessage = "The opponent is choosing whether to digivolve in the breeding area or not.";
  168. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements,
  169. selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage,
  170. notSelectPlayerMessage: notSelectPlayerMessage);
  171. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager
  172. .WaitForEndSelect());
  173. if (GManager.instance.userSelectionManager.SelectedBoolValue)
  174. {
  175. bool canSelectHand = CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectDigivolveCardCondition);
  176. bool canSelectTrash =
  177. CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectDigivolveCardCondition);
  178. if (canSelectHand || canSelectTrash)
  179. {
  180. if (canSelectHand && canSelectTrash)
  181. {
  182. selectionElements = new List<SelectionElement<bool>>()
  183. {
  184. new(message: "From hand", value: true, spriteIndex: 0),
  185. new(message: "From trash", value: false, spriteIndex: 1),
  186. };
  187. selectPlayerMessage = "From which area do you play a card?";
  188. notSelectPlayerMessage = "The opponent is choosing from which area to play a card.";
  189. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements,
  190. selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage,
  191. notSelectPlayerMessage: notSelectPlayerMessage);
  192. }
  193. else
  194. {
  195. GManager.instance.userSelectionManager.SetBool(canSelectHand);
  196. }
  197. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager
  198. .WaitForEndSelect());
  199. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DigivolveIntoHandOrTrashCard(
  200. targetPermanent: card.Owner.GetBreedingAreaPermanents()[0],
  201. cardCondition: CanSelectDigivolveCardCondition,
  202. payCost: false,
  203. reduceCostTuple: null,
  204. fixedCostTuple: null,
  205. ignoreDigivolutionRequirementFixedCost: -1,
  206. isHand: GManager.instance.userSelectionManager.SelectedBoolValue,
  207. activateClass: activateClass,
  208. successProcess: null));
  209. }
  210. }
  211. }
  212. }
  213. }
  214. #endregion
  215. #region All Turns
  216. if (timing == EffectTiming.OnLoseSecurity)
  217. {
  218. ActivateClass activateClass = new ActivateClass();
  219. activateClass.SetUpICardEffect("1 of your opponent's Digimon gets -8000 DP", CanUseCondition, card);
  220. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDescription());
  221. activateClass.SetHashString("RemovedSec_BT20_056");
  222. cardEffects.Add(activateClass);
  223. string EffectDescription()
  224. {
  225. return
  226. "[All Turns] (Once Per Turn) When security stacks are removed from, 1 of your opponent's Digimon gets -8000 DP for the turn.";
  227. }
  228. bool CanUseCondition(Hashtable hashtable)
  229. {
  230. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  231. CardEffectCommons.CanTriggerWhenLoseSecurity(hashtable, _ => true);
  232. }
  233. bool CanSelectPermanentCondition(Permanent permanent)
  234. {
  235. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  236. }
  237. bool CanActivateCondition(Hashtable hashtable)
  238. {
  239. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  240. CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition);
  241. }
  242. IEnumerator ActivateCoroutine(Hashtable hashtable)
  243. {
  244. Permanent selectedPermanent = null;
  245. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  246. selectPermanentEffect.SetUp(
  247. selectPlayer: card.Owner,
  248. canTargetCondition: CanSelectPermanentCondition,
  249. canTargetCondition_ByPreSelecetedList: null,
  250. canEndSelectCondition: null,
  251. maxCount: 1,
  252. canNoSelect: false,
  253. canEndNotMax: false,
  254. selectPermanentCoroutine: SelectPermanentCoroutine,
  255. afterSelectPermanentCoroutine: null,
  256. mode: SelectPermanentEffect.Mode.Custom,
  257. cardEffect: activateClass);
  258. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will get DP -8000.",
  259. "The opponent is selecting 1 Digimon that will get DP -8000.");
  260. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  261. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  262. {
  263. selectedPermanent = permanent;
  264. yield return null;
  265. }
  266. if (selectedPermanent != null)
  267. {
  268. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDP(
  269. targetPermanent: selectedPermanent,
  270. changeValue: -8000,
  271. effectDuration: EffectDuration.UntilEachTurnEnd,
  272. activateClass: activateClass));
  273. }
  274. }
  275. }
  276. #endregion
  277. #region All Turns - ESS
  278. if (timing == EffectTiming.WhenRemoveField)
  279. {
  280. ActivateClass activateClass = new ActivateClass();
  281. activateClass.SetUpICardEffect("Trash your top security card to prevent this Digimon from leaving the battle area",
  282. CanUseCondition, card);
  283. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDescription());
  284. activateClass.SetIsInheritedEffect(true);
  285. activateClass.SetHashString("TrashSecurityToStay_BT20_056");
  286. cardEffects.Add(activateClass);
  287. string EffectDescription()
  288. {
  289. return
  290. "[All Turns] (Once Per Turn) When this Digimon would leave the battle are other than by your effects, if this Digimon is [Alphamon: Ouryuken], by trashing your top security card, it doesn't leave.";
  291. }
  292. bool CanUseCondition(Hashtable hashtable)
  293. {
  294. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  295. CardEffectCommons.CanTriggerWhenRemoveField(hashtable, card) &&
  296. !CardEffectCommons.IsByEffect(hashtable, cardEffect => CardEffectCommons.IsOwnerEffect(cardEffect, card));
  297. }
  298. bool CanActivateCondition(Hashtable hashtable)
  299. {
  300. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  301. card.PermanentOfThisCard().TopCard.EqualsCardName("Alphamon: Ouryuken") &&
  302. card.Owner.SecurityCards.Count > 0;
  303. }
  304. IEnumerator ActivateCoroutine(Hashtable hashtable)
  305. {
  306. yield return ContinuousController.instance.StartCoroutine(new IDestroySecurity(
  307. player: card.Owner,
  308. destroySecurityCount: 1,
  309. cardEffect: activateClass,
  310. fromTop: true).DestroySecurity());
  311. Permanent thisCardPermanent = card.PermanentOfThisCard();
  312. thisCardPermanent.willBeRemoveField = false;
  313. thisCardPermanent.HideDeleteEffect();
  314. thisCardPermanent.HideHandBounceEffect();
  315. thisCardPermanent.HideDeckBounceEffect();
  316. thisCardPermanent.HideWillRemoveFieldEffect();
  317. yield return null;
  318. }
  319. }
  320. #endregion
  321. return cardEffects;
  322. }
  323. }
  324. }