P_096.cs 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.P
  6. {
  7. public class P_096 : 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 PermanentCondition(Permanent permanent)
  20. {
  21. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card))
  22. {
  23. if (permanent.IsTamer)
  24. {
  25. if (permanent.TopCard.CardTraits.Contains("Hunter"))
  26. {
  27. return true;
  28. }
  29. }
  30. }
  31. return false;
  32. }
  33. bool CanUseCondition(Hashtable hashtable)
  34. {
  35. if (CardEffectCommons.HasMatchConditionPermanent(PermanentCondition))
  36. {
  37. return true;
  38. }
  39. return false;
  40. }
  41. bool CardCondition(CardSource cardSource)
  42. {
  43. return cardSource == card;
  44. }
  45. }
  46. #endregion
  47. #region Main
  48. if (timing == EffectTiming.OptionSkill)
  49. {
  50. ActivateClass activateClass = new ActivateClass();
  51. activateClass.SetUpICardEffect(card.BaseENGCardNameFromEntity, CanUseCondition, card);
  52. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDiscription());
  53. cardEffects.Add(activateClass);
  54. string EffectDiscription()
  55. {
  56. return "[Main] By placing up to 2 Digimon cards with <Save> in their text from under your Tamers or your trash under 1 of your Digimon with <Save> in its text as its bottom digivolution cards, that Digimon gains +1000 DP for each card placed by this effect.";
  57. }
  58. bool CanSelectGetDigivolutionCardsPermanentCondition(Permanent permanent)
  59. {
  60. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  61. {
  62. if (permanent.TopCard.HasSaveText)
  63. {
  64. if (!permanent.IsToken)
  65. {
  66. return true;
  67. }
  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 (card.Owner.GetBattleAreaPermanents().Some(CanSelectGetDigivolutionCardsPermanentCondition))
  79. {
  80. List<CardSource> digivolutionCards = new List<CardSource>();
  81. bool CanSelectDigivolutionCardsCondition(CardSource cardSource)
  82. {
  83. if (cardSource.IsDigimon)
  84. {
  85. if (cardSource.HasSaveText)
  86. {
  87. if (!digivolutionCards.Contains(cardSource))
  88. {
  89. return true;
  90. }
  91. }
  92. }
  93. return false;
  94. }
  95. bool CanSelectTamerCondition(Permanent permanent)
  96. {
  97. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card))
  98. {
  99. if (permanent.IsTamer)
  100. {
  101. if (permanent.DigivolutionCards.Count(CanSelectDigivolutionCardsCondition) >= 1)
  102. {
  103. return true;
  104. }
  105. }
  106. }
  107. return false;
  108. }
  109. bool canSelectTamer() => card.Owner.GetBattleAreaPermanents().Some(CanSelectTamerCondition);
  110. bool canSelectTrash() => CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectDigivolutionCardsCondition);
  111. int maxSelectCardCount() => 2 - digivolutionCards.Count;
  112. bool canSelect() => (canSelectTamer() || canSelectTrash()) && maxSelectCardCount() >= 1;
  113. while (canSelect() && digivolutionCards.Count <2)
  114. {
  115. bool fromTrash = false;
  116. bool noSelect = false;
  117. if (canSelectTamer() && canSelectTrash())
  118. {
  119. List<SelectionElement<int>> selectionElements = new List<SelectionElement<int>>()
  120. {
  121. new SelectionElement<int>(message: $"Under Tamer", value : 0, spriteIndex: 0),
  122. new SelectionElement<int>(message: $"From trash", value : 1, spriteIndex: 0),
  123. new SelectionElement<int>(message: $"No Select", value : 2, spriteIndex: 1),
  124. };
  125. string selectPlayerMessage = "From which area do you select cards?";
  126. string notSelectPlayerMessage = "The opponent is choosing from which area to select cards.";
  127. GManager.instance.userSelectionManager.SetIntSelection(
  128. selectionElements: selectionElements,
  129. selectPlayer: card.Owner,
  130. selectPlayerMessage: selectPlayerMessage,
  131. notSelectPlayerMessage: notSelectPlayerMessage);
  132. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  133. if (GManager.instance.userSelectionManager.SelectedIntValue == 2)
  134. {
  135. noSelect = true;
  136. }
  137. else
  138. {
  139. fromTrash = GManager.instance.userSelectionManager.SelectedIntValue == 1;
  140. }
  141. }
  142. else if (!canSelectTamer() && canSelectTrash())
  143. {
  144. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  145. {
  146. new SelectionElement<bool>(message: $"Select", value : true, spriteIndex: 0),
  147. new SelectionElement<bool>(message: $"Not Select", value : false, spriteIndex: 1),
  148. };
  149. string selectPlayerMessage = "Will you select cards from trash?";
  150. string notSelectPlayerMessage = "The opponent is choosing whether to select cards from trash.";
  151. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  152. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  153. bool doSelect = GManager.instance.userSelectionManager.SelectedBoolValue;
  154. if (doSelect)
  155. {
  156. fromTrash = true;
  157. }
  158. else
  159. {
  160. noSelect = true;
  161. }
  162. }
  163. else if (canSelectTamer() && !canSelectTrash())
  164. {
  165. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  166. {
  167. new SelectionElement<bool>(message: $"Select", value : true, spriteIndex: 0),
  168. new SelectionElement<bool>(message: $"Not Select", value : false, spriteIndex: 1),
  169. };
  170. string selectPlayerMessage = "Will you select cards from under Tamer?";
  171. string notSelectPlayerMessage = "The opponent is choosing whether to select cards from under Tamer.";
  172. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  173. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  174. bool doSelect = GManager.instance.userSelectionManager.SelectedBoolValue;
  175. if (doSelect)
  176. {
  177. fromTrash = false;
  178. }
  179. else
  180. {
  181. noSelect = true;
  182. }
  183. }
  184. else
  185. {
  186. noSelect = true;
  187. }
  188. if (noSelect)
  189. {
  190. break;
  191. }
  192. else
  193. {
  194. if (fromTrash)
  195. {
  196. if (canSelectTrash())
  197. {
  198. List<CardSource> selectedCards = new List<CardSource>();
  199. int _maxCount = Math.Min(maxSelectCardCount(), CardEffectCommons.MatchConditionOwnersCardCountInTrash(card, CanSelectDigivolutionCardsCondition));
  200. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  201. selectCardEffect.SetUp(
  202. canTargetCondition: CanSelectDigivolutionCardsCondition,
  203. canTargetCondition_ByPreSelecetedList: null,
  204. canEndSelectCondition: null,
  205. canNoSelect: () => true,
  206. selectCardCoroutine: SelectCardCoroutine,
  207. afterSelectCardCoroutine: null,
  208. message: "Select cards from trash to place in Digivolution cards.",
  209. maxCount: _maxCount,
  210. canEndNotMax: true,
  211. isShowOpponent: true,
  212. mode: SelectCardEffect.Mode.Custom,
  213. root: SelectCardEffect.Root.Trash,
  214. customRootCardList: null,
  215. canLookReverseCard: true,
  216. selectPlayer: card.Owner,
  217. cardEffect: activateClass);
  218. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  219. selectCardEffect.SetUpCustomMessage(
  220. "Select cards from trash to place in Digivolution cards.",
  221. "The opponent is selecting cards to place in Digivolution cards.");
  222. yield return StartCoroutine(selectCardEffect.Activate());
  223. IEnumerator SelectCardCoroutine(CardSource cardSource)
  224. {
  225. selectedCards.Add(cardSource);
  226. digivolutionCards.Add(cardSource);
  227. yield return null;
  228. }
  229. }
  230. }
  231. else
  232. {
  233. if (canSelectTamer())
  234. {
  235. Permanent selectedPermanent = null;
  236. int _maxCount = 1;
  237. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  238. selectPermanentEffect.SetUp(
  239. selectPlayer: card.Owner,
  240. canTargetCondition: CanSelectTamerCondition,
  241. canTargetCondition_ByPreSelecetedList: null,
  242. canEndSelectCondition: null,
  243. maxCount: 1,
  244. canNoSelect: true,
  245. canEndNotMax: true,
  246. selectPermanentCoroutine: SelectPermanentCoroutine,
  247. afterSelectPermanentCoroutine: null,
  248. mode: SelectPermanentEffect.Mode.Custom,
  249. cardEffect: activateClass);
  250. selectPermanentEffect.SetUpCustomMessage("Select 1 Tamer.", "The opponent is selecting 1 Tamer.");
  251. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  252. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  253. {
  254. selectedPermanent = permanent;
  255. yield return null;
  256. }
  257. if (selectedPermanent != null)
  258. {
  259. if (selectedPermanent.DigivolutionCards.Count(CanSelectDigivolutionCardsCondition) >= 1)
  260. {
  261. _maxCount = Math.Min(
  262. maxSelectCardCount(),
  263. selectedPermanent.DigivolutionCards.Count(CanSelectDigivolutionCardsCondition));
  264. List<CardSource> selectedCards = new List<CardSource>();
  265. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  266. selectCardEffect.SetUp(
  267. canTargetCondition: CanSelectDigivolutionCardsCondition,
  268. canTargetCondition_ByPreSelecetedList: null,
  269. canEndSelectCondition: null,
  270. canNoSelect: () => true,
  271. selectCardCoroutine: SelectCardCoroutine,
  272. afterSelectCardCoroutine: null,
  273. message: "Select digivolution cards.",
  274. maxCount: 1,
  275. canEndNotMax: true,
  276. isShowOpponent: true,
  277. mode: SelectCardEffect.Mode.Custom,
  278. root: SelectCardEffect.Root.Custom,
  279. customRootCardList: selectedPermanent.DigivolutionCards,
  280. canLookReverseCard: true,
  281. selectPlayer: card.Owner,
  282. cardEffect: activateClass);
  283. selectCardEffect.SetUpCustomMessage("Select digivolution cards.", "The opponent is selecting digivolution cards.");
  284. yield return StartCoroutine(selectCardEffect.Activate());
  285. IEnumerator SelectCardCoroutine(CardSource cardSource)
  286. {
  287. selectedCards.Add(cardSource);
  288. digivolutionCards.Add(cardSource);
  289. yield return null;
  290. }
  291. }
  292. }
  293. }
  294. }
  295. }
  296. }
  297. if (digivolutionCards.Count >= 1)
  298. {
  299. List<CardSource> digivolutionCards_fixed = new List<CardSource>();
  300. if (digivolutionCards.Count == 1)
  301. {
  302. digivolutionCards_fixed = digivolutionCards.Clone();
  303. }
  304. else
  305. {
  306. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  307. selectCardEffect.SetUp(
  308. canTargetCondition: (cardSource) => true,
  309. canTargetCondition_ByPreSelecetedList: null,
  310. canEndSelectCondition: null,
  311. canNoSelect: () => false,
  312. selectCardCoroutine: null,
  313. afterSelectCardCoroutine: AfterSelectCardCoroutine1,
  314. message: "Specify the order to place the cards in the digivolution cards\n(cards will be placed so that cards with lower numbers are on top).",
  315. maxCount: digivolutionCards.Count,
  316. canEndNotMax: false,
  317. isShowOpponent: false,
  318. mode: SelectCardEffect.Mode.Custom,
  319. root: SelectCardEffect.Root.Custom,
  320. customRootCardList: digivolutionCards,
  321. canLookReverseCard: true,
  322. selectPlayer: card.Owner,
  323. cardEffect: activateClass);
  324. selectCardEffect.SetNotShowCard();
  325. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  326. IEnumerator AfterSelectCardCoroutine1(List<CardSource> cardSources)
  327. {
  328. foreach (CardSource cardSource in cardSources)
  329. {
  330. digivolutionCards_fixed.Add(cardSource);
  331. }
  332. yield return null;
  333. }
  334. }
  335. if (digivolutionCards_fixed.Count >= 1)
  336. {
  337. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().ShowCardEffect2(digivolutionCards_fixed, "Digivolutuion Cards", true, true));
  338. if (card.Owner.GetBattleAreaPermanents().Count(CanSelectGetDigivolutionCardsPermanentCondition) >= 1)
  339. {
  340. int maxCount = 1;
  341. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  342. selectPermanentEffect.SetUp(
  343. selectPlayer: card.Owner,
  344. canTargetCondition: CanSelectGetDigivolutionCardsPermanentCondition,
  345. canTargetCondition_ByPreSelecetedList: null,
  346. canEndSelectCondition: null,
  347. maxCount: maxCount,
  348. canNoSelect: false,
  349. canEndNotMax: false,
  350. selectPermanentCoroutine: SelectPermanentCoroutine,
  351. afterSelectPermanentCoroutine: null,
  352. mode: SelectPermanentEffect.Mode.Custom,
  353. cardEffect: activateClass);
  354. selectPermanentEffect.SetUpCustomMessage(
  355. "Select 1 Digimon that will get digivolution cards.",
  356. "The opponent is selecting 1 Digimon that will get digivolution cards.");
  357. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  358. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  359. {
  360. yield return ContinuousController.instance.StartCoroutine(permanent.AddDigivolutionCardsBottom(
  361. digivolutionCards_fixed, activateClass));
  362. int getDigivolutionCardsCount = digivolutionCards_fixed.Count((cardSource) =>
  363. permanent.DigivolutionCards.Contains(cardSource));
  364. int plusDP = 1000 * getDigivolutionCardsCount;
  365. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDP(
  366. targetPermanent: permanent,
  367. changeValue: plusDP,
  368. effectDuration: EffectDuration.UntilEachTurnEnd,
  369. activateClass: activateClass));
  370. }
  371. }
  372. }
  373. }
  374. }
  375. }
  376. }
  377. #endregion
  378. #region Security Effect
  379. if (timing == EffectTiming.SecuritySkill)
  380. {
  381. ActivateClass activateClass = new ActivateClass();
  382. activateClass.SetUpICardEffect($"Add this card to hand", CanUseCondition, card);
  383. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDiscription());
  384. activateClass.SetIsSecurityEffect(true);
  385. cardEffects.Add(activateClass);
  386. string EffectDiscription()
  387. {
  388. return "[Security] Add this card to its owner's hand.";
  389. }
  390. bool CanUseCondition(Hashtable hashtable)
  391. {
  392. return CardEffectCommons.CanTriggerSecurityEffect(hashtable, card);
  393. }
  394. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  395. {
  396. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.AddThisCardToHand(card, activateClass));
  397. }
  398. }
  399. #endregion
  400. return cardEffects;
  401. }
  402. }
  403. }