P_107.cs 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  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_107 : 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.Black;
  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 black 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 black 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 black 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(
  90. targetPermanents: new List<Permanent>() { card.PermanentOfThisCard() },
  91. activateClass: activateClass,
  92. successProcess: permanents => SuccessProcess(),
  93. failureProcess: null));
  94. IEnumerator SuccessProcess()
  95. {
  96. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  97. {
  98. Permanent selectedPermanent = null;
  99. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  100. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  101. selectPermanentEffect.SetUp(
  102. selectPlayer: card.Owner,
  103. canTargetCondition: CanSelectPermanentCondition,
  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: CanSelectCardCondition,
  125. payCost: true,
  126. reduceCostTuple: (reduceCost: 2, reduceCostCardCondition: null),
  127. fixedCostTuple: null,
  128. ignoreDigivolutionRequirementFixedCost: -1,
  129. isHand: true,
  130. activateClass: activateClass,
  131. successProcess: null));
  132. }
  133. }
  134. }
  135. }
  136. }
  137. if (timing == EffectTiming.SecuritySkill)
  138. {
  139. cardEffects.Add(CardEffectFactory.PlaceSelfDelayOptionSecurityEffect(card));
  140. }
  141. return cardEffects;
  142. }
  143. }