BT19_065.cs 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395
  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 Digiolving
  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);
  192. }
  193. bool CanActivateCondition(Hashtable hashtable)
  194. {
  195. return CardEffectCommons.CanActivateOnDeletion(card) &&
  196. CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, IsTargetableDigimon);
  197. }
  198. IEnumerator ActivateCoroutine(Hashtable hashtable)
  199. {
  200. CardSource playedSource = null;
  201. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  202. selectCardEffect.SetUp(
  203. canTargetCondition: IsTargetableDigimon,
  204. canTargetCondition_ByPreSelecetedList: null,
  205. canEndSelectCondition: null,
  206. canNoSelect: () => false,
  207. selectCardCoroutine: SelectCardCoroutine,
  208. afterSelectCardCoroutine: null,
  209. message: "Select 1 Digimon to play.",
  210. maxCount: 1,
  211. canEndNotMax: false,
  212. isShowOpponent: false,
  213. mode: SelectCardEffect.Mode.Custom,
  214. root: SelectCardEffect.Root.Trash,
  215. customRootCardList: null,
  216. canLookReverseCard: true,
  217. selectPlayer: card.Owner,
  218. cardEffect: activateClass);
  219. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  220. IEnumerator SelectCardCoroutine(CardSource source)
  221. {
  222. PlayCardClass playCard = new PlayCardClass(
  223. cardSources: new List<CardSource>() { source },
  224. hashtable: CardEffectCommons.CardEffectHashtable(activateClass),
  225. payCost: false,
  226. targetPermanent: null,
  227. isTapped: false,
  228. root: SelectCardEffect.Root.Trash,
  229. activateETB: true);
  230. yield return ContinuousController.instance.StartCoroutine(playCard.PlayCard());
  231. }
  232. }
  233. }
  234. #endregion
  235. #region Opponents Turn - ESS
  236. if (timing == EffectTiming.OnAllyAttack)
  237. {
  238. ActivateClass activateClass = new ActivateClass();
  239. activateClass.SetUpICardEffect("Switch attack target", CanUseCondition, card);
  240. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  241. activateClass.SetHashString("SwitchTarget_BT18-073");
  242. activateClass.SetIsInheritedEffect(true);
  243. cardEffects.Add(activateClass);
  244. string EffectDiscription()
  245. {
  246. 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.";
  247. }
  248. bool CanSelectPermanentCondition(Permanent permanent)
  249. {
  250. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card) &&
  251. (permanent.TopCard.EqualsTraits("Composite") || permanent.TopCard.EqualsTraits("Wicked God"));
  252. }
  253. bool PermanentCondition(Permanent permanent)
  254. {
  255. return CardEffectCommons.IsOpponentPermanent(permanent, card);
  256. }
  257. bool CanUseCondition(Hashtable hashtable)
  258. {
  259. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  260. {
  261. if (CardEffectCommons.IsOpponentTurn(card))
  262. {
  263. if (CardEffectCommons.CanTriggerOnPermanentAttack(hashtable, PermanentCondition))
  264. {
  265. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  266. {
  267. return true;
  268. }
  269. }
  270. }
  271. }
  272. return false;
  273. }
  274. bool CanActivateCondition(Hashtable hashtable)
  275. {
  276. if (CardEffectCommons.IsExistOnBattleArea(card))
  277. {
  278. if (GManager.instance.attackProcess.IsAttacking)
  279. {
  280. if (GManager.instance.attackProcess.AttackingPermanent.CanSwitchAttackTarget)
  281. {
  282. return true;
  283. }
  284. }
  285. }
  286. return false;
  287. }
  288. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  289. {
  290. if (CardEffectCommons.IsExistOnBattleArea(card))
  291. {
  292. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleArea(GManager.instance.attackProcess.AttackingPermanent, card))
  293. {
  294. if (GManager.instance.attackProcess.IsAttacking)
  295. {
  296. if (GManager.instance.attackProcess.AttackingPermanent.CanSwitchAttackTarget)
  297. {
  298. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  299. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  300. selectPermanentEffect.SetUp(
  301. selectPlayer: card.Owner,
  302. canTargetCondition: CanSelectPermanentCondition,
  303. canTargetCondition_ByPreSelecetedList: null,
  304. canEndSelectCondition: null,
  305. maxCount: maxCount,
  306. canNoSelect: false,
  307. canEndNotMax: false,
  308. selectPermanentCoroutine: SelectPermanentCoroutine,
  309. afterSelectPermanentCoroutine: null,
  310. mode: SelectPermanentEffect.Mode.Custom,
  311. cardEffect: activateClass);
  312. selectPermanentEffect.SetUpCustomMessage(
  313. "Select 1 Digimon to switch the attack to.",
  314. "The opponent is selecting 1 Digimon to switch the attack to.");
  315. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  316. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  317. {
  318. yield return ContinuousController.instance.StartCoroutine(GManager.instance.attackProcess.SwitchDefender(
  319. activateClass,
  320. false,
  321. permanent));
  322. }
  323. }
  324. }
  325. }
  326. }
  327. }
  328. }
  329. #endregion
  330. return cardEffects;
  331. }
  332. }
  333. }