EX1_022.cs 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.EX1
  6. {
  7. public class EX1_022 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. if (timing == EffectTiming.OnEnterFieldAnyone)
  13. {
  14. ActivateClass activateClass = new ActivateClass();
  15. activateClass.SetUpICardEffect("Unsuspend this Digimon and suspend 1 Digimon", CanUseCondition, card);
  16. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  17. cardEffects.Add(activateClass);
  18. string EffectDiscription()
  19. {
  20. return "[When Digivolving] If a Digimon card with [Free] in its traits is in this Digimon's digivolution cards, unsuspend this Digimon and suspend 1 of your opponent's Digimon.";
  21. }
  22. bool CanSelectPermanentCondition(Permanent permanent)
  23. {
  24. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  25. }
  26. bool CanUseCondition(Hashtable hashtable)
  27. {
  28. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  29. }
  30. bool CanActivateCondition(Hashtable hashtable)
  31. {
  32. if (CardEffectCommons.IsExistOnBattleArea(card))
  33. {
  34. if (card.PermanentOfThisCard().DigivolutionCards.Count((cardSource) => cardSource.IsDigimon && cardSource.CardTraits.Contains("Free")) >= 1)
  35. {
  36. return true;
  37. }
  38. }
  39. return false;
  40. }
  41. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  42. {
  43. if (isExistOnField(card))
  44. {
  45. if (card.Owner.GetBattleAreaDigimons().Contains(card.PermanentOfThisCard()))
  46. {
  47. Permanent selectedPermanent = card.PermanentOfThisCard();
  48. yield return ContinuousController.instance.StartCoroutine(new IUnsuspendPermanents(new List<Permanent>() { selectedPermanent }, activateClass).Unsuspend());
  49. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  50. {
  51. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  52. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  53. selectPermanentEffect.SetUp(
  54. selectPlayer: card.Owner,
  55. canTargetCondition: CanSelectPermanentCondition,
  56. canTargetCondition_ByPreSelecetedList: null,
  57. canEndSelectCondition: null,
  58. maxCount: maxCount,
  59. canNoSelect: false,
  60. canEndNotMax: false,
  61. selectPermanentCoroutine: null,
  62. afterSelectPermanentCoroutine: null,
  63. mode: SelectPermanentEffect.Mode.Tap,
  64. cardEffect: activateClass);
  65. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  66. }
  67. }
  68. }
  69. }
  70. }
  71. if (timing == EffectTiming.None)
  72. {
  73. int count()
  74. {
  75. if (CardEffectCommons.IsExistOnBattleArea(card))
  76. {
  77. return card.PermanentOfThisCard().DigivolutionCardsColors.Count;
  78. }
  79. return 0;
  80. }
  81. bool Condition()
  82. {
  83. if (CardEffectCommons.IsExistOnBattleArea(card))
  84. {
  85. if (CardEffectCommons.IsOwnerTurn(card))
  86. {
  87. if (count() >= 1)
  88. {
  89. return true;
  90. }
  91. }
  92. }
  93. return false;
  94. }
  95. cardEffects.Add(CardEffectFactory.ChangeSelfDPStaticEffect<Func<int>>(changeValue: () => 1000 * count(), isInheritedEffect: false, card: card, condition: Condition));
  96. }
  97. return cardEffects;
  98. }
  99. }
  100. }