BT19_065.cs 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. namespace DCGO.CardEffects.BT19
  5. {
  6. public class BT19_065 : CEntity_Effect
  7. {
  8. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  9. {
  10. List<ICardEffect> cardEffects = new List<ICardEffect>();
  11. #region DigiXros
  12. if (timing == EffectTiming.None)
  13. {
  14. AddDigiXrosConditionClass addDigiXrosConditionClass = new AddDigiXrosConditionClass();
  15. addDigiXrosConditionClass.SetUpICardEffect($"DigiXros", CanUseCondition, card);
  16. addDigiXrosConditionClass.SetUpAddDigiXrosConditionClass(getDigiXrosCondition: GetDigiXros);
  17. addDigiXrosConditionClass.SetNotShowUI(true);
  18. cardEffects.Add(addDigiXrosConditionClass);
  19. bool CanUseCondition(Hashtable hashtable)
  20. {
  21. return true;
  22. }
  23. DigiXrosCondition GetDigiXros(CardSource cardSource)
  24. {
  25. if (cardSource == card)
  26. {
  27. DigiXrosConditionElement element = new DigiXrosConditionElement(CanSelectCardCondition, "5 Lv.5 or lower [Cyborg]/[Composite] trait Digimon cards w/different card numbers.");
  28. bool CanSelectCardCondition(CardSource cardSource)
  29. {
  30. if (cardSource != null)
  31. {
  32. if (cardSource.Owner == card.Owner)
  33. {
  34. if (cardSource.IsDigimon)
  35. {
  36. if(cardSource.HasLevel && cardSource.Level <= 5)
  37. {
  38. if (cardSource.EqualsTraits("Cyborg"))
  39. {
  40. return true;
  41. }
  42. if (cardSource.EqualsTraits("Composite"))
  43. {
  44. return true;
  45. }
  46. }
  47. }
  48. }
  49. }
  50. return false;
  51. }
  52. List<DigiXrosConditionElement> elements = new List<DigiXrosConditionElement>();
  53. for (int i = 0; i < 5; i++)
  54. {
  55. elements.Add(element);
  56. }
  57. bool CanTargetCondition_ByPreSelecetedList(List<CardSource> cardSources, CardSource cardSource)
  58. {
  59. List<string> cardIDs = new List<string>();
  60. foreach (CardSource cardSource1 in cardSources)
  61. {
  62. if (!cardIDs.Contains(cardSource1.CardID))
  63. {
  64. cardIDs.Add(cardSource1.CardID);
  65. }
  66. }
  67. if (cardIDs.Contains(cardSource.CardID))
  68. {
  69. return false;
  70. }
  71. return true;
  72. }
  73. DigiXrosCondition digiXrosCondition = new DigiXrosCondition(elements, CanTargetCondition_ByPreSelecetedList, 1);
  74. return digiXrosCondition;
  75. }
  76. return null;
  77. }
  78. }
  79. #endregion
  80. #region On Play
  81. if (timing == EffectTiming.OnEnterFieldAnyone)
  82. {
  83. ActivateClass activateClass = new ActivateClass();
  84. activateClass.SetUpICardEffect("Delete 1 level 5 or lower Digimon", CanUseCondition, card);
  85. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  86. cardEffects.Add(activateClass);
  87. string EffectDiscription()
  88. {
  89. return "[On Play] Delete 1 level 5 or lower Digimon.";
  90. }
  91. bool IsLevel5Digimon(Permanent permanent)
  92. {
  93. return CardEffectCommons.IsPermanentExistsOnBattleAreaDigimon(permanent) &&
  94. permanent.TopCard.HasLevel && permanent.TopCard.Level <= 5;
  95. }
  96. bool CanUseCondition(Hashtable hashtable)
  97. {
  98. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  99. }
  100. bool CanActivateCondition(Hashtable hashtable)
  101. {
  102. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  103. CardEffectCommons.HasMatchConditionPermanent(IsLevel5Digimon);
  104. }
  105. IEnumerator ActivateCoroutine(Hashtable hashtable)
  106. {
  107. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  108. selectPermanentEffect.SetUp(
  109. selectPlayer: card.Owner,
  110. canTargetCondition: IsLevel5Digimon,
  111. canTargetCondition_ByPreSelecetedList: null,
  112. canEndSelectCondition: null,
  113. maxCount: 1,
  114. canNoSelect: false,
  115. canEndNotMax: false,
  116. selectPermanentCoroutine: null,
  117. afterSelectPermanentCoroutine: null,
  118. mode: SelectPermanentEffect.Mode.Destroy,
  119. cardEffect: activateClass);
  120. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to delete.","The opponent is selecting 1 Digimon to delete.");
  121. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  122. }
  123. }
  124. #endregion
  125. #region When Digivolving
  126. if (timing == EffectTiming.OnEnterFieldAnyone)
  127. {
  128. ActivateClass activateClass = new ActivateClass();
  129. activateClass.SetUpICardEffect("Delete 1 level 5 or lower Digimon", CanUseCondition, card);
  130. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  131. cardEffects.Add(activateClass);
  132. string EffectDiscription()
  133. {
  134. return "[When Digivolving] Delete 1 level 5 or lower Digimon.";
  135. }
  136. bool IsLevel5Digimon(Permanent permanent)
  137. {
  138. return CardEffectCommons.IsPermanentExistsOnBattleAreaDigimon(permanent) &&
  139. permanent.TopCard.HasLevel && permanent.TopCard.Level <= 5;
  140. }
  141. bool CanUseCondition(Hashtable hashtable)
  142. {
  143. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  144. CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  145. }
  146. bool CanActivateCondition(Hashtable hashtable)
  147. {
  148. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  149. CardEffectCommons.HasMatchConditionPermanent(IsLevel5Digimon);
  150. }
  151. IEnumerator ActivateCoroutine(Hashtable hashtable)
  152. {
  153. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  154. selectPermanentEffect.SetUp(
  155. selectPlayer: card.Owner,
  156. canTargetCondition: IsLevel5Digimon,
  157. canTargetCondition_ByPreSelecetedList: null,
  158. canEndSelectCondition: null,
  159. maxCount: 1,
  160. canNoSelect: false,
  161. canEndNotMax: false,
  162. selectPermanentCoroutine: null,
  163. afterSelectPermanentCoroutine: null,
  164. mode: SelectPermanentEffect.Mode.Destroy,
  165. cardEffect: activateClass);
  166. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to delete.", "The opponent is selecting 1 Digimon to delete.");
  167. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  168. }
  169. }
  170. #endregion
  171. #region On Deletion
  172. if (timing == EffectTiming.OnDestroyedAnyone)
  173. {
  174. ActivateClass activateClass = new ActivateClass();
  175. activateClass.SetUpICardEffect("Play 1 level 5 or lower digimon from trash", CanUseCondition, card);
  176. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  177. cardEffects.Add(activateClass);
  178. string EffectDiscription()
  179. {
  180. return "[On Deletion] You may play 1 level 5 or lower Digimon card with the [Cyborg] or [Composite] trait from your trash without paying the cost.";
  181. }
  182. bool IsTargetableDigimon(CardSource source)
  183. {
  184. return source.IsDigimon &&
  185. source.HasLevel && source.Level <= 5 &&
  186. (source.EqualsTraits("Cyborg") || source.EqualsTraits("Composite")) &&
  187. CardEffectCommons.CanPlayAsNewPermanent(source, false, activateClass,SelectCardEffect.Root.Trash);
  188. }
  189. bool CanUseCondition(Hashtable hashtable)
  190. {
  191. return CardEffectCommons.CanTriggerOnDeletion(hashtable, card, activateClass);
  192. }
  193. bool CanActivateCondition(Hashtable hashtable)
  194. {
  195. return CardEffectCommons.CanActivateOnDeletion(card, activateClass) &&
  196. CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, IsTargetableDigimon);
  197. }
  198. IEnumerator ActivateCoroutine(Hashtable hashtable)
  199. {
  200. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  201. selectCardEffect.SetUp(
  202. canTargetCondition: IsTargetableDigimon,
  203. canTargetCondition_ByPreSelecetedList: null,
  204. canEndSelectCondition: null,
  205. canNoSelect: () => false,
  206. selectCardCoroutine: SelectCardCoroutine,
  207. afterSelectCardCoroutine: null,
  208. message: "Select 1 Digimon to play.",
  209. maxCount: 1,
  210. canEndNotMax: false,
  211. isShowOpponent: false,
  212. mode: SelectCardEffect.Mode.Custom,
  213. root: SelectCardEffect.Root.Trash,
  214. customRootCardList: null,
  215. canLookReverseCard: true,
  216. selectPlayer: card.Owner,
  217. cardEffect: activateClass);
  218. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  219. IEnumerator SelectCardCoroutine(CardSource source)
  220. {
  221. PlayCardClass playCard = new PlayCardClass(
  222. cardSources: new List<CardSource>() { source },
  223. hashtable: CardEffectCommons.CardEffectHashtable(activateClass),
  224. payCost: false,
  225. targetPermanent: null,
  226. isTapped: false,
  227. root: SelectCardEffect.Root.Trash,
  228. activateETB: true);
  229. yield return ContinuousController.instance.StartCoroutine(playCard.PlayCard());
  230. }
  231. }
  232. }
  233. #endregion
  234. #region Opponents Turn - ESS
  235. if (timing == EffectTiming.OnAllyAttack)
  236. {
  237. ActivateClass activateClass = new ActivateClass();
  238. activateClass.SetUpICardEffect("Switch attack target", CanUseCondition, card);
  239. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  240. activateClass.SetHashString("SwitchTarget_BT18-073");
  241. activateClass.SetIsInheritedEffect(true);
  242. cardEffects.Add(activateClass);
  243. string EffectDiscription()
  244. {
  245. return "[Opponent's Turn] [Once Per Turn] When any of your opponent's Digimon attack, you may change the attack target to 1 of your Digimon with the [Composite] or [Wicked God] trait.";
  246. }
  247. bool CanSelectPermanentCondition(Permanent permanent)
  248. {
  249. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card) &&
  250. (permanent.TopCard.EqualsTraits("Composite") || permanent.TopCard.EqualsTraits("Wicked God"));
  251. }
  252. bool PermanentCondition(Permanent permanent)
  253. {
  254. return CardEffectCommons.IsOpponentPermanent(permanent, card);
  255. }
  256. bool CanUseCondition(Hashtable hashtable)
  257. {
  258. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  259. {
  260. if (CardEffectCommons.IsOpponentTurn(card))
  261. {
  262. if (CardEffectCommons.CanTriggerOnPermanentAttack(hashtable, PermanentCondition))
  263. {
  264. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  265. {
  266. return true;
  267. }
  268. }
  269. }
  270. }
  271. return false;
  272. }
  273. bool CanActivateCondition(Hashtable hashtable)
  274. {
  275. if (CardEffectCommons.IsExistOnBattleArea(card))
  276. {
  277. if (GManager.instance.attackProcess.IsAttacking)
  278. {
  279. if (GManager.instance.attackProcess.AttackingPermanent.CanSwitchAttackTarget)
  280. {
  281. return true;
  282. }
  283. }
  284. }
  285. return false;
  286. }
  287. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  288. {
  289. if (CardEffectCommons.IsExistOnBattleArea(card))
  290. {
  291. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleArea(GManager.instance.attackProcess.AttackingPermanent, card))
  292. {
  293. if (GManager.instance.attackProcess.IsAttacking)
  294. {
  295. if (GManager.instance.attackProcess.AttackingPermanent.CanSwitchAttackTarget)
  296. {
  297. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  298. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  299. selectPermanentEffect.SetUp(
  300. selectPlayer: card.Owner,
  301. canTargetCondition: CanSelectPermanentCondition,
  302. canTargetCondition_ByPreSelecetedList: null,
  303. canEndSelectCondition: null,
  304. maxCount: maxCount,
  305. canNoSelect: false,
  306. canEndNotMax: false,
  307. selectPermanentCoroutine: SelectPermanentCoroutine,
  308. afterSelectPermanentCoroutine: null,
  309. mode: SelectPermanentEffect.Mode.Custom,
  310. cardEffect: activateClass);
  311. selectPermanentEffect.SetUpCustomMessage(
  312. "Select 1 Digimon to switch the attack to.",
  313. "The opponent is selecting 1 Digimon to switch the attack to.");
  314. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  315. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  316. {
  317. yield return ContinuousController.instance.StartCoroutine(GManager.instance.attackProcess.SwitchDefender(
  318. activateClass,
  319. false,
  320. permanent));
  321. }
  322. }
  323. }
  324. }
  325. }
  326. }
  327. }
  328. #endregion
  329. return cardEffects;
  330. }
  331. }
  332. }