BT20_022.cs 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. namespace DCGO.CardEffects.BT20
  4. {
  5. public class BT20_022 : CEntity_Effect
  6. {
  7. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  8. {
  9. List<ICardEffect> cardEffects = new List<ICardEffect>();
  10. #region Alternate Digivolution Requirement
  11. if (timing == EffectTiming.None)
  12. {
  13. bool PermanentCondition(Permanent targetPermanent)
  14. {
  15. return targetPermanent.TopCard.EqualsCardName("Crabmon");
  16. }
  17. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  18. permanentCondition: PermanentCondition,
  19. digivolutionCost: 0,
  20. ignoreDigivolutionRequirement: false,
  21. card: card,
  22. condition: null)
  23. );
  24. }
  25. #endregion
  26. #region On Play
  27. if (timing == EffectTiming.OnEnterFieldAnyone)
  28. {
  29. ActivateClass activatePlayClass = new ActivateClass();
  30. activatePlayClass.SetUpICardEffect("Select 1 of your Digimon to gain battle protection", CanUsePlayCondition, card);
  31. activatePlayClass.SetUpActivateClass(CanActivateCondition, ActivatePlayCoroutine, -1, false, EffectDiscription());
  32. cardEffects.Add(activatePlayClass);
  33. string EffectDiscription()
  34. {
  35. return "[On Play] 1 of your Digimon can't be deleted in battle until the end of your opponent's turn.";
  36. }
  37. bool CanSelectPermanentCondition(Permanent permanent)
  38. {
  39. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card);
  40. }
  41. bool CanUsePlayCondition(Hashtable hashtable)
  42. {
  43. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  44. }
  45. bool CanActivateCondition(Hashtable hashtable)
  46. {
  47. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  48. }
  49. IEnumerator ActivatePlayCoroutine(Hashtable hashtable)
  50. {
  51. var selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  52. selectPermanentEffect.SetUp(
  53. selectPlayer: card.Owner,
  54. canTargetCondition: CanSelectPermanentCondition,
  55. canTargetCondition_ByPreSelecetedList: null,
  56. canEndSelectCondition: null,
  57. maxCount: 1,
  58. canNoSelect: false,
  59. canEndNotMax: false,
  60. selectPermanentCoroutine: SelectPermanentCoroutine,
  61. afterSelectPermanentCoroutine: null,
  62. mode: SelectPermanentEffect.Mode.Custom,
  63. cardEffect: activatePlayClass);
  64. selectPermanentEffect.SetUpCustomMessage(
  65. "Select 1 Digimon that will get effects.",
  66. "The opponent is selecting 1 Digimon that will get effects.");
  67. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  68. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  69. {
  70. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainCanNotBeDeletedByBattle(
  71. targetPermanent: permanent,
  72. canNotBeDestroyedByBattleCondition: CanNotBeDestroyedByBattleCondition,
  73. effectDuration: EffectDuration.UntilOpponentTurnEnd,
  74. activateClass: activatePlayClass,
  75. effectName: "Can't be deleted in battle"));
  76. bool CanNotBeDestroyedByBattleCondition(Permanent permanent1, Permanent attackingPermanent, Permanent defendingPermanent, CardSource defendingCard)
  77. {
  78. return permanent1 == attackingPermanent || permanent1 == defendingPermanent;
  79. }
  80. }
  81. }
  82. }
  83. #endregion
  84. #region When Digivolving
  85. if (timing == EffectTiming.OnEnterFieldAnyone)
  86. {
  87. ActivateClass activatePlayClass = new ActivateClass();
  88. activatePlayClass.SetUpICardEffect("Select 1 of your Digimon to gain battle protection", CanUsePlayCondition, card);
  89. activatePlayClass.SetUpActivateClass(CanActivateCondition, ActivatePlayCoroutine, -1, false, EffectDiscription());
  90. cardEffects.Add(activatePlayClass);
  91. string EffectDiscription()
  92. {
  93. return "[When Digivolving] 1 of your Digimon can't be deleted in battle until the end of your opponent's turn.";
  94. }
  95. bool CanSelectPermanentCondition(Permanent permanent)
  96. {
  97. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card);
  98. }
  99. bool CanUsePlayCondition(Hashtable hashtable)
  100. {
  101. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  102. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  103. return false;
  104. }
  105. bool CanActivateCondition(Hashtable hashtable)
  106. {
  107. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  108. }
  109. IEnumerator ActivatePlayCoroutine(Hashtable hashtable)
  110. {
  111. var selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  112. selectPermanentEffect.SetUp(
  113. selectPlayer: card.Owner,
  114. canTargetCondition: CanSelectPermanentCondition,
  115. canTargetCondition_ByPreSelecetedList: null,
  116. canEndSelectCondition: null,
  117. maxCount: 1,
  118. canNoSelect: false,
  119. canEndNotMax: false,
  120. selectPermanentCoroutine: SelectPermanentCoroutine,
  121. afterSelectPermanentCoroutine: null,
  122. mode: SelectPermanentEffect.Mode.Custom,
  123. cardEffect: activatePlayClass);
  124. selectPermanentEffect.SetUpCustomMessage(
  125. "Select 1 Digimon that will get effects.",
  126. "The opponent is selecting 1 Digimon that will get effects.");
  127. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  128. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  129. {
  130. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainCanNotBeDeletedByBattle(
  131. targetPermanent: permanent,
  132. canNotBeDestroyedByBattleCondition: CanNotBeDestroyedByBattleCondition,
  133. effectDuration: EffectDuration.UntilOpponentTurnEnd,
  134. activateClass: activatePlayClass,
  135. effectName: "Can't be deleted in battle"));
  136. bool CanNotBeDestroyedByBattleCondition(Permanent permanent1, Permanent attackingPermanent, Permanent defendingPermanent, CardSource defendingCard)
  137. {
  138. return permanent1 == attackingPermanent || permanent1 == defendingPermanent;
  139. }
  140. }
  141. }
  142. }
  143. #endregion
  144. #region When Attacking
  145. if (timing == EffectTiming.OnAllyAttack)
  146. {
  147. ActivateClass activateClass = new ActivateClass();
  148. activateClass.SetUpICardEffect("Draw 1 card", CanUseCondition, card);
  149. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDiscription());
  150. activateClass.SetHashString("Draw_BT20_022");
  151. activateClass.SetIsInheritedEffect(true);
  152. cardEffects.Add(activateClass);
  153. string EffectDiscription()
  154. {
  155. return "[When Attacking][Once Per Turn] If you have 7 or fewer cards in your hand, <Draw 1>.";
  156. }
  157. bool CanUseCondition(Hashtable hashtable)
  158. {
  159. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  160. }
  161. bool CanActivateCondition(Hashtable hashtable)
  162. {
  163. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  164. {
  165. if (card.Owner.HandCards.Count <= 7)
  166. {
  167. return true;
  168. }
  169. }
  170. return false;
  171. }
  172. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  173. {
  174. yield return ContinuousController.instance.StartCoroutine(new DrawClass(card.Owner, 1, activateClass).Draw());
  175. }
  176. }
  177. #endregion
  178. return cardEffects;
  179. }
  180. }
  181. }