BT16_024.cs 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.BT16
  6. {
  7. public class BT16_024 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. var cardEffects = new List<ICardEffect>();
  12. #region Alternate Digivolution Requirement
  13. if (timing == EffectTiming.None)
  14. {
  15. bool PermanentCondition(Permanent targetPermanent)
  16. {
  17. return targetPermanent.TopCard.CardNames.Contains("Angemon");
  18. }
  19. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  20. permanentCondition: PermanentCondition,
  21. digivolutionCost: 3,
  22. ignoreDigivolutionRequirement: false,
  23. card: card,
  24. condition: null)
  25. );
  26. }
  27. #endregion
  28. #region On Play
  29. if (timing == EffectTiming.OnEnterFieldAnyone)
  30. {
  31. ActivateClass activateClass = new ActivateClass();
  32. activateClass.SetUpICardEffect("This Digimon digivolves into a Digimon card from security", CanUseCondition, card);
  33. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  34. activateClass.SetHashString("MagnaAngemon_BT16_024_OnPlay_WhenDigivolving");
  35. cardEffects.Add(activateClass);
  36. string EffectDiscription()
  37. {
  38. return
  39. "[On Play] If it's your turn, search your security stack. This Digimon may digivolve into a Digimon card with the [Angel] " +
  40. "or [Three Great Angels] trait among them with the digivolution cost reduced by 2. Then, shuffle your security stack. If this effect digivolved, " +
  41. "you may place 1 Digimon card with the [Angel], [Archangel] or [Three Great Angels] trait from your hand at the bottom of your security stack.";
  42. }
  43. bool CanSelectCardDigivolutionCondition(CardSource cardSource)
  44. {
  45. if (cardSource.CardTraits.Contains("Angel") || cardSource.CardTraits.Contains("Three Great Angels") || cardSource.CardTraits.Contains("ThreeGreatAngels"))
  46. {
  47. if (cardSource.IsDigimon)
  48. {
  49. if (CardEffectCommons.IsExistOnBattleArea(card))
  50. {
  51. if (cardSource.CanPlayCardTargetFrame(card.PermanentOfThisCard().PermanentFrame, false, activateClass))
  52. {
  53. return true;
  54. }
  55. }
  56. }
  57. }
  58. return false;
  59. }
  60. bool CanSelectCardRecoverCondition(CardSource cardSource)
  61. {
  62. if (cardSource.IsDigimon)
  63. {
  64. if (cardSource.HasAngelTraitRestrictive)
  65. {
  66. return true;
  67. }
  68. }
  69. return false;
  70. }
  71. bool CanUseCondition(Hashtable hashtable)
  72. {
  73. return CardEffectCommons.IsOwnerTurn(card) && CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  74. }
  75. bool CanActivateCondition(Hashtable hashtable)
  76. {
  77. if (CardEffectCommons.IsExistOnBattleArea(card))
  78. {
  79. if (card.Owner.SecurityCards.Count >= 1)
  80. {
  81. return true;
  82. }
  83. }
  84. return false;
  85. }
  86. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  87. {
  88. if (card.Owner.SecurityCards.Count >= 1)
  89. {
  90. int maxCount = Math.Min(1, card.Owner.SecurityCards.Count);
  91. CardSource selectedCard = null;
  92. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  93. selectCardEffect.SetUp(
  94. canTargetCondition: CanSelectCardDigivolutionCondition,
  95. canTargetCondition_ByPreSelecetedList: null,
  96. canEndSelectCondition: null,
  97. canNoSelect: () => true,
  98. selectCardCoroutine: SelectCardCoroutine,
  99. afterSelectCardCoroutine: null,
  100. message: "Select 1 card to digivolve.",
  101. maxCount: maxCount,
  102. canEndNotMax: false,
  103. isShowOpponent: true,
  104. mode: SelectCardEffect.Mode.Custom,
  105. root: SelectCardEffect.Root.Security,
  106. customRootCardList: null,
  107. canLookReverseCard: true,
  108. selectPlayer: card.Owner,
  109. cardEffect: activateClass);
  110. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  111. IEnumerator SelectCardCoroutine(CardSource cardSource)
  112. {
  113. selectedCard = cardSource;
  114. yield return null;
  115. }
  116. ContinuousController.instance.PlaySE(GManager.instance.ShuffleSE);
  117. card.Owner.SecurityCards = RandomUtility.ShuffledDeckCards(card.Owner.SecurityCards);
  118. if (selectedCard != null)
  119. {
  120. if (CardEffectCommons.IsExistOnBattleArea(card))
  121. {
  122. GManager.instance.turnStateMachine.gameContext.IsSecurityLooking = true;
  123. if (selectedCard.CanPlayCardTargetFrame(card.PermanentOfThisCard().PermanentFrame,
  124. PayCost: false, activateClass, root: SelectCardEffect.Root.Security))
  125. {
  126. PlayCardClass playCardClass = new PlayCardClass(
  127. cardSources: new List<CardSource>() { selectedCard },
  128. hashtable: CardEffectCommons.CardEffectHashtable(activateClass),
  129. payCost: true,
  130. targetPermanent: card.PermanentOfThisCard(),
  131. isTapped: false,
  132. root: SelectCardEffect.Root.Security,
  133. activateETB: true);
  134. playCardClass.SetReducedCost(2);
  135. yield return ContinuousController.instance.StartCoroutine(playCardClass.PlayCard());
  136. }
  137. GManager.instance.turnStateMachine.gameContext.IsSecurityLooking = false;
  138. if (CardEffectCommons.IsDigivolvedByTheEffect(card.PermanentOfThisCard(), selectedCard,
  139. activateClass))
  140. {
  141. if (card.Owner.CanAddSecurity(activateClass))
  142. {
  143. if (card.Owner.HandCards.Count(CanSelectCardRecoverCondition) >= 1)
  144. {
  145. List<CardSource> selectedCards = new List<CardSource>();
  146. maxCount = 1;
  147. SelectHandEffect selectHandEffect =
  148. GManager.instance.GetComponent<SelectHandEffect>();
  149. selectHandEffect.SetUp(
  150. selectPlayer: card.Owner,
  151. canTargetCondition: CanSelectCardRecoverCondition,
  152. canTargetCondition_ByPreSelecetedList: null,
  153. canEndSelectCondition: null,
  154. maxCount: maxCount,
  155. canNoSelect: true,
  156. canEndNotMax: false,
  157. isShowOpponent: true,
  158. selectCardCoroutine: SelectCardCoroutine1,
  159. afterSelectCardCoroutine: null,
  160. mode: SelectHandEffect.Mode.Custom,
  161. cardEffect: activateClass);
  162. selectHandEffect.SetUpCustomMessage(
  163. "Select 1 card to place at the bottom of security.",
  164. "The opponent is selecting 1 card to place at the bottom of security.");
  165. selectHandEffect.SetUpCustomMessage_ShowCard("Security Bottom Card");
  166. yield return StartCoroutine(selectHandEffect.Activate());
  167. IEnumerator SelectCardCoroutine1(CardSource cardSource)
  168. {
  169. selectedCards.Add(cardSource);
  170. yield return null;
  171. }
  172. foreach (CardSource cardSource in selectedCards)
  173. {
  174. yield return ContinuousController.instance.StartCoroutine(
  175. CardObjectController.AddSecurityCard(cardSource, toTop: false));
  176. }
  177. }
  178. }
  179. }
  180. }
  181. }
  182. }
  183. }
  184. }
  185. #endregion
  186. #region When Digivolving
  187. if (timing == EffectTiming.OnEnterFieldAnyone)
  188. {
  189. ActivateClass activateClass = new ActivateClass();
  190. activateClass.SetUpICardEffect("This Digimon digivolves into a Digimon card from security", CanUseCondition, card);
  191. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  192. activateClass.SetHashString("MagnaAngemon_BT16_024_OnPlay_WhenDigivolving");
  193. cardEffects.Add(activateClass);
  194. string EffectDiscription()
  195. {
  196. return
  197. "[When Digivolving] If it's your turn, search your security stack. This Digimon may digivolve into a Digimon card with the [Angel] " +
  198. "or [Three Great Angels] trait among them with the digivolution cost reduced by 2. Then, shuffle your security stack. If this effect digivolved, " +
  199. "you may place 1 Digimon card with the [Angel], [Archangel] or [Three Great Angels] trait from your hand at the bottom of your security stack.";
  200. }
  201. bool CanSelectCardDigivolutionCondition(CardSource cardSource)
  202. {
  203. if (cardSource.CardTraits.Contains("Angel") || cardSource.CardTraits.Contains("Three Great Angels") || cardSource.CardTraits.Contains("ThreeGreatAngels"))
  204. {
  205. if (cardSource.IsDigimon)
  206. {
  207. if (CardEffectCommons.IsExistOnBattleArea(card))
  208. {
  209. if (cardSource.CanPlayCardTargetFrame(card.PermanentOfThisCard().PermanentFrame, false, activateClass))
  210. {
  211. return true;
  212. }
  213. }
  214. }
  215. }
  216. return false;
  217. }
  218. bool CanSelectCardRecoverCondition(CardSource cardSource)
  219. {
  220. if (cardSource.IsDigimon)
  221. {
  222. if (cardSource.HasAngelTraitRestrictive)
  223. {
  224. return true;
  225. }
  226. }
  227. return false;
  228. }
  229. bool CanUseCondition(Hashtable hashtable)
  230. {
  231. return CardEffectCommons.IsOwnerTurn(card) && CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  232. }
  233. bool CanActivateCondition(Hashtable hashtable)
  234. {
  235. if (CardEffectCommons.IsExistOnBattleArea(card))
  236. {
  237. if (card.Owner.SecurityCards.Count >= 1)
  238. {
  239. return true;
  240. }
  241. }
  242. return false;
  243. }
  244. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  245. {
  246. if (card.Owner.SecurityCards.Count >= 1)
  247. {
  248. int maxCount = Math.Min(1, card.Owner.SecurityCards.Count);
  249. CardSource selectedCard = null;
  250. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  251. selectCardEffect.SetUp(
  252. canTargetCondition: CanSelectCardDigivolutionCondition,
  253. canTargetCondition_ByPreSelecetedList: null,
  254. canEndSelectCondition: null,
  255. canNoSelect: () => true,
  256. selectCardCoroutine: SelectCardCoroutine,
  257. afterSelectCardCoroutine: null,
  258. message: "Select 1 card to digivolve.",
  259. maxCount: maxCount,
  260. canEndNotMax: false,
  261. isShowOpponent: true,
  262. mode: SelectCardEffect.Mode.Custom,
  263. root: SelectCardEffect.Root.Security,
  264. customRootCardList: null,
  265. canLookReverseCard: true,
  266. selectPlayer: card.Owner,
  267. cardEffect: activateClass);
  268. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  269. IEnumerator SelectCardCoroutine(CardSource cardSource)
  270. {
  271. selectedCard = cardSource;
  272. yield return null;
  273. }
  274. ContinuousController.instance.PlaySE(GManager.instance.ShuffleSE);
  275. card.Owner.SecurityCards = RandomUtility.ShuffledDeckCards(card.Owner.SecurityCards);
  276. if (selectedCard != null)
  277. {
  278. if (CardEffectCommons.IsExistOnBattleArea(card))
  279. {
  280. GManager.instance.turnStateMachine.gameContext.IsSecurityLooking = true;
  281. if (selectedCard.CanPlayCardTargetFrame(card.PermanentOfThisCard().PermanentFrame,
  282. PayCost: false, activateClass, root: SelectCardEffect.Root.Security))
  283. {
  284. PlayCardClass playCardClass = new PlayCardClass(
  285. cardSources: new List<CardSource>() { selectedCard },
  286. hashtable: CardEffectCommons.CardEffectHashtable(activateClass),
  287. payCost: true,
  288. targetPermanent: card.PermanentOfThisCard(),
  289. isTapped: false,
  290. root: SelectCardEffect.Root.Security,
  291. activateETB: true);
  292. playCardClass.SetReducedCost(2);
  293. yield return ContinuousController.instance.StartCoroutine(playCardClass.PlayCard());
  294. }
  295. GManager.instance.turnStateMachine.gameContext.IsSecurityLooking = false;
  296. if (CardEffectCommons.IsDigivolvedByTheEffect(card.PermanentOfThisCard(), selectedCard,
  297. activateClass))
  298. {
  299. if (card.Owner.CanAddSecurity(activateClass))
  300. {
  301. if (card.Owner.HandCards.Count(CanSelectCardRecoverCondition) >= 1)
  302. {
  303. List<CardSource> selectedCards = new List<CardSource>();
  304. maxCount = 1;
  305. SelectHandEffect selectHandEffect =
  306. GManager.instance.GetComponent<SelectHandEffect>();
  307. selectHandEffect.SetUp(
  308. selectPlayer: card.Owner,
  309. canTargetCondition: CanSelectCardRecoverCondition,
  310. canTargetCondition_ByPreSelecetedList: null,
  311. canEndSelectCondition: null,
  312. maxCount: maxCount,
  313. canNoSelect: true,
  314. canEndNotMax: false,
  315. isShowOpponent: true,
  316. selectCardCoroutine: SelectCardCoroutine1,
  317. afterSelectCardCoroutine: null,
  318. mode: SelectHandEffect.Mode.Custom,
  319. cardEffect: activateClass);
  320. selectHandEffect.SetUpCustomMessage(
  321. "Select 1 card to place at the bottom of security.",
  322. "The opponent is selecting 1 card to place at the bottom of security.");
  323. selectHandEffect.SetUpCustomMessage_ShowCard("Security Bottom Card");
  324. yield return StartCoroutine(selectHandEffect.Activate());
  325. IEnumerator SelectCardCoroutine1(CardSource cardSource)
  326. {
  327. selectedCards.Add(cardSource);
  328. yield return null;
  329. }
  330. foreach (CardSource cardSource in selectedCards)
  331. {
  332. yield return ContinuousController.instance.StartCoroutine(
  333. CardObjectController.AddSecurityCard(cardSource, toTop: false));
  334. }
  335. }
  336. }
  337. }
  338. }
  339. }
  340. }
  341. }
  342. }
  343. #endregion
  344. #region Inherited Effect
  345. if (timing == EffectTiming.None)
  346. {
  347. bool CanUseCondition()
  348. {
  349. if (CardEffectCommons.IsExistOnBattleArea(card))
  350. {
  351. if (CardEffectCommons.IsOpponentTurn(card))
  352. {
  353. return true;
  354. }
  355. }
  356. return false;
  357. }
  358. bool PermanentCondition(Permanent permanent)
  359. {
  360. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  361. {
  362. return permanent.TopCard.HasAngelTraitRestrictive;
  363. }
  364. return false;
  365. }
  366. cardEffects.Add(CardEffectFactory.BlockerStaticEffect(permanentCondition: PermanentCondition, isInheritedEffect: true, card: card, condition: CanUseCondition));
  367. }
  368. #endregion
  369. return cardEffects;
  370. }
  371. }
  372. }