BT25_039.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. // Sirenmon
  5. namespace DCGO.CardEffects.BT25
  6. {
  7. public class BT25_039 : 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. static bool PermanentCondition(Permanent targetPermanent)
  16. {
  17. return targetPermanent.TopCard.HasTSTraits;
  18. }
  19. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(level: 4, permanentCondition: PermanentCondition, digivolutionCost: 3, ignoreDigivolutionRequirement: false, card: card, condition: null));
  20. }
  21. #endregion
  22. #region End of your Turn - Security
  23. if (timing == EffectTiming.OnEndTurn)
  24. {
  25. ActivateClass activateClass = new();
  26. activateClass.SetUpICardEffect("May play [Ceresmon] for -7, then may place this under played card", CanUseCondition, card);
  27. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription());
  28. activateClass.SetIsSkippable(true);
  29. cardEffects.Add(activateClass);
  30. string EffectDescription()
  31. => "(Security) [End of Your Turn] You may play 1 [Ceresmon] from your hand with the cost reduced by 7. If this effect played, you may place this card as the played Digimon's bottom digivolution card.";
  32. bool CanUseCondition(Hashtable hashtable)
  33. {
  34. return CardEffectCommons.IsExistInSecurity(card, false)
  35. && CardEffectCommons.IsOwnerTurn(card);
  36. }
  37. bool CanActivateCondition(Hashtable hashtable)
  38. {
  39. return CardEffectCommons.IsExistInSecurity(card, false)
  40. && CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectCardCondition);
  41. }
  42. bool CanSelectCardCondition(CardSource cardSource)
  43. {
  44. return cardSource.HasPlayCost
  45. && cardSource.EqualsCardName("Ceresmon")
  46. && CardEffectCommons.CanPlayAsNewPermanent(cardSource, true, activateClass, fixedCost: cardSource.GetCostItself - 7);
  47. }
  48. IEnumerator ActivateCoroutine(Hashtable hashtable)
  49. {
  50. CardSource selectedCard = null;
  51. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayByEffect(
  52. canTargetCondition: CanSelectCardCondition,
  53. SelectCardEffect.Root.Hand,
  54. activateClass,
  55. payCost: true,
  56. reduceCostTuple: (7, null),
  57. afterSelectCardCoroutine: AfterSelectCardCoroutine
  58. ));
  59. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  60. {
  61. if (cardSources.Count > 0)
  62. selectedCard = cardSources[0];
  63. yield return null;
  64. }
  65. if (selectedCard != null)
  66. {
  67. Permanent playedPermanent = selectedCard.PermanentOfThisCard();
  68. if (playedPermanent != null)
  69. {
  70. string selectPlayerMessage = "Will you place Sirenmon under Ceresmon?";
  71. string notSelectPlayerMessage = "The opponent is choosing if they will place Sirenmon under Ceresmon.";
  72. List<SelectionElement<bool>> command_SelectCommands = new List<SelectionElement<bool>>()
  73. {
  74. new SelectionElement<bool>(message: $"Yes", value: true, spriteIndex: 0),
  75. new SelectionElement<bool>(message: $"No", value: false, spriteIndex: 1),
  76. };
  77. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: command_SelectCommands, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  78. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  79. if (GManager.instance.userSelectionManager.SelectedBoolValue)
  80. {
  81. yield return ContinuousController.instance.StartCoroutine(
  82. playedPermanent.AddDigivolutionCardsBottom(new List<CardSource> { card }, activateClass));
  83. yield return ContinuousController.instance.StartCoroutine(new IReduceSecurity(
  84. player: card.Owner,
  85. refSkillInfos: ref ContinuousController.instance.nullSkillInfos,
  86. activateClass).ReduceSecurity());
  87. }
  88. }
  89. }
  90. }
  91. }
  92. #endregion
  93. #region All turns
  94. if (timing == EffectTiming.WhenRemoveField)
  95. {
  96. ActivateClass activateClass = new ActivateClass();
  97. activateClass.SetUpICardEffect("By deleting this, they don't leave", CanUseCondition, card);
  98. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDescription());
  99. cardEffects.Add(activateClass);
  100. string EffectDescription()
  101. {
  102. return "[All Turns] When any of your other [Shaman] or [Iliad] trait Digimon or Tamers would leave the battle area other than by your effects, by deleting this Digimon, they don't leave.";
  103. }
  104. bool CanUseCondition(Hashtable hashtable)
  105. {
  106. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  107. && CardEffectCommons.CanTriggerWhenPermanentRemoveField(hashtable, PermanentCondition)
  108. && !CardEffectCommons.IsByEffect(hashtable, cardEffect => CardEffectCommons.IsOwnerEffect(cardEffect, card));
  109. }
  110. bool CanActivateCondition(Hashtable hashtable)
  111. {
  112. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  113. }
  114. bool PermanentCondition(Permanent permanent)
  115. {
  116. return permanent != card.PermanentOfThisCard()
  117. && CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card)
  118. && (permanent.IsDigimon || permanent.IsTamer)
  119. && (permanent.TopCard.HasShamanTraits || permanent.TopCard.HasIliadTraits);
  120. }
  121. IEnumerator ActivateCoroutine(Hashtable hashtable)
  122. {
  123. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DeletePeremanentAndProcessAccordingToResult(targetPermanents: new List<Permanent>() { card.PermanentOfThisCard() }, activateClass: activateClass, successProcess: permanents => SuccessProcess(), failureProcess: null));
  124. IEnumerator SuccessProcess()
  125. {
  126. List<Permanent> protectedPermanents = CardEffectCommons.GetPermanentsFromHashtable(hashtable)
  127. .Filter(PermanentCondition);
  128. foreach (Permanent permanent in protectedPermanents)
  129. {
  130. permanent.willBeRemoveField = false;
  131. permanent.HideDeleteEffect();
  132. permanent.HideHandBounceEffect();
  133. permanent.HideDeckBounceEffect();
  134. permanent.HideWillRemoveFieldEffect();
  135. }
  136. yield return null;
  137. }
  138. }
  139. }
  140. #endregion
  141. #region On Deletion
  142. if (timing == EffectTiming.OnDestroyedAnyone)
  143. {
  144. cardEffects.Add(CardEffectFactory.OnDeletionClass(
  145. card,
  146. "Place this card face up as the bottom security card",
  147. ActivateCoroutine,
  148. "[On Deletion] You may place this card face up as the bottom security card.",
  149. optional: true,
  150. additionalActivateCondition: AdditionalActivateCondition
  151. ));
  152. bool AdditionalActivateCondition(Hashtable hashtable, ActivateClass activateClass) => card.Owner.CanAddSecurity(activateClass);
  153. IEnumerator ActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  154. {
  155. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddSecurityCard(card, toTop: false, faceUp: true));
  156. }
  157. }
  158. #endregion
  159. #region Opponent's Turn - ESS
  160. if (timing == EffectTiming.OnAllyAttack)
  161. {
  162. ActivateClass activateClass = new ActivateClass();
  163. activateClass.SetUpICardEffect("You may change the attack target to 1 of your suspended Digimon.", CanUseCondition, card);
  164. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDescription());
  165. activateClass.SetIsSkippable(true);
  166. activateClass.SetIsInheritedEffect(true);
  167. activateClass.SetHashString("Redirect_BT25_039");
  168. cardEffects.Add(activateClass);
  169. string EffectDescription()
  170. => "[Opponent's Turn] [Once Per Turn] When one of your opponent's Digimon attacks, you may change the attack target to 1 of your suspended Digimon.";
  171. bool IsOpponentDigimon(Permanent permanent) => CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  172. bool CanUseCondition(Hashtable hashtable)
  173. {
  174. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  175. && CardEffectCommons.IsOpponentTurn(card)
  176. && CardEffectCommons.CanTriggerOnPermanentAttack(hashtable, IsOpponentDigimon);
  177. }
  178. bool CanActivateCondition(Hashtable hashtable)
  179. {
  180. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  181. && CardEffectCommons.HasMatchConditionOwnersPermanent(card, IsSuspendedDigimon);
  182. }
  183. bool IsSuspendedDigimon(Permanent permanent)
  184. {
  185. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card)
  186. && permanent.IsSuspended;
  187. }
  188. IEnumerator ActivateCoroutine(Hashtable hashtable)
  189. {
  190. Permanent selectedPermanent = null;
  191. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  192. selectPermanentEffect.SetUp(
  193. selectPlayer: card.Owner,
  194. canTargetCondition: IsSuspendedDigimon,
  195. canTargetCondition_ByPreSelecetedList: null,
  196. canEndSelectCondition: null,
  197. maxCount: 1,
  198. canNoSelect: true,
  199. canEndNotMax: false,
  200. selectPermanentCoroutine: SelectPermanentCoroutine,
  201. afterSelectPermanentCoroutine: null,
  202. mode: SelectPermanentEffect.Mode.Custom,
  203. cardEffect: activateClass);
  204. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to change the attack target to.", "The opponent is selecting 1 Digimon to change the attack target to.");
  205. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  206. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  207. {
  208. selectedPermanent = permanent;
  209. yield return null;
  210. }
  211. if (selectedPermanent != null)
  212. {
  213. yield return ContinuousController.instance.StartCoroutine(GManager.instance.attackProcess.SwitchDefender(
  214. activateClass,
  215. false,
  216. selectedPermanent));
  217. }
  218. else activateClass.RemoveUse();
  219. }
  220. }
  221. #endregion
  222. return cardEffects;
  223. }
  224. }
  225. }