EX6_065.cs 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System;
  5. namespace DCGO.CardEffects.EX6
  6. {
  7. public class EX6_065 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Ignore Color Requirements
  13. if (timing == EffectTiming.None)
  14. {
  15. IgnoreColorConditionClass ignoreColorConditionClass = new IgnoreColorConditionClass();
  16. ignoreColorConditionClass.SetUpICardEffect("Ignore color requirements", CanUseCondition, card);
  17. ignoreColorConditionClass.SetUpIgnoreColorConditionClass(cardCondition: CardCondition);
  18. cardEffects.Add(ignoreColorConditionClass);
  19. bool CanUseCondition(Hashtable hashtable)
  20. {
  21. if (card.Owner.GetBattleAreaDigimons()
  22. .Count(permanent => permanent.TopCard.CardTraits.Contains("Legend-Arms")) >= 1)
  23. {
  24. return true;
  25. }
  26. return false;
  27. }
  28. bool CardCondition(CardSource cardSource)
  29. {
  30. if (cardSource == card)
  31. {
  32. return true;
  33. }
  34. return false;
  35. }
  36. }
  37. #endregion
  38. #region Main Effect
  39. if (timing == EffectTiming.OptionSkill)
  40. {
  41. ActivateClass activateClass = new ActivateClass();
  42. activateClass.SetUpICardEffect(card.BaseENGCardNameFromEntity, CanUseCondition, card);
  43. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, true, EffectDescription());
  44. cardEffects.Add(activateClass);
  45. string EffectDescription()
  46. {
  47. return
  48. "[Main] You may place 1 Digimon card with the [Legend-Arms] trait from your trash as 1 of your Digimon’s bottom digivolution card. Then, place this card in the battle area.";
  49. }
  50. bool CanSelectCardCondition(CardSource cardSource)
  51. {
  52. if (cardSource.IsDigimon)
  53. {
  54. if (cardSource.CardTraits.Contains("Legend-Arms"))
  55. {
  56. return true;
  57. }
  58. }
  59. return false;
  60. }
  61. bool CanSelectPermanentCondition(Permanent permanent)
  62. {
  63. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  64. {
  65. if (!permanent.IsToken)
  66. {
  67. return true;
  68. }
  69. }
  70. return false;
  71. }
  72. bool CanUseCondition(Hashtable hashtable)
  73. {
  74. return CardEffectCommons.CanTriggerOptionMainEffect(hashtable, card);
  75. }
  76. IEnumerator ActivateCoroutine(Hashtable hashtable)
  77. {
  78. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  79. {
  80. List<CardSource> selectedCards = new List<CardSource>();
  81. int maxCount = 1;
  82. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  83. selectCardEffect.SetUp(
  84. canTargetCondition: CanSelectCardCondition,
  85. canTargetCondition_ByPreSelecetedList: null,
  86. canEndSelectCondition: null,
  87. canNoSelect: () => false,
  88. selectCardCoroutine: SelectCardCoroutine,
  89. afterSelectCardCoroutine: null,
  90. message: "Select 1 card to place on bottom of digivolution cards.",
  91. maxCount: maxCount,
  92. canEndNotMax: false,
  93. isShowOpponent: true,
  94. mode: SelectCardEffect.Mode.Custom,
  95. root: SelectCardEffect.Root.Trash,
  96. customRootCardList: null,
  97. canLookReverseCard: true,
  98. selectPlayer: card.Owner,
  99. cardEffect: activateClass);
  100. selectCardEffect.SetUpCustomMessage_ShowCard("Digivolution Card");
  101. selectCardEffect.SetUpCustomMessage("Select 1 card to place on bottom of digivolution cards.",
  102. "The opponent is selecting 1 card to place on bottom of digivolution cards.");
  103. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  104. IEnumerator SelectCardCoroutine(CardSource cardSource)
  105. {
  106. selectedCards.Add(cardSource);
  107. yield return null;
  108. }
  109. if (selectedCards.Count >= 1)
  110. {
  111. maxCount = Math.Min(1,
  112. CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  113. SelectPermanentEffect selectPermanentEffect =
  114. GManager.instance.GetComponent<SelectPermanentEffect>();
  115. selectPermanentEffect.SetUp(
  116. selectPlayer: card.Owner,
  117. canTargetCondition: CanSelectPermanentCondition,
  118. canTargetCondition_ByPreSelecetedList: null,
  119. canEndSelectCondition: null,
  120. maxCount: maxCount,
  121. canNoSelect: true,
  122. canEndNotMax: false,
  123. selectPermanentCoroutine: SelectPermanentCoroutine,
  124. afterSelectPermanentCoroutine: null,
  125. mode: SelectPermanentEffect.Mode.Custom,
  126. cardEffect: activateClass);
  127. selectPermanentEffect.SetUpCustomMessage(
  128. "Select 1 Digimon that will get a bottom digivolution card.",
  129. "The opponent is selecting 1 Digimon that will get a bottom digivolution card.");
  130. yield return ContinuousController.instance.StartCoroutine(
  131. selectPermanentEffect.Activate());
  132. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  133. {
  134. if (permanent != null)
  135. {
  136. yield return ContinuousController.instance.StartCoroutine(
  137. permanent.AddDigivolutionCardsBottom(selectedCards, activateClass));
  138. }
  139. }
  140. }
  141. }
  142. yield return ContinuousController.instance.StartCoroutine(
  143. CardEffectCommons.PlaceDelayOptionCards(card: card, cardEffect: activateClass));
  144. }
  145. }
  146. #endregion
  147. #region Delay Effect
  148. if (timing == EffectTiming.WhenRemoveField)
  149. {
  150. ActivateClass activateClass = new ActivateClass();
  151. activateClass.SetUpICardEffect(
  152. "Play 1 card with the [Legend-Arms] trait from the removed Digimon's digivolution cards without paying the cost",
  153. CanUseCondition, card);
  154. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, true, EffectDescription());
  155. activateClass.SetHashString("PlayDigivolutionCard_EX6_065");
  156. cardEffects.Add(activateClass);
  157. string EffectDescription()
  158. {
  159. return
  160. "[All Turns] When one of your Digimon would leave the battle area other than by one of your effects,[Delay] • You may play 1 card with the [Legend-Arms] trait from that Digimon's digivolution cards without paying the cost.";
  161. }
  162. bool IsOwnerPermanentCondition(Permanent permanent)
  163. {
  164. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  165. {
  166. if (permanent.DigivolutionCards.Count(CanSelectLegendArmsSourceCardCondition) >= 1)
  167. {
  168. return true;
  169. }
  170. }
  171. return false;
  172. }
  173. bool IsOwnerPermanentToBeDeletedCondition(Permanent permanent)
  174. {
  175. if (IsOwnerPermanentCondition(permanent))
  176. {
  177. if (permanent.willBeRemoveField)
  178. {
  179. return true;
  180. }
  181. }
  182. return false;
  183. }
  184. bool CanSelectLegendArmsSourceCardCondition(CardSource cardSource)
  185. {
  186. if (cardSource.IsDigimon)
  187. {
  188. if (cardSource.CardTraits.Contains("Legend-Arms"))
  189. {
  190. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false,
  191. cardEffect: activateClass))
  192. {
  193. return true;
  194. }
  195. }
  196. }
  197. return false;
  198. }
  199. bool CanUseCondition(Hashtable hashtable)
  200. {
  201. if (CardEffectCommons.CanDeclareOptionDelayEffect(card))
  202. {
  203. if (CardEffectCommons.CanTriggerWhenPermanentRemoveField(hashtable, IsOwnerPermanentCondition))
  204. {
  205. if (!CardEffectCommons.IsByEffect(hashtable,
  206. cardEffect => CardEffectCommons.IsOwnerEffect(cardEffect, card)))
  207. {
  208. return true;
  209. }
  210. }
  211. }
  212. return false;
  213. }
  214. IEnumerator ActivateCoroutine(Hashtable hashtable)
  215. {
  216. yield return ContinuousController.instance.StartCoroutine(
  217. CardEffectCommons.DeletePeremanentAndProcessAccordingToResult(
  218. targetPermanents: new List<Permanent>() { card.PermanentOfThisCard() },
  219. activateClass: activateClass, successProcess: permanents => SuccessProcess(),
  220. failureProcess: null));
  221. }
  222. IEnumerator SuccessProcess()
  223. {
  224. if (CardEffectCommons.HasMatchConditionPermanent(IsOwnerPermanentToBeDeletedCondition))
  225. {
  226. int maxCount = Math.Min(1,
  227. CardEffectCommons.MatchConditionPermanentCount(IsOwnerPermanentToBeDeletedCondition));
  228. SelectPermanentEffect selectPermanentEffect =
  229. GManager.instance.GetComponent<SelectPermanentEffect>();
  230. selectPermanentEffect.SetUp(
  231. selectPlayer: card.Owner,
  232. canTargetCondition: IsOwnerPermanentToBeDeletedCondition,
  233. canTargetCondition_ByPreSelecetedList: null,
  234. canEndSelectCondition: null,
  235. maxCount: maxCount,
  236. canNoSelect: true,
  237. canEndNotMax: false,
  238. selectPermanentCoroutine: SelectPermanentCoroutine,
  239. afterSelectPermanentCoroutine: null,
  240. mode: SelectPermanentEffect.Mode.Custom,
  241. cardEffect: activateClass);
  242. selectPermanentEffect.SetUpCustomMessage(
  243. "Select 1 Digimon which has digivolution cards.",
  244. "The opponent is selecting 1 Digimon which has digivolution cards.");
  245. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  246. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  247. {
  248. Permanent selectedPermanent = permanent;
  249. if (selectedPermanent != null)
  250. {
  251. if (selectedPermanent.DigivolutionCards.Count(CanSelectLegendArmsSourceCardCondition) >= 1)
  252. {
  253. maxCount = Math.Min(1,
  254. selectedPermanent.DigivolutionCards.Count(CanSelectLegendArmsSourceCardCondition));
  255. List<CardSource> selectedCards = new List<CardSource>();
  256. SelectCardEffect selectCardEffect =
  257. GManager.instance.GetComponent<SelectCardEffect>();
  258. selectCardEffect.SetUp(
  259. canTargetCondition: CanSelectLegendArmsSourceCardCondition,
  260. canTargetCondition_ByPreSelecetedList: null,
  261. canEndSelectCondition: null,
  262. canNoSelect: () => true,
  263. selectCardCoroutine: SelectCardCoroutine,
  264. afterSelectCardCoroutine: null,
  265. message: "Select 1 digivolution card to play.",
  266. maxCount: maxCount,
  267. canEndNotMax: false,
  268. isShowOpponent: true,
  269. mode: SelectCardEffect.Mode.Custom,
  270. root: SelectCardEffect.Root.Custom,
  271. customRootCardList: selectedPermanent.DigivolutionCards,
  272. canLookReverseCard: true,
  273. selectPlayer: card.Owner,
  274. cardEffect: activateClass);
  275. selectCardEffect.SetUpCustomMessage(
  276. "Select 1 digivolution card to play.",
  277. "The opponent is selecting 1 digivolution card to play.");
  278. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  279. yield return StartCoroutine(selectCardEffect.Activate());
  280. IEnumerator SelectCardCoroutine(CardSource cardSource)
  281. {
  282. selectedCards.Add(cardSource);
  283. yield return null;
  284. }
  285. yield return ContinuousController.instance.StartCoroutine(
  286. CardEffectCommons.PlayPermanentCards(
  287. cardSources: selectedCards,
  288. activateClass: activateClass,
  289. payCost: false,
  290. isTapped: false,
  291. root: SelectCardEffect.Root.DigivolutionCards,
  292. activateETB: true));
  293. }
  294. }
  295. }
  296. }
  297. }
  298. }
  299. #endregion
  300. #region Security Effect
  301. if (timing == EffectTiming.SecuritySkill)
  302. {
  303. CardEffectCommons.AddActivateMainOptionSecurityEffect(card: card, cardEffects: ref cardEffects,
  304. effectName: card.BaseENGCardNameFromEntity);
  305. }
  306. #endregion
  307. return cardEffects;
  308. }
  309. }
  310. }