BT24_050.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System;
  4. using System.Linq;
  5. // WereGarurumon
  6. namespace DCGO.CardEffects.BT24
  7. {
  8. public class BT24_050 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region Digivolution condition
  14. if (timing == EffectTiming.None)
  15. {
  16. bool Condition(Permanent permanent)
  17. {
  18. return (permanent.TopCard.ContainsCardName("Garurumon")
  19. || permanent.TopCard.EqualsTraits("TS"))
  20. && permanent.TopCard.IsLevel4;
  21. }
  22. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(Condition, 3, false, card, null));
  23. }
  24. #endregion
  25. #region Evade
  26. if (timing == EffectTiming.WhenPermanentWouldBeDeleted)
  27. {
  28. cardEffects.Add(CardEffectFactory.EvadeSelfEffect(
  29. isInheritedEffect: false,
  30. card: card,
  31. condition: null));
  32. }
  33. #endregion
  34. #region OP/WD Shared
  35. string SharedEffectName() => "Unsuspend 1 of your Digimon, then stun 1 opponent's Digimon.";
  36. string SharedEffectDescription(string tag) => $"[{tag}] 1 of your Digimon may unsuspend. Then, 1 of your opponent's Digimon or Tamers can't unsuspend until their turn ends.";
  37. bool SharedCanActivateCondition(Hashtable hashtable)
  38. {
  39. return CardEffectCommons.IsExistOnBattleArea(card);
  40. }
  41. bool CanSelectPermanentCondition(Permanent permanent)
  42. {
  43. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card);
  44. }
  45. bool CanSelectPermanentCondition1(Permanent permanent)
  46. {
  47. return CardEffectCommons.IsPermanentExistsOnOpponentBattleArea(permanent, card)
  48. && (permanent.TopCard.IsDigimon
  49. || permanent.TopCard.IsTamer);
  50. }
  51. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  52. {
  53. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  54. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  55. {
  56. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  57. selectPermanentEffect.SetUp(
  58. selectPlayer: card.Owner,
  59. canTargetCondition: CanSelectPermanentCondition,
  60. canTargetCondition_ByPreSelecetedList: null,
  61. canEndSelectCondition: null,
  62. maxCount: maxCount,
  63. canNoSelect: false,
  64. canEndNotMax: false,
  65. selectPermanentCoroutine: null,
  66. afterSelectPermanentCoroutine: null,
  67. mode: SelectPermanentEffect.Mode.UnTap,
  68. cardEffect: activateClass);
  69. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  70. }
  71. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition1))
  72. {
  73. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition1));
  74. selectPermanentEffect.SetUp(
  75. selectPlayer: card.Owner,
  76. canTargetCondition: CanSelectPermanentCondition1,
  77. canTargetCondition_ByPreSelecetedList: null,
  78. canEndSelectCondition: null,
  79. maxCount: maxCount,
  80. canNoSelect: false,
  81. canEndNotMax: false,
  82. selectPermanentCoroutine: SelectPermanentCoroutine,
  83. afterSelectPermanentCoroutine: null,
  84. mode: SelectPermanentEffect.Mode.Custom,
  85. cardEffect: activateClass);
  86. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon or Tamer that will get unable to suspend.", "The opponent is selecting 1 Digimon or Tamer that will get unable to suspend.");
  87. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  88. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  89. {
  90. Permanent selectedPermanent = permanent;
  91. if (selectedPermanent != null)
  92. {
  93. CanNotUnsuspendClass canNotUnsuspendClass = new CanNotUnsuspendClass();
  94. canNotUnsuspendClass.SetUpICardEffect("Can't Unsuspend", CanUseCondition1, card);
  95. canNotUnsuspendClass.SetUpCanNotUntapClass(PermanentCondition: PermanentCondition);
  96. selectedPermanent.UntilOwnerTurnEndEffects.Add((_timing) => canNotUnsuspendClass);
  97. if (!selectedPermanent.TopCard.CanNotBeAffected(activateClass))
  98. {
  99. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().CreateDebuffEffect(selectedPermanent));
  100. }
  101. bool CanUseCondition1(Hashtable hashtable)
  102. {
  103. return selectedPermanent.TopCard != null
  104. && !selectedPermanent.TopCard.CanNotBeAffected(activateClass);
  105. }
  106. bool PermanentCondition(Permanent permanent)
  107. {
  108. return permanent == selectedPermanent;
  109. }
  110. }
  111. }
  112. }
  113. }
  114. #endregion
  115. #region On Play
  116. if (timing == EffectTiming.OnEnterFieldAnyone)
  117. {
  118. ActivateClass activateClass = new ActivateClass();
  119. activateClass.SetUpICardEffect(SharedEffectName(), CanUseCondition, card);
  120. activateClass.SetUpActivateClass(SharedCanActivateCondition, (hashTable) => SharedActivateCoroutine(hashTable, activateClass), -1, false, SharedEffectDescription("On Play"));
  121. cardEffects.Add(activateClass);
  122. bool CanUseCondition(Hashtable hashtable)
  123. {
  124. return CardEffectCommons.CanTriggerOnPlay(hashtable, card)
  125. && CardEffectCommons.IsExistOnBattleArea(card);
  126. }
  127. }
  128. #endregion
  129. #region When Digivolving
  130. if (timing == EffectTiming.OnEnterFieldAnyone)
  131. {
  132. ActivateClass activateClass = new ActivateClass();
  133. activateClass.SetUpICardEffect(SharedEffectName(), CanUseCondition, card);
  134. activateClass.SetUpActivateClass(SharedCanActivateCondition, (hashTable) => SharedActivateCoroutine(hashTable, activateClass), -1, false, SharedEffectDescription("When Digivolving"));
  135. cardEffects.Add(activateClass);
  136. bool CanUseCondition(Hashtable hashtable)
  137. {
  138. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card)
  139. && CardEffectCommons.IsExistOnBattleArea(card);
  140. }
  141. }
  142. #endregion
  143. #region Inherit - When Attacking
  144. if (timing == EffectTiming.OnAllyAttack)
  145. {
  146. ActivateClass activateClass = new ActivateClass();
  147. activateClass.SetUpICardEffect("Play a Digimon", CanUseCondition, card);
  148. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDescription());
  149. activateClass.SetHashString("BT24_050_Inherited");
  150. activateClass.SetIsInheritedEffect(true);
  151. cardEffects.Add(activateClass);
  152. string EffectDescription()
  153. {
  154. return "[When Attacking] [Once Per Turn] You may play 1 4000 DP or lower Digimon card with the [Iliad] trait or [Beast], [Animal] or [Sovereign], other than [Sea Animal], in any of its traits from your hand without paying the cost.";
  155. }
  156. bool CanUseCondition(Hashtable hashtable)
  157. {
  158. return CardEffectCommons.CanTriggerOnAttack(hashtable, card)
  159. && CardEffectCommons.IsExistOnBattleArea(card);
  160. }
  161. bool CanActivateCondition(Hashtable hashtable)
  162. {
  163. return CardEffectCommons.IsExistOnBattleArea(card);
  164. }
  165. bool CanSelectCardCondition(CardSource cardSource)
  166. {
  167. return cardSource.IsDigimon
  168. && cardSource.HasDP
  169. && cardSource.CardDP <= 4000
  170. && (cardSource.HasIliadTraits
  171. || cardSource.HasBeastTraits)
  172. && CardEffectCommons.CanPlayAsNewPermanent(cardSource, false, activateClass);
  173. }
  174. IEnumerator ActivateCoroutine(Hashtable hashtable)
  175. {
  176. int maxCount = Math.Min(1, card.Owner.HandCards.Count(CanSelectCardCondition));
  177. List<CardSource> selectedCards = new List<CardSource>();
  178. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  179. selectHandEffect.SetUp(
  180. selectPlayer: card.Owner,
  181. canTargetCondition: CanSelectCardCondition,
  182. canTargetCondition_ByPreSelecetedList: null,
  183. canEndSelectCondition: null,
  184. maxCount: maxCount,
  185. canNoSelect: true,
  186. canEndNotMax: false,
  187. isShowOpponent: true,
  188. selectCardCoroutine: SelectCardCoroutine,
  189. afterSelectCardCoroutine: null,
  190. mode: SelectHandEffect.Mode.Custom,
  191. cardEffect: activateClass);
  192. selectHandEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  193. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  194. yield return StartCoroutine(selectHandEffect.Activate());
  195. IEnumerator SelectCardCoroutine(CardSource cardSource)
  196. {
  197. selectedCards.Add(cardSource);
  198. yield return null;
  199. }
  200. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  201. cardSources: selectedCards,
  202. activateClass: activateClass,
  203. payCost: false,
  204. isTapped: false,
  205. root: SelectCardEffect.Root.Hand,
  206. activateETB: true));
  207. }
  208. }
  209. #endregion
  210. return cardEffects;
  211. }
  212. }
  213. }