EX7_065.cs 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. namespace DCGO.CardEffects.EX7
  5. {
  6. public class EX7_065 : CEntity_Effect
  7. {
  8. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  9. {
  10. List<ICardEffect> cardEffects = new List<ICardEffect>();
  11. #region Security Effect
  12. if (timing == EffectTiming.SecuritySkill)
  13. {
  14. cardEffects.Add(CardEffectFactory.PlaySelfTamerSecurityEffect(card));
  15. }
  16. #endregion
  17. #region Start of Your Main Phase
  18. if (timing == EffectTiming.OnStartMainPhase)
  19. {
  20. ActivateClass activateClass = new ActivateClass();
  21. activateClass.SetUpICardEffect("Memory +1", CanUseCondition, card);
  22. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription());
  23. cardEffects.Add(activateClass);
  24. string EffectDescription()
  25. {
  26. return "[Start of Your Main Phase] If your opponent has a Digimon, gain 1 memory.";
  27. }
  28. bool CanUseCondition(Hashtable hashtable)
  29. {
  30. if (CardEffectCommons.IsExistOnBattleArea(card))
  31. {
  32. if (CardEffectCommons.IsOwnerTurn(card))
  33. {
  34. return true;
  35. }
  36. }
  37. return false;
  38. }
  39. bool CanActivateCondition(Hashtable hashtable)
  40. {
  41. if (CardEffectCommons.IsExistOnBattleArea(card))
  42. {
  43. if (card.Owner.Enemy.GetBattleAreaDigimons().Count >= 1)
  44. {
  45. if (card.Owner.CanAddMemory(activateClass))
  46. {
  47. return true;
  48. }
  49. }
  50. }
  51. return false;
  52. }
  53. IEnumerator ActivateCoroutine(Hashtable hashtable)
  54. {
  55. yield return ContinuousController.instance.StartCoroutine(card.Owner.AddMemory(1, activateClass));
  56. }
  57. }
  58. #endregion
  59. #region Main
  60. if(timing == EffectTiming.OnDeclaration)
  61. {
  62. ActivateClass activateClass = new ActivateClass();
  63. activateClass.SetUpICardEffect("Digivolve into [Dark Dragon]/[Evil Dragon] trait trash card", CanUseCondition, card);
  64. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDiscription());
  65. cardEffects.Add(activateClass);
  66. string EffectDiscription()
  67. {
  68. return "[Main] If you have 4 or fewer cards in your hand, by suspending this Tamer, 1 of your Digimon may digivolve into a Digimon card with the [Dark Dragon]/[Evil Dragon] trait in the trash.";
  69. }
  70. bool CanSelectPermanentCondition(Permanent permanent)
  71. {
  72. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  73. {
  74. foreach (CardSource cardSource in card.Owner.TrashCards)
  75. {
  76. if (CanSelectCardCondition(cardSource))
  77. {
  78. if (cardSource.CanPlayCardTargetFrame(permanent.PermanentFrame, true, activateClass))
  79. {
  80. return true;
  81. }
  82. }
  83. }
  84. }
  85. return false;
  86. }
  87. bool CanSelectCardCondition(CardSource cardSource)
  88. {
  89. if (cardSource.IsDigimon)
  90. {
  91. if (cardSource.ContainsTraits("Dark Dragon") || cardSource.ContainsTraits("Evil Dragon"))
  92. {
  93. return true;
  94. }
  95. }
  96. return false;
  97. }
  98. bool CanUseCondition(Hashtable hashtable)
  99. {
  100. if (isExistOnField(card))
  101. {
  102. if (card.Owner.HandCards.Count <= 4)
  103. {
  104. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  105. {
  106. if (CardEffectCommons.CanActivateSuspendCostEffect(card))
  107. {
  108. return true;
  109. }
  110. }
  111. }
  112. }
  113. return false;
  114. }
  115. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  116. {
  117. yield return ContinuousController.instance.StartCoroutine(new SuspendPermanentsClass(new List<Permanent>() { card.PermanentOfThisCard() }, CardEffectCommons.CardEffectHashtable(activateClass)).Tap());
  118. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  119. {
  120. Permanent selectedPermanent = null;
  121. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  122. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  123. selectPermanentEffect.SetUp(
  124. selectPlayer: card.Owner,
  125. canTargetCondition: CanSelectPermanentCondition,
  126. canTargetCondition_ByPreSelecetedList: null,
  127. canEndSelectCondition: null,
  128. maxCount: maxCount,
  129. canNoSelect: true,
  130. canEndNotMax: false,
  131. selectPermanentCoroutine: SelectPermanentCoroutine,
  132. afterSelectPermanentCoroutine: null,
  133. mode: SelectPermanentEffect.Mode.Custom,
  134. cardEffect: activateClass);
  135. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to digivolve.", "The opponent is selecting 1 Digimon to digivolve.");
  136. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  137. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  138. {
  139. selectedPermanent = permanent;
  140. yield return null;
  141. }
  142. if (selectedPermanent != null)
  143. {
  144. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DigivolveIntoHandOrTrashCard(
  145. targetPermanent: selectedPermanent,
  146. cardCondition: CanSelectCardCondition,
  147. payCost: true,
  148. reduceCostTuple: null,
  149. fixedCostTuple: null,
  150. ignoreDigivolutionRequirementFixedCost: -1,
  151. isHand: false,
  152. activateClass: activateClass,
  153. successProcess: null));
  154. }
  155. }
  156. }
  157. }
  158. #endregion
  159. return cardEffects;
  160. }
  161. }
  162. }