BT23_043.cs 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. // CannonBeemon
  6. namespace DCGO.CardEffects.BT23
  7. {
  8. public class BT23_043 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region Alternative Digivolution Condition
  14. if (timing == EffectTiming.None)
  15. {
  16. bool PermanentCondition(Permanent targetPermanent)
  17. {
  18. return targetPermanent.TopCard.HasLevel && targetPermanent.TopCard.IsLevel4
  19. && (targetPermanent.TopCard.HasCSTraits || targetPermanent.TopCard.HasRoyalBaseTraits);
  20. }
  21. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  22. permanentCondition: PermanentCondition,
  23. digivolutionCost: 3,
  24. ignoreDigivolutionRequirement: false,
  25. card: card,
  26. condition: null)
  27. );
  28. }
  29. #endregion Alternative Digivolution Condition
  30. #region Opponents Turn - Security
  31. if (timing == EffectTiming.None)
  32. {
  33. bool Condition()
  34. {
  35. return CardEffectCommons.IsExistInSecurity(card, false) &&
  36. CardEffectCommons.IsOpponentTurn(card);
  37. }
  38. bool PermanentCondition(Permanent permanent)
  39. {
  40. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card))
  41. {
  42. if (permanent.TopCard.EqualsTraits("Royal Base"))
  43. {
  44. return true;
  45. }
  46. }
  47. return false;
  48. }
  49. cardEffects.Add(CardEffectFactory.BlockerStaticEffect(
  50. permanentCondition: PermanentCondition,
  51. isInheritedEffect: false,
  52. card: card,
  53. condition: Condition));
  54. }
  55. #endregion
  56. #region All Turns - OPT
  57. if (timing == EffectTiming.WhenRemoveField)
  58. {
  59. ActivateClass activateClass = new ActivateClass();
  60. activateClass.SetUpICardEffect("By flipping your top face up security card face down, prevent remove from field", CanUseCondition, card);
  61. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  62. activateClass.SetHashString("BT23_AT");
  63. cardEffects.Add(activateClass);
  64. string EffectDiscription()
  65. {
  66. return "[All Turns] [Once Per Turn] When this Digimon would leave the battle area other than by your effects, by flipping your top face-up security card face down, it doesn't leave.";
  67. }
  68. bool CanUseCondition(Hashtable hashtable)
  69. {
  70. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  71. && CardEffectCommons.CanTriggerWhenRemoveField(hashtable, card)
  72. && !CardEffectCommons.IsByEffect(hashtable, cardEffect => CardEffectCommons.IsOwnerEffect(cardEffect, card));
  73. }
  74. bool CanActivateCondition(Hashtable hashtable)
  75. {
  76. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  77. && CardEffectCommons.HasMatchConditionOwnersSecurity(card, _ => true, false);
  78. }
  79. IEnumerator ActivateCoroutine(Hashtable hashtable)
  80. {
  81. var flippedSecurity = false;
  82. foreach (CardSource source in card.Owner.SecurityCards)
  83. {
  84. if (source.IsFlipped) continue;
  85. source.SetReverse();
  86. GManager.OnSecurityStackChanged?.Invoke(card.Owner.Enemy);
  87. flippedSecurity = true;
  88. break;
  89. }
  90. if (flippedSecurity)
  91. {
  92. var thisPermament = card.PermanentOfThisCard();
  93. thisPermament.HideDeleteEffect();
  94. thisPermament.HideHandBounceEffect();
  95. thisPermament.HideDeckBounceEffect();
  96. thisPermament.HideWillRemoveFieldEffect();
  97. thisPermament.DestroyingEffect = null;
  98. thisPermament.IsDestroyedByBattle = false;
  99. thisPermament.HandBounceEffect = null;
  100. thisPermament.LibraryBounceEffect = null;
  101. thisPermament.willBeRemoveField = false;
  102. }
  103. yield return null;
  104. }
  105. }
  106. #endregion
  107. #region All Turns - ESS - OPT
  108. if (timing == EffectTiming.WhenRemoveField)
  109. {
  110. List<Permanent> removedPermanents = new List<Permanent>();
  111. ActivateClass activateClass = new ActivateClass();
  112. activateClass.SetUpICardEffect("By flipping your top face up security card face down, prevent remove from field", CanUseCondition, card);
  113. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  114. activateClass.SetHashString("BT23_ESS_AT");
  115. activateClass.SetIsInheritedEffect(true);
  116. cardEffects.Add(activateClass);
  117. string EffectDiscription()
  118. {
  119. return "[All Turns] [Once Per Turn] When any of your [Royal Base] trait Digimon would leave the battle area other than by your effects, by flipping your top face-up security card face down, 1 of those Digimon doesn't leave.";
  120. }
  121. bool CanUseCondition(Hashtable hashtable)
  122. {
  123. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  124. && CardEffectCommons.CanTriggerWhenPermanentRemoveField(hashtable, CanSelectPermanentCondition)
  125. && !CardEffectCommons.IsByEffect(hashtable, cardEffect => CardEffectCommons.IsOwnerEffect(cardEffect, card));
  126. }
  127. bool CanActivateCondition(Hashtable hashtable)
  128. {
  129. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  130. && card.Owner.SecurityCards.Count(source => !source.IsFlipped) > 0;
  131. }
  132. bool CanSelectPermanentCondition(Permanent permanent)
  133. {
  134. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card)
  135. && permanent.TopCard.HasRoyalBaseTraits;
  136. }
  137. bool CanSelectPermament(Permanent permanent)
  138. {
  139. return removedPermanents.Contains(permanent);
  140. }
  141. IEnumerator ActivateCoroutine(Hashtable hashtable)
  142. {
  143. removedPermanents = CardEffectCommons.GetPermanentsFromHashtable(hashtable).Filter(CanSelectPermanentCondition);
  144. var flippedSecurity = false;
  145. foreach (CardSource source in card.Owner.SecurityCards)
  146. {
  147. if (source.IsFlipped) continue;
  148. source.SetReverse();
  149. GManager.OnSecurityStackChanged?.Invoke(card.Owner.Enemy);
  150. flippedSecurity = true;
  151. break;
  152. }
  153. if (flippedSecurity)
  154. {
  155. Permanent selectedPermanent = null;
  156. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  157. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermament));
  158. selectPermanentEffect.SetUp(
  159. selectPlayer: card.Owner,
  160. canTargetCondition: CanSelectPermament,
  161. canTargetCondition_ByPreSelecetedList: null,
  162. canEndSelectCondition: null,
  163. maxCount: maxCount,
  164. canNoSelect: false,
  165. canEndNotMax: false,
  166. selectPermanentCoroutine: SelectPermanentCoroutine,
  167. afterSelectPermanentCoroutine: null,
  168. mode: SelectPermanentEffect.Mode.Custom,
  169. cardEffect: activateClass);
  170. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  171. {
  172. selectedPermanent = permanent;
  173. yield return null;
  174. }
  175. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to prevent removal.", "The opponent is selecting 1 Digimon to prevent removal.");
  176. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  177. if (selectedPermanent != null)
  178. {
  179. selectedPermanent.HideDeleteEffect();
  180. selectedPermanent.HideHandBounceEffect();
  181. selectedPermanent.HideDeckBounceEffect();
  182. selectedPermanent.HideWillRemoveFieldEffect();
  183. selectedPermanent.DestroyingEffect = null;
  184. selectedPermanent.IsDestroyedByBattle = false;
  185. selectedPermanent.HandBounceEffect = null;
  186. selectedPermanent.LibraryBounceEffect = null;
  187. selectedPermanent.willBeRemoveField = false;
  188. }
  189. }
  190. yield return null;
  191. }
  192. }
  193. #endregion
  194. return cardEffects;
  195. }
  196. }
  197. }