EX4_023.cs 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. namespace DCGO.CardEffects.EX4
  5. {
  6. public class EX4_023 : CEntity_Effect
  7. {
  8. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  9. {
  10. List<ICardEffect> cardEffects = new List<ICardEffect>();
  11. if (timing == EffectTiming.OnEnterFieldAnyone)
  12. {
  13. ActivateClass activateClass = new ActivateClass();
  14. activateClass.SetUpICardEffect("Reveal 1 card from hand", CanUseCondition, card);
  15. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  16. activateClass.SetHashString("Reveal_EX4_023");
  17. cardEffects.Add(activateClass);
  18. string EffectDiscription()
  19. {
  20. return "[Opponent's Turn][Once Per Turn] When an opponent plays a Digimon, by revealing 1 card of the same level in your hand, place that card on top of your security stack face down.";
  21. }
  22. bool PermanentCondition(Permanent permanent)
  23. {
  24. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  25. {
  26. if (permanent.TopCard.HasLevel)
  27. {
  28. return true;
  29. }
  30. }
  31. return false;
  32. }
  33. bool CanUseCondition(Hashtable hashtable)
  34. {
  35. if (CardEffectCommons.IsExistOnBattleArea(card))
  36. {
  37. if (CardEffectCommons.IsOpponentTurn(card))
  38. {
  39. if (CardEffectCommons.CanTriggerOnPermanentPlay(hashtable, PermanentCondition))
  40. {
  41. return true;
  42. }
  43. }
  44. }
  45. return false;
  46. }
  47. bool CanActivateCondition(Hashtable hashtable)
  48. {
  49. if (CardEffectCommons.IsExistOnBattleArea(card))
  50. {
  51. List<Permanent> permanents = CardEffectCommons.GetPlayedPermanentsFromEnterFieldHashtable(
  52. hashtable: hashtable,
  53. rootCondition: null);
  54. if (permanents != null)
  55. {
  56. List<int> levels = permanents
  57. .Filter(permanent => permanent != null && permanent.LevelJustAfterPlayed >= 0)
  58. .Map(permanent => permanent.LevelJustAfterPlayed);
  59. bool CanSelectCardCondition(CardSource cardSource)
  60. {
  61. if (cardSource.HasLevel && levels.Contains(cardSource.Level))
  62. {
  63. return true;
  64. }
  65. return false;
  66. }
  67. if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  68. {
  69. if (levels.Count == 1)
  70. {
  71. activateClass.SetEffectName($"Reveal 1 level {levels[0]} card from hand");
  72. }
  73. return true;
  74. }
  75. }
  76. }
  77. return false;
  78. }
  79. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  80. {
  81. List<Permanent> permanents = CardEffectCommons.GetPlayedPermanentsFromEnterFieldHashtable(
  82. hashtable: _hashtable,
  83. rootCondition: null);
  84. if (permanents != null)
  85. {
  86. List<int> levels = permanents
  87. .Filter(permanent => permanent != null && permanent.LevelJustAfterPlayed >= 0)
  88. .Map(permanent => permanent.LevelJustAfterPlayed);
  89. bool CanSelectCardCondition(CardSource cardSource)
  90. {
  91. if (cardSource.HasLevel && levels.Contains(cardSource.Level))
  92. {
  93. return true;
  94. }
  95. return false;
  96. }
  97. if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  98. {
  99. List<CardSource> selectedCards = new List<CardSource>();
  100. int maxCount = 1;
  101. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  102. selectHandEffect.SetUp(
  103. selectPlayer: card.Owner,
  104. canTargetCondition: CanSelectCardCondition,
  105. canTargetCondition_ByPreSelecetedList: null,
  106. canEndSelectCondition: null,
  107. maxCount: maxCount,
  108. canNoSelect: true,
  109. canEndNotMax: false,
  110. isShowOpponent: true,
  111. selectCardCoroutine: SelectCardCoroutine,
  112. afterSelectCardCoroutine: null,
  113. mode: SelectHandEffect.Mode.Custom,
  114. cardEffect: activateClass);
  115. selectHandEffect.SetUpCustomMessage("Select 1 card to reveal.", "The opponent is selecting 1 card to reveal.");
  116. selectHandEffect.SetUpCustomMessage_ShowCard("Revealed Card");
  117. yield return StartCoroutine(selectHandEffect.Activate());
  118. IEnumerator SelectCardCoroutine(CardSource cardSource)
  119. {
  120. selectedCards.Add(cardSource);
  121. yield return null;
  122. }
  123. if (selectedCards.Count >= 1)
  124. {
  125. foreach (CardSource selectedCard in selectedCards)
  126. {
  127. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddSecurityCard(selectedCard));
  128. }
  129. }
  130. }
  131. }
  132. }
  133. }
  134. return cardEffects;
  135. }
  136. }
  137. }