BT20_037.cs 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System;
  5. using UnityEngine;
  6. namespace DCGO.CardEffects.BT20
  7. {
  8. public class BT20_037 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region DNA
  14. if (timing == EffectTiming.None)
  15. {
  16. AddJogressConditionClass addJogressConditionClass = new AddJogressConditionClass();
  17. addJogressConditionClass.SetUpICardEffect($"DNA Digivolution", CanUseCondition, card);
  18. addJogressConditionClass.SetUpAddJogressConditionClass(getJogressCondition: GetJogress);
  19. addJogressConditionClass.SetNotShowUI(true);
  20. cardEffects.Add(addJogressConditionClass);
  21. bool CanUseCondition(Hashtable hashtable)
  22. {
  23. return true;
  24. }
  25. JogressCondition GetJogress(CardSource cardSource)
  26. {
  27. if (cardSource == card)
  28. {
  29. bool PermanentCondition1(Permanent permanent) => permanent.TopCard.CardColors.Contains(CardColor.Yellow) && permanent.Levels_ForJogress(card).Contains(6);
  30. bool PermanentCondition2(Permanent permanent) => (permanent.TopCard.CardColors.Contains(CardColor.Green) || permanent.TopCard.CardColors.Contains(CardColor.Black)) && permanent.Levels_ForJogress(card).Contains(6);
  31. JogressConditionElement[] elements = new JogressConditionElement[]
  32. {
  33. new JogressConditionElement(PermanentCondition1, "a level 6 yellow Digimon"),
  34. new JogressConditionElement(PermanentCondition2, "a level 6 green/black Digimon"),
  35. };
  36. JogressCondition jogressCondition = new JogressCondition(elements, 0);
  37. return jogressCondition;
  38. }
  39. return null;
  40. }
  41. }
  42. #endregion
  43. #region Partition
  44. if (timing == EffectTiming.WhenRemoveField)
  45. {
  46. List<PartitionCondition> partitionConditions = new List<PartitionCondition>();
  47. partitionConditions.Add(new PartitionCondition(6, CardColor.Yellow));
  48. partitionConditions.Add(new PartitionCondition(6, CardColor.Green, CardColor.Black));
  49. cardEffects.Add(CardEffectFactory.PartitionSelfEffect(
  50. isInheritedEffect: false,
  51. card: card,
  52. condition: null,
  53. cardSourceConditions: partitionConditions));
  54. }
  55. #endregion
  56. #region Security Attack +1
  57. if (timing == EffectTiming.None)
  58. {
  59. cardEffects.Add(CardEffectFactory.ChangeSelfSAttackStaticEffect(changeValue: 1, isInheritedEffect: false, card: card, condition: null));
  60. }
  61. #endregion
  62. #region When Digivolving
  63. if (timing == EffectTiming.OnEnterFieldAnyone)
  64. {
  65. ActivateClass activateClass = new ActivateClass();
  66. activateClass.SetUpICardEffect("For each level 6 in sources, suspend 1 Digimon and memory +1, Then Opponent's Digimon/Tamers can't activate [On Play] or unsuspend", CanUseCondition, card);
  67. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  68. cardEffects.Add(activateClass);
  69. string EffectDiscription()
  70. {
  71. return "[When Digivolving] For each of this Digimon's level 6 digivolution cards, suspend 1 of your opponent's Digimon or Tamers and gain 1 memory. Then, none of their Digimon or Tamers can activate [On Play] effects or unsuspend until the end of their turn.";
  72. }
  73. bool IsLevel6(CardSource source)
  74. {
  75. return source.HasLevel && source.IsLevel6 && !source.IsFlipped;
  76. }
  77. bool OpponentsDigimonOrTamer(Permanent permanent)
  78. {
  79. return CardEffectCommons.IsPermanentExistsOnOpponentBattleArea(permanent, card) &&
  80. (permanent.IsDigimon || permanent.IsTamer);
  81. }
  82. bool CanUseCondition(Hashtable hashtable)
  83. {
  84. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  85. CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  86. }
  87. bool CanActivateCondition(Hashtable hashtable)
  88. {
  89. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  90. }
  91. IEnumerator ActivateCoroutine(Hashtable hashtable)
  92. {
  93. if(card.PermanentOfThisCard().DigivolutionCards.Count(IsLevel6) > 0)
  94. {
  95. int maxCount = Mathf.Min(CardEffectCommons.MatchConditionPermanentCount(OpponentsDigimonOrTamer), card.PermanentOfThisCard().DigivolutionCards.Count(IsLevel6));
  96. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  97. selectPermanentEffect.SetUp(
  98. selectPlayer: card.Owner,
  99. canTargetCondition: OpponentsDigimonOrTamer,
  100. canTargetCondition_ByPreSelecetedList: null,
  101. canEndSelectCondition: null,
  102. maxCount: maxCount,
  103. canNoSelect: false,
  104. canEndNotMax: false,
  105. selectPermanentCoroutine: null,
  106. afterSelectPermanentCoroutine: null,
  107. mode: SelectPermanentEffect.Mode.Tap,
  108. cardEffect: activateClass);
  109. selectPermanentEffect.SetUpCustomMessage($"Select {maxCount} Digimon/Tamers to suspend.", $"The opponent is selecting {maxCount} Digimon/Tamers to suspend.");
  110. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  111. if (card.Owner.CanAddMemory(activateClass))
  112. yield return ContinuousController.instance.StartCoroutine(card.Owner.AddMemory(card.PermanentOfThisCard().DigivolutionCards.Count(IsLevel6), activateClass));
  113. }
  114. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainCanNotUnsuspendPlayerEffect(
  115. permanentCondition: OpponentsDigimonOrTamer,
  116. effectDuration: EffectDuration.UntilOpponentTurnEnd,
  117. activateClass: activateClass,
  118. isOnlyActivePhase: false,
  119. effectName: "Your card can't unsuspend"));
  120. DisableEffectClass invalidationClass = new DisableEffectClass();
  121. invalidationClass.SetUpICardEffect("Ignore [On Play] Effect of opponent's Digimon/Tamers", CanUseCondition, card);
  122. invalidationClass.SetUpDisableEffectClass(DisableCondition: InvalidateCondition);
  123. card.Owner.UntilOpponentTurnEndEffects.Add((_timing) => invalidationClass);
  124. bool CanUseCondition(Hashtable hashtable)
  125. {
  126. return true;
  127. }
  128. bool InvalidateCondition(ICardEffect cardEffect)
  129. {
  130. if (cardEffect != null)
  131. {
  132. if (cardEffect is ActivateICardEffect)
  133. {
  134. if (cardEffect.EffectSourceCard != null)
  135. {
  136. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleArea(cardEffect.EffectSourceCard.PermanentOfThisCard(), card))
  137. {
  138. if (cardEffect.EffectSourceCard.PermanentOfThisCard().IsTamer || cardEffect.EffectSourceCard.PermanentOfThisCard().IsDigimon)
  139. {
  140. if (!cardEffect.EffectSourceCard.PermanentOfThisCard().TopCard.CanNotBeAffected(invalidationClass))
  141. {
  142. if (cardEffect.IsOnPlay)
  143. {
  144. return true;
  145. }
  146. }
  147. }
  148. }
  149. }
  150. }
  151. }
  152. return false;
  153. }
  154. }
  155. }
  156. #endregion
  157. return cardEffects;
  158. }
  159. }
  160. }