EX6_022.cs 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.EX6
  6. {
  7. public class EX6_022 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Barrier
  13. if (timing == EffectTiming.WhenPermanentWouldBeDeleted)
  14. {
  15. cardEffects.Add(CardEffectFactory.BarrierSelfEffect(isInheritedEffect: false, card: card, condition: null));
  16. }
  17. #endregion
  18. #region On PLay
  19. if (timing == EffectTiming.OnEnterFieldAnyone)
  20. {
  21. ActivateClass activateClass = new ActivateClass();
  22. activateClass.SetUpICardEffect("Give a Digimon Security Attack -2 or play [Mirei Mikagura] from hand", CanUseCondition, card);
  23. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  24. cardEffects.Add(activateClass);
  25. string EffectDiscription()
  26. {
  27. return "[On Play] If you have a [Mirei Mikagura], 1 of your opponent's Digimon gains Security Attack -2 until the end of their turn. If you don't have a [Mirei Mikagura], you may play 1 [Mirei Mikagura] from your hand without paying the cost.";
  28. }
  29. bool CanSelectCardCondition(CardSource cardSource)
  30. {
  31. if (cardSource.CardNames.Contains("Mirei Mikagura") || cardSource.CardNames.Contains("MireiMikagura"))
  32. {
  33. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  34. {
  35. return true;
  36. }
  37. }
  38. return false;
  39. }
  40. bool CanSelectPermanentCondition(Permanent permanent)
  41. {
  42. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  43. }
  44. bool CanUseCondition(Hashtable hashtable)
  45. {
  46. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  47. }
  48. bool CanActivateCondition(Hashtable hashtable)
  49. {
  50. if (CardEffectCommons.IsExistOnBattleArea(card))
  51. {
  52. if (card.Owner.GetBattleAreaPermanents().Count((permanent) => permanent.TopCard.CardNames.Contains("Mirei Mikagura") || permanent.TopCard.CardNames.Contains("MireiMikagura")) == 0)
  53. {
  54. if (card.Owner.HandCards.Count >= 1)
  55. {
  56. return true;
  57. }
  58. }
  59. else
  60. {
  61. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  62. {
  63. return true;
  64. }
  65. }
  66. }
  67. return false;
  68. }
  69. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  70. {
  71. if (card.Owner.GetBattleAreaPermanents().Count((permanent) => permanent.TopCard.CardNames.Contains("Mirei Mikagura") || permanent.TopCard.CardNames.Contains("MireiMikagura")) == 0)
  72. {
  73. if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  74. {
  75. List<CardSource> selectedCards = new List<CardSource>();
  76. int maxCount = 1;
  77. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  78. selectHandEffect.SetUp(
  79. selectPlayer: card.Owner,
  80. canTargetCondition: CanSelectCardCondition,
  81. canTargetCondition_ByPreSelecetedList: null,
  82. canEndSelectCondition: null,
  83. maxCount: maxCount,
  84. canNoSelect: true,
  85. canEndNotMax: false,
  86. isShowOpponent: true,
  87. selectCardCoroutine: SelectCardCoroutine,
  88. afterSelectCardCoroutine: null,
  89. mode: SelectHandEffect.Mode.Custom,
  90. cardEffect: activateClass);
  91. selectHandEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  92. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  93. yield return StartCoroutine(selectHandEffect.Activate());
  94. IEnumerator SelectCardCoroutine(CardSource cardSource)
  95. {
  96. selectedCards.Add(cardSource);
  97. yield return null;
  98. }
  99. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(cardSources: selectedCards, activateClass: activateClass, payCost: false, isTapped: false, root: SelectCardEffect.Root.Hand, activateETB: true));
  100. }
  101. }
  102. else
  103. {
  104. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  105. {
  106. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  107. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  108. selectPermanentEffect.SetUp(
  109. selectPlayer: card.Owner,
  110. canTargetCondition: CanSelectPermanentCondition,
  111. canTargetCondition_ByPreSelecetedList: null,
  112. canEndSelectCondition: null,
  113. maxCount: maxCount,
  114. canNoSelect: false,
  115. canEndNotMax: false,
  116. selectPermanentCoroutine: SelectPermanentCoroutine,
  117. afterSelectPermanentCoroutine: null,
  118. mode: SelectPermanentEffect.Mode.Custom,
  119. cardEffect: activateClass);
  120. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will get Security Attack -2.", "The opponent is selecting 1 Digimon that will get Security Attack -2.");
  121. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  122. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  123. {
  124. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonSAttack(targetPermanent: permanent, changeValue: -2, effectDuration: EffectDuration.UntilOpponentTurnEnd, activateClass: activateClass));
  125. }
  126. }
  127. }
  128. }
  129. }
  130. #endregion
  131. #region When Digivolving
  132. if (timing == EffectTiming.OnEnterFieldAnyone)
  133. {
  134. ActivateClass activateClass = new ActivateClass();
  135. activateClass.SetUpICardEffect("Give a Digimon Security Attack -2 or play [Mirei Mikagura] from hand", CanUseCondition, card);
  136. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  137. cardEffects.Add(activateClass);
  138. string EffectDiscription()
  139. {
  140. return "[When Digivolving] If you have a [Mirei Mikagura], 1 of your opponent's Digimon gains Security Attack -2 until the end of their turn. If you don't have a [Mirei Mikagura], you may play 1 [Mirei Mikagura] from your hand without paying the cost.";
  141. }
  142. bool CanSelectCardCondition(CardSource cardSource)
  143. {
  144. if (cardSource.CardNames.Contains("Mirei Mikagura") || cardSource.CardNames.Contains("MireiMikagura"))
  145. {
  146. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  147. {
  148. return true;
  149. }
  150. }
  151. return false;
  152. }
  153. bool CanSelectPermanentCondition(Permanent permanent)
  154. {
  155. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  156. }
  157. bool CanUseCondition(Hashtable hashtable)
  158. {
  159. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  160. }
  161. bool CanActivateCondition(Hashtable hashtable)
  162. {
  163. if (CardEffectCommons.IsExistOnBattleArea(card))
  164. {
  165. if (card.Owner.GetBattleAreaPermanents().Count((permanent) => permanent.TopCard.CardNames.Contains("Mirei Mikagura") || permanent.TopCard.CardNames.Contains("MireiMikagura")) == 0)
  166. {
  167. if (card.Owner.HandCards.Count >= 1)
  168. {
  169. return true;
  170. }
  171. }
  172. else
  173. {
  174. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  175. {
  176. return true;
  177. }
  178. }
  179. }
  180. return false;
  181. }
  182. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  183. {
  184. if (card.Owner.GetBattleAreaPermanents().Count((permanent) => permanent.TopCard.CardNames.Contains("Mirei Mikagura") || permanent.TopCard.CardNames.Contains("MireiMikagura")) == 0)
  185. {
  186. if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  187. {
  188. List<CardSource> selectedCards = new List<CardSource>();
  189. int maxCount = 1;
  190. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  191. selectHandEffect.SetUp(
  192. selectPlayer: card.Owner,
  193. canTargetCondition: CanSelectCardCondition,
  194. canTargetCondition_ByPreSelecetedList: null,
  195. canEndSelectCondition: null,
  196. maxCount: maxCount,
  197. canNoSelect: true,
  198. canEndNotMax: false,
  199. isShowOpponent: true,
  200. selectCardCoroutine: SelectCardCoroutine,
  201. afterSelectCardCoroutine: null,
  202. mode: SelectHandEffect.Mode.Custom,
  203. cardEffect: activateClass);
  204. selectHandEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  205. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  206. yield return StartCoroutine(selectHandEffect.Activate());
  207. IEnumerator SelectCardCoroutine(CardSource cardSource)
  208. {
  209. selectedCards.Add(cardSource);
  210. yield return null;
  211. }
  212. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(cardSources: selectedCards, activateClass: activateClass, payCost: false, isTapped: false, root: SelectCardEffect.Root.Hand, activateETB: true));
  213. }
  214. }
  215. else
  216. {
  217. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  218. {
  219. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  220. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  221. selectPermanentEffect.SetUp(
  222. selectPlayer: card.Owner,
  223. canTargetCondition: CanSelectPermanentCondition,
  224. canTargetCondition_ByPreSelecetedList: null,
  225. canEndSelectCondition: null,
  226. maxCount: maxCount,
  227. canNoSelect: false,
  228. canEndNotMax: false,
  229. selectPermanentCoroutine: SelectPermanentCoroutine,
  230. afterSelectPermanentCoroutine: null,
  231. mode: SelectPermanentEffect.Mode.Custom,
  232. cardEffect: activateClass);
  233. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will get Security Attack -2.", "The opponent is selecting 1 Digimon that will get Security Attack -2.");
  234. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  235. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  236. {
  237. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonSAttack(targetPermanent: permanent, changeValue: -2, effectDuration: EffectDuration.UntilOpponentTurnEnd, activateClass: activateClass));
  238. }
  239. }
  240. }
  241. }
  242. }
  243. #endregion
  244. #region Inherit
  245. if (timing == EffectTiming.OnAllyAttack)
  246. {
  247. bool Condition()
  248. {
  249. if (CardEffectCommons.IsExistOnBattleArea(card))
  250. {
  251. if (card.PermanentOfThisCard().TopCard.CardTraits.Contains("Angel"))
  252. {
  253. return true;
  254. }
  255. if (card.PermanentOfThisCard().TopCard.CardTraits.Contains("Three Great Angels") || card.PermanentOfThisCard().TopCard.CardTraits.Contains("ThreeGreatAngels"))
  256. {
  257. return true;
  258. }
  259. }
  260. return false;
  261. }
  262. cardEffects.Add(CardEffectFactory.AllianceSelfEffect(isInheritedEffect: true, card: card, condition: Condition));
  263. }
  264. #endregion
  265. return cardEffects;
  266. }
  267. }
  268. }