BT23_045.cs 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. // TigerVespamon
  5. namespace DCGO.CardEffects.BT23
  6. {
  7. public class BT23_045 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Blast Digivolve
  13. if (timing == EffectTiming.OnCounterTiming)
  14. {
  15. cardEffects.Add(CardEffectFactory.BlastDigivolveEffect(card: card, condition: null));
  16. }
  17. #endregion
  18. #region Alternative Digivolution Condition
  19. if (timing == EffectTiming.None)
  20. {
  21. bool PermanentCondition(Permanent targetPermanent)
  22. {
  23. return targetPermanent.TopCard.HasLevel && targetPermanent.TopCard.IsLevel5
  24. && (targetPermanent.TopCard.HasCSTraits || targetPermanent.TopCard.HasRoyalBaseTraits);
  25. }
  26. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  27. permanentCondition: PermanentCondition,
  28. digivolutionCost: 3,
  29. ignoreDigivolutionRequirement: false,
  30. card: card,
  31. condition: null)
  32. );
  33. }
  34. #endregion Alternative Digivolution Condition
  35. #region OP/WD Shared
  36. bool CanSelectCardCondition(CardSource cardSource)
  37. {
  38. return cardSource.IsDigimon
  39. && (cardSource.HasRoyalBaseTraits || cardSource.EqualsTraits("Zaxon"));
  40. }
  41. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  42. {
  43. bool canSelectHand = CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectCardCondition);
  44. bool canSelectTrash = CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition);
  45. if (canSelectHand || canSelectTrash)
  46. {
  47. if (canSelectHand && canSelectTrash)
  48. {
  49. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  50. {
  51. new SelectionElement<bool>(message: $"From hand", value : true, spriteIndex: 0),
  52. new SelectionElement<bool>(message: $"From trash", value : false, spriteIndex: 1),
  53. };
  54. string selectPlayerMessage = "From which area do you select a card?";
  55. string notSelectPlayerMessage = "The opponent is choosing from which area to select a card.";
  56. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  57. }
  58. else
  59. {
  60. GManager.instance.userSelectionManager.SetBool(canSelectHand);
  61. }
  62. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  63. bool fromHand = GManager.instance.userSelectionManager.SelectedBoolValue;
  64. CardSource selectedCard = null;
  65. IEnumerator SelectCardCoroutine(CardSource cardSource)
  66. {
  67. selectedCard = cardSource;
  68. yield return null;
  69. }
  70. if (fromHand)
  71. {
  72. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  73. selectHandEffect.SetUp(
  74. selectPlayer: card.Owner,
  75. canTargetCondition: CanSelectCardCondition,
  76. canTargetCondition_ByPreSelecetedList: null,
  77. canEndSelectCondition: null,
  78. maxCount: 1,
  79. canNoSelect: true,
  80. canEndNotMax: false,
  81. isShowOpponent: true,
  82. selectCardCoroutine: SelectCardCoroutine,
  83. afterSelectCardCoroutine: null,
  84. mode: SelectHandEffect.Mode.Custom,
  85. cardEffect: activateClass);
  86. selectHandEffect.SetUpCustomMessage("Select 1 digimon to place in security.", "The opponent is selecting 1 digimon to place in security.");
  87. yield return ContinuousController.instance.StartCoroutine(selectHandEffect.Activate());
  88. }
  89. else
  90. {
  91. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  92. selectCardEffect.SetUp(
  93. canTargetCondition: CanSelectCardCondition,
  94. canTargetCondition_ByPreSelecetedList: null,
  95. canEndSelectCondition: null,
  96. canNoSelect: () => true,
  97. selectCardCoroutine: SelectCardCoroutine,
  98. afterSelectCardCoroutine: null,
  99. message: "Select 1 digimon to place in security.",
  100. maxCount: 1,
  101. canEndNotMax: false,
  102. isShowOpponent: true,
  103. mode: SelectCardEffect.Mode.Custom,
  104. root: SelectCardEffect.Root.Trash,
  105. customRootCardList: null,
  106. canLookReverseCard: true,
  107. selectPlayer: card.Owner,
  108. cardEffect: activateClass);
  109. selectCardEffect.SetUpCustomMessage("Select 1 digimon to place in security.", "The opponent is selecting 1 digimon to place in security.");
  110. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  111. }
  112. if (selectedCard != null)
  113. {
  114. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddSecurityCard(selectedCard, toTop: false, faceUp: true));
  115. bool CanSelectPermanentCondition(Permanent permanent)
  116. {
  117. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card)
  118. && permanent.HasDP && permanent.DP <= card.PermanentOfThisCard().DP;
  119. }
  120. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  121. {
  122. Permanent selectedPermanent = null;
  123. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  124. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  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: SelectPermanentCoroutine,
  134. afterSelectPermanentCoroutine: null,
  135. mode: SelectPermanentEffect.Mode.Custom,
  136. cardEffect: activateClass);
  137. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  138. {
  139. selectedPermanent = permanent;
  140. yield return null;
  141. }
  142. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to bounce to hand.", "The opponent is selecting 1 Digimon to bounce to hand.");
  143. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  144. if (selectedPermanent != null) yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.BouncePeremanentAndProcessAccordingToResult(
  145. targetPermanents: new List<Permanent>() { selectedPermanent },
  146. activateClass: activateClass,
  147. successProcess: null,
  148. failureProcess: null));
  149. }
  150. }
  151. }
  152. }
  153. #endregion
  154. #region On Play
  155. if (timing == EffectTiming.OnEnterFieldAnyone)
  156. {
  157. ActivateClass activateClass = new ActivateClass();
  158. activateClass.SetUpICardEffect("By placing 1 [Royal Base]/[Zaxon] as bottom security card, bounce 1 digimon to hand", CanUseCondition, card);
  159. activateClass.SetUpActivateClass(CanActivateCondition, hash => SharedActivateCoroutine(hash, activateClass), -1, false, EffectDiscription());
  160. cardEffects.Add(activateClass);
  161. string EffectDiscription()
  162. {
  163. return "[On Play] By placing 1 [Royal Base] or [Zaxon] trait Digimon card from your hand or trash face up as the bottom security card, return 1 of your opponent's Digimon with as much or less DP as this Digimon to the hand.";
  164. }
  165. bool CanUseCondition(Hashtable hashtable)
  166. {
  167. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  168. && CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  169. }
  170. bool CanActivateCondition(Hashtable hashtable)
  171. {
  172. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  173. && card.Owner.CanAddSecurity(activateClass)
  174. && (CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectCardCondition) || CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition));
  175. }
  176. }
  177. #endregion
  178. #region When Digivolving
  179. if (timing == EffectTiming.OnEnterFieldAnyone)
  180. {
  181. ActivateClass activateClass = new ActivateClass();
  182. activateClass.SetUpICardEffect("By placing 1 [Royal Base]/[Zaxon] as bottom security card, bounce 1 digimon to hand", CanUseCondition, card);
  183. activateClass.SetUpActivateClass(CanActivateCondition, hash => SharedActivateCoroutine(hash, activateClass), -1, false, EffectDiscription());
  184. cardEffects.Add(activateClass);
  185. string EffectDiscription()
  186. {
  187. return "[When Digivolving] By placing 1 [Royal Base] or [Zaxon] trait Digimon card from your hand or trash face up as the bottom security card, return 1 of your opponent's Digimon with as much or less DP as this Digimon to the hand.";
  188. }
  189. bool CanUseCondition(Hashtable hashtable)
  190. {
  191. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  192. && CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  193. }
  194. bool CanActivateCondition(Hashtable hashtable)
  195. {
  196. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  197. && card.Owner.CanAddSecurity(activateClass)
  198. && (CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectCardCondition) || CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition));
  199. }
  200. }
  201. #endregion
  202. #region All Turns
  203. if (timing == EffectTiming.OnTappedAnyone)
  204. {
  205. ActivateClass activateClass = new ActivateClass();
  206. activateClass.SetUpICardEffect("By flipping your top face up security card face down, unsuspend 1 digimon", CanUseCondition, card);
  207. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  208. cardEffects.Add(activateClass);
  209. string EffectDiscription()
  210. {
  211. return "[All Turns] When this Digimon suspends, by flipping your top face-up security card face down, 1 of your Digimon unsuspends.";
  212. }
  213. bool CanUseCondition(Hashtable hashtable)
  214. {
  215. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  216. && CardEffectCommons.CanTriggerWhenSelfPermanentSuspends(hashtable, card);
  217. }
  218. bool CanActivateCondition(Hashtable hashtable)
  219. {
  220. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  221. && CardEffectCommons.HasMatchConditionOwnersSecurity(card, _ => true, false);
  222. }
  223. bool CanSelectPermanentCondition(Permanent permanent)
  224. {
  225. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card);
  226. }
  227. IEnumerator ActivateCoroutine(Hashtable hashtable)
  228. {
  229. var flippedSecurity = false;
  230. foreach (CardSource source in card.Owner.SecurityCards)
  231. {
  232. if (source.IsFlipped) continue;
  233. source.SetReverse();
  234. GManager.OnSecurityStackChanged?.Invoke(card.Owner.Enemy);
  235. flippedSecurity = true;
  236. break;
  237. }
  238. if (flippedSecurity && CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  239. {
  240. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  241. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  242. selectPermanentEffect.SetUp(
  243. selectPlayer: card.Owner,
  244. canTargetCondition: CanSelectPermanentCondition,
  245. canTargetCondition_ByPreSelecetedList: null,
  246. canEndSelectCondition: null,
  247. maxCount: maxCount,
  248. canNoSelect: false,
  249. canEndNotMax: false,
  250. selectPermanentCoroutine: null,
  251. afterSelectPermanentCoroutine: null,
  252. mode: SelectPermanentEffect.Mode.UnTap,
  253. cardEffect: activateClass);
  254. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to unsuspend.", "The opponent is selecting 1 Digimon to unsuspend.");
  255. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  256. }
  257. }
  258. }
  259. #endregion
  260. return cardEffects;
  261. }
  262. }
  263. }