BT18_062.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.BT18
  6. {
  7. public class BT18_062 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region On Play
  13. if (timing == EffectTiming.OnEnterFieldAnyone)
  14. {
  15. ActivateClass activateClass = new ActivateClass();
  16. activateClass.SetUpICardEffect("Trash 1 card to give effects", CanUseCondition, card);
  17. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  18. cardEffects.Add(activateClass);
  19. string EffectDiscription()
  20. {
  21. return "[On Play] By trashing 1 card with [Knightmon] in its text in your hand, 1 of your Digimon can't be deleted by your opponent's effects until the end of their turn.";
  22. }
  23. bool CanSelectCardCondition(CardSource cardSource)
  24. {
  25. if (cardSource.HasText("Knightmon"))
  26. {
  27. return true;
  28. }
  29. return false;
  30. }
  31. bool CanSelectPermanentCondition(Permanent permanent)
  32. {
  33. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card);
  34. }
  35. bool CanUseCondition(Hashtable hashtable)
  36. {
  37. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  38. }
  39. bool CanActivateCondition(Hashtable hashtable)
  40. {
  41. if (CardEffectCommons.IsExistOnBattleArea(card))
  42. {
  43. if (card.Owner.HandCards.Count >= 1)
  44. {
  45. return true;
  46. }
  47. }
  48. return false;
  49. }
  50. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  51. {
  52. if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  53. {
  54. bool discarded = false;
  55. int discardCount = 1;
  56. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  57. selectHandEffect.SetUp(
  58. selectPlayer: card.Owner,
  59. canTargetCondition: CanSelectCardCondition,
  60. canTargetCondition_ByPreSelecetedList: null,
  61. canEndSelectCondition: null,
  62. maxCount: discardCount,
  63. canNoSelect: true,
  64. canEndNotMax: false,
  65. isShowOpponent: true,
  66. selectCardCoroutine: null,
  67. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  68. mode: SelectHandEffect.Mode.Discard,
  69. cardEffect: activateClass);
  70. yield return StartCoroutine(selectHandEffect.Activate());
  71. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  72. {
  73. if (cardSources.Count >= 1)
  74. {
  75. discarded = true;
  76. yield return null;
  77. }
  78. }
  79. if (discarded)
  80. {
  81. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  82. {
  83. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  84. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  85. selectPermanentEffect.SetUp(
  86. selectPlayer: card.Owner,
  87. canTargetCondition: CanSelectPermanentCondition,
  88. canTargetCondition_ByPreSelecetedList: null,
  89. canEndSelectCondition: null,
  90. maxCount: maxCount,
  91. canNoSelect: false,
  92. canEndNotMax: false,
  93. selectPermanentCoroutine: SelectPermanentCoroutine,
  94. afterSelectPermanentCoroutine: null,
  95. mode: SelectPermanentEffect.Mode.Custom,
  96. cardEffect: activateClass);
  97. selectPermanentEffect.SetUpCustomMessage(
  98. "Select 1 Digimon that will get effects.",
  99. "The opponent is selecting 1 Digimon that will get effects.");
  100. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  101. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  102. {
  103. bool CardEffectCondition(ICardEffect cardEffect)
  104. {
  105. return CardEffectCommons.IsOpponentEffect(cardEffect, card);
  106. }
  107. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainCanNotBeDeletedByEffect(
  108. targetPermanent: permanent,
  109. cardEffectCondition: CardEffectCondition,
  110. effectDuration: EffectDuration.UntilOpponentTurnEnd,
  111. activateClass: activateClass,
  112. effectName: "Can't be deleted by opponent's effects"));
  113. }
  114. }
  115. }
  116. }
  117. }
  118. }
  119. #endregion
  120. #region When Digivolving
  121. if (timing == EffectTiming.OnEnterFieldAnyone)
  122. {
  123. ActivateClass activateClass = new ActivateClass();
  124. activateClass.SetUpICardEffect("Trash 1 card to give effects", CanUseCondition, card);
  125. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  126. cardEffects.Add(activateClass);
  127. string EffectDiscription()
  128. {
  129. return "[When Digivolving] By trashing 1 card with [Knightmon] in its text in your hand, 1 of your Digimon can't be deleted by your opponent's effects until the end of their turn.";
  130. }
  131. bool CanSelectCardCondition(CardSource cardSource)
  132. {
  133. if (cardSource.HasText("Knightmon"))
  134. {
  135. return true;
  136. }
  137. return false;
  138. }
  139. bool CanSelectPermanentCondition(Permanent permanent)
  140. {
  141. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card);
  142. }
  143. bool CanUseCondition(Hashtable hashtable)
  144. {
  145. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  146. }
  147. bool CanActivateCondition(Hashtable hashtable)
  148. {
  149. if (CardEffectCommons.IsExistOnBattleArea(card))
  150. {
  151. if (card.Owner.HandCards.Count >= 1)
  152. {
  153. return true;
  154. }
  155. }
  156. return false;
  157. }
  158. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  159. {
  160. if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  161. {
  162. bool discarded = false;
  163. int discardCount = 1;
  164. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  165. selectHandEffect.SetUp(
  166. selectPlayer: card.Owner,
  167. canTargetCondition: CanSelectCardCondition,
  168. canTargetCondition_ByPreSelecetedList: null,
  169. canEndSelectCondition: null,
  170. maxCount: discardCount,
  171. canNoSelect: true,
  172. canEndNotMax: false,
  173. isShowOpponent: true,
  174. selectCardCoroutine: null,
  175. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  176. mode: SelectHandEffect.Mode.Discard,
  177. cardEffect: activateClass);
  178. yield return StartCoroutine(selectHandEffect.Activate());
  179. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  180. {
  181. if (cardSources.Count >= 1)
  182. {
  183. discarded = true;
  184. yield return null;
  185. }
  186. }
  187. if (discarded)
  188. {
  189. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  190. {
  191. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  192. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  193. selectPermanentEffect.SetUp(
  194. selectPlayer: card.Owner,
  195. canTargetCondition: CanSelectPermanentCondition,
  196. canTargetCondition_ByPreSelecetedList: null,
  197. canEndSelectCondition: null,
  198. maxCount: maxCount,
  199. canNoSelect: false,
  200. canEndNotMax: false,
  201. selectPermanentCoroutine: SelectPermanentCoroutine,
  202. afterSelectPermanentCoroutine: null,
  203. mode: SelectPermanentEffect.Mode.Custom,
  204. cardEffect: activateClass);
  205. selectPermanentEffect.SetUpCustomMessage(
  206. "Select 1 Digimon that will get effects.",
  207. "The opponent is selecting 1 Digimon that will get effects.");
  208. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  209. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  210. {
  211. bool CardEffectCondition(ICardEffect cardEffect)
  212. {
  213. return CardEffectCommons.IsOpponentEffect(cardEffect, card);
  214. }
  215. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainCanNotBeDeletedByEffect(
  216. targetPermanent: permanent,
  217. cardEffectCondition: CardEffectCondition,
  218. effectDuration: EffectDuration.UntilOpponentTurnEnd,
  219. activateClass: activateClass,
  220. effectName: "Can't be deleted by opponent's effects"));
  221. }
  222. }
  223. }
  224. }
  225. }
  226. }
  227. #endregion
  228. #region All Turn - ESS
  229. if (timing == EffectTiming.None)
  230. {
  231. cardEffects.Add(CardEffectFactory.ChangeSelfDPStaticEffect(changeValue: 1000, isInheritedEffect: true, card: card, condition: null));
  232. }
  233. #endregion
  234. return cardEffects;
  235. }
  236. }
  237. }