BT21_001.cs 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. //Gigimon
  6. namespace DCGO.CardEffects.BT21
  7. {
  8. public class BT21_001 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region Your Turn - ESS
  14. if (timing == EffectTiming.OnLoseSecurity)
  15. {
  16. ActivateClass activateClass = new ActivateClass();
  17. activateClass.SetUpICardEffect("Digivolve a digimon", CanUseCondition, card);
  18. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDescription());
  19. activateClass.SetIsInheritedEffect(true);
  20. activateClass.SetHashString("Digivolve_BT21_001");
  21. cardEffects.Add(activateClass);
  22. string EffectDescription()
  23. => "[Your Turn] [Once Per Turn] When your opponent's security stack is removed from, 1 of your Digimon may digivolve into a Digimon card with the [Reptile]/[Dragonkin] trait in the hand with the digivolution cost reduced by 1.";
  24. bool CanUseCondition(Hashtable hashtable)
  25. {
  26. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  27. {
  28. if (CardEffectCommons.IsOwnerTurn(card))
  29. {
  30. if (CardEffectCommons.CanTriggerWhenLoseSecurity(hashtable, player => player == card.Owner.Enemy))
  31. {
  32. return true;
  33. }
  34. }
  35. }
  36. return false;
  37. }
  38. bool CanSelectDigivolvePermanent(Permanent permanent)
  39. {
  40. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  41. {
  42. return true;
  43. }
  44. return false;
  45. }
  46. bool CanSelectCardCondition(CardSource digivolveTarget, Permanent digivolvingTarget)
  47. {
  48. if (digivolveTarget.CardTraits.FirstOrDefault(x => x.Equals("Reptile")) != null || digivolveTarget.CardTraits.FirstOrDefault(x => x.Equals("Dragonkin")) != null)
  49. {
  50. if (digivolveTarget.CanPlayCardTargetFrame(digivolvingTarget.PermanentFrame, true, activateClass))
  51. {
  52. return true;
  53. }
  54. }
  55. return false;
  56. }
  57. bool CanActivateCondition(Hashtable hashtable)
  58. {
  59. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  60. }
  61. IEnumerator ActivateCoroutine(Hashtable hashtable)
  62. {
  63. Permanent selectedPermanent = null;
  64. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectDigivolvePermanent));
  65. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  66. selectPermanentEffect.SetUp(
  67. selectPlayer: card.Owner,
  68. canTargetCondition: CanSelectDigivolvePermanent,
  69. canTargetCondition_ByPreSelecetedList: null,
  70. canEndSelectCondition: null,
  71. maxCount: maxCount,
  72. canNoSelect: true,
  73. canEndNotMax: false,
  74. selectPermanentCoroutine: SelectPermanentCoroutine,
  75. afterSelectPermanentCoroutine: null,
  76. mode: SelectPermanentEffect.Mode.Custom,
  77. cardEffect: activateClass);
  78. selectPermanentEffect.SetUpCustomMessage("Select 1 digimon to digivolve", "The opponent is selecting 1 digimon to digivolve");
  79. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  80. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  81. {
  82. selectedPermanent = permanent;
  83. yield return null;
  84. }
  85. if (selectedPermanent != null)
  86. {
  87. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DigivolveIntoHandOrTrashCard(
  88. targetPermanent: selectedPermanent,
  89. cardCondition: (cardSource) => CanSelectCardCondition(cardSource, selectedPermanent),
  90. payCost: true,
  91. reduceCostTuple: (reduceCost: 1, reduceCostCardCondition: null),
  92. fixedCostTuple: null,
  93. ignoreDigivolutionRequirementFixedCost: -1,
  94. isHand: true,
  95. activateClass: activateClass,
  96. successProcess: null));
  97. }
  98. }
  99. }
  100. #endregion
  101. return cardEffects;
  102. }
  103. }
  104. }