BT7_025.cs 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using System.Linq;
  5. using Photon;
  6. using System;
  7. using Photon.Pun;
  8. public class BT7_025 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. if (timing == EffectTiming.None)
  14. {
  15. bool Condition()
  16. {
  17. return card.Owner.HandCards.Contains(card);
  18. }
  19. bool PermanentCondition(Permanent targetPermanent)
  20. {
  21. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(targetPermanent, card))
  22. {
  23. if (targetPermanent.DigivolutionCards.Count((cardSource) => cardSource.IsTamer) >= 1)
  24. {
  25. return true;
  26. }
  27. }
  28. return false;
  29. }
  30. bool CardSourceCondition(CardSource cardSource)
  31. {
  32. return cardSource == card && cardSource.Owner.HandCards.Contains(cardSource);
  33. }
  34. bool RootCondition(SelectCardEffect.Root root)
  35. {
  36. return root == SelectCardEffect.Root.Hand;
  37. }
  38. cardEffects.Add(CardEffectFactory.ChangeDigivolutionCostStaticEffect(
  39. changeValue: -2,
  40. permanentCondition: PermanentCondition,
  41. cardCondition: CardSourceCondition,
  42. rootCondition: RootCondition,
  43. isInheritedEffect: false,
  44. card: card,
  45. condition: Condition,
  46. setFixedCost: false));
  47. }
  48. if (timing == EffectTiming.OnAllyAttack)
  49. {
  50. ActivateClass activateClass = new ActivateClass();
  51. activateClass.SetUpICardEffect("Return 1 digivolution card and return 1 Digimon to hand", CanUseCondition, card);
  52. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  53. cardEffects.Add(activateClass);
  54. string EffectDiscription()
  55. {
  56. return "[When Attacking] You may return 1 card with [Hybrid] in its traits from this Digimon's digivolution cards to your hand to return 1 of your opponent's level 4 or lower Digimon to its owner's hand. Trash all of the digivolution cards of that Digimon.";
  57. }
  58. bool CanSelectCardCondition(CardSource cardSource)
  59. {
  60. return cardSource.CardTraits.Contains("Hybrid");
  61. }
  62. bool CanSelectPermanentCondition(Permanent permanent)
  63. {
  64. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  65. {
  66. if (permanent.Level <= 4)
  67. {
  68. if (permanent.TopCard.HasLevel)
  69. {
  70. return true;
  71. }
  72. }
  73. }
  74. return false;
  75. }
  76. bool CanUseCondition(Hashtable hashtable)
  77. {
  78. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  79. }
  80. bool CanActivateCondition(Hashtable hashtable)
  81. {
  82. if (CardEffectCommons.IsExistOnBattleArea(card))
  83. {
  84. if (card.PermanentOfThisCard().DigivolutionCards.Count(CanSelectCardCondition) >= 1)
  85. {
  86. return true;
  87. }
  88. }
  89. return false;
  90. }
  91. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  92. {
  93. Permanent selectedPermanent = card.PermanentOfThisCard();
  94. if (selectedPermanent.DigivolutionCards.Count(CanSelectCardCondition) >= 1)
  95. {
  96. int maxCount = Math.Min(1, selectedPermanent.DigivolutionCards.Count(CanSelectCardCondition));
  97. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  98. selectCardEffect.SetUp(
  99. canTargetCondition: CanSelectCardCondition,
  100. canTargetCondition_ByPreSelecetedList: null,
  101. canEndSelectCondition: null,
  102. canNoSelect: () => false,
  103. selectCardCoroutine: null,
  104. afterSelectCardCoroutine: null,
  105. message: "Select 1 card to add to your hand.",
  106. maxCount: maxCount,
  107. canEndNotMax: false,
  108. isShowOpponent: true,
  109. mode: SelectCardEffect.Mode.AddHand,
  110. root: SelectCardEffect.Root.Custom,
  111. customRootCardList: selectedPermanent.DigivolutionCards,
  112. canLookReverseCard: true,
  113. selectPlayer: card.Owner,
  114. cardEffect: activateClass);
  115. yield return StartCoroutine(selectCardEffect.Activate());
  116. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  117. {
  118. maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  119. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  120. selectPermanentEffect.SetUp(
  121. selectPlayer: card.Owner,
  122. canTargetCondition: CanSelectPermanentCondition,
  123. canTargetCondition_ByPreSelecetedList: null,
  124. canEndSelectCondition: null,
  125. maxCount: maxCount,
  126. canNoSelect: false,
  127. canEndNotMax: false,
  128. selectPermanentCoroutine: null,
  129. afterSelectPermanentCoroutine: null,
  130. mode: SelectPermanentEffect.Mode.Bounce,
  131. cardEffect: activateClass);
  132. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  133. }
  134. }
  135. }
  136. }
  137. return cardEffects;
  138. }
  139. }