P_108.cs 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  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 P_108 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. CardColor targetColor = CardColor.Purple;
  14. if (timing == EffectTiming.OptionSkill)
  15. {
  16. ActivateClass activateClass = new ActivateClass();
  17. activateClass.SetUpICardEffect(card.BaseENGCardNameFromEntity, CanUseCondition, card);
  18. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDiscription());
  19. cardEffects.Add(activateClass);
  20. string EffectDiscription()
  21. {
  22. return "[Main] Reveal the top 2 cards of your deck. Add 1 purple card among them to your hand. Place the rest at the bottom of your deck in any order. Then, place this card into your battle area.";
  23. }
  24. bool CanSelectCardCondition(CardSource cardSource)
  25. {
  26. return cardSource.HasCardColor(targetColor);
  27. }
  28. bool CanUseCondition(Hashtable hashtable)
  29. {
  30. return CardEffectCommons.CanTriggerOptionMainEffect(hashtable, card);
  31. }
  32. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  33. {
  34. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.SimplifiedRevealDeckTopCardsAndSelect(
  35. revealCount: 2,
  36. simplifiedSelectCardConditions:
  37. new SimplifiedSelectCardConditionClass[]
  38. {
  39. new SimplifiedSelectCardConditionClass(
  40. canTargetCondition:CanSelectCardCondition,
  41. message: "Select 1 purple card.",
  42. mode: SelectCardEffect.Mode.AddHand,
  43. maxCount: 1,
  44. selectCardCoroutine: null),
  45. },
  46. remainingCardsPlace: RemainingCardsPlace.DeckBottom,
  47. activateClass: activateClass
  48. ));
  49. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlaceDelayOptionCards(card: card, cardEffect: activateClass));
  50. }
  51. }
  52. if (timing == EffectTiming.OnDeclaration)
  53. {
  54. ActivateClass activateClass = new ActivateClass();
  55. activateClass.SetUpICardEffect("Your 1 Digimon digivolves", CanUseCondition, card);
  56. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDiscription());
  57. cardEffects.Add(activateClass);
  58. string EffectDiscription()
  59. {
  60. return "[Main] <Delay> (Trash this card in your battle area to activate the effect below. You can't activate this effect the turn this card enters play.) - 1 of your Digimon may digivolve into a purple Digimon card in your hand for its digivolution cost. When it would digivolve by this effect, reduce the cost by 2.";
  61. }
  62. bool CanSelectPermanentCondition(Permanent permanent)
  63. {
  64. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  65. {
  66. foreach (CardSource cardSource in card.Owner.HandCards)
  67. {
  68. if (CanSelectCardCondition(cardSource))
  69. {
  70. if (cardSource.CanPlayCardTargetFrame(permanent.PermanentFrame, false, activateClass))
  71. {
  72. return true;
  73. }
  74. }
  75. }
  76. }
  77. return false;
  78. }
  79. bool CanSelectCardCondition(CardSource cardSource)
  80. {
  81. return cardSource.IsDigimon && cardSource.HasCardColor(targetColor);
  82. }
  83. bool CanUseCondition(Hashtable hashtable)
  84. {
  85. return CardEffectCommons.CanDeclareOptionDelayEffect(card);
  86. }
  87. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  88. {
  89. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DeletePeremanentAndProcessAccordingToResult(targetPermanents: new List<Permanent>() { card.PermanentOfThisCard() }, activateClass: activateClass, successProcess: permanents => SuccessProcess(), failureProcess: null));
  90. IEnumerator SuccessProcess()
  91. {
  92. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  93. {
  94. Permanent selectedPermanent = null;
  95. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  96. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  97. selectPermanentEffect.SetUp(
  98. selectPlayer: card.Owner,
  99. canTargetCondition: CanSelectPermanentCondition,
  100. canTargetCondition_ByPreSelecetedList: null,
  101. canEndSelectCondition: null,
  102. maxCount: maxCount,
  103. canNoSelect: true,
  104. canEndNotMax: false,
  105. selectPermanentCoroutine: SelectPermanentCoroutine,
  106. afterSelectPermanentCoroutine: null,
  107. mode: SelectPermanentEffect.Mode.Custom,
  108. cardEffect: activateClass);
  109. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will digivolve.", "The opponent is selecting 1 Digimon that will digivolve.");
  110. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  111. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  112. {
  113. selectedPermanent = permanent;
  114. yield return null;
  115. }
  116. if (selectedPermanent != null)
  117. {
  118. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DigivolveIntoHandOrTrashCard(
  119. targetPermanent: selectedPermanent,
  120. cardCondition: CanSelectCardCondition,
  121. payCost: true,
  122. reduceCostTuple: (reduceCost: 2, reduceCostCardCondition: null),
  123. fixedCostTuple: null,
  124. ignoreDigivolutionRequirementFixedCost: -1,
  125. isHand: true,
  126. activateClass: activateClass,
  127. successProcess: null));
  128. }
  129. }
  130. }
  131. }
  132. }
  133. if (timing == EffectTiming.SecuritySkill)
  134. {
  135. cardEffects.Add(CardEffectFactory.PlaceSelfDelayOptionSecurityEffect(card));
  136. }
  137. return cardEffects;
  138. }
  139. }