EX4_046.cs 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. namespace DCGO.CardEffects.EX4
  5. {
  6. public class EX4_046 : CEntity_Effect
  7. {
  8. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  9. {
  10. List<ICardEffect> cardEffects = new List<ICardEffect>();
  11. if (timing == EffectTiming.None)
  12. {
  13. cardEffects.Add(CardEffectFactory.BlockerSelfStaticEffect(isInheritedEffect: false, card: card, condition: null));
  14. }
  15. if (timing == EffectTiming.OnEnterFieldAnyone)
  16. {
  17. ActivateClass activateClass = new ActivateClass();
  18. activateClass.SetUpICardEffect("Your 1 Digimon can digivolve to 1 level 6 or lower Digimon card with [Greymon] in its name from hand", CanUseCondition, card);
  19. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  20. cardEffects.Add(activateClass);
  21. string EffectDiscription()
  22. {
  23. return "[When Digivolving] 1 of your other Digimon may digivolve into a level 6 or lower Digimon card with [Greymon] in its name in your hand for the digivolution cost. When that Digimon would digivolve by this effect, reduce the digivolution cost by 2.";
  24. }
  25. bool CanSelectPermanentCondition(Permanent permanent)
  26. {
  27. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  28. {
  29. if (permanent != card.PermanentOfThisCard())
  30. {
  31. foreach (CardSource cardSource in card.Owner.HandCards)
  32. {
  33. if (CanSelectCardCondition(cardSource))
  34. {
  35. if (cardSource.CanPlayCardTargetFrame(permanent.PermanentFrame, false, activateClass))
  36. {
  37. return true;
  38. }
  39. }
  40. }
  41. }
  42. }
  43. return false;
  44. }
  45. bool CanSelectCardCondition(CardSource cardSource)
  46. {
  47. return cardSource.IsDigimon && cardSource.HasGreymonName && cardSource.Level <= 6 && cardSource.HasLevel;
  48. }
  49. bool CanUseCondition(Hashtable hashtable)
  50. {
  51. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  52. }
  53. bool CanActivateCondition(Hashtable hashtable)
  54. {
  55. if (CardEffectCommons.IsExistOnBattleArea(card))
  56. {
  57. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  58. {
  59. if (card.Owner.HandCards.Count >= 1)
  60. {
  61. return true;
  62. }
  63. }
  64. }
  65. return false;
  66. }
  67. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  68. {
  69. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  70. {
  71. Permanent selectedPermanent = null;
  72. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  73. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  74. selectPermanentEffect.SetUp(
  75. selectPlayer: card.Owner,
  76. canTargetCondition: CanSelectPermanentCondition,
  77. canTargetCondition_ByPreSelecetedList: null,
  78. canEndSelectCondition: null,
  79. maxCount: maxCount,
  80. canNoSelect: true,
  81. canEndNotMax: false,
  82. selectPermanentCoroutine: SelectPermanentCoroutine,
  83. afterSelectPermanentCoroutine: null,
  84. mode: SelectPermanentEffect.Mode.Custom,
  85. cardEffect: activateClass);
  86. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will digivolve.", "The opponent is selecting 1 Digimon that will digivolve.");
  87. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  88. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  89. {
  90. selectedPermanent = permanent;
  91. yield return null;
  92. }
  93. if (selectedPermanent != null)
  94. {
  95. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DigivolveIntoHandOrTrashCard(
  96. targetPermanent: selectedPermanent,
  97. cardCondition: CanSelectCardCondition,
  98. payCost: true,
  99. reduceCostTuple: (reduceCost: 2, reduceCostCardCondition: null),
  100. fixedCostTuple: null,
  101. ignoreDigivolutionRequirementFixedCost: -1,
  102. isHand: true,
  103. activateClass: activateClass,
  104. successProcess: null));
  105. }
  106. }
  107. }
  108. }
  109. if (timing == EffectTiming.None)
  110. {
  111. cardEffects.Add(CardEffectFactory.BlockerSelfStaticEffect(isInheritedEffect: true, card: card, condition: null));
  112. }
  113. return cardEffects;
  114. }
  115. }
  116. }