EX6_053.cs 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356
  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_053 : CEntity_Effect
  11. {
  12. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  13. {
  14. List<ICardEffect> cardEffects = new List<ICardEffect>();
  15. #region Retaliation
  16. if(timing == EffectTiming.OnDestroyedAnyone)
  17. {
  18. cardEffects.Add(CardEffectFactory.RetaliationSelfEffect(isInheritedEffect: false, card: card, condition: null));
  19. }
  20. #endregion
  21. #region On Play
  22. if (timing == EffectTiming.OnEnterFieldAnyone)
  23. {
  24. ActivateClass activateClass = new ActivateClass();
  25. activateClass.SetUpICardEffect("Delete 1 of your opponent's level 4 or lower Digimon/Play 1 [Mirei Mikagura]", CanUseCondition, card);
  26. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  27. cardEffects.Add(activateClass);
  28. string EffectDiscription()
  29. {
  30. return "[On Play] If you have a [Mirei Mikagura], delete 1 of your opponent's level 4 or lower Digimon. If you don't have a [Mirei Mikagura], you may play 1 [Mirei Mikagura] from your trash without paying the cost.";
  31. }
  32. bool CanUseCondition(Hashtable hashtable)
  33. {
  34. return CardEffectCommons.CanTriggerOnPlay(hashtable,card);
  35. }
  36. bool CanSelectCardCondition(CardSource cardSource)
  37. {
  38. if (cardSource != null)
  39. {
  40. if (cardSource.CardNames.Contains("Mirei Mikagura") || cardSource.CardNames.Contains("MireiMikagura"))
  41. {
  42. if (cardSource.Owner == card.Owner)
  43. {
  44. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  45. {
  46. return true;
  47. }
  48. }
  49. }
  50. }
  51. return false;
  52. }
  53. bool CanSelectPermanentCondition(Permanent permanent)
  54. {
  55. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  56. {
  57. if (permanent.Level <= 4 && permanent.IsDigimon)
  58. {
  59. return true;
  60. }
  61. }
  62. return false;
  63. }
  64. bool CanActivateCondition(Hashtable hashtable)
  65. {
  66. if (CardEffectCommons.IsExistOnBattleArea(card))
  67. {
  68. if (card.Owner.TrashCards.Count >= 1)
  69. {
  70. if (card.Owner.GetBattleAreaPermanents().Count((permanent) => permanent.TopCard.CardNames.Contains("Mirei Mikagura") || permanent.TopCard.CardNames.Contains("MireiMikagura")) == 0)
  71. {
  72. return true;
  73. }
  74. }
  75. if(CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  76. {
  77. return true;
  78. }
  79. }
  80. return false; ;
  81. }
  82. IEnumerator ActivateCoroutine(Hashtable hashtable)
  83. {
  84. bool justPlayedMirei = false;
  85. if(card.Owner.GetBattleAreaPermanents().Count((permanent) => permanent.TopCard.CardNames.Contains("Mirei Mikagura") || permanent.TopCard.CardNames.Contains("MireiMikagura")) == 0)
  86. {
  87. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  88. {
  89. int maxCount = Math.Min(1, card.Owner.TrashCards.Count(CanSelectCardCondition));
  90. List<CardSource> selectedCards = new List<CardSource>();
  91. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  92. selectCardEffect.SetUp(
  93. canTargetCondition: CanSelectCardCondition,
  94. canTargetCondition_ByPreSelecetedList: null,
  95. canEndSelectCondition: null,
  96. canNoSelect: () => true,
  97. selectCardCoroutine: SelectCardCoroutine,
  98. afterSelectCardCoroutine: null,
  99. message: "Select 1 card to play.",
  100. maxCount: maxCount,
  101. canEndNotMax: false,
  102. isShowOpponent: true,
  103. mode: SelectCardEffect.Mode.Custom,
  104. root: SelectCardEffect.Root.Trash,
  105. customRootCardList: null,
  106. canLookReverseCard: true,
  107. selectPlayer: card.Owner,
  108. cardEffect: activateClass);
  109. selectCardEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  110. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  111. yield return StartCoroutine(selectCardEffect.Activate());
  112. IEnumerator SelectCardCoroutine(CardSource cardSource)
  113. {
  114. selectedCards.Add(cardSource);
  115. yield return null;
  116. }
  117. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  118. cardSources: selectedCards,
  119. activateClass: activateClass,
  120. payCost: false,
  121. isTapped: false,
  122. root: SelectCardEffect.Root.Trash,
  123. activateETB: true));
  124. justPlayedMirei = true;
  125. }
  126. }
  127. if (card.Owner.GetBattleAreaPermanents().Count((permanent) => permanent.TopCard.CardNames.Contains("Mirei Mikagura") || permanent.TopCard.CardNames.Contains("MireiMikagura")) >= 1 && justPlayedMirei == false)
  128. {
  129. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  130. {
  131. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  132. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  133. selectPermanentEffect.SetUp(
  134. selectPlayer: card.Owner,
  135. canTargetCondition: CanSelectPermanentCondition,
  136. canTargetCondition_ByPreSelecetedList: null,
  137. canEndSelectCondition: null,
  138. maxCount: maxCount,
  139. canNoSelect: false,
  140. canEndNotMax: false,
  141. selectPermanentCoroutine: null,
  142. afterSelectPermanentCoroutine: null,
  143. mode: SelectPermanentEffect.Mode.Destroy,
  144. cardEffect: activateClass);
  145. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  146. }
  147. }
  148. }
  149. }
  150. #endregion
  151. #region When Digivolving
  152. if (timing == EffectTiming.OnEnterFieldAnyone)
  153. {
  154. ActivateClass activateClass = new ActivateClass();
  155. activateClass.SetUpICardEffect("Delete 1 of your opponent's level 4 or lower Digimon/Play 1 [Mirei Mikagura]", CanUseCondition, card);
  156. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  157. cardEffects.Add(activateClass);
  158. string EffectDiscription()
  159. {
  160. return "[When Digivolving] If you have a [Mirei Mikagura], delete 1 of your opponent's level 4 or lower Digimon. If you don't have a [Mirei Mikagura], you may play 1 [Mirei Mikagura] from your trash without paying the cost.";
  161. }
  162. bool CanUseCondition(Hashtable hashtable)
  163. {
  164. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  165. }
  166. bool CanSelectCardCondition(CardSource cardSource)
  167. {
  168. if (cardSource != null)
  169. {
  170. if (cardSource.CardNames.Contains("Mirei Mikagura") || cardSource.CardNames.Contains("MireiMikagura"))
  171. {
  172. if (cardSource.Owner == card.Owner)
  173. {
  174. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  175. {
  176. return true;
  177. }
  178. }
  179. }
  180. }
  181. return false;
  182. }
  183. bool CanSelectPermanentCondition(Permanent permanent)
  184. {
  185. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  186. {
  187. if (permanent.Level <= 4 && permanent.IsDigimon)
  188. {
  189. return true;
  190. }
  191. }
  192. return false;
  193. }
  194. bool CanActivateCondition(Hashtable hashtable)
  195. {
  196. if (CardEffectCommons.IsExistOnBattleArea(card))
  197. {
  198. if (card.Owner.TrashCards.Count >= 1)
  199. {
  200. if (card.Owner.GetBattleAreaPermanents().Count((permanent) => permanent.TopCard.CardNames.Contains("Mirei Mikagura") || permanent.TopCard.CardNames.Contains("MireiMikagura")) == 0)
  201. {
  202. return true;
  203. }
  204. }
  205. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  206. {
  207. return true;
  208. }
  209. }
  210. return false; ;
  211. }
  212. IEnumerator ActivateCoroutine(Hashtable hashtable)
  213. {
  214. bool justPlayedMirei = false;
  215. if (card.Owner.GetBattleAreaPermanents().Count((permanent) => permanent.TopCard.CardNames.Contains("Mirei Mikagura") || permanent.TopCard.CardNames.Contains("MireiMikagura")) == 0)
  216. {
  217. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  218. {
  219. int maxCount = Math.Min(1, card.Owner.TrashCards.Count(CanSelectCardCondition));
  220. List<CardSource> selectedCards = new List<CardSource>();
  221. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  222. selectCardEffect.SetUp(
  223. canTargetCondition: CanSelectCardCondition,
  224. canTargetCondition_ByPreSelecetedList: null,
  225. canEndSelectCondition: null,
  226. canNoSelect: () => true,
  227. selectCardCoroutine: SelectCardCoroutine,
  228. afterSelectCardCoroutine: null,
  229. message: "Select 1 card to play.",
  230. maxCount: maxCount,
  231. canEndNotMax: false,
  232. isShowOpponent: true,
  233. mode: SelectCardEffect.Mode.Custom,
  234. root: SelectCardEffect.Root.Trash,
  235. customRootCardList: null,
  236. canLookReverseCard: true,
  237. selectPlayer: card.Owner,
  238. cardEffect: activateClass);
  239. selectCardEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  240. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  241. yield return StartCoroutine(selectCardEffect.Activate());
  242. IEnumerator SelectCardCoroutine(CardSource cardSource)
  243. {
  244. selectedCards.Add(cardSource);
  245. yield return null;
  246. }
  247. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  248. cardSources: selectedCards,
  249. activateClass: activateClass,
  250. payCost: false,
  251. isTapped: false,
  252. root: SelectCardEffect.Root.Trash,
  253. activateETB: true));
  254. justPlayedMirei = true;
  255. }
  256. }
  257. if (card.Owner.GetBattleAreaPermanents().Count((permanent) => permanent.TopCard.CardNames.Contains("Mirei Mikagura") || permanent.TopCard.CardNames.Contains("MireiMikagura")) >= 1 && justPlayedMirei == false)
  258. {
  259. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  260. {
  261. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  262. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  263. selectPermanentEffect.SetUp(
  264. selectPlayer: card.Owner,
  265. canTargetCondition: CanSelectPermanentCondition,
  266. canTargetCondition_ByPreSelecetedList: null,
  267. canEndSelectCondition: null,
  268. maxCount: maxCount,
  269. canNoSelect: false,
  270. canEndNotMax: false,
  271. selectPermanentCoroutine: null,
  272. afterSelectPermanentCoroutine: null,
  273. mode: SelectPermanentEffect.Mode.Destroy,
  274. cardEffect: activateClass);
  275. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  276. }
  277. }
  278. }
  279. }
  280. #endregion
  281. #region Inherit
  282. if (timing == EffectTiming.WhenPermanentWouldBeDeleted)
  283. {
  284. string EffectDiscription()
  285. {
  286. return "<Scapegoat> (When this Digimon would be deleted other than by your own effects, by deleting 1 of your other Digimon, prevent that deletion.)";
  287. }
  288. bool Condition()
  289. {
  290. if(card.PermanentOfThisCard().TopCard.CardTraits.Contains("Angel") || card.PermanentOfThisCard().TopCard.CardTraits.Contains("Seven Great Demon Lords") || card.PermanentOfThisCard().TopCard.CardTraits.Contains("SevenGreatDemonLords"))
  291. {
  292. return true;
  293. }
  294. return false;
  295. }
  296. cardEffects.Add(CardEffectFactory.ScapegoatSelfEffect(isInheritedEffect: true, card: card, condition: Condition, effectName: "<Scapegoat>", effectDiscription: EffectDiscription()));
  297. }
  298. #endregion
  299. return cardEffects;
  300. }
  301. }
  302. }