P_168.cs 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. namespace DCGO.CardEffects.P
  5. {
  6. public class P_168 : CEntity_Effect
  7. {
  8. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  9. {
  10. List<ICardEffect> cardEffects = new List<ICardEffect>();
  11. #region Start of Your Main Phase
  12. if (timing == EffectTiming.OnStartMainPhase)
  13. {
  14. ActivateClass activateClass = new ActivateClass();
  15. activateClass.SetUpICardEffect("Memory +1", CanUseCondition, card);
  16. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription());
  17. cardEffects.Add(activateClass);
  18. string EffectDescription()
  19. {
  20. return "[Start of Your Main Phase] If your opponent has a Digimon, gain 1 memory.";
  21. }
  22. bool CanUseCondition(Hashtable hashtable)
  23. {
  24. return CardEffectCommons.IsExistOnBattleArea(card) &&
  25. CardEffectCommons.IsOwnerTurn(card);
  26. }
  27. bool CanActivateCondition(Hashtable hashtable)
  28. {
  29. return CardEffectCommons.IsExistOnBattleArea(card) &&
  30. card.Owner.Enemy.GetBattleAreaDigimons().Count >= 1 &&
  31. card.Owner.CanAddMemory(activateClass);
  32. }
  33. IEnumerator ActivateCoroutine(Hashtable hashtable)
  34. {
  35. yield return ContinuousController.instance.StartCoroutine(card.Owner.AddMemory(1, activateClass));
  36. }
  37. }
  38. #endregion
  39. #region Your Turn
  40. if (timing == EffectTiming.OnAddDigivolutionCards)
  41. {
  42. Permanent sourcesAddedPermanent = null;
  43. ActivateClass activateClass = new ActivateClass();
  44. activateClass.SetUpICardEffect("Digivolve 1 of you Digimon", CanUseCondition, card);
  45. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDescription());
  46. cardEffects.Add(activateClass);
  47. string EffectDescription()
  48. {
  49. return "[Your Turn] When effects add digivolution cards to any of your Digimon with [Aqua] or [Sea Animal] in any of their traits, by suspending this Tamer, one of those Digimon may digivolve into a Digimon card with [Aqua] or [Sea Animal] in any of its traits in the hand with the digivolution cost reduced by 1.";
  50. }
  51. bool IsValidPermanentToDigivolveCondition(Permanent permanent)
  52. {
  53. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card) &&
  54. (permanent.TopCard.HasAquaTraits || permanent.TopCard.HasSeaAnimalTraits);
  55. }
  56. bool IsValidCardToDigivolveIntoCondition(CardSource cardSource)
  57. {
  58. return cardSource.IsDigimon && cardSource.HasLevel && cardSource.HasAquaTraits;
  59. }
  60. bool CanUseCondition(Hashtable hashtable)
  61. {
  62. if (CardEffectCommons.IsExistOnBattleArea(card))
  63. {
  64. if (CardEffectCommons.IsOwnerTurn(card))
  65. {
  66. if (CardEffectCommons.CanTriggerOnAddDigivolutionCard(
  67. hashtable: hashtable,
  68. permanentCondition: IsValidPermanentToDigivolveCondition,
  69. cardEffectCondition: cardEffect => cardEffect.EffectSourceCard != null,
  70. cardCondition: null))
  71. {
  72. return true;
  73. }
  74. }
  75. }
  76. return false;
  77. }
  78. bool CanSelectDigimonToDigivolve(Permanent permanent)
  79. {
  80. return sourcesAddedPermanent == permanent &&
  81. CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card);
  82. }
  83. bool CanActivateCondition(Hashtable hashtable)
  84. {
  85. sourcesAddedPermanent = CardEffectCommons.GetPermanentFromHashtable(hashtable);
  86. return CardEffectCommons.IsExistOnBattleArea(card) &&
  87. CardEffectCommons.CanActivateSuspendCostEffect(card) &&
  88. IsValidPermanentToDigivolveCondition(sourcesAddedPermanent);
  89. }
  90. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  91. {
  92. List<Permanent> selectedCards = new List<Permanent>();
  93. yield return ContinuousController.instance.StartCoroutine(
  94. new SuspendPermanentsClass(new List<Permanent>() { card.PermanentOfThisCard() },
  95. CardEffectCommons.CardEffectHashtable(activateClass)).Tap());
  96. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectDigimonToDigivolve))
  97. {
  98. Permanent selectedPermanent = null;
  99. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectDigimonToDigivolve));
  100. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  101. selectPermanentEffect.SetUp(
  102. selectPlayer: card.Owner,
  103. canTargetCondition: CanSelectDigimonToDigivolve,
  104. canTargetCondition_ByPreSelecetedList: null,
  105. canEndSelectCondition: null,
  106. maxCount: maxCount,
  107. canNoSelect: true,
  108. canEndNotMax: false,
  109. selectPermanentCoroutine: SelectPermanentCoroutine,
  110. afterSelectPermanentCoroutine: null,
  111. mode: SelectPermanentEffect.Mode.Custom,
  112. cardEffect: activateClass);
  113. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will digivolve.", "The opponent is selecting 1 Digimon that will digivolve.");
  114. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  115. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  116. {
  117. selectedPermanent = permanent;
  118. yield return null;
  119. }
  120. if (selectedPermanent != null)
  121. {
  122. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DigivolveIntoHandOrTrashCard(
  123. targetPermanent: selectedPermanent,
  124. cardCondition: IsValidCardToDigivolveIntoCondition,
  125. payCost: true,
  126. reduceCostTuple: (reduceCost: 1, reduceCostCardCondition: null),
  127. fixedCostTuple: null,
  128. ignoreDigivolutionRequirementFixedCost: -1,
  129. isHand: true,
  130. activateClass: activateClass,
  131. successProcess: null));
  132. }
  133. }
  134. }
  135. }
  136. #endregion
  137. #region Security Effect
  138. if (timing == EffectTiming.SecuritySkill)
  139. {
  140. cardEffects.Add(CardEffectFactory.PlaySelfTamerSecurityEffect(card));
  141. }
  142. #endregion
  143. return cardEffects;
  144. }
  145. }
  146. }