EX2_016.cs 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.EX2
  6. {
  7. public class EX2_016 : 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("Play 1 digivolution card", CanUseCondition, card);
  16. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  17. cardEffects.Add(activateClass);
  18. string EffectDiscription()
  19. {
  20. return "[On Play] You may play 1 level 3 Digimon card from 1 of your blue Digimon's digivolution cards without paying its memory cost.";
  21. }
  22. bool CanSelectPermanentCondition(Permanent permanent)
  23. {
  24. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  25. {
  26. if (permanent.DigivolutionCards.Count(CanSelectCardCondition) >= 1)
  27. {
  28. if (permanent.TopCard.CardColors.Contains(CardColor.Blue))
  29. {
  30. return true;
  31. }
  32. }
  33. }
  34. return false;
  35. }
  36. bool CanSelectCardCondition(CardSource cardSource)
  37. {
  38. if (cardSource != null)
  39. {
  40. if (cardSource.IsDigimon)
  41. {
  42. if (cardSource.Owner == card.Owner)
  43. {
  44. if (cardSource.Level == 3)
  45. {
  46. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  47. {
  48. if (cardSource.HasLevel)
  49. {
  50. return true;
  51. }
  52. }
  53. }
  54. }
  55. }
  56. }
  57. return false;
  58. }
  59. bool CanUseCondition(Hashtable hashtable)
  60. {
  61. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  62. }
  63. bool CanActivateCondition(Hashtable hashtable)
  64. {
  65. if (CardEffectCommons.IsExistOnBattleArea(card))
  66. {
  67. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  68. {
  69. return true;
  70. }
  71. }
  72. return false;
  73. }
  74. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  75. {
  76. if (isExistOnField(card))
  77. {
  78. if (card.Owner.GetBattleAreaDigimons().Contains(card.PermanentOfThisCard()))
  79. {
  80. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  81. {
  82. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  83. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  84. selectPermanentEffect.SetUp(
  85. selectPlayer: card.Owner,
  86. canTargetCondition: CanSelectPermanentCondition,
  87. canTargetCondition_ByPreSelecetedList: null,
  88. canEndSelectCondition: null,
  89. maxCount: maxCount,
  90. canNoSelect: true,
  91. canEndNotMax: false,
  92. selectPermanentCoroutine: SelectPermanentCoroutine,
  93. afterSelectPermanentCoroutine: null,
  94. mode: SelectPermanentEffect.Mode.Custom,
  95. cardEffect: activateClass);
  96. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon which has digivolution cards.", "The opponent is selecting 1 Digimon which has digivolution cards.");
  97. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  98. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  99. {
  100. Permanent selectedPermanent = permanent;
  101. if (selectedPermanent != null)
  102. {
  103. if (selectedPermanent.DigivolutionCards.Count(CanSelectCardCondition) >= 1)
  104. {
  105. maxCount = Math.Min(1, selectedPermanent.DigivolutionCards.Count(CanSelectCardCondition));
  106. List<CardSource> selectedCards = new List<CardSource>();
  107. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  108. selectCardEffect.SetUp(
  109. canTargetCondition: CanSelectCardCondition,
  110. canTargetCondition_ByPreSelecetedList: null,
  111. canEndSelectCondition: null,
  112. canNoSelect: () => true,
  113. selectCardCoroutine: SelectCardCoroutine,
  114. afterSelectCardCoroutine: null,
  115. message: "Select 1 digivolution card to play.",
  116. maxCount: maxCount,
  117. canEndNotMax: false,
  118. isShowOpponent: true,
  119. mode: SelectCardEffect.Mode.Custom,
  120. root: SelectCardEffect.Root.Custom,
  121. customRootCardList: selectedPermanent.DigivolutionCards,
  122. canLookReverseCard: true,
  123. selectPlayer: card.Owner,
  124. cardEffect: activateClass);
  125. selectCardEffect.SetUpCustomMessage("Select 1 digivolution card to play.", "The opponent is selecting 1 digivolution card to play.");
  126. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  127. yield return StartCoroutine(selectCardEffect.Activate());
  128. IEnumerator SelectCardCoroutine(CardSource cardSource)
  129. {
  130. selectedCards.Add(cardSource);
  131. yield return null;
  132. }
  133. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  134. cardSources: selectedCards,
  135. activateClass: activateClass,
  136. payCost: false,
  137. isTapped: false,
  138. root: SelectCardEffect.Root.DigivolutionCards,
  139. activateETB: true));
  140. }
  141. }
  142. }
  143. }
  144. }
  145. }
  146. }
  147. }
  148. return cardEffects;
  149. }
  150. }
  151. }