BT19_089.cs 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System;
  5. namespace DCGO.CardEffects.BT19
  6. {
  7. public class BT19_089 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Ignore Color Requirements
  13. if (timing == EffectTiming.None)
  14. {
  15. IgnoreColorConditionClass ignoreColorConditionClass = new IgnoreColorConditionClass();
  16. ignoreColorConditionClass.SetUpICardEffect("Ignore color requirements", CanUseCondition, card);
  17. ignoreColorConditionClass.SetUpIgnoreColorConditionClass(cardCondition: CardCondition);
  18. cardEffects.Add(ignoreColorConditionClass);
  19. bool CanUseCondition(Hashtable hashtable)
  20. {
  21. return CardEffectCommons.HasMatchConditionOpponentsPermanent(card, (permanent) =>
  22. (permanent.IsDigimon || permanent.IsTamer) &&
  23. permanent.TopCard.CardColors.Contains(CardColor.White));
  24. }
  25. bool CardCondition(CardSource cardSource)
  26. {
  27. return (cardSource == card);
  28. }
  29. }
  30. #endregion
  31. #region Main
  32. if (timing == EffectTiming.OptionSkill)
  33. {
  34. ActivateClass activateClass = new ActivateClass();
  35. activateClass.SetUpICardEffect("This Digimon becomes immune to opponent's options, and can't be DP reduced", CanUseCondition, card);
  36. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDiscription());
  37. cardEffects.Add(activateClass);
  38. string EffectDiscription()
  39. {
  40. return "[Main] Until the end of your opponent's turn, 1 of your Digimon isn't affected by the effects of your opponent's Option cards and it can't have its DP reduced.";
  41. }
  42. bool CanSelectDigimonCondition(Permanent permanent)
  43. {
  44. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card);
  45. }
  46. bool CanUseCondition(Hashtable hashtable)
  47. {
  48. return CardEffectCommons.CanTriggerOptionMainEffect(hashtable, card);
  49. }
  50. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  51. {
  52. Permanent selectedPermanent = null;
  53. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectDigimonCondition))
  54. {
  55. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectDigimonCondition));
  56. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  57. selectPermanentEffect.SetUp(
  58. selectPlayer: card.Owner,
  59. canTargetCondition: CanSelectDigimonCondition,
  60. canTargetCondition_ByPreSelecetedList: null,
  61. canEndSelectCondition: null,
  62. maxCount: maxCount,
  63. canNoSelect: false,
  64. canEndNotMax: false,
  65. selectPermanentCoroutine: SelectPermanentCoroutine,
  66. afterSelectPermanentCoroutine: null,
  67. mode: SelectPermanentEffect.Mode.Custom,
  68. cardEffect: activateClass);
  69. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will gain effect.", "The opponent is selecting 1 Digimon that will gain effect.");
  70. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  71. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  72. {
  73. selectedPermanent = permanent;
  74. yield return null;
  75. }
  76. if (selectedPermanent != null)
  77. {
  78. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainImmuneFromDPMinus(
  79. targetPermanent: selectedPermanent,
  80. cardEffectCondition: SkillCondition,
  81. effectDuration: EffectDuration.UntilOpponentTurnEnd,
  82. activateClass: activateClass,
  83. effectName: "Can't have DP reduced"));
  84. CanNotAffectedClass canNotAffectedClass = new CanNotAffectedClass();
  85. canNotAffectedClass.SetUpICardEffect("Isn't affected by opponent's option effects", CanUseCondition1, card);
  86. canNotAffectedClass.SetUpCanNotAffectedClass(CardCondition: CardCondition, SkillCondition: SkillCondition);
  87. selectedPermanent.UntilOpponentTurnEndEffects.Add((_timing) => canNotAffectedClass);
  88. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().CreateBuffEffect(selectedPermanent));
  89. bool CanUseCondition1(Hashtable hashtable)
  90. {
  91. return CardEffectCommons.IsPermanentExistsOnBattleArea(selectedPermanent);
  92. }
  93. bool CardCondition(CardSource cardSource)
  94. {
  95. if (CardEffectCommons.IsPermanentExistsOnBattleArea(selectedPermanent))
  96. {
  97. if (cardSource == selectedPermanent.TopCard)
  98. {
  99. return true;
  100. }
  101. }
  102. return false;
  103. }
  104. bool SkillCondition(ICardEffect cardEffect)
  105. {
  106. if (cardEffect != null)
  107. {
  108. if (cardEffect.EffectSourceCard != null)
  109. {
  110. if (cardEffect.EffectSourceCard.Owner == card.Owner.Enemy)
  111. {
  112. if (!cardEffect.IsDigimonEffect && !cardEffect.IsTamerEffect)
  113. {
  114. return true;
  115. }
  116. }
  117. }
  118. }
  119. return false;
  120. }
  121. }
  122. }
  123. }
  124. }
  125. #endregion
  126. #region Security
  127. if (timing == EffectTiming.SecuritySkill)
  128. {
  129. ActivateClass activateClass = new ActivateClass();
  130. activateClass.SetUpICardEffect($"Add this card to hand", CanUseCondition, card);
  131. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDiscription());
  132. activateClass.SetIsSecurityEffect(true);
  133. cardEffects.Add(activateClass);
  134. string EffectDiscription()
  135. {
  136. return "[Security] Add this card to the hand.";
  137. }
  138. bool CanUseCondition(Hashtable hashtable)
  139. {
  140. return CardEffectCommons.CanTriggerSecurityEffect(hashtable, card);
  141. }
  142. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  143. {
  144. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.AddThisCardToHand(card, activateClass));
  145. }
  146. }
  147. #endregion
  148. return cardEffects;
  149. }
  150. }
  151. }