P_209.cs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. // Titamon
  6. namespace DCGO.CardEffects.P
  7. {
  8. public class P_209 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region Alternate Digivolution Requirement
  14. if (timing == EffectTiming.None)
  15. {
  16. static bool PermanentCondition(Permanent targetPermanent)
  17. {
  18. return targetPermanent.TopCard.IsLevel5 &&
  19. (targetPermanent.TopCard.EqualsTraits("Demon") || targetPermanent.TopCard.HasTSTraits);
  20. }
  21. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 3, ignoreDigivolutionRequirement: false, card: card, condition: null));
  22. }
  23. #endregion
  24. #region Alliance
  25. if (timing == EffectTiming.OnAllyAttack)
  26. {
  27. cardEffects.Add(CardEffectFactory.AllianceSelfEffect(isInheritedEffect: false, card: card, condition: null));
  28. }
  29. #endregion
  30. #region OP/WD Shared
  31. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  32. {
  33. bool CanSelectPermanentCondition(Permanent targetPermanent)
  34. {
  35. return CardEffectCommons.IsPermanentExistsOnOpponentBattleArea(targetPermanent, card)
  36. && (targetPermanent.IsDigimon || targetPermanent.IsTamer);
  37. }
  38. bool trashed = false;
  39. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  40. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionOwnersCardCountInHand(card, _ => true));
  41. selectHandEffect.SetUp(
  42. selectPlayer: card.Owner,
  43. canTargetCondition: _ => true,
  44. canTargetCondition_ByPreSelecetedList: null,
  45. canEndSelectCondition: null,
  46. maxCount: maxCount,
  47. canNoSelect: true,
  48. canEndNotMax: false,
  49. isShowOpponent: true,
  50. selectCardCoroutine: null,
  51. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  52. mode: SelectHandEffect.Mode.Discard,
  53. cardEffect: activateClass);
  54. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  55. {
  56. if (cardSources.Any()) trashed = true;
  57. yield return null;
  58. }
  59. selectHandEffect.SetUpCustomMessage("Select 1 card to discard.", "The opponent is selecting 1 card to discard.");
  60. selectHandEffect.SetUpCustomMessage_ShowCard("Selected Card");
  61. yield return ContinuousController.instance.StartCoroutine(selectHandEffect.Activate());
  62. if (trashed)
  63. {
  64. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  65. {
  66. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  67. int maxCount1 = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  68. selectPermanentEffect.SetUp(
  69. selectPlayer: card.Owner,
  70. canTargetCondition: CanSelectPermanentCondition,
  71. canTargetCondition_ByPreSelecetedList: null,
  72. canEndSelectCondition: null,
  73. maxCount: maxCount1,
  74. canNoSelect: false,
  75. canEndNotMax: false,
  76. selectPermanentCoroutine: null,
  77. afterSelectPermanentCoroutine: null,
  78. mode: SelectPermanentEffect.Mode.Tap,
  79. cardEffect: activateClass);
  80. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon or Tamer to suspend.", "The opponent is selecting Digimon or Tamer to suspend.");
  81. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  82. }
  83. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  84. {
  85. Permanent selectedPermament = null;
  86. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  87. int maxCount1 = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  88. selectPermanentEffect.SetUp(
  89. selectPlayer: card.Owner,
  90. canTargetCondition: CanSelectPermanentCondition,
  91. canTargetCondition_ByPreSelecetedList: null,
  92. canEndSelectCondition: null,
  93. maxCount: maxCount1,
  94. canNoSelect: false,
  95. canEndNotMax: false,
  96. selectPermanentCoroutine: SelectPermanentCoroutine,
  97. afterSelectPermanentCoroutine: null,
  98. mode: SelectPermanentEffect.Mode.Custom,
  99. cardEffect: activateClass);
  100. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  101. {
  102. selectedPermament = permanent;
  103. yield return null;
  104. }
  105. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon or Tamer that cant unsuspend.", "The opponent is selecting 1 Digimon or Tamer that cant unsuspend.");
  106. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  107. if (selectedPermament != null) yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainCanNotUnsuspend(
  108. targetPermanent: selectedPermament,
  109. effectDuration: EffectDuration.UntilOpponentTurnEnd,
  110. activateClass: activateClass,
  111. condition: null,
  112. effectName: "Cannot Unsuspend"));
  113. }
  114. }
  115. }
  116. #endregion
  117. #region On Play
  118. if (timing == EffectTiming.OnEnterFieldAnyone)
  119. {
  120. ActivateClass activateClass = new ActivateClass();
  121. activateClass.SetUpICardEffect("By trashing 1 card from your hand, suspend 1 digimon or tamer, then 1 digimon or tamer cant unsuspend", CanUseCondition, card);
  122. activateClass.SetUpActivateClass(CanActivateCondition, hash => SharedActivateCoroutine(hash, activateClass), -1, false, EffectDiscription());
  123. cardEffects.Add(activateClass);
  124. string EffectDiscription()
  125. {
  126. return "[When Digivolving] By trashing 1 card in your hand, suspend 1 of your opponent's Digimon or Tamers. Then, 1 of their Digimon or Tamers can't unsuspend until their turn ends.";
  127. }
  128. bool CanUseCondition(Hashtable hashtable)
  129. {
  130. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  131. && CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  132. }
  133. bool CanActivateCondition(Hashtable hashtable)
  134. {
  135. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  136. }
  137. }
  138. #endregion
  139. #region When Digivolving
  140. if (timing == EffectTiming.OnEnterFieldAnyone)
  141. {
  142. ActivateClass activateClass = new ActivateClass();
  143. activateClass.SetUpICardEffect("By trashing 1 card from your hand, suspend 1 digimon or tamer, then 1 digimon or tamer cant unsuspend", CanUseCondition, card);
  144. activateClass.SetUpActivateClass(CanActivateCondition, hash => SharedActivateCoroutine(hash, activateClass), -1, false, EffectDiscription());
  145. cardEffects.Add(activateClass);
  146. string EffectDiscription()
  147. {
  148. return "[When Digivolving] By trashing 1 card in your hand, suspend 1 of your opponent's Digimon or Tamers. Then, 1 of their Digimon or Tamers can't unsuspend until their turn ends.";
  149. }
  150. bool CanUseCondition(Hashtable hashtable)
  151. {
  152. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  153. && CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  154. }
  155. bool CanActivateCondition(Hashtable hashtable)
  156. {
  157. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  158. }
  159. }
  160. #endregion
  161. #region All Turns - OPT
  162. if (timing == EffectTiming.OnDiscardHand)
  163. {
  164. ActivateClass activateClass = new ActivateClass();
  165. activateClass.SetUpICardEffect("Play 1 level 4 or lower [Demon] or [Titan] card", CanUseCondition, card);
  166. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  167. activateClass.SetHashString("P_209_AT");
  168. cardEffects.Add(activateClass);
  169. string EffectDiscription()
  170. {
  171. return "[All Turns] [Once Per Turn] When your hand is trashed from, you may play 1 level 4 or lower [Demon] or [Titan] trait card from your trash without paying the cost.";
  172. }
  173. bool CanUseCondition(Hashtable hashtable)
  174. {
  175. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  176. && CardEffectCommons.CanTriggerOnTrashHand(hashtable, null, cardSource => cardSource.Owner == card.Owner);
  177. }
  178. bool CanActivateCondition(Hashtable hashtable)
  179. {
  180. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  181. }
  182. bool CanSelectCardCondition(CardSource cardSource)
  183. {
  184. return cardSource.IsDigimon
  185. && cardSource.HasLevel && cardSource.Level <= 4
  186. && (cardSource.EqualsTraits("Demon")
  187. || cardSource.EqualsTraits("Titan"))
  188. && CardEffectCommons.CanPlayAsNewPermanent(cardSource, false, activateClass);
  189. }
  190. IEnumerator ActivateCoroutine(Hashtable hashtable)
  191. {
  192. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  193. {
  194. CardSource selectedCard = null;
  195. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  196. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionOwnersCardCountInTrash(card, CanSelectCardCondition));
  197. selectCardEffect.SetUp(
  198. canTargetCondition: CanSelectCardCondition,
  199. canTargetCondition_ByPreSelecetedList: null,
  200. canEndSelectCondition: null,
  201. canNoSelect: () => true,
  202. selectCardCoroutine: SelectCardCoroutine,
  203. afterSelectCardCoroutine: null,
  204. message: "Select 1 card to play.",
  205. maxCount: maxCount,
  206. canEndNotMax: false,
  207. isShowOpponent: true,
  208. mode: SelectCardEffect.Mode.Custom,
  209. root: SelectCardEffect.Root.Trash,
  210. customRootCardList: null,
  211. canLookReverseCard: true,
  212. selectPlayer: card.Owner,
  213. cardEffect: activateClass);
  214. selectCardEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  215. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  216. IEnumerator SelectCardCoroutine(CardSource cardSource)
  217. {
  218. selectedCard = cardSource;
  219. yield return null;
  220. }
  221. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  222. if (selectedCard != null) yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  223. cardSources: new List<CardSource>() { selectedCard },
  224. activateClass: activateClass,
  225. payCost: false,
  226. isTapped: false,
  227. root: SelectCardEffect.Root.Trash,
  228. activateETB: true));
  229. }
  230. }
  231. }
  232. #endregion
  233. return cardEffects;
  234. }
  235. }
  236. }