BT20_037.cs 8.9 KB

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