EX1_041.cs 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  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_041 : 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("Suspend 1 Digimon with 5000 DP or less", 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, suspend 1 of your opponent's Digimon with 5000 DP or less.";
  21. }
  22. bool CanSelectPermanentCondition(Permanent permanent)
  23. {
  24. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  25. {
  26. if (permanent.DP <= 5000)
  27. {
  28. return true;
  29. }
  30. }
  31. return false;
  32. }
  33. bool CanUseCondition(Hashtable hashtable)
  34. {
  35. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  36. }
  37. bool CanActivateCondition(Hashtable hashtable)
  38. {
  39. if (CardEffectCommons.IsExistOnBattleArea(card))
  40. {
  41. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  42. {
  43. if (card.PermanentOfThisCard().DigivolutionCards.Count((cardSource) => cardSource.IsDigimon && cardSource.CardTraits.Contains("Free")) >= 1)
  44. {
  45. return true;
  46. }
  47. }
  48. }
  49. return false;
  50. }
  51. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  52. {
  53. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  54. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  55. selectPermanentEffect.SetUp(
  56. selectPlayer: card.Owner,
  57. canTargetCondition: CanSelectPermanentCondition,
  58. canTargetCondition_ByPreSelecetedList: null,
  59. canEndSelectCondition: null,
  60. maxCount: maxCount,
  61. canNoSelect: false,
  62. canEndNotMax: false,
  63. selectPermanentCoroutine: null,
  64. afterSelectPermanentCoroutine: null,
  65. mode: SelectPermanentEffect.Mode.Tap,
  66. cardEffect: activateClass);
  67. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  68. }
  69. }
  70. if (timing == EffectTiming.OnEndBattle)
  71. {
  72. ActivateClass activateClass = new ActivateClass();
  73. activateClass.SetUpICardEffect("Memory +1", CanUseCondition, card);
  74. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  75. activateClass.SetIsInheritedEffect(true);
  76. cardEffects.Add(activateClass);
  77. string EffectDiscription()
  78. {
  79. return "[Your Turn] When one of your Digimon with [Imperialdramon] in its name deletes an opponent's Digimon in battle and survives, gain 1 memory.";
  80. }
  81. bool PermanentCondition(Permanent permanent)
  82. {
  83. if (permanent.TopCard.Owner == card.Owner)
  84. {
  85. if (permanent.TopCard.ContainsCardName("Imperialdramon"))
  86. {
  87. return true;
  88. }
  89. }
  90. return false;
  91. }
  92. bool CanUseCondition(Hashtable hashtable)
  93. {
  94. if (CardEffectCommons.IsExistOnBattleArea(card))
  95. {
  96. if (CardEffectCommons.IsOwnerTurn(card))
  97. {
  98. bool WinnerCondition(Permanent permanent) => PermanentCondition(permanent);
  99. bool LoserCondition(Permanent permanent) => CardEffectCommons.IsOpponentPermanent(permanent, card);
  100. if (CardEffectCommons.CanTriggerWhenDeleteOpponentDigimonByBattle(hashtable: hashtable, winnerCondition: WinnerCondition, loserCondition: LoserCondition, isOnlyWinnerSurvive: true))
  101. {
  102. return true;
  103. }
  104. }
  105. }
  106. return false;
  107. }
  108. bool CanActivateCondition(Hashtable hashtable)
  109. {
  110. if (CardEffectCommons.IsExistOnBattleArea(card))
  111. {
  112. if (card.Owner.CanAddMemory(activateClass))
  113. {
  114. return true;
  115. }
  116. }
  117. return false;
  118. }
  119. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  120. {
  121. yield return ContinuousController.instance.StartCoroutine(card.Owner.AddMemory(1, activateClass));
  122. }
  123. }
  124. return cardEffects;
  125. }
  126. }
  127. }