LM_019.cs 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System;
  4. namespace DCGO.CardEffects.LM
  5. {
  6. public class LM_019 : CEntity_Effect
  7. {
  8. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  9. {
  10. List<ICardEffect> cardEffects = new List<ICardEffect>();
  11. #region OnPlay
  12. if (timing == EffectTiming.OnEnterFieldAnyone)
  13. {
  14. ActivateClass activateClass = new ActivateClass();
  15. activateClass.SetUpICardEffect("Reveal the top 4 cards of deck", CanUseCondition, card);
  16. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  17. cardEffects.Add(activateClass);
  18. string EffectDiscription()
  19. {
  20. return "[On Play] Reveal the top 4 cards of your deck. Add 1 card with [Gammamon] in its text among them to the hand. Return the rest to the bottom of the deck.";
  21. }
  22. bool CanSelectCardCondition(CardSource cardSource)
  23. {
  24. return cardSource.HasText("Gammamon");
  25. }
  26. bool CanUseCondition(Hashtable hashtable)
  27. {
  28. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  29. }
  30. bool CanActivateCondition(Hashtable hashtable)
  31. {
  32. if (CardEffectCommons.IsExistOnBattleArea(card))
  33. {
  34. if (card.Owner.LibraryCards.Count >= 1)
  35. {
  36. return true;
  37. }
  38. }
  39. return false;
  40. }
  41. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  42. {
  43. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.SimplifiedRevealDeckTopCardsAndSelect(
  44. revealCount: 4,
  45. simplifiedSelectCardConditions:
  46. new SimplifiedSelectCardConditionClass[]
  47. {
  48. new SimplifiedSelectCardConditionClass(
  49. canTargetCondition:CanSelectCardCondition,
  50. message: "Select 1 card with [Gammamon] in it's text.",
  51. mode: SelectCardEffect.Mode.AddHand,
  52. maxCount: 1,
  53. selectCardCoroutine: null),
  54. },
  55. remainingCardsPlace: RemainingCardsPlace.DeckBottom,
  56. activateClass: activateClass
  57. ));
  58. }
  59. }
  60. #endregion
  61. #region All Turns
  62. if (timing == EffectTiming.WhenRemoveField)
  63. {
  64. ActivateClass activateClass = new ActivateClass();
  65. activateClass.SetUpICardEffect("Delete this Digimon to prevent 1 other Digimon from leaving Battle Area", CanUseCondition, card);
  66. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  67. activateClass.SetHashString("Substitute_LM01_019");
  68. cardEffects.Add(activateClass);
  69. string EffectDiscription()
  70. {
  71. return "[All Turns] When one of your Digimon with [Gammamon] in its text, other than [Bokomon], would leave the battle area other than by one of your effects, by deleting this Digimon, prevent it from leaving.";
  72. }
  73. bool PermanentCondition(Permanent permanent)
  74. {
  75. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  76. {
  77. if (permanent.TopCard.HasText("Gammamon") && !permanent.TopCard.CardNames.Contains("Bokomon"))
  78. {
  79. if (permanent.willBeRemoveField)
  80. return true;
  81. }
  82. }
  83. return false;
  84. }
  85. bool CanUseCondition(Hashtable hashtable)
  86. {
  87. if (CardEffectCommons.IsExistOnBattleArea(card))
  88. {
  89. if (CardEffectCommons.CanTriggerWhenPermanentRemoveField(hashtable, PermanentCondition))
  90. {
  91. if (!CardEffectCommons.IsByEffect(hashtable, cardEffect => CardEffectCommons.IsOwnerEffect(cardEffect, card)))
  92. {
  93. return true;
  94. }
  95. }
  96. }
  97. return false;
  98. }
  99. bool CanActivateCondition(Hashtable hashtable)
  100. {
  101. if (CardEffectCommons.IsExistOnBattleArea(card))
  102. {
  103. return true;
  104. }
  105. return false;
  106. }
  107. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  108. {
  109. if (CardEffectCommons.IsExistOnBattleArea(card))
  110. {
  111. Permanent thisCardPermanent = card.PermanentOfThisCard();
  112. if (CardEffectCommons.HasMatchConditionPermanent(PermanentCondition))
  113. {
  114. List<Permanent> permanents = new List<Permanent>();
  115. if (_hashtable.ContainsKey("Permanents"))
  116. {
  117. if (_hashtable["Permanents"] is List<Permanent>)
  118. {
  119. permanents = (List<Permanent>)_hashtable["Permanents"];
  120. permanents = permanents.Filter(PermanentCondition);
  121. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DeletePeremanentAndProcessAccordingToResult(
  122. targetPermanents: new List<Permanent>() { thisCardPermanent },
  123. activateClass: activateClass,
  124. successProcess: permanents => SuccessProcess(),
  125. failureProcess: null));
  126. }
  127. }
  128. IEnumerator SuccessProcess()
  129. {
  130. foreach (Permanent permanent in permanents)
  131. {
  132. permanent.willBeRemoveField = false;
  133. permanent.HideDeleteEffect();
  134. permanent.HideHandBounceEffect();
  135. permanent.HideDeckBounceEffect();
  136. permanent.HideWillRemoveFieldEffect();
  137. }
  138. yield return null;
  139. }
  140. }
  141. }
  142. }
  143. }
  144. #endregion
  145. return cardEffects;
  146. }
  147. }
  148. }