EX6_051.cs 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using System.Linq;
  5. using Photon;
  6. using System;
  7. using Photon.Pun;
  8. namespace DCGO.CardEffects.EX6
  9. {
  10. public class EX6_051 : CEntity_Effect
  11. {
  12. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  13. {
  14. List<ICardEffect> cardEffects = new List<ICardEffect>();
  15. #region On Play
  16. if (timing == EffectTiming.OnEnterFieldAnyone)
  17. {
  18. ActivateClass activateClass = new ActivateClass();
  19. activateClass.SetUpICardEffect("Delete 1 opponent level 4 Digimon/Your opponent trashes 1 card", CanUseCondition, card);
  20. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  21. cardEffects.Add(activateClass);
  22. string EffectDiscription()
  23. {
  24. return "[On Play] If your opponent has 5 or fewer cards in their hand, delete 1 of their level 4 or lower Digimon. If your opponent has 7 or more cards in their hand, your opponent trashes 1 card in their hand.";
  25. }
  26. bool CanUseCondition(Hashtable hashtable)
  27. {
  28. return CardEffectCommons.CanTriggerOnPlay(hashtable,card);
  29. }
  30. bool CanSelectPermanentCondition(Permanent permanent)
  31. {
  32. if(CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent,card))
  33. {
  34. if(permanent.Level <= 4 && permanent.IsDigimon)
  35. {
  36. return true;
  37. }
  38. }
  39. return false;
  40. }
  41. bool CanActivateCondition(Hashtable hashtable)
  42. {
  43. if (CardEffectCommons.IsExistOnBattleArea(card))
  44. {
  45. if (card.Owner.Enemy.HandCards.Count <= 5)
  46. {
  47. return true;
  48. }
  49. if (card.Owner.Enemy.HandCards.Count >= 7)
  50. {
  51. return true;
  52. }
  53. }
  54. return false;
  55. }
  56. IEnumerator ActivateCoroutine(Hashtable hashtable)
  57. {
  58. if (card.Owner.Enemy.HandCards.Count <= 5)
  59. {
  60. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  61. {
  62. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  63. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  64. selectPermanentEffect.SetUp(
  65. selectPlayer: card.Owner,
  66. canTargetCondition: CanSelectPermanentCondition,
  67. canTargetCondition_ByPreSelecetedList: null,
  68. canEndSelectCondition: null,
  69. maxCount: maxCount,
  70. canNoSelect: false,
  71. canEndNotMax: false,
  72. selectPermanentCoroutine: null,
  73. afterSelectPermanentCoroutine: null,
  74. mode: SelectPermanentEffect.Mode.Destroy,
  75. cardEffect: activateClass);
  76. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  77. }
  78. }
  79. if (card.Owner.Enemy.HandCards.Count >= 7)
  80. {
  81. int discardCount = 1;
  82. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  83. selectHandEffect.SetUp(
  84. selectPlayer: card.Owner.Enemy,
  85. canTargetCondition: (cardSource) => true,
  86. canTargetCondition_ByPreSelecetedList: null,
  87. canEndSelectCondition: null,
  88. maxCount: discardCount,
  89. canNoSelect: false,
  90. canEndNotMax: false,
  91. isShowOpponent: true,
  92. selectCardCoroutine: null,
  93. afterSelectCardCoroutine: null,
  94. mode: SelectHandEffect.Mode.Discard,
  95. cardEffect: activateClass);
  96. yield return StartCoroutine(selectHandEffect.Activate());
  97. }
  98. }
  99. }
  100. #endregion
  101. #region When Digivolving
  102. if (timing == EffectTiming.OnEnterFieldAnyone)
  103. {
  104. ActivateClass activateClass = new ActivateClass();
  105. activateClass.SetUpICardEffect("Delete 1 opponent level 4 Digimon/Your opponent trashes 1 card", CanUseCondition, card);
  106. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  107. cardEffects.Add(activateClass);
  108. string EffectDiscription()
  109. {
  110. return "[When Digivolving] If your opponent has 5 or fewer cards in their hand, delete 1 of their level 4 or lower Digimon. If your opponent has 7 or more cards in their hand, your opponent trashes 1 card in their hand.";
  111. }
  112. bool CanUseCondition(Hashtable hashtable)
  113. {
  114. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  115. }
  116. bool CanSelectPermanentCondition(Permanent permanent)
  117. {
  118. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  119. {
  120. if (permanent.Level <= 4 && permanent.IsDigimon)
  121. {
  122. return true;
  123. }
  124. }
  125. return false;
  126. }
  127. bool CanActivateCondition(Hashtable hashtable)
  128. {
  129. if (CardEffectCommons.IsExistOnBattleArea(card))
  130. {
  131. if (card.Owner.Enemy.HandCards.Count <= 5)
  132. {
  133. return true;
  134. }
  135. if (card.Owner.Enemy.HandCards.Count >= 7)
  136. {
  137. return true;
  138. }
  139. }
  140. return false;
  141. }
  142. IEnumerator ActivateCoroutine(Hashtable hashtable)
  143. {
  144. if (card.Owner.Enemy.HandCards.Count <= 5)
  145. {
  146. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  147. {
  148. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  149. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  150. selectPermanentEffect.SetUp(
  151. selectPlayer: card.Owner,
  152. canTargetCondition: CanSelectPermanentCondition,
  153. canTargetCondition_ByPreSelecetedList: null,
  154. canEndSelectCondition: null,
  155. maxCount: maxCount,
  156. canNoSelect: false,
  157. canEndNotMax: false,
  158. selectPermanentCoroutine: null,
  159. afterSelectPermanentCoroutine: null,
  160. mode: SelectPermanentEffect.Mode.Destroy,
  161. cardEffect: activateClass);
  162. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  163. }
  164. }
  165. if (card.Owner.Enemy.HandCards.Count >= 7)
  166. {
  167. int discardCount = 1;
  168. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  169. selectHandEffect.SetUp(
  170. selectPlayer: card.Owner.Enemy,
  171. canTargetCondition: (cardSource) => true,
  172. canTargetCondition_ByPreSelecetedList: null,
  173. canEndSelectCondition: null,
  174. maxCount: discardCount,
  175. canNoSelect: false,
  176. canEndNotMax: false,
  177. isShowOpponent: true,
  178. selectCardCoroutine: null,
  179. afterSelectCardCoroutine: null,
  180. mode: SelectHandEffect.Mode.Discard,
  181. cardEffect: activateClass);
  182. yield return StartCoroutine(selectHandEffect.Activate());
  183. }
  184. }
  185. }
  186. #endregion
  187. #region On Deletion
  188. if (timing == EffectTiming.OnDestroyedAnyone)
  189. {
  190. ActivateClass activateClass = new ActivateClass();
  191. activateClass.SetUpICardEffect("Play 1 [DanDevimon] from your trash", CanUseCondition, card);
  192. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  193. cardEffects.Add(activateClass);
  194. string EffectDiscription()
  195. {
  196. return "[On Deletion] If your opponent has 10 or more cards in their trash, you may play 1 [DanDevimon] from your trash without paying the cost.";
  197. }
  198. bool CanUseCondition(Hashtable hashtable)
  199. {
  200. return CardEffectCommons.CanTriggerOnDeletion(hashtable, card, activateClass);
  201. }
  202. bool CanSelectCardInTrash(CardSource cardSource)
  203. {
  204. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  205. {
  206. if (cardSource.CardNames.Contains("DanDevimon"))
  207. {
  208. return true;
  209. }
  210. }
  211. return false;
  212. }
  213. bool CanActivateCondition(Hashtable hashtable)
  214. {
  215. if(card.Owner.Enemy.TrashCards.Count >= 10)
  216. {
  217. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardInTrash))
  218. {
  219. return true;
  220. }
  221. }
  222. return false;
  223. }
  224. IEnumerator ActivateCoroutine(Hashtable hashtable)
  225. {
  226. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardInTrash))
  227. {
  228. int maxCount = Math.Min(1, card.Owner.TrashCards.Count(CanSelectCardInTrash));
  229. List<CardSource> selectedCards = new List<CardSource>();
  230. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  231. selectCardEffect.SetUp(
  232. canTargetCondition: CanSelectCardInTrash,
  233. canTargetCondition_ByPreSelecetedList: null,
  234. canEndSelectCondition: null,
  235. canNoSelect: () => true,
  236. selectCardCoroutine: SelectCardCoroutine,
  237. afterSelectCardCoroutine: null,
  238. message: "Select 1 card to play.",
  239. maxCount: maxCount,
  240. canEndNotMax: false,
  241. isShowOpponent: true,
  242. mode: SelectCardEffect.Mode.Custom,
  243. root: SelectCardEffect.Root.Trash,
  244. customRootCardList: null,
  245. canLookReverseCard: true,
  246. selectPlayer: card.Owner,
  247. cardEffect: activateClass);
  248. selectCardEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  249. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  250. yield return StartCoroutine(selectCardEffect.Activate());
  251. IEnumerator SelectCardCoroutine(CardSource cardSource)
  252. {
  253. selectedCards.Add(cardSource);
  254. yield return null;
  255. }
  256. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  257. cardSources: selectedCards,
  258. activateClass: activateClass,
  259. payCost: false,
  260. isTapped: false,
  261. root: SelectCardEffect.Root.Trash,
  262. activateETB: true));
  263. }
  264. }
  265. }
  266. #endregion
  267. #region Inherit
  268. if (timing == EffectTiming.OnAllyAttack)
  269. {
  270. ActivateClass activateClass = new ActivateClass();
  271. activateClass.SetUpICardEffect("Your opponent trashes 1 card/Play 1 level 3 purple Digimon from your trash.", CanUseCondition, card);
  272. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDiscription());
  273. activateClass.SetHashString("TrashOrPlay_EX6_051");
  274. activateClass.SetIsInheritedEffect(true);
  275. cardEffects.Add(activateClass);
  276. string EffectDiscription()
  277. {
  278. return "[When Attacking] [Once Per Turn] Your opponent may trash 1 card in their hand. If they don't, you may play 1 purple level 3 Digimon card from your trash without paying the cost.";
  279. }
  280. bool CanSelectCardInTrash(CardSource cardSource)
  281. {
  282. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  283. {
  284. if (cardSource.HasCardColor(CardColor.Purple))
  285. {
  286. if (cardSource.IsDigimon)
  287. {
  288. if (cardSource.Level == 3)
  289. {
  290. if (cardSource.HasLevel)
  291. {
  292. return true;
  293. }
  294. }
  295. }
  296. }
  297. }
  298. return false;
  299. }
  300. bool CanUseCondition(Hashtable hashtable)
  301. {
  302. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  303. }
  304. bool CanActivateCondition(Hashtable hashtable)
  305. {
  306. if (CardEffectCommons.IsExistOnBattleArea(card))
  307. {
  308. if (card.Owner.TrashCards.Count >= 1)
  309. {
  310. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardInTrash))
  311. {
  312. return true;
  313. }
  314. }
  315. }
  316. return false;
  317. }
  318. IEnumerator ActivateCoroutine(Hashtable hashtable)
  319. {
  320. bool discarded = false;
  321. if (card.Owner.Enemy.HandCards.Count >= 1)
  322. {
  323. int discardCount = 1;
  324. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  325. selectHandEffect.SetUp(
  326. selectPlayer: card.Owner.Enemy,
  327. canTargetCondition: (cardSource) => true,
  328. canTargetCondition_ByPreSelecetedList: null,
  329. canEndSelectCondition: null,
  330. maxCount: discardCount,
  331. canNoSelect: true,
  332. canEndNotMax: false,
  333. isShowOpponent: true,
  334. selectCardCoroutine: null,
  335. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  336. mode: SelectHandEffect.Mode.Discard,
  337. cardEffect: activateClass);
  338. yield return StartCoroutine(selectHandEffect.Activate());
  339. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  340. {
  341. if (cardSources.Count >= 1)
  342. {
  343. discarded = true;
  344. yield return null;
  345. }
  346. }
  347. }
  348. if (!discarded)
  349. {
  350. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardInTrash))
  351. {
  352. int maxCount = Math.Min(1, card.Owner.TrashCards.Count(CanSelectCardInTrash));
  353. List<CardSource> selectedCards = new List<CardSource>();
  354. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  355. selectCardEffect.SetUp(
  356. canTargetCondition: CanSelectCardInTrash,
  357. canTargetCondition_ByPreSelecetedList: null,
  358. canEndSelectCondition: null,
  359. canNoSelect: () => true,
  360. selectCardCoroutine: SelectCardCoroutine,
  361. afterSelectCardCoroutine: null,
  362. message: "Select 1 card to play.",
  363. maxCount: maxCount,
  364. canEndNotMax: false,
  365. isShowOpponent: true,
  366. mode: SelectCardEffect.Mode.Custom,
  367. root: SelectCardEffect.Root.Trash,
  368. customRootCardList: null,
  369. canLookReverseCard: true,
  370. selectPlayer: card.Owner,
  371. cardEffect: activateClass);
  372. selectCardEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  373. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  374. yield return StartCoroutine(selectCardEffect.Activate());
  375. IEnumerator SelectCardCoroutine(CardSource cardSource)
  376. {
  377. selectedCards.Add(cardSource);
  378. yield return null;
  379. }
  380. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  381. cardSources: selectedCards,
  382. activateClass: activateClass,
  383. payCost: false,
  384. isTapped: false,
  385. root: SelectCardEffect.Root.Trash,
  386. activateETB: true));
  387. }
  388. }
  389. }
  390. }
  391. #endregion
  392. return cardEffects;
  393. }
  394. }
  395. }