BT21_053.cs 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. namespace DCGO.CardEffects.BT21
  5. {
  6. //Watchmon
  7. public class BT21_053 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Link Condition
  13. if (timing == EffectTiming.None)
  14. {
  15. static bool PermanentCondition(Permanent targetPermanent)
  16. {
  17. return targetPermanent.TopCard.HasAppmonTraits;
  18. }
  19. cardEffects.Add(CardEffectFactory.AddSelfLinkConditionStaticEffect(permanentCondition: PermanentCondition, linkCost: 1, card: card));
  20. }
  21. #endregion
  22. #region Alternative Digivolution Condition
  23. if (timing == EffectTiming.None)
  24. {
  25. bool PermanentCondition(Permanent targetPermanent)
  26. {
  27. return targetPermanent.TopCard.IsLevel2 && targetPermanent.TopCard.EqualsTraits("Appmon");
  28. }
  29. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  30. permanentCondition: PermanentCondition,
  31. digivolutionCost: 0,
  32. ignoreDigivolutionRequirement: false,
  33. card: card,
  34. condition: null)
  35. );
  36. }
  37. #endregion
  38. #region On Play
  39. if (timing == EffectTiming.OnEnterFieldAnyone)
  40. {
  41. ActivateClass activateClass = new ActivateClass();
  42. activateClass.SetUpICardEffect("1 of your opponent's Digimon can't attack players until their turn ends", CanUseCondition, card);
  43. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  44. cardEffects.Add(activateClass);
  45. string EffectDiscription()
  46. {
  47. return "[On Play] Until your opponent's turn ends, 1 of their Digimon can't attack players.";
  48. }
  49. bool IsOpponentsDigimon(Permanent permanent)
  50. {
  51. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  52. }
  53. bool CanUseCondition(Hashtable hashtable)
  54. {
  55. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  56. CardEffectCommons.CanTriggerOnPlay(hashtable, card) &&
  57. CardEffectCommons.HasMatchConditionOpponentsPermanent(card, IsOpponentsDigimon);
  58. }
  59. bool CanActivateCondition(Hashtable hashtable)
  60. {
  61. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  62. }
  63. IEnumerator ActivateCoroutine(Hashtable hashtable)
  64. {
  65. if (CardEffectCommons.HasMatchConditionPermanent(IsOpponentsDigimon))
  66. {
  67. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(IsOpponentsDigimon));
  68. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  69. selectPermanentEffect.SetUp(
  70. selectPlayer: card.Owner,
  71. canTargetCondition: IsOpponentsDigimon,
  72. canTargetCondition_ByPreSelecetedList: null,
  73. canEndSelectCondition: null,
  74. maxCount: maxCount,
  75. canNoSelect: false,
  76. canEndNotMax: false,
  77. selectPermanentCoroutine: SelectCantAttackPermanent,
  78. afterSelectPermanentCoroutine: null,
  79. mode: SelectPermanentEffect.Mode.Custom,
  80. cardEffect: activateClass);
  81. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  82. }
  83. IEnumerator SelectCantAttackPermanent(Permanent permanent)
  84. {
  85. bool DefenderCondition(Permanent Defender)
  86. {
  87. return Defender == null;
  88. }
  89. if (permanent != null)
  90. {
  91. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainCanNotAttack(
  92. targetPermanent: permanent,
  93. defenderCondition: DefenderCondition,
  94. effectDuration: EffectDuration.UntilOpponentTurnEnd,
  95. activateClass: activateClass,
  96. effectName: "Can't Attack Player"));
  97. }
  98. }
  99. }
  100. }
  101. #endregion
  102. #region Link
  103. if (timing == EffectTiming.OnDeclaration)
  104. {
  105. cardEffects.Add(CardEffectFactory.LinkEffect(card));
  106. }
  107. #endregion
  108. #region When Linking
  109. if (timing == EffectTiming.WhenLinked)
  110. {
  111. ActivateClass activateClass = new ActivateClass();
  112. activateClass.SetUpICardEffect("1 of your opponent's Digimon can't attack players until their turn ends", CanUseCondition, card);
  113. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  114. activateClass.SetIsLinkedEffect(true);
  115. cardEffects.Add(activateClass);
  116. string EffectDiscription()
  117. {
  118. return "[When Linking] Until your opponent's turn ends, 1 of their Digimon can't attack players.";
  119. }
  120. bool IsOpponentsDigimon(Permanent permanent)
  121. {
  122. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  123. }
  124. bool CanUseCondition(Hashtable hashtable)
  125. {
  126. return CardEffectCommons.CanTriggerWhenLinking(hashtable, null, card);
  127. }
  128. bool CanActivateCondition(Hashtable hashtable)
  129. {
  130. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  131. CardEffectCommons.HasMatchConditionOpponentsPermanent(card, IsOpponentsDigimon);
  132. }
  133. IEnumerator ActivateCoroutine(Hashtable hashtable)
  134. {
  135. if (CardEffectCommons.HasMatchConditionPermanent(IsOpponentsDigimon))
  136. {
  137. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(IsOpponentsDigimon));
  138. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  139. selectPermanentEffect.SetUp(
  140. selectPlayer: card.Owner,
  141. canTargetCondition: IsOpponentsDigimon,
  142. canTargetCondition_ByPreSelecetedList: null,
  143. canEndSelectCondition: null,
  144. maxCount: maxCount,
  145. canNoSelect: false,
  146. canEndNotMax: false,
  147. selectPermanentCoroutine: SelectCantAttackPermanent,
  148. afterSelectPermanentCoroutine: null,
  149. mode: SelectPermanentEffect.Mode.Custom,
  150. cardEffect: activateClass);
  151. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  152. }
  153. IEnumerator SelectCantAttackPermanent(Permanent permanent)
  154. {
  155. bool DefenderCondition(Permanent Defender)
  156. {
  157. return Defender == null;
  158. }
  159. if (permanent != null)
  160. {
  161. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainCanNotAttack(
  162. targetPermanent: permanent,
  163. defenderCondition: DefenderCondition,
  164. effectDuration: EffectDuration.UntilOpponentTurnEnd,
  165. activateClass: activateClass,
  166. effectName: "Can't Attack Player"));
  167. }
  168. }
  169. }
  170. }
  171. #endregion
  172. return cardEffects;
  173. }
  174. }
  175. }