BT20_049.cs 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System;
  4. namespace DCGO.CardEffects.BT20
  5. {
  6. public class BT20_049 : CEntity_Effect
  7. {
  8. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  9. {
  10. List<ICardEffect> cardEffects = new List<ICardEffect>();
  11. #region On Play
  12. if (timing == EffectTiming.OnEnterFieldAnyone)
  13. {
  14. ActivateClass activateClass = new ActivateClass();
  15. activateClass.SetUpICardEffect("1 of your opponent's Digimon can't attack players until the end of their turn", CanUseCondition, card);
  16. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  17. cardEffects.Add(activateClass);
  18. string EffectDiscription()
  19. {
  20. return "[On Play] 1 of your opponent's Digimon can't attack players until the end of their turn.";
  21. }
  22. bool OpponentsDigimon(Permanent permanent)
  23. {
  24. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  25. }
  26. bool CanUseCondition(Hashtable hashtable)
  27. {
  28. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  29. }
  30. bool CanActivateCondition(Hashtable hashtable)
  31. {
  32. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  33. CardEffectCommons.HasMatchConditionPermanent(OpponentsDigimon);
  34. }
  35. IEnumerator ActivateCoroutine(Hashtable hashtable)
  36. {
  37. Permanent selectedPermanent = null;
  38. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(OpponentsDigimon));
  39. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  40. selectPermanentEffect.SetUp(
  41. selectPlayer: card.Owner,
  42. canTargetCondition: OpponentsDigimon,
  43. canTargetCondition_ByPreSelecetedList: null,
  44. canEndSelectCondition: null,
  45. maxCount: maxCount,
  46. canNoSelect: false,
  47. canEndNotMax: false,
  48. selectPermanentCoroutine: SelectPermanentCoroutine,
  49. afterSelectPermanentCoroutine: null,
  50. mode: SelectPermanentEffect.Mode.Custom,
  51. cardEffect: activateClass);
  52. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  53. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  54. {
  55. selectedPermanent = permanent;
  56. yield return null;
  57. }
  58. if(selectedPermanent != null)
  59. {
  60. bool AttackerCondition(Permanent Attacker)
  61. {
  62. return Attacker == selectedPermanent;
  63. }
  64. bool DefenderCondition(Permanent Defender)
  65. {
  66. return Defender == null;
  67. }
  68. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainCanNotAttackPlayerEffect(
  69. attackerCondition: AttackerCondition,
  70. defenderCondition: DefenderCondition,
  71. effectDuration: EffectDuration.UntilOpponentTurnEnd,
  72. activateClass: activateClass,
  73. effectName: "Can't Attack"));
  74. }
  75. }
  76. }
  77. #endregion
  78. #region When Digivolving
  79. if (timing == EffectTiming.OnEnterFieldAnyone)
  80. {
  81. ActivateClass activateClass = new ActivateClass();
  82. activateClass.SetUpICardEffect("1 of your opponent's Digimon can't attack players until the end of their turn", CanUseCondition, card);
  83. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  84. cardEffects.Add(activateClass);
  85. string EffectDiscription()
  86. {
  87. return "[When Digivolving] 1 of your opponent's Digimon can't attack players until the end of their turn.";
  88. }
  89. bool OpponentsDigimon(Permanent permanent)
  90. {
  91. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  92. }
  93. bool CanUseCondition(Hashtable hashtable)
  94. {
  95. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  96. CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  97. }
  98. bool CanActivateCondition(Hashtable hashtable)
  99. {
  100. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  101. CardEffectCommons.HasMatchConditionPermanent(OpponentsDigimon);
  102. }
  103. IEnumerator ActivateCoroutine(Hashtable hashtable)
  104. {
  105. Permanent selectedPermanent = null;
  106. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(OpponentsDigimon));
  107. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  108. selectPermanentEffect.SetUp(
  109. selectPlayer: card.Owner,
  110. canTargetCondition: OpponentsDigimon,
  111. canTargetCondition_ByPreSelecetedList: null,
  112. canEndSelectCondition: null,
  113. maxCount: maxCount,
  114. canNoSelect: false,
  115. canEndNotMax: false,
  116. selectPermanentCoroutine: SelectPermanentCoroutine,
  117. afterSelectPermanentCoroutine: null,
  118. mode: SelectPermanentEffect.Mode.Custom,
  119. cardEffect: activateClass);
  120. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  121. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  122. {
  123. selectedPermanent = permanent;
  124. yield return null;
  125. }
  126. if (selectedPermanent != null)
  127. {
  128. bool AttackerCondition(Permanent Attacker)
  129. {
  130. return Attacker == selectedPermanent;
  131. }
  132. bool DefenderCondition(Permanent Defender)
  133. {
  134. return Defender == null;
  135. }
  136. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainCanNotAttackPlayerEffect(
  137. attackerCondition: AttackerCondition,
  138. defenderCondition: DefenderCondition,
  139. effectDuration: EffectDuration.UntilOpponentTurnEnd,
  140. activateClass: activateClass,
  141. effectName: "Can't Attack"));
  142. }
  143. }
  144. }
  145. #endregion
  146. #region Reboot - ESS
  147. if (timing == EffectTiming.None)
  148. {
  149. cardEffects.Add(CardEffectFactory.RebootSelfStaticEffect(isInheritedEffect: true, card: card, condition: null));
  150. }
  151. #endregion
  152. return cardEffects;
  153. }
  154. }
  155. }