P_096.cs 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493
  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. yield return GManager.instance.photonWaitController.StartWait("PrismGallet_Select");
  118. if (canSelectTamer() && canSelectTrash())
  119. {
  120. List<SelectionElement<int>> selectionElements = new List<SelectionElement<int>>()
  121. {
  122. new SelectionElement<int>(message: $"Under Tamer", value : 0, spriteIndex: 0),
  123. new SelectionElement<int>(message: $"From trash", value : 1, spriteIndex: 0),
  124. new SelectionElement<int>(message: $"No Select", value : 2, spriteIndex: 1),
  125. };
  126. string selectPlayerMessage = "From which area do you select cards?";
  127. string notSelectPlayerMessage = "The opponent is choosing from which area to select cards.";
  128. GManager.instance.userSelectionManager.SetIntSelection(
  129. selectionElements: selectionElements,
  130. selectPlayer: card.Owner,
  131. selectPlayerMessage: selectPlayerMessage,
  132. notSelectPlayerMessage: notSelectPlayerMessage);
  133. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  134. if (GManager.instance.userSelectionManager.SelectedIntValue == 2)
  135. {
  136. noSelect = true;
  137. }
  138. else
  139. {
  140. fromTrash = GManager.instance.userSelectionManager.SelectedIntValue == 1;
  141. }
  142. }
  143. else if (!canSelectTamer() && canSelectTrash())
  144. {
  145. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  146. {
  147. new SelectionElement<bool>(message: $"Select", value : true, spriteIndex: 0),
  148. new SelectionElement<bool>(message: $"Not Select", value : false, spriteIndex: 1),
  149. };
  150. string selectPlayerMessage = "Will you select cards from trash?";
  151. string notSelectPlayerMessage = "The opponent is choosing whether to select cards from trash.";
  152. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  153. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  154. bool doSelect = GManager.instance.userSelectionManager.SelectedBoolValue;
  155. if (doSelect)
  156. {
  157. fromTrash = true;
  158. }
  159. else
  160. {
  161. noSelect = true;
  162. }
  163. }
  164. else if (canSelectTamer() && !canSelectTrash())
  165. {
  166. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  167. {
  168. new SelectionElement<bool>(message: $"Select", value : true, spriteIndex: 0),
  169. new SelectionElement<bool>(message: $"Not Select", value : false, spriteIndex: 1),
  170. };
  171. string selectPlayerMessage = "Will you select cards from under Tamer?";
  172. string notSelectPlayerMessage = "The opponent is choosing whether to select cards from under Tamer.";
  173. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  174. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  175. bool doSelect = GManager.instance.userSelectionManager.SelectedBoolValue;
  176. if (doSelect)
  177. {
  178. fromTrash = false;
  179. }
  180. else
  181. {
  182. noSelect = true;
  183. }
  184. }
  185. else
  186. {
  187. noSelect = true;
  188. }
  189. if (noSelect)
  190. {
  191. break;
  192. }
  193. else
  194. {
  195. if (fromTrash)
  196. {
  197. if (canSelectTrash())
  198. {
  199. List<CardSource> selectedCards = new List<CardSource>();
  200. int _maxCount = Math.Min(maxSelectCardCount(), CardEffectCommons.MatchConditionOwnersCardCountInTrash(card, CanSelectDigivolutionCardsCondition));
  201. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  202. selectCardEffect.SetUp(
  203. canTargetCondition: CanSelectDigivolutionCardsCondition,
  204. canTargetCondition_ByPreSelecetedList: null,
  205. canEndSelectCondition: null,
  206. canNoSelect: () => true,
  207. selectCardCoroutine: SelectCardCoroutine,
  208. afterSelectCardCoroutine: null,
  209. message: "Select cards from trash to place in Digivolution cards.",
  210. maxCount: _maxCount,
  211. canEndNotMax: true,
  212. isShowOpponent: true,
  213. mode: SelectCardEffect.Mode.Custom,
  214. root: SelectCardEffect.Root.Trash,
  215. customRootCardList: null,
  216. canLookReverseCard: true,
  217. selectPlayer: card.Owner,
  218. cardEffect: activateClass);
  219. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  220. selectCardEffect.SetUpCustomMessage(
  221. "Select cards from trash to place in Digivolution cards.",
  222. "The opponent is selecting cards to place in Digivolution cards.");
  223. yield return StartCoroutine(selectCardEffect.Activate());
  224. IEnumerator SelectCardCoroutine(CardSource cardSource)
  225. {
  226. selectedCards.Add(cardSource);
  227. digivolutionCards.Add(cardSource);
  228. yield return null;
  229. }
  230. }
  231. }
  232. else
  233. {
  234. if (canSelectTamer())
  235. {
  236. Permanent selectedPermanent = null;
  237. int _maxCount = 1;
  238. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  239. selectPermanentEffect.SetUp(
  240. selectPlayer: card.Owner,
  241. canTargetCondition: CanSelectTamerCondition,
  242. canTargetCondition_ByPreSelecetedList: null,
  243. canEndSelectCondition: null,
  244. maxCount: 1,
  245. canNoSelect: true,
  246. canEndNotMax: true,
  247. selectPermanentCoroutine: SelectPermanentCoroutine,
  248. afterSelectPermanentCoroutine: null,
  249. mode: SelectPermanentEffect.Mode.Custom,
  250. cardEffect: activateClass);
  251. selectPermanentEffect.SetUpCustomMessage("Select 1 Tamer.", "The opponent is selecting 1 Tamer.");
  252. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  253. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  254. {
  255. selectedPermanent = permanent;
  256. yield return null;
  257. }
  258. if (selectedPermanent != null)
  259. {
  260. if (selectedPermanent.DigivolutionCards.Count(CanSelectDigivolutionCardsCondition) >= 1)
  261. {
  262. _maxCount = Math.Min(
  263. maxSelectCardCount(),
  264. selectedPermanent.DigivolutionCards.Count(CanSelectDigivolutionCardsCondition));
  265. List<CardSource> selectedCards = new List<CardSource>();
  266. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  267. selectCardEffect.SetUp(
  268. canTargetCondition: CanSelectDigivolutionCardsCondition,
  269. canTargetCondition_ByPreSelecetedList: null,
  270. canEndSelectCondition: null,
  271. canNoSelect: () => true,
  272. selectCardCoroutine: SelectCardCoroutine,
  273. afterSelectCardCoroutine: null,
  274. message: "Select digivolution cards.",
  275. maxCount: 1,
  276. canEndNotMax: true,
  277. isShowOpponent: true,
  278. mode: SelectCardEffect.Mode.Custom,
  279. root: SelectCardEffect.Root.Custom,
  280. customRootCardList: selectedPermanent.DigivolutionCards,
  281. canLookReverseCard: true,
  282. selectPlayer: card.Owner,
  283. cardEffect: activateClass);
  284. selectCardEffect.SetUpCustomMessage("Select digivolution cards.", "The opponent is selecting digivolution cards.");
  285. yield return StartCoroutine(selectCardEffect.Activate());
  286. IEnumerator SelectCardCoroutine(CardSource cardSource)
  287. {
  288. selectedCards.Add(cardSource);
  289. digivolutionCards.Add(cardSource);
  290. yield return null;
  291. }
  292. }
  293. }
  294. }
  295. }
  296. }
  297. }
  298. if (digivolutionCards.Count >= 1)
  299. {
  300. List<CardSource> digivolutionCards_fixed = new List<CardSource>();
  301. if (digivolutionCards.Count == 1)
  302. {
  303. digivolutionCards_fixed = digivolutionCards.Clone();
  304. }
  305. else
  306. {
  307. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  308. selectCardEffect.SetUp(
  309. canTargetCondition: (cardSource) => true,
  310. canTargetCondition_ByPreSelecetedList: null,
  311. canEndSelectCondition: null,
  312. canNoSelect: () => false,
  313. selectCardCoroutine: null,
  314. afterSelectCardCoroutine: AfterSelectCardCoroutine1,
  315. 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).",
  316. maxCount: digivolutionCards.Count,
  317. canEndNotMax: false,
  318. isShowOpponent: false,
  319. mode: SelectCardEffect.Mode.Custom,
  320. root: SelectCardEffect.Root.Custom,
  321. customRootCardList: digivolutionCards,
  322. canLookReverseCard: true,
  323. selectPlayer: card.Owner,
  324. cardEffect: activateClass);
  325. selectCardEffect.SetNotShowCard();
  326. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  327. IEnumerator AfterSelectCardCoroutine1(List<CardSource> cardSources)
  328. {
  329. foreach (CardSource cardSource in cardSources)
  330. {
  331. digivolutionCards_fixed.Add(cardSource);
  332. }
  333. yield return null;
  334. }
  335. }
  336. if (digivolutionCards_fixed.Count >= 1)
  337. {
  338. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().ShowCardEffect2(digivolutionCards_fixed, "Digivolutuion Cards", true, true));
  339. if (card.Owner.GetBattleAreaPermanents().Count(CanSelectGetDigivolutionCardsPermanentCondition) >= 1)
  340. {
  341. int maxCount = 1;
  342. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  343. selectPermanentEffect.SetUp(
  344. selectPlayer: card.Owner,
  345. canTargetCondition: CanSelectGetDigivolutionCardsPermanentCondition,
  346. canTargetCondition_ByPreSelecetedList: null,
  347. canEndSelectCondition: null,
  348. maxCount: maxCount,
  349. canNoSelect: false,
  350. canEndNotMax: false,
  351. selectPermanentCoroutine: SelectPermanentCoroutine,
  352. afterSelectPermanentCoroutine: null,
  353. mode: SelectPermanentEffect.Mode.Custom,
  354. cardEffect: activateClass);
  355. selectPermanentEffect.SetUpCustomMessage(
  356. "Select 1 Digimon that will get digivolution cards.",
  357. "The opponent is selecting 1 Digimon that will get digivolution cards.");
  358. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  359. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  360. {
  361. yield return ContinuousController.instance.StartCoroutine(permanent.AddDigivolutionCardsBottom(
  362. digivolutionCards_fixed, activateClass));
  363. int getDigivolutionCardsCount = digivolutionCards_fixed.Count((cardSource) =>
  364. permanent.DigivolutionCards.Contains(cardSource));
  365. int plusDP = 1000 * getDigivolutionCardsCount;
  366. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDP(
  367. targetPermanent: permanent,
  368. changeValue: plusDP,
  369. effectDuration: EffectDuration.UntilEachTurnEnd,
  370. activateClass: activateClass));
  371. }
  372. }
  373. }
  374. }
  375. }
  376. }
  377. }
  378. #endregion
  379. #region Security Effect
  380. if (timing == EffectTiming.SecuritySkill)
  381. {
  382. ActivateClass activateClass = new ActivateClass();
  383. activateClass.SetUpICardEffect($"Add this card to hand", CanUseCondition, card);
  384. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDiscription());
  385. activateClass.SetIsSecurityEffect(true);
  386. cardEffects.Add(activateClass);
  387. string EffectDiscription()
  388. {
  389. return "[Security] Add this card to its owner's hand.";
  390. }
  391. bool CanUseCondition(Hashtable hashtable)
  392. {
  393. return CardEffectCommons.CanTriggerSecurityEffect(hashtable, card);
  394. }
  395. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  396. {
  397. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.AddThisCardToHand(card, activateClass));
  398. }
  399. }
  400. #endregion
  401. return cardEffects;
  402. }
  403. }
  404. }