P_175.cs 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System;
  5. namespace DCGO.CardEffects.P
  6. {
  7. public class P_175 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Start of your turn
  13. if (timing == EffectTiming.OnStartTurn)
  14. cardEffects.Add(CardEffectFactory.SetMemoryTo3TamerEffect(card));
  15. #endregion
  16. #region Your Turn
  17. if (timing == EffectTiming.OnEnterFieldAnyone)
  18. {
  19. ActivateClass activateClass = new ActivateClass();
  20. activateClass.SetUpICardEffect("Digivolve, for reduced cost of 2", CanUseCondition, card);
  21. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  22. cardEffects.Add(activateClass);
  23. string EffectDiscription()
  24. {
  25. return "[Your Turn] When any of your Digimon with the [Rock Dragon] or [Machine Dragon] trait are played, by suspending this Tamer, 1 of your level 4 or higher Digimon may digivolve into a Digimon card with the [Rock Dragon], [Earth Dragon], [Machine Dragon] or [Sky Dragon] trait in the hand with the digivolution cost reduced by 2.";
  26. }
  27. bool IsYourRockMachineDigimon(Permanent permanent)
  28. {
  29. return CardEffectCommons.IsOwnerPermanent(permanent, card) &&
  30. (permanent.TopCard.EqualsTraits("Rock Dragon") || permanent.TopCard.EqualsTraits("Machine Dragon"));
  31. }
  32. bool CanSelectPermanentCondition(Permanent permanent)
  33. {
  34. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  35. {
  36. if(permanent.TopCard.HasLevel && permanent.TopCard.Level >= 4)
  37. {
  38. foreach (CardSource cardSource in card.Owner.HandCards)
  39. {
  40. if (IsYourDigimonToDigivolve(cardSource))
  41. {
  42. if (cardSource.CanPlayCardTargetFrame(permanent.PermanentFrame, true, activateClass))
  43. {
  44. return true;
  45. }
  46. }
  47. }
  48. }
  49. }
  50. return false;
  51. }
  52. bool IsYourDigimonToDigivolve(CardSource source)
  53. {
  54. return source.EqualsTraits("Rock Dragon") ||
  55. source.EqualsTraits("Earth Dragon") ||
  56. source.EqualsTraits("Machine Dragon") ||
  57. source.EqualsTraits("Sky Dragon");
  58. }
  59. bool CanUseCondition(Hashtable hashtable)
  60. {
  61. return isExistOnField(card) &&
  62. CardEffectCommons.IsOwnerTurn(card) &&
  63. CardEffectCommons.CanTriggerOnPermanentPlay(hashtable, IsYourRockMachineDigimon);
  64. }
  65. bool CanActivateCondition(Hashtable hashtable)
  66. {
  67. return isExistOnField(card) &&
  68. CardEffectCommons.CanActivateSuspendCostEffect(card) &&
  69. CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition);
  70. }
  71. IEnumerator ActivateCoroutine(Hashtable hashtable)
  72. {
  73. yield return ContinuousController.instance.StartCoroutine(new SuspendPermanentsClass(new List<Permanent>() { card.PermanentOfThisCard() }, CardEffectCommons.CardEffectHashtable(activateClass)).Tap());
  74. Permanent selectedPermanent = null;
  75. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  76. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  77. selectPermanentEffect.SetUp(
  78. selectPlayer: card.Owner,
  79. canTargetCondition: CanSelectPermanentCondition,
  80. canTargetCondition_ByPreSelecetedList: null,
  81. canEndSelectCondition: null,
  82. maxCount: maxCount,
  83. canNoSelect: true,
  84. canEndNotMax: false,
  85. selectPermanentCoroutine: SelectPermanentCoroutine,
  86. afterSelectPermanentCoroutine: null,
  87. mode: SelectPermanentEffect.Mode.Custom,
  88. cardEffect: activateClass);
  89. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to digivolve.", "The opponent is selecting 1 Digimon to digivolve.");
  90. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  91. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  92. {
  93. selectedPermanent = permanent;
  94. yield return null;
  95. }
  96. if (selectedPermanent != null)
  97. {
  98. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DigivolveIntoHandOrTrashCard(
  99. targetPermanent: selectedPermanent,
  100. cardCondition: IsYourDigimonToDigivolve,
  101. payCost: true,
  102. reduceCostTuple: (reduceCost: 2, reduceCostCardCondition: null),
  103. fixedCostTuple: null,
  104. ignoreDigivolutionRequirementFixedCost: -1,
  105. isHand: true,
  106. activateClass: activateClass,
  107. successProcess: null));
  108. }
  109. }
  110. }
  111. #endregion
  112. #region Security Effect
  113. if (timing == EffectTiming.SecuritySkill)
  114. cardEffects.Add(CardEffectFactory.PlaySelfTamerSecurityEffect(card));
  115. #endregion
  116. return cardEffects;
  117. }
  118. }
  119. }