ST23_12.cs 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. // Chiropmon
  6. namespace DCGO.CardEffects.ST23
  7. {
  8. public class ST23_12 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region Alt Digivolution Condition
  14. if (timing == EffectTiming.None)
  15. {
  16. static bool PermanentCondition(Permanent targetPermanent)
  17. {
  18. return targetPermanent.TopCard.EqualsTraits("Glowing Dawn");
  19. }
  20. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(level: 2, permanentCondition: PermanentCondition, digivolutionCost: 0, ignoreDigivolutionRequirement: false, card: card, condition: null));
  21. }
  22. #endregion
  23. #region On Play
  24. if (timing == EffectTiming.OnEnterFieldAnyone)
  25. {
  26. ActivateClass activateClass = new ActivateClass();
  27. activateClass.SetUpICardEffect("Trash 1 face-down from under your Tamers to return 1 [Glowing Dawn] Digimon card", CanUseCondition, card);
  28. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription());
  29. cardEffects.Add(activateClass);
  30. string EffectDescription()
  31. {
  32. return
  33. "[On Play] By trashing the bottom face-down card from under any of your Tamers, you may return 1 Digimon card with the [Glowing Dawn] trait from your trash to the hand.";
  34. }
  35. bool CanUseCondition(Hashtable hashtable)
  36. {
  37. return CardEffectCommons.IsExistOnBattleArea(card)
  38. && CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  39. }
  40. bool CanActivateCondition(Hashtable hashtable)
  41. {
  42. return CardEffectCommons.IsExistOnBattleArea(card)
  43. && CardEffectCommons.HasMatchConditionOwnersPermanent(card, TamerWithOneFaceDownSource);
  44. }
  45. bool TamerWithOneFaceDownSource(Permanent permanent)
  46. {
  47. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaTamer(permanent, card)
  48. && permanent.DigivolutionCards.Any(CanSelectTrashSourceCardCondition);
  49. }
  50. bool CanSelectTrashSourceCardCondition(CardSource cardSource)
  51. {
  52. return cardSource.IsFlipped;
  53. }
  54. bool CanSelectCardCondition(CardSource cardSource)
  55. {
  56. return cardSource.IsDigimon
  57. && cardSource.EqualsTraits("Glowing Dawn");
  58. }
  59. IEnumerator ActivateCoroutine(Hashtable hashtable)
  60. {
  61. bool trashed = false;
  62. SelectPermanentEffect selectPermanentEffect1 = GManager.instance.GetComponent<SelectPermanentEffect>();
  63. selectPermanentEffect1.SetUp(
  64. selectPlayer: card.Owner,
  65. canTargetCondition: TamerWithOneFaceDownSource,
  66. canTargetCondition_ByPreSelecetedList: null,
  67. canEndSelectCondition: null,
  68. maxCount: 1,
  69. canNoSelect: true,
  70. canEndNotMax: true,
  71. selectPermanentCoroutine: null,
  72. afterSelectPermanentCoroutine: AfterSelectPermanentCoroutine,
  73. mode: SelectPermanentEffect.Mode.Custom,
  74. cardEffect: activateClass);
  75. selectPermanentEffect1.SetUpCustomMessage("Select 1 Tamer to trash 1 bottom face-down card from", "The opponent is selecting 1 Tamer to trash 1 bottom face-down card from");
  76. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect1.Activate());
  77. IEnumerator AfterSelectPermanentCoroutine(List<Permanent> permanents)
  78. {
  79. if (permanents.Count == 1)
  80. {
  81. trashed = true;
  82. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.TrashDigivolutionCardsFromTopOrBottom(targetPermanent: permanents[0], trashCount: 1, isFromTop: false, activateClass: activateClass, CanSelectTrashSourceCardCondition));
  83. }
  84. }
  85. if (trashed)
  86. {
  87. int maxCount = Math.Min(1, card.Owner.TrashCards.Count(CanSelectCardCondition));
  88. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  89. selectCardEffect.SetUp(
  90. canTargetCondition: CanSelectCardCondition,
  91. canTargetCondition_ByPreSelecetedList: null,
  92. canEndSelectCondition: null,
  93. canNoSelect: () => true,
  94. selectCardCoroutine: null,
  95. afterSelectCardCoroutine: null,
  96. message: "Select 1 card to add to your hand.",
  97. maxCount: maxCount,
  98. canEndNotMax: false,
  99. isShowOpponent: true,
  100. mode: SelectCardEffect.Mode.AddHand,
  101. root: SelectCardEffect.Root.Trash,
  102. customRootCardList: null,
  103. canLookReverseCard: true,
  104. selectPlayer: card.Owner,
  105. cardEffect: activateClass);
  106. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  107. }
  108. }
  109. }
  110. #endregion
  111. #region Inherited Retaliation
  112. if (timing == EffectTiming.OnDestroyedAnyone)
  113. {
  114. cardEffects.Add(CardEffectFactory.RetaliationSelfEffect(isInheritedEffect: true, card: card, condition: null));
  115. }
  116. #endregion
  117. return cardEffects;
  118. }
  119. }
  120. }