P_216.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using UnityEngine;
  6. //WaruMonzaemon
  7. namespace DCGO.CardEffects.P
  8. {
  9. public class P_216 : CEntity_Effect
  10. {
  11. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  12. {
  13. List<ICardEffect> cardEffects = new List<ICardEffect>();
  14. #region Blocker
  15. if (timing == EffectTiming.None)
  16. {
  17. cardEffects.Add(CardEffectFactory.BlockerSelfStaticEffect(isInheritedEffect: false, card: card, condition: null));
  18. }
  19. #endregion
  20. #region On Play
  21. if (timing == EffectTiming.OnEnterFieldAnyone)
  22. {
  23. ActivateClass activateClass = new ActivateClass();
  24. activateClass.SetUpICardEffect("Play a Dark Master from Hand.", CanUseCondition, card);
  25. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  26. cardEffects.Add(activateClass);
  27. string EffectDiscription()
  28. {
  29. return "[On Play] You may play 1 [Dark Master] trait Digimon card from your hand without paying the cost. The Digimon this effect played can't digivolve and is deleted at turn end.";
  30. }
  31. bool CanSelectHandCondition(CardSource cardSource)
  32. {
  33. return cardSource.IsDigimon
  34. && cardSource.EqualsTraits("Dark Masters")
  35. && CardEffectCommons.CanPlayAsNewPermanent(cardSource, false, activateClass);
  36. }
  37. bool CanUseCondition(Hashtable hashtable)
  38. {
  39. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  40. && CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  41. }
  42. bool CanActivateCondition(Hashtable hashtable)
  43. {
  44. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  45. && CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectHandCondition);
  46. }
  47. IEnumerator ActivateCoroutine(Hashtable hashtable)
  48. {
  49. CardSource selectCard = null;
  50. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  51. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionOwnersCardCountInHand(card, CanSelectHandCondition));
  52. selectHandEffect.SetUp(
  53. selectPlayer: card.Owner,
  54. canTargetCondition: CanSelectHandCondition,
  55. canTargetCondition_ByPreSelecetedList: null,
  56. canEndSelectCondition: null,
  57. maxCount: maxCount,
  58. canNoSelect: true,
  59. canEndNotMax: false,
  60. isShowOpponent: true,
  61. selectCardCoroutine: SelectCardCoroutine,
  62. afterSelectCardCoroutine: null,
  63. mode: SelectHandEffect.Mode.Custom,
  64. cardEffect: activateClass);
  65. selectHandEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  66. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  67. IEnumerator SelectCardCoroutine(CardSource cardSource)
  68. {
  69. selectCard = cardSource;
  70. yield return null;
  71. }
  72. yield return ContinuousController.instance.StartCoroutine(selectHandEffect.Activate());
  73. if (selectCard != null)
  74. {
  75. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  76. cardSources: new List<CardSource> { selectCard },
  77. activateClass: activateClass,
  78. payCost: false,
  79. isTapped: false,
  80. root: SelectCardEffect.Root.Security,
  81. activateETB: true));
  82. Permanent playedDigimon = null;
  83. yield return new WaitForSeconds(0.2f);
  84. playedDigimon = selectCard.PermanentOfThisCard();
  85. #region Can't Digivolve
  86. CanNotDigivolveClass canNotEvolveClass = new CanNotDigivolveClass();
  87. canNotEvolveClass.SetUpICardEffect("Can't digivolve", CanUseCantEvoCondition, card);
  88. canNotEvolveClass.SetUpCanNotEvolveClass(permanentCondition: PermanentCondition, cardCondition: CardCondition);
  89. playedDigimon.PermanentEffects.Add((_timing) => canNotEvolveClass);
  90. bool CanUseCantEvoCondition(Hashtable hashtable)
  91. {
  92. return CardEffectCommons.IsPermanentExistsOnBattleArea(playedDigimon);
  93. }
  94. bool PermanentCondition(Permanent permanent)
  95. {
  96. return permanent == playedDigimon;
  97. }
  98. bool CardCondition(CardSource cardSource)
  99. {
  100. return true;
  101. }
  102. #endregion
  103. #region Delete Played Digimon
  104. Permanent selectedPermanent = selectCard.PermanentOfThisCard();
  105. ActivateClass activateClass1 = new ActivateClass();
  106. activateClass1.SetUpICardEffect("Delete this Digimon", CanUseCondition2, card);
  107. activateClass1.SetUpActivateClass(CanActivateCondition1, ActivateCoroutine1, -1, false, "");
  108. activateClass1.SetEffectSourcePermanent(selectedPermanent);
  109. CardEffectCommons.AddEffectToPlayer(effectDuration: EffectDuration.UntilEachTurnEnd, card: card, cardEffect: activateClass1, timing: EffectTiming.OnEndTurn);
  110. bool CanUseCondition2(Hashtable hashtable)
  111. {
  112. return true;
  113. }
  114. bool CanActivateCondition1(Hashtable hashtable)
  115. {
  116. return selectedPermanent.TopCard != null
  117. && selectedPermanent.CanBeDestroyedBySkill(activateClass1)
  118. && !selectedPermanent.TopCard.CanNotBeAffected(activateClass1);
  119. }
  120. IEnumerator ActivateCoroutine1(Hashtable _hashtable1)
  121. {
  122. yield return ContinuousController.instance.StartCoroutine(new DestroyPermanentsClass(new List<Permanent>() { selectedPermanent }, CardEffectCommons.CardEffectHashtable(activateClass1)).Destroy());
  123. }
  124. #endregion
  125. }
  126. }
  127. }
  128. #endregion
  129. #region On Deletion
  130. if (timing == EffectTiming.OnDestroyedAnyone)
  131. {
  132. ActivateClass activateClass = new ActivateClass();
  133. activateClass.SetUpICardEffect("Play a Dark Master from Security", CanUseCondition, card);
  134. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  135. cardEffects.Add(activateClass);
  136. string EffectDiscription()
  137. {
  138. return "[On Deletion] You may play 1 face-up [Dark Masters] trait Digimon card from your security stack without paying the cost. At the end of your turn, delete the Digimon this effect played.";
  139. }
  140. bool CanSelectCardCondition(CardSource cardSource)
  141. {
  142. return cardSource.IsDigimon && !cardSource.IsFlipped &&
  143. cardSource.EqualsTraits("Dark Masters") &&
  144. CardEffectCommons.CanPlayAsNewPermanent(cardSource, false, activateClass, SelectCardEffect.Root.Security);
  145. }
  146. bool CanUseCondition(Hashtable hashtable)
  147. {
  148. return CardEffectCommons.CanTriggerOnDeletion(hashtable, card, activateClass);
  149. }
  150. bool CanActivateCondition(Hashtable hashtable)
  151. {
  152. return CardEffectCommons.CanActivateOnDeletion(card, activateClass)
  153. && card.Owner.SecurityCards.Any(CanSelectCardCondition);
  154. }
  155. IEnumerator ActivateCoroutine(Hashtable hashtable)
  156. {
  157. List<CardSource> selectedCards = new List<CardSource>();
  158. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  159. selectCardEffect.SetUp(
  160. canTargetCondition: CanSelectCardCondition,
  161. canTargetCondition_ByPreSelecetedList: null,
  162. canEndSelectCondition: null,
  163. canNoSelect: () => true,
  164. selectCardCoroutine: SelectCardCoroutine,
  165. afterSelectCardCoroutine: null,
  166. message: "Select 1 card to play.",
  167. maxCount: 1,
  168. canEndNotMax: false,
  169. isShowOpponent: true,
  170. mode: SelectCardEffect.Mode.Custom,
  171. root: SelectCardEffect.Root.Security,
  172. customRootCardList: null,
  173. canLookReverseCard: false,
  174. selectPlayer: card.Owner,
  175. cardEffect: activateClass);
  176. selectCardEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  177. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  178. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  179. IEnumerator SelectCardCoroutine(CardSource cardSource)
  180. {
  181. selectedCards.Add(cardSource);
  182. yield return null;
  183. }
  184. if (selectedCards.Count > 0)
  185. {
  186. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  187. cardSources: selectedCards,
  188. activateClass: activateClass,
  189. payCost: false,
  190. isTapped: false,
  191. root: SelectCardEffect.Root.Security,
  192. activateETB: true));
  193. #region Delete Played Digimon
  194. Permanent selectedPermanent = selectedCards[0].PermanentOfThisCard();
  195. ActivateClass activateClass1 = new ActivateClass();
  196. activateClass1.SetUpICardEffect("Delete this Digimon", CanUseCondition2, card);
  197. activateClass1.SetUpActivateClass(CanActivateCondition1, ActivateCoroutine1, -1, false, "");
  198. activateClass1.SetEffectSourcePermanent(selectedPermanent);
  199. CardEffectCommons.AddEffectToPlayer(effectDuration: EffectDuration.UntilOwnerTurnEnd, card: card, cardEffect: activateClass1, timing: EffectTiming.OnEndTurn);
  200. bool CanUseCondition2(Hashtable hashtable)
  201. {
  202. return CardEffectCommons.IsOwnerTurn(card);
  203. }
  204. bool CanActivateCondition1(Hashtable hashtable)
  205. {
  206. return selectedPermanent.TopCard != null
  207. && selectedPermanent.CanBeDestroyedBySkill(activateClass1)
  208. && !selectedPermanent.TopCard.CanNotBeAffected(activateClass1);
  209. }
  210. IEnumerator ActivateCoroutine1(Hashtable _hashtable1)
  211. {
  212. yield return ContinuousController.instance.StartCoroutine(new DestroyPermanentsClass(new List<Permanent>() { selectedPermanent }, CardEffectCommons.CardEffectHashtable(activateClass1)).Destroy());
  213. }
  214. #endregion
  215. }
  216. }
  217. }
  218. #endregion
  219. #region Blocker - ESS
  220. if (timing == EffectTiming.None)
  221. {
  222. cardEffects.Add(CardEffectFactory.BlockerSelfStaticEffect(isInheritedEffect: true, card: card, condition: null));
  223. }
  224. #endregion
  225. return cardEffects;
  226. }
  227. }
  228. }