BT25_039.cs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  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. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  52. selectHandEffect.SetUp(
  53. selectPlayer: card.Owner,
  54. canTargetCondition: CanSelectCardCondition,
  55. canTargetCondition_ByPreSelecetedList: null,
  56. canEndSelectCondition: null,
  57. maxCount: 1,
  58. canNoSelect: true,
  59. canEndNotMax: false,
  60. isShowOpponent: true,
  61. selectCardCoroutine: null,
  62. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  63. mode: SelectHandEffect.Mode.PlayForCost,
  64. cardEffect: activateClass);
  65. selectHandEffect.SetReducedCostTuple((7, null));
  66. selectHandEffect.SetUpCustomMessage("Select 1 card to play", "The opponent is selecting 1 card to play");
  67. yield return ContinuousController.instance.StartCoroutine(selectHandEffect.Activate());
  68. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  69. {
  70. if (cardSources.Count > 0)
  71. selectedCard = cardSources[0];
  72. yield return null;
  73. }
  74. if (selectedCard != null)
  75. {
  76. Permanent playedPermanent = selectedCard.PermanentOfThisCard();
  77. if (playedPermanent != null)
  78. {
  79. string selectPlayerMessage = "Will you place Sirenmon under Ceresmon?";
  80. string notSelectPlayerMessage = "The opponent is choosing if they will place Sirenmon under Ceresmon.";
  81. List<SelectionElement<bool>> command_SelectCommands = new List<SelectionElement<bool>>()
  82. {
  83. new SelectionElement<bool>(message: $"Yes", value: true, spriteIndex: 0),
  84. new SelectionElement<bool>(message: $"No", value: false, spriteIndex: 1),
  85. };
  86. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: command_SelectCommands, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  87. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  88. if (GManager.instance.userSelectionManager.SelectedBoolValue)
  89. {
  90. yield return ContinuousController.instance.StartCoroutine(
  91. playedPermanent.AddDigivolutionCardsBottom(new List<CardSource> { card }, activateClass));
  92. yield return ContinuousController.instance.StartCoroutine(new IReduceSecurity(
  93. player: card.Owner,
  94. refSkillInfos: ref ContinuousController.instance.nullSkillInfos,
  95. activateClass).ReduceSecurity());
  96. }
  97. }
  98. }
  99. }
  100. }
  101. #endregion
  102. #region All turns
  103. if (timing == EffectTiming.WhenRemoveField)
  104. {
  105. ActivateClass activateClass = new ActivateClass();
  106. activateClass.SetUpICardEffect("By deleting this, they don't leave", CanUseCondition, card);
  107. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDescription());
  108. cardEffects.Add(activateClass);
  109. string EffectDescription()
  110. {
  111. 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.";
  112. }
  113. bool CanUseCondition(Hashtable hashtable)
  114. {
  115. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  116. && CardEffectCommons.CanTriggerWhenPermanentRemoveField(hashtable, PermanentCondition)
  117. && !CardEffectCommons.IsByEffect(hashtable, cardEffect => CardEffectCommons.IsOwnerEffect(cardEffect, card));
  118. }
  119. bool CanActivateCondition(Hashtable hashtable)
  120. {
  121. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  122. }
  123. bool PermanentCondition(Permanent permanent)
  124. {
  125. return permanent != card.PermanentOfThisCard()
  126. && CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card)
  127. && (permanent.IsDigimon || permanent.IsTamer)
  128. && (permanent.TopCard.HasShamanTraits || permanent.TopCard.HasIliadTraits);
  129. }
  130. IEnumerator ActivateCoroutine(Hashtable hashtable)
  131. {
  132. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DeletePeremanentAndProcessAccordingToResult(targetPermanents: new List<Permanent>() { card.PermanentOfThisCard() }, activateClass: activateClass, successProcess: permanents => SuccessProcess(), failureProcess: null));
  133. IEnumerator SuccessProcess()
  134. {
  135. List<Permanent> protectedPermanents = CardEffectCommons.GetPermanentsFromHashtable(hashtable)
  136. .Filter(PermanentCondition);
  137. foreach (Permanent permanent in protectedPermanents)
  138. {
  139. permanent.willBeRemoveField = false;
  140. permanent.HideDeleteEffect();
  141. permanent.HideHandBounceEffect();
  142. permanent.HideDeckBounceEffect();
  143. permanent.HideWillRemoveFieldEffect();
  144. }
  145. yield return null;
  146. }
  147. }
  148. }
  149. #endregion
  150. #region On Deletion
  151. if (timing == EffectTiming.OnDestroyedAnyone)
  152. {
  153. cardEffects.Add(CardEffectFactory.OnDeletionClass(
  154. card,
  155. "Place this card face up as the bottom security card",
  156. ActivateCoroutine,
  157. "[On Deletion] You may place this card face up as the bottom security card.",
  158. optional: true,
  159. additionalActivateCondition: AdditionalActivateCondition
  160. ));
  161. bool AdditionalActivateCondition(Hashtable hashtable, ActivateClass activateClass) => card.Owner.CanAddSecurity(activateClass);
  162. IEnumerator ActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  163. {
  164. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddSecurityCard(card, toTop: false, faceUp: true));
  165. }
  166. }
  167. #endregion
  168. #region Opponent's Turn - ESS
  169. if (timing == EffectTiming.OnAllyAttack)
  170. {
  171. ActivateClass activateClass = new ActivateClass();
  172. activateClass.SetUpICardEffect("You may change the attack target to 1 of your suspended Digimon.", CanUseCondition, card);
  173. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDescription());
  174. activateClass.SetIsSkippable(true);
  175. activateClass.SetIsInheritedEffect(true);
  176. activateClass.SetHashString("Redirect_BT25_039");
  177. cardEffects.Add(activateClass);
  178. string EffectDescription()
  179. => "[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.";
  180. bool IsOpponentDigimon(Permanent permanent) => CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  181. bool CanUseCondition(Hashtable hashtable)
  182. {
  183. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  184. && CardEffectCommons.IsOpponentTurn(card)
  185. && CardEffectCommons.CanTriggerOnPermanentAttack(hashtable, IsOpponentDigimon);
  186. }
  187. bool CanActivateCondition(Hashtable hashtable)
  188. {
  189. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  190. && CardEffectCommons.HasMatchConditionOwnersPermanent(card, IsSuspendedDigimon);
  191. }
  192. bool IsSuspendedDigimon(Permanent permanent)
  193. {
  194. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card)
  195. && permanent.IsSuspended;
  196. }
  197. IEnumerator ActivateCoroutine(Hashtable hashtable)
  198. {
  199. Permanent selectedPermanent = null;
  200. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  201. selectPermanentEffect.SetUp(
  202. selectPlayer: card.Owner,
  203. canTargetCondition: IsSuspendedDigimon,
  204. canTargetCondition_ByPreSelecetedList: null,
  205. canEndSelectCondition: null,
  206. maxCount: 1,
  207. canNoSelect: true,
  208. canEndNotMax: false,
  209. selectPermanentCoroutine: SelectPermanentCoroutine,
  210. afterSelectPermanentCoroutine: null,
  211. mode: SelectPermanentEffect.Mode.Custom,
  212. cardEffect: activateClass);
  213. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to change the attack target to.", "The opponent is selecting 1 Digimon to change the attack target to.");
  214. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  215. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  216. {
  217. selectedPermanent = permanent;
  218. yield return null;
  219. }
  220. if (selectedPermanent != null)
  221. {
  222. yield return ContinuousController.instance.StartCoroutine(GManager.instance.attackProcess.SwitchDefender(
  223. activateClass,
  224. false,
  225. selectedPermanent));
  226. }
  227. else activateClass.RemoveUse();
  228. }
  229. }
  230. #endregion
  231. return cardEffects;
  232. }
  233. }
  234. }