BT19_023.cs 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. namespace DCGO.CardEffects.BT19
  4. {
  5. public class BT19_023 : CEntity_Effect
  6. {
  7. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  8. {
  9. List<ICardEffect> cardEffects = new List<ICardEffect>();
  10. #region Blocker
  11. if (timing == EffectTiming.None)
  12. {
  13. cardEffects.Add(CardEffectFactory.BlockerSelfStaticEffect(
  14. isInheritedEffect: false,
  15. card: card,
  16. condition: null));
  17. }
  18. #endregion
  19. #region On Play/ When Digivolving Shared
  20. bool CanSelectDigimonPermanentConditionShared(Permanent permanent)
  21. {
  22. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card);
  23. }
  24. bool CanActivateConditionShared(Hashtable hashtable)
  25. {
  26. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  27. }
  28. #endregion
  29. #region On Play
  30. if (timing == EffectTiming.OnEnterFieldAnyone)
  31. {
  32. ActivateClass activateClass = new ActivateClass();
  33. activateClass.SetUpICardEffect("Select 1 of your Digimon to gain battle protection", CanUseCondition, card);
  34. activateClass.SetUpActivateClass(CanActivateConditionShared, ActivateCoroutine, -1, false, EffectDescription());
  35. cardEffects.Add(activateClass);
  36. string EffectDescription()
  37. {
  38. return
  39. "[On Play] 1 of your Digimon can't be deleted by battle until the end of your opponent's turn.";
  40. }
  41. bool CanUseCondition(Hashtable hashtable)
  42. {
  43. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  44. }
  45. IEnumerator ActivateCoroutine(Hashtable hashtable)
  46. {
  47. Permanent selectedPermanent = null;
  48. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  49. selectPermanentEffect.SetUp(
  50. selectPlayer: card.Owner,
  51. canTargetCondition: CanSelectDigimonPermanentConditionShared,
  52. canTargetCondition_ByPreSelecetedList: null,
  53. canEndSelectCondition: null,
  54. maxCount: 1,
  55. canNoSelect: false,
  56. canEndNotMax: false,
  57. selectPermanentCoroutine: SelectPermanentCoroutine,
  58. afterSelectPermanentCoroutine: null,
  59. mode: SelectPermanentEffect.Mode.Custom,
  60. cardEffect: activateClass);
  61. selectPermanentEffect.SetUpCustomMessage(
  62. "Select 1 Digimon that will not be able to be deleted by battle.",
  63. "The opponent is selecting 1 Digimon that will not be able to be deleted by battle.");
  64. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  65. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  66. {
  67. selectedPermanent = permanent;
  68. yield return null;
  69. }
  70. if (selectedPermanent != null)
  71. {
  72. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainCanNotBeDeletedByBattle(
  73. targetPermanent: selectedPermanent,
  74. canNotBeDestroyedByBattleCondition: CanNotBeDestroyedByBattleCondition,
  75. effectDuration: EffectDuration.UntilOpponentTurnEnd,
  76. activateClass: activateClass,
  77. effectName: "Can't be deleted in battle"));
  78. bool CanNotBeDestroyedByBattleCondition(Permanent permanent, Permanent attackingPermanent,
  79. Permanent defendingPermanent, CardSource defendingCard)
  80. {
  81. return permanent == attackingPermanent || permanent == defendingPermanent;
  82. }
  83. }
  84. }
  85. }
  86. #endregion
  87. #region When Digivolving
  88. if (timing == EffectTiming.OnEnterFieldAnyone)
  89. {
  90. ActivateClass activateClass = new ActivateClass();
  91. activateClass.SetUpICardEffect("Select 1 of your Digimon to gain battle protection", CanUseCondition, card);
  92. activateClass.SetUpActivateClass(CanActivateConditionShared, ActivateCoroutine, -1, false, EffectDescription());
  93. cardEffects.Add(activateClass);
  94. string EffectDescription()
  95. {
  96. return
  97. "[When Digivolving] 1 of your Digimon can't be deleted by battle until the end of your opponent's turn.";
  98. }
  99. bool CanUseCondition(Hashtable hashtable)
  100. {
  101. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  102. }
  103. IEnumerator ActivateCoroutine(Hashtable hashtable)
  104. {
  105. Permanent selectedPermanent = null;
  106. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  107. selectPermanentEffect.SetUp(
  108. selectPlayer: card.Owner,
  109. canTargetCondition: CanSelectDigimonPermanentConditionShared,
  110. canTargetCondition_ByPreSelecetedList: null,
  111. canEndSelectCondition: null,
  112. maxCount: 1,
  113. canNoSelect: false,
  114. canEndNotMax: false,
  115. selectPermanentCoroutine: SelectPermanentCoroutine,
  116. afterSelectPermanentCoroutine: null,
  117. mode: SelectPermanentEffect.Mode.Custom,
  118. cardEffect: activateClass);
  119. selectPermanentEffect.SetUpCustomMessage(
  120. "Select 1 Digimon that will not be able to be deleted by battle.",
  121. "The opponent is selecting 1 Digimon that will not be able to be deleted by battle.");
  122. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  123. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  124. {
  125. selectedPermanent = permanent;
  126. yield return null;
  127. }
  128. if (selectedPermanent != null)
  129. {
  130. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainCanNotBeDeletedByBattle(
  131. targetPermanent: selectedPermanent,
  132. canNotBeDestroyedByBattleCondition: CanNotBeDestroyedByBattleCondition,
  133. effectDuration: EffectDuration.UntilOpponentTurnEnd,
  134. activateClass: activateClass,
  135. effectName: "Can't be deleted in battle"));
  136. bool CanNotBeDestroyedByBattleCondition(Permanent permanent, Permanent attackingPermanent,
  137. Permanent defendingPermanent, CardSource defendingCard)
  138. {
  139. return permanent == attackingPermanent || permanent == defendingPermanent;
  140. }
  141. }
  142. }
  143. }
  144. #endregion
  145. #region Your Turn - ESS
  146. if (timing == EffectTiming.None)
  147. {
  148. CanNotSwitchAttackTargetClass canNotSwitchAttackTargetClass = new CanNotSwitchAttackTargetClass();
  149. canNotSwitchAttackTargetClass.SetUpICardEffect("This Digimon's attack target can't be switched.", CanUseCondition, card);
  150. canNotSwitchAttackTargetClass.SetUpCanNotSwitchAttackTargetClass(PermanentCondition: PermanentCondition);
  151. canNotSwitchAttackTargetClass.SetIsInheritedEffect(true);
  152. cardEffects.Add(canNotSwitchAttackTargetClass);
  153. bool CanUseCondition(Hashtable hashtable)
  154. {
  155. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  156. CardEffectCommons.IsOwnerTurn(card);
  157. }
  158. bool PermanentCondition(Permanent permanent)
  159. {
  160. return permanent != null && permanent.TopCard && permanent == card.PermanentOfThisCard();
  161. }
  162. }
  163. #endregion
  164. return cardEffects;
  165. }
  166. }
  167. }