BT15_061.cs 14 KB

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