P_103.cs 7.2 KB

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