EX6_021.cs 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413
  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_021 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region On Play/ When Digivolving Shared
  13. bool CanSelectPermanentSharedCondition(Permanent permanent)
  14. {
  15. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  16. }
  17. bool CanSelectCardSharedCondition(CardSource cardSource)
  18. {
  19. if (cardSource.IsDigimon)
  20. {
  21. if (cardSource.HasAngelTraitRestrictive)
  22. {
  23. return true;
  24. }
  25. }
  26. return false;
  27. }
  28. bool CanActivateSharedCondition(Hashtable hashtable)
  29. {
  30. if (CardEffectCommons.IsExistOnBattleArea(card))
  31. {
  32. if (card.Owner.SecurityCards.Count >= 1)
  33. {
  34. return true;
  35. }
  36. if (card.Owner.HandCards.Count >= 1)
  37. {
  38. return true;
  39. }
  40. }
  41. return false;
  42. }
  43. #endregion
  44. #region On Play
  45. if (timing == EffectTiming.OnEnterFieldAnyone)
  46. {
  47. ActivateClass activateClass = new ActivateClass();
  48. activateClass.SetUpICardEffect(
  49. "Add 1 card from top or bottom security to hand to -4000 DP an opponent's Digimon, then place 1 card from hand at the bottom of security",
  50. CanUseCondition, card);
  51. activateClass.SetUpActivateClass(CanActivateSharedCondition, ActivateCoroutine, -1, false,
  52. EffectDescription());
  53. cardEffects.Add(activateClass);
  54. string EffectDescription()
  55. {
  56. return
  57. "[On Play] By adding the top or bottom card of your security stack to the hand, 1 of your opponent's Digimon gets -4000 DP for the turn. Then, you may place 1 Digimon card with the [Angel]/[Archangel]/[Three Great Angels] trait from your hand at the bottom of your security stack.";
  58. }
  59. bool CanUseCondition(Hashtable hashtable)
  60. {
  61. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  62. }
  63. IEnumerator ActivateCoroutine(Hashtable hashtable)
  64. {
  65. if (card.Owner.SecurityCards.Count >= 1)
  66. {
  67. List<SelectionElement<int>> selectionElements = new List<SelectionElement<int>>()
  68. {
  69. new(message: "Security Top", value: 0, spriteIndex: 0),
  70. new(message: "Security Bottom", value: 1, spriteIndex: 0),
  71. new(message: "No Selection", value: 2, spriteIndex: 1),
  72. };
  73. string selectPlayerMessage = "Add the top or bottom card of the security stack to hand";
  74. string notSelectPlayerMessage =
  75. "The opponent is selecting the top or bottom card of security stack.";
  76. GManager.instance.userSelectionManager.SetIntSelection(selectionElements: selectionElements,
  77. selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage,
  78. notSelectPlayerMessage: notSelectPlayerMessage);
  79. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager
  80. .WaitForEndSelect());
  81. int selectionValue = GManager.instance.userSelectionManager.SelectedIntValue;
  82. if (selectionValue != 2)
  83. {
  84. CardSource chosenSecurityCard = (selectionValue == 0)
  85. ? card.Owner.SecurityCards[0]
  86. : card.Owner.SecurityCards[^1];
  87. string placementValue = (selectionValue == 0)
  88. ? "From Top Of Security"
  89. : "From Bottom Of Security";
  90. #region Log
  91. if (chosenSecurityCard != null)
  92. {
  93. string log = "";
  94. log += $"\nAdded Card {placementValue} to Hand:";
  95. log += $"\n{chosenSecurityCard.BaseENGCardNameFromEntity}({chosenSecurityCard.CardID})";
  96. log += "\n";
  97. PlayLog.OnAddLog?.Invoke(log);
  98. }
  99. #endregion
  100. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().ShowCardEffect(new List<CardSource>() { chosenSecurityCard }, $"Added Hand Card {placementValue}", true, true));
  101. yield return ContinuousController.instance.StartCoroutine(
  102. CardObjectController.AddHandCards(new List<CardSource>() { chosenSecurityCard }, false,
  103. activateClass));
  104. yield return ContinuousController.instance.StartCoroutine(new IReduceSecurity(
  105. player: card.Owner,
  106. refSkillInfos: ref ContinuousController.instance.nullSkillInfos,
  107. activateClass).ReduceSecurity());
  108. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentSharedCondition))
  109. {
  110. int maxCount = Math.Min(1,
  111. CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentSharedCondition));
  112. SelectPermanentEffect selectPermanentEffect =
  113. GManager.instance.GetComponent<SelectPermanentEffect>();
  114. selectPermanentEffect.SetUp(
  115. selectPlayer: card.Owner,
  116. canTargetCondition: CanSelectPermanentSharedCondition,
  117. canTargetCondition_ByPreSelecetedList: null,
  118. canEndSelectCondition: null,
  119. maxCount: maxCount,
  120. canNoSelect: false,
  121. canEndNotMax: false,
  122. selectPermanentCoroutine: SelectPermanentCoroutine,
  123. afterSelectPermanentCoroutine: null,
  124. mode: SelectPermanentEffect.Mode.Custom,
  125. cardEffect: activateClass);
  126. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will get DP -4000.",
  127. "The opponent is selecting 1 Digimon that will get DP -4000.");
  128. yield return ContinuousController.instance.StartCoroutine(
  129. selectPermanentEffect.Activate());
  130. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  131. {
  132. yield return ContinuousController.instance.StartCoroutine(
  133. CardEffectCommons.ChangeDigimonDP(
  134. targetPermanent: permanent,
  135. changeValue: -4000,
  136. effectDuration: EffectDuration.UntilEachTurnEnd,
  137. activateClass: activateClass));
  138. }
  139. }
  140. if (card.Owner.HandCards.Count(CanSelectCardSharedCondition) >= 1)
  141. {
  142. int maxCount = Math.Min(1, card.Owner.HandCards.Count(CanSelectCardSharedCondition));
  143. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  144. selectHandEffect.SetUp(
  145. selectPlayer: card.Owner,
  146. canTargetCondition: CanSelectCardSharedCondition,
  147. canTargetCondition_ByPreSelecetedList: null,
  148. canEndSelectCondition: null,
  149. maxCount: maxCount,
  150. canNoSelect: true,
  151. canEndNotMax: false,
  152. isShowOpponent: true,
  153. selectCardCoroutine: SelectCardCoroutine,
  154. afterSelectCardCoroutine: null,
  155. mode: SelectHandEffect.Mode.Custom,
  156. cardEffect: activateClass);
  157. selectHandEffect.SetUpCustomMessage("Select 1 card to place at the bottom of security.",
  158. "The opponent is selecting 1 card to place at the bottom of security.");
  159. selectHandEffect.SetUpCustomMessage_ShowCard("Security Bottom Card");
  160. yield return StartCoroutine(selectHandEffect.Activate());
  161. IEnumerator SelectCardCoroutine(CardSource cardSource)
  162. {
  163. yield return ContinuousController.instance.StartCoroutine(
  164. CardObjectController.AddSecurityCard(cardSource, toTop: false));
  165. }
  166. }
  167. }
  168. }
  169. }
  170. }
  171. #endregion
  172. #region When Digivolving
  173. if (timing == EffectTiming.OnEnterFieldAnyone)
  174. {
  175. ActivateClass activateClass = new ActivateClass();
  176. activateClass.SetUpICardEffect(
  177. "Add 1 card from top or bottom security to hand to -4000 DP an opponent's Digimon, then place 1 card from hand at the bottom of security",
  178. CanUseCondition, card);
  179. activateClass.SetUpActivateClass(CanActivateSharedCondition, ActivateCoroutine, -1, false,
  180. EffectDescription());
  181. cardEffects.Add(activateClass);
  182. string EffectDescription()
  183. {
  184. return
  185. "[When Digivolving] By adding the top or bottom card of your security stack to the hand, 1 of your opponent's Digimon gets -4000 DP for the turn. Then, you may place 1 Digimon card with the [Angel]/[Archangel]/[Three Great Angels] trait from your hand at the bottom of your security stack.";
  186. }
  187. bool CanUseCondition(Hashtable hashtable)
  188. {
  189. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  190. }
  191. IEnumerator ActivateCoroutine(Hashtable hashtable)
  192. {
  193. if (card.Owner.SecurityCards.Count >= 1)
  194. {
  195. List<SelectionElement<int>> selectionElements = new List<SelectionElement<int>>()
  196. {
  197. new(message: "Security Top", value: 0, spriteIndex: 0),
  198. new(message: "Security Bottom", value: 1, spriteIndex: 0),
  199. new(message: "No Selection", value: 2, spriteIndex: 1),
  200. };
  201. string selectPlayerMessage = "Add the top or bottom card of the security stack to hand";
  202. string notSelectPlayerMessage =
  203. "The opponent is selecting the top or bottom card of security stack.";
  204. GManager.instance.userSelectionManager.SetIntSelection(selectionElements: selectionElements,
  205. selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage,
  206. notSelectPlayerMessage: notSelectPlayerMessage);
  207. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager
  208. .WaitForEndSelect());
  209. int selectionValue = GManager.instance.userSelectionManager.SelectedIntValue;
  210. if (selectionValue != 2)
  211. {
  212. CardSource chosenSecurityCard = (selectionValue == 0)
  213. ? card.Owner.SecurityCards[0]
  214. : card.Owner.SecurityCards[^1];
  215. string placementValue = (selectionValue == 0)
  216. ? "From Top Of Security"
  217. : "From Bottom Of Security";
  218. #region Log
  219. if (chosenSecurityCard != null)
  220. {
  221. string log = "";
  222. log += $"\nAdded Card {placementValue} to Hand:";
  223. log += $"\n{chosenSecurityCard.BaseENGCardNameFromEntity}({chosenSecurityCard.CardID})";
  224. log += "\n";
  225. PlayLog.OnAddLog?.Invoke(log);
  226. }
  227. #endregion
  228. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().ShowCardEffect(new List<CardSource>() { chosenSecurityCard }, $"Added Hand Card {placementValue}", true, true));
  229. yield return ContinuousController.instance.StartCoroutine(
  230. CardObjectController.AddHandCards(new List<CardSource>() { chosenSecurityCard }, false,
  231. activateClass));
  232. yield return ContinuousController.instance.StartCoroutine(new IReduceSecurity(
  233. player: card.Owner,
  234. refSkillInfos: ref ContinuousController.instance.nullSkillInfos,
  235. activateClass).ReduceSecurity());
  236. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentSharedCondition))
  237. {
  238. int maxCount = Math.Min(1,
  239. CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentSharedCondition));
  240. SelectPermanentEffect selectPermanentEffect =
  241. GManager.instance.GetComponent<SelectPermanentEffect>();
  242. selectPermanentEffect.SetUp(
  243. selectPlayer: card.Owner,
  244. canTargetCondition: CanSelectPermanentSharedCondition,
  245. canTargetCondition_ByPreSelecetedList: null,
  246. canEndSelectCondition: null,
  247. maxCount: maxCount,
  248. canNoSelect: false,
  249. canEndNotMax: false,
  250. selectPermanentCoroutine: SelectPermanentCoroutine,
  251. afterSelectPermanentCoroutine: null,
  252. mode: SelectPermanentEffect.Mode.Custom,
  253. cardEffect: activateClass);
  254. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will get DP -4000.",
  255. "The opponent is selecting 1 Digimon that will get DP -4000.");
  256. yield return ContinuousController.instance.StartCoroutine(
  257. selectPermanentEffect.Activate());
  258. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  259. {
  260. yield return ContinuousController.instance.StartCoroutine(
  261. CardEffectCommons.ChangeDigimonDP(
  262. targetPermanent: permanent,
  263. changeValue: -4000,
  264. effectDuration: EffectDuration.UntilEachTurnEnd,
  265. activateClass: activateClass));
  266. }
  267. }
  268. if (card.Owner.HandCards.Count(CanSelectCardSharedCondition) >= 1)
  269. {
  270. int maxCount = Math.Min(1, card.Owner.HandCards.Count(CanSelectCardSharedCondition));
  271. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  272. selectHandEffect.SetUp(
  273. selectPlayer: card.Owner,
  274. canTargetCondition: CanSelectCardSharedCondition,
  275. canTargetCondition_ByPreSelecetedList: null,
  276. canEndSelectCondition: null,
  277. maxCount: maxCount,
  278. canNoSelect: true,
  279. canEndNotMax: false,
  280. isShowOpponent: true,
  281. selectCardCoroutine: SelectCardCoroutine,
  282. afterSelectCardCoroutine: null,
  283. mode: SelectHandEffect.Mode.Custom,
  284. cardEffect: activateClass);
  285. selectHandEffect.SetUpCustomMessage("Select 1 card to place at the bottom of security.",
  286. "The opponent is selecting 1 card to place at the bottom of security.");
  287. selectHandEffect.SetUpCustomMessage_ShowCard("Security Bottom Card");
  288. yield return StartCoroutine(selectHandEffect.Activate());
  289. IEnumerator SelectCardCoroutine(CardSource cardSource)
  290. {
  291. yield return ContinuousController.instance.StartCoroutine(
  292. CardObjectController.AddSecurityCard(cardSource, toTop: false));
  293. }
  294. }
  295. }
  296. }
  297. }
  298. }
  299. #endregion
  300. #region Opponent's Turn - ESS
  301. if (timing == EffectTiming.None)
  302. {
  303. bool CanUseCondition()
  304. {
  305. if (CardEffectCommons.IsExistOnBattleArea(card))
  306. {
  307. if (CardEffectCommons.IsOpponentTurn(card))
  308. {
  309. return true;
  310. }
  311. }
  312. return false;
  313. }
  314. bool PermanentCondition(Permanent permanent)
  315. {
  316. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  317. {
  318. if (permanent.TopCard.ContainsTraits("Angel") ||
  319. permanent.TopCard.ContainsTraits("Archangel") ||
  320. permanent.TopCard.ContainsTraits("Three Great Angels") ||
  321. permanent.TopCard.ContainsTraits("ThreeGreatAngels"))
  322. {
  323. return true;
  324. }
  325. }
  326. return false;
  327. }
  328. cardEffects.Add(CardEffectFactory.BlockerStaticEffect(
  329. permanentCondition: PermanentCondition,
  330. isInheritedEffect: true,
  331. card: card,
  332. condition: CanUseCondition));
  333. }
  334. #endregion
  335. return cardEffects;
  336. }
  337. }
  338. }