ST20_14.cs 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using UnityEngine;
  5. //ST20 Our Courage United
  6. namespace DCGO.CardEffects.ST20
  7. {
  8. public class ST20_14 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region ignoring colors
  14. if (timing == EffectTiming.None)
  15. {
  16. IgnoreColorConditionClass ignoreColorConditionClass = new IgnoreColorConditionClass();
  17. ignoreColorConditionClass.SetUpICardEffect("Ignore color requirements", CanUseCondition, card);
  18. ignoreColorConditionClass.SetUpIgnoreColorConditionClass(cardCondition: CardCondition);
  19. cardEffects.Add(ignoreColorConditionClass);
  20. bool CanUseCondition(Hashtable hashtable)
  21. => CardEffectCommons.HasMatchConditionPermanent((permanent) => (permanent.IsTamer || permanent.IsDigimon) && permanent.TopCard.HasAdventureTraits, true);
  22. bool CardCondition(CardSource cardSource)
  23. => cardSource == card;
  24. }
  25. #endregion
  26. #region Main effect
  27. if (timing == EffectTiming.OptionSkill)
  28. {
  29. ActivateClass activateClass = new ActivateClass();
  30. activateClass.SetUpICardEffect("Draw 2", CanUseCondition, card);
  31. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDescription());
  32. cardEffects.Add(activateClass);
  33. string EffectDescription()
  34. {
  35. return "[Main] <Draw 2>. (Draw 2 cards from your deck.) Then, place this card in the battle area.";
  36. }
  37. bool CanUseCondition(Hashtable hashtable)
  38. {
  39. return CardEffectCommons.CanTriggerOptionMainEffect(hashtable, card);
  40. }
  41. IEnumerator ActivateCoroutine(Hashtable hashtable)
  42. {
  43. yield return ContinuousController.instance.StartCoroutine(new DrawClass(card.Owner, 2, activateClass).Draw());
  44. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlaceDelayOptionCards(card: card, cardEffect: activateClass));
  45. }
  46. }
  47. #endregion
  48. #region delay
  49. if (timing == EffectTiming.WhenRemoveField)
  50. {
  51. ActivateClass activateClass = new ActivateClass();
  52. activateClass.SetUpICardEffect("Play level 5 ADVENTURE digimon", CanUseCondition, card);
  53. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, true, EffectDescription());
  54. cardEffects.Add(activateClass);
  55. string EffectDescription()
  56. {
  57. return "[All Turns] When any of your level 5 or higher Digimon would leave the battle area, <Delay> (By trashing this card after the placing turn, activate the effect.)\r\n• You may play 1 level 5 or lower Digimon card with the [ADVENTURE] trait from your hand without paying the cost.";
  58. }
  59. bool PermanentCondition(Permanent permanent)
  60. {
  61. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card) &&
  62. permanent.TopCard.HasLevel && permanent.TopCard.Level >= 5
  63. && permanent.willBeRemoveField;
  64. }
  65. bool CanUseCondition(Hashtable hashtable)
  66. {
  67. return CardEffectCommons.CanTriggerWhenPermanentRemoveField(hashtable, PermanentCondition) &&
  68. CardEffectCommons.CanDeclareOptionDelayEffect(card);
  69. }
  70. IEnumerator ActivateCoroutine(Hashtable hashtable)
  71. {
  72. bool deleted = false;
  73. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DeletePeremanentAndProcessAccordingToResult(
  74. targetPermanents: new List<Permanent>() { card.PermanentOfThisCard() },
  75. activateClass: activateClass,
  76. successProcess: permanents => SuccessProcess(),
  77. failureProcess: null));
  78. IEnumerator SuccessProcess()
  79. {
  80. deleted = true;
  81. yield return null;
  82. }
  83. if (deleted)
  84. {
  85. List<Permanent> selectedPermanents = CardEffectCommons.GetPermanentsFromHashtable(hashtable);
  86. bool CanPlayAdventureCondition(CardSource cardSource)
  87. {
  88. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  89. {
  90. return cardSource.IsDigimon &&
  91. cardSource.HasAdventureTraits &&
  92. cardSource.HasLevel &&
  93. cardSource.Level <= 5;
  94. }
  95. return false;
  96. }
  97. if (selectedPermanents.Count > 0)
  98. {
  99. if (card.Owner.HandCards.Count(CanPlayAdventureCondition) >= 1)
  100. {
  101. List<CardSource> selectedCards = new List<CardSource>();
  102. IEnumerator SelectCardCoroutine(CardSource cardSource)
  103. {
  104. selectedCards.Add(cardSource);
  105. yield return null;
  106. }
  107. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  108. selectHandEffect.SetUp(
  109. selectPlayer: card.Owner,
  110. canTargetCondition: CanPlayAdventureCondition,
  111. canTargetCondition_ByPreSelecetedList: null,
  112. canEndSelectCondition: null,
  113. maxCount: 1,
  114. canNoSelect: true,
  115. canEndNotMax: false,
  116. isShowOpponent: true,
  117. selectCardCoroutine: SelectCardCoroutine,
  118. afterSelectCardCoroutine: null,
  119. mode: SelectHandEffect.Mode.Custom,
  120. cardEffect: activateClass);
  121. selectHandEffect.SetUpCustomMessage(
  122. "Select 1 level 5 or lower [ADVENTURE] trait Digimon card to play.",
  123. "The opponent is selecting 1 level 5 or lower [ADVENTURE] trait Digimon card to play.");
  124. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  125. yield return ContinuousController.instance.StartCoroutine(selectHandEffect.Activate());
  126. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  127. cardSources: selectedCards,
  128. activateClass: activateClass,
  129. payCost: false,
  130. isTapped: false,
  131. root: SelectCardEffect.Root.Hand,
  132. activateETB: true));
  133. }
  134. }
  135. }
  136. }
  137. }
  138. #endregion
  139. #region Security
  140. if (timing == EffectTiming.SecuritySkill)
  141. {
  142. cardEffects.Add(CardEffectFactory.PlaceSelfDelayOptionSecurityEffect(card));
  143. }
  144. #endregion
  145. return cardEffects;
  146. }
  147. }
  148. }