BT10_042.cs 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using System.Linq;
  5. using Photon;
  6. using System;
  7. using Photon.Pun;
  8. namespace DCGO.CardEffects.BT10
  9. {
  10. public class BT10_042 : CEntity_Effect
  11. {
  12. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  13. {
  14. List<ICardEffect> cardEffects = new List<ICardEffect>();
  15. if (timing == EffectTiming.OnEnterFieldAnyone)
  16. {
  17. ActivateClass activateClass = new ActivateClass();
  18. activateClass.SetUpICardEffect("Security Attack -1", CanUseCondition, card);
  19. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  20. cardEffects.Add(activateClass);
  21. string EffectDiscription()
  22. {
  23. return "[When Digivolving] All of your opponent's Digimon gain <Security Attack -1> until the end of your opponent's turn. (This Digimon checks 1 fewer security cards.)";
  24. }
  25. bool CanUseCondition(Hashtable hashtable)
  26. {
  27. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  28. }
  29. bool CanActivateCondition(Hashtable hashtable)
  30. {
  31. return CardEffectCommons.IsExistOnBattleArea(card);
  32. }
  33. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  34. {
  35. bool PermanentCondition(Permanent permanent)
  36. {
  37. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  38. }
  39. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonSAttackPlayerEffect(
  40. permanentCondition: PermanentCondition,
  41. changeValue: -1,
  42. effectDuration: EffectDuration.UntilOpponentTurnEnd,
  43. activateClass: activateClass));
  44. }
  45. }
  46. if (timing == EffectTiming.None)
  47. {
  48. bool AttackerCondition(Permanent permanent)
  49. {
  50. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  51. {
  52. if (permanent.HasSecurityAttackChanges)
  53. {
  54. return true;
  55. }
  56. }
  57. return false;
  58. }
  59. bool DefenderCondition(Permanent permanent)
  60. {
  61. return permanent == card.PermanentOfThisCard();
  62. }
  63. bool Condition()
  64. {
  65. if (CardEffectCommons.IsExistOnBattleArea(card))
  66. {
  67. if (CardEffectCommons.IsOpponentTurn(card))
  68. {
  69. return true;
  70. }
  71. }
  72. return false;
  73. }
  74. string effectName = "Opponent's Digimon that has <Security Attack> can't attack to this Digimon";
  75. cardEffects.Add(CardEffectFactory.CanNotAttackStaticEffect(
  76. attackerCondition: AttackerCondition,
  77. defenderCondition: DefenderCondition,
  78. isInheritedEffect: false,
  79. card: card,
  80. condition: Condition,
  81. effectName: effectName
  82. ));
  83. }
  84. if (timing == EffectTiming.None)
  85. {
  86. DisableEffectClass invalidationClass = new DisableEffectClass();
  87. invalidationClass.SetUpICardEffect("Ignore [When Attacking] and [When Digivolving] Effect of opponent's Digimon that has <Security Attack>", CanUseCondition, card);
  88. invalidationClass.SetUpDisableEffectClass(DisableCondition: InvalidateCondition);
  89. cardEffects.Add(invalidationClass);
  90. bool CanUseCondition(Hashtable hashtable)
  91. {
  92. return true;
  93. }
  94. bool InvalidateCondition(ICardEffect cardEffect)
  95. {
  96. if (CardEffectCommons.IsExistOnBattleArea(card))
  97. {
  98. if (CardEffectCommons.IsOpponentTurn(card))
  99. {
  100. if (cardEffect != null)
  101. {
  102. if (cardEffect is ActivateICardEffect)
  103. {
  104. if (cardEffect.EffectSourceCard != null)
  105. {
  106. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleArea(cardEffect.EffectSourceCard.PermanentOfThisCard(), card))
  107. {
  108. if (cardEffect.EffectSourceCard.PermanentOfThisCard().HasSecurityAttackChanges)
  109. {
  110. if (!cardEffect.EffectSourceCard.PermanentOfThisCard().TopCard.CanNotBeAffected(invalidationClass))
  111. {
  112. if (cardEffect.IsWhenDigivolving)
  113. {
  114. return true;
  115. }
  116. if (cardEffect.IsOnAttack)
  117. {
  118. return true;
  119. }
  120. }
  121. }
  122. }
  123. }
  124. }
  125. }
  126. }
  127. }
  128. return false;
  129. }
  130. }
  131. return cardEffects;
  132. }
  133. }
  134. }