SuperDigivolutionPlugIn_EX2_070.cs 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  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 SuperDigivolutionPlugIn_EX2_070 : 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. IgnoreColorConditionClass ignoreColorConditionClass = new IgnoreColorConditionClass();
  16. ignoreColorConditionClass.SetUpICardEffect("Ignore color requirements", CanUseCondition, card);
  17. ignoreColorConditionClass.SetUpIgnoreColorConditionClass(cardCondition: CardCondition);
  18. cardEffects.Add(ignoreColorConditionClass);
  19. bool CanUseCondition(Hashtable hashtable)
  20. {
  21. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, (permanent) => permanent.IsTamer))
  22. {
  23. return true;
  24. }
  25. return false;
  26. }
  27. bool CardCondition(CardSource cardSource)
  28. {
  29. if (cardSource == card)
  30. {
  31. return true;
  32. }
  33. return false;
  34. }
  35. }
  36. if (timing == EffectTiming.OptionSkill)
  37. {
  38. ActivateClass activateClass = new ActivateClass();
  39. activateClass.SetUpICardEffect(card.BaseENGCardNameFromEntity, CanUseCondition, card);
  40. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDiscription());
  41. cardEffects.Add(activateClass);
  42. string EffectDiscription()
  43. {
  44. return "[Main] <Draw 1>. (Draw 1 card from your deck.) Then, you may digivolve 1 of your Digimon into a Digimon card in your hand that can digivolve for a digivolution cost of 3 or less without paying its digivolution cost.";
  45. }
  46. bool CanSelectPermanentCondition(Permanent permanent)
  47. {
  48. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  49. {
  50. foreach (CardSource cardSource in card.Owner.HandCards)
  51. {
  52. if (CanSelectCardCondition(cardSource, permanent))
  53. {
  54. if (cardSource.CanPlayCardTargetFrame(permanent.PermanentFrame, false, activateClass))
  55. {
  56. return true;
  57. }
  58. }
  59. }
  60. }
  61. return false;
  62. }
  63. bool CanSelectCardCondition(CardSource cardSource, Permanent permanent)
  64. {
  65. return cardSource.IsDigimon && cardSource.PayingCost(SelectCardEffect.Root.Hand, new List<Permanent>() { permanent }, checkAvailability: false) <= 3;
  66. }
  67. bool CanUseCondition(Hashtable hashtable)
  68. {
  69. return CardEffectCommons.CanTriggerOptionMainEffect(hashtable, card);
  70. }
  71. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  72. {
  73. yield return ContinuousController.instance.StartCoroutine(new DrawClass(card.Owner, 1, activateClass).Draw());
  74. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  75. {
  76. Permanent selectedPermanent = null;
  77. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  78. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  79. selectPermanentEffect.SetUp(
  80. selectPlayer: card.Owner,
  81. canTargetCondition: CanSelectPermanentCondition,
  82. canTargetCondition_ByPreSelecetedList: null,
  83. canEndSelectCondition: null,
  84. maxCount: maxCount,
  85. canNoSelect: true,
  86. canEndNotMax: false,
  87. selectPermanentCoroutine: SelectPermanentCoroutine,
  88. afterSelectPermanentCoroutine: null,
  89. mode: SelectPermanentEffect.Mode.Custom,
  90. cardEffect: activateClass);
  91. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to digivolve.", "The opponent is selecting 1 Digimon to digivolve.");
  92. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  93. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  94. {
  95. selectedPermanent = permanent;
  96. yield return null;
  97. }
  98. if (selectedPermanent != null)
  99. {
  100. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DigivolveIntoHandOrTrashCard(
  101. targetPermanent: selectedPermanent,
  102. cardCondition: (cardSource) => CanSelectCardCondition(cardSource, selectedPermanent),
  103. payCost: false,
  104. reduceCostTuple: null,
  105. fixedCostTuple: null,
  106. ignoreDigivolutionRequirementFixedCost: -1,
  107. isHand: true,
  108. activateClass: activateClass,
  109. successProcess: null));
  110. }
  111. }
  112. }
  113. }
  114. if (timing == EffectTiming.SecuritySkill)
  115. {
  116. ActivateClass activateClass = new ActivateClass();
  117. activateClass.SetUpICardEffect($"Reveal the top 3 cards of deck and add this card to hand", CanUseCondition, card);
  118. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDiscription());
  119. activateClass.SetIsSecurityEffect(true);
  120. cardEffects.Add(activateClass);
  121. string EffectDiscription()
  122. {
  123. return "[Security] Reveal the top 3 cards of your deck. Add 1 Digimon card among them to your hand. Place the remaining cards at the bottom of your deck in any order. Then, add this card to your hand.";
  124. }
  125. bool CanSelectCardCondition(CardSource cardSource)
  126. {
  127. return cardSource.IsDigimon;
  128. }
  129. bool CanUseCondition(Hashtable hashtable)
  130. {
  131. return CardEffectCommons.CanTriggerSecurityEffect(hashtable, card);
  132. }
  133. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  134. {
  135. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.SimplifiedRevealDeckTopCardsAndSelect(
  136. revealCount: 3,
  137. simplifiedSelectCardConditions:
  138. new SimplifiedSelectCardConditionClass[]
  139. {
  140. new SimplifiedSelectCardConditionClass(
  141. canTargetCondition:CanSelectCardCondition,
  142. message: "Select 1 Digimon card.",
  143. mode: SelectCardEffect.Mode.AddHand,
  144. maxCount: 1,
  145. selectCardCoroutine: null),
  146. },
  147. remainingCardsPlace: RemainingCardsPlace.DeckBottom,
  148. activateClass: activateClass
  149. ));
  150. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.AddThisCardToHand(card, activateClass));
  151. }
  152. }
  153. return cardEffects;
  154. }
  155. }