BT7_063.cs 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using System.Linq;
  5. using Photon;
  6. using System;
  7. using Photon.Pun;
  8. public class BT7_063 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. if (timing == EffectTiming.OnEnterFieldAnyone)
  14. {
  15. ActivateClass activateClass = new ActivateClass();
  16. activateClass.SetUpICardEffect("Place cards in digivolution cards", CanUseCondition, card);
  17. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  18. cardEffects.Add(activateClass);
  19. string EffectDiscription()
  20. {
  21. return "[On Play] You may place 1 [SkullKnightmon] and 1 [DeadlyAxemon] from your hand and/or trash in this Digimon's digivolution cards in any order.";
  22. }
  23. bool CanSelectCardCondition(CardSource cardSource)
  24. {
  25. return cardSource.CardNames.Contains("SkullKnightmon");
  26. }
  27. bool CanSelectCardCondition1(CardSource cardSource)
  28. {
  29. return cardSource.CardNames.Contains("DeadlyAxemon");
  30. }
  31. bool CanUseCondition(Hashtable hashtable)
  32. {
  33. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  34. }
  35. bool CanActivateCondition(Hashtable hashtable)
  36. {
  37. if (CardEffectCommons.IsExistOnBattleArea(card))
  38. {
  39. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, (cardSource) => CanSelectCardCondition(cardSource) || CanSelectCardCondition1(cardSource)))
  40. {
  41. return true;
  42. }
  43. if (card.Owner.HandCards.Count((cardSource) => CanSelectCardCondition(cardSource) || CanSelectCardCondition1(cardSource)) >= 1)
  44. {
  45. return true;
  46. }
  47. }
  48. return false;
  49. }
  50. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  51. {
  52. if (CardEffectCommons.IsExistOnBattleArea(card))
  53. {
  54. List<CardSource> selectedCards = new List<CardSource>();
  55. {
  56. bool canSelectHand = card.Owner.HandCards.Count(CanSelectCardCondition) >= 1;
  57. bool canSelectTrash = CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition);
  58. if (canSelectHand || canSelectTrash)
  59. {
  60. if (canSelectHand && canSelectTrash)
  61. {
  62. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  63. {
  64. new SelectionElement<bool>(message: $"From hand", value : true, spriteIndex: 0),
  65. new SelectionElement<bool>(message: $"From trash", value : false, spriteIndex: 1),
  66. };
  67. string selectPlayerMessage = "From which area do you select 1 [SkullKnightmon]?";
  68. string notSelectPlayerMessage = "The opponent is choosing from which area to select 1 [SkullKnightmon].";
  69. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  70. }
  71. else
  72. {
  73. GManager.instance.userSelectionManager.SetBool(canSelectHand);
  74. }
  75. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  76. bool fromHand = GManager.instance.userSelectionManager.SelectedBoolValue;
  77. IEnumerator SelectCardCoroutine(CardSource cardSource)
  78. {
  79. selectedCards.Add(cardSource);
  80. yield return null;
  81. }
  82. if (fromHand)
  83. {
  84. int maxCount = 1;
  85. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  86. selectHandEffect.SetUp(
  87. selectPlayer: card.Owner,
  88. canTargetCondition: CanSelectCardCondition,
  89. canTargetCondition_ByPreSelecetedList: null,
  90. canEndSelectCondition: null,
  91. maxCount: maxCount,
  92. canNoSelect: true,
  93. canEndNotMax: false,
  94. isShowOpponent: true,
  95. selectCardCoroutine: SelectCardCoroutine,
  96. afterSelectCardCoroutine: null,
  97. mode: SelectHandEffect.Mode.Custom,
  98. cardEffect: activateClass);
  99. selectHandEffect.SetUpCustomMessage("Select 1 [SkullKnightmon].", "The opponent is selecting 1 [SkullKnightmon].");
  100. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  101. yield return StartCoroutine(selectHandEffect.Activate());
  102. }
  103. else
  104. {
  105. int maxCount = 1;
  106. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  107. selectCardEffect.SetUp(
  108. canTargetCondition: CanSelectCardCondition,
  109. canTargetCondition_ByPreSelecetedList: null,
  110. canEndSelectCondition: null,
  111. canNoSelect: () => false,
  112. selectCardCoroutine: SelectCardCoroutine,
  113. afterSelectCardCoroutine: null,
  114. message: "Select 1 [SkullKnightmon].",
  115. maxCount: maxCount,
  116. canEndNotMax: false,
  117. isShowOpponent: true,
  118. mode: SelectCardEffect.Mode.Custom,
  119. root: SelectCardEffect.Root.Trash,
  120. customRootCardList: null,
  121. canLookReverseCard: true,
  122. selectPlayer: card.Owner,
  123. cardEffect: activateClass);
  124. selectCardEffect.SetUpCustomMessage("Select 1 [SkullKnightmon].", "The opponent is selecting 1 [SkullKnightmon].");
  125. selectCardEffect.SetUpCustomMessage_ShowCard("Selected Card");
  126. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  127. }
  128. }
  129. }
  130. {
  131. bool canSelectHand = card.Owner.HandCards.Count(CanSelectCardCondition1) >= 1;
  132. bool canSelectTrash = CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition1);
  133. if (canSelectHand || canSelectTrash)
  134. {
  135. if (canSelectHand && canSelectTrash)
  136. {
  137. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  138. {
  139. new SelectionElement<bool>(message: $"From hand", value : true, spriteIndex: 0),
  140. new SelectionElement<bool>(message: $"From trash", value : false, spriteIndex: 1),
  141. };
  142. string selectPlayerMessage = "From which area do you select 1 [DeadlyAxemon]?";
  143. string notSelectPlayerMessage = "The opponent is choosing from which area to select 1 [DeadlyAxemon].";
  144. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  145. }
  146. else
  147. {
  148. GManager.instance.userSelectionManager.SetBool(canSelectHand);
  149. }
  150. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  151. bool fromHand = GManager.instance.userSelectionManager.SelectedBoolValue;
  152. IEnumerator SelectCardCoroutine(CardSource cardSource)
  153. {
  154. selectedCards.Add(cardSource);
  155. yield return null;
  156. }
  157. if (fromHand)
  158. {
  159. int maxCount = 1;
  160. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  161. selectHandEffect.SetUp(
  162. selectPlayer: card.Owner,
  163. canTargetCondition: CanSelectCardCondition1,
  164. canTargetCondition_ByPreSelecetedList: null,
  165. canEndSelectCondition: null,
  166. maxCount: maxCount,
  167. canNoSelect: true,
  168. canEndNotMax: false,
  169. isShowOpponent: true,
  170. selectCardCoroutine: SelectCardCoroutine,
  171. afterSelectCardCoroutine: null,
  172. mode: SelectHandEffect.Mode.Custom,
  173. cardEffect: activateClass);
  174. selectHandEffect.SetUpCustomMessage("Select 1 [DeadlyAxemon].", "The opponent is selecting 1 [DeadlyAxemon].");
  175. selectHandEffect.SetUpCustomMessage_ShowCard("Selected Card");
  176. yield return StartCoroutine(selectHandEffect.Activate());
  177. }
  178. else
  179. {
  180. int maxCount = 1;
  181. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  182. selectCardEffect.SetUp(
  183. canTargetCondition: CanSelectCardCondition1,
  184. canTargetCondition_ByPreSelecetedList: null,
  185. canEndSelectCondition: null,
  186. canNoSelect: () => false,
  187. selectCardCoroutine: SelectCardCoroutine,
  188. afterSelectCardCoroutine: null,
  189. message: "Select 1 [DeadlyAxemon].",
  190. maxCount: maxCount,
  191. canEndNotMax: false,
  192. isShowOpponent: true,
  193. mode: SelectCardEffect.Mode.Custom,
  194. root: SelectCardEffect.Root.Trash,
  195. customRootCardList: null,
  196. canLookReverseCard: true,
  197. selectPlayer: card.Owner,
  198. cardEffect: activateClass);
  199. selectCardEffect.SetUpCustomMessage("Select 1 [DeadlyAxemon].", "The opponent is selecting 1 [DeadlyAxemon].");
  200. selectCardEffect.SetUpCustomMessage_ShowCard("Selected Card");
  201. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  202. }
  203. }
  204. }
  205. if (selectedCards.Count >= 1)
  206. {
  207. foreach (CardSource selectedCard in selectedCards)
  208. {
  209. yield return ContinuousController.instance.StartCoroutine(CardObjectController.RemoveFromAllArea(selectedCard));
  210. }
  211. if (selectedCards.Count >= 1)
  212. {
  213. List<CardSource> digivolutionCards_fixed = new List<CardSource>();
  214. if (selectedCards.Count == 1)
  215. {
  216. foreach (CardSource cardSource in selectedCards)
  217. {
  218. digivolutionCards_fixed = selectedCards.Clone();
  219. }
  220. }
  221. else
  222. {
  223. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  224. selectCardEffect.SetUp(
  225. canTargetCondition: (cardSource) => true,
  226. canTargetCondition_ByPreSelecetedList: null,
  227. canEndSelectCondition: null,
  228. canNoSelect: () => false,
  229. selectCardCoroutine: null,
  230. afterSelectCardCoroutine: AfterSelectCardCoroutine1,
  231. 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).",
  232. maxCount: selectedCards.Count,
  233. canEndNotMax: false,
  234. isShowOpponent: false,
  235. mode: SelectCardEffect.Mode.Custom,
  236. root: SelectCardEffect.Root.Custom,
  237. customRootCardList: selectedCards,
  238. canLookReverseCard: true,
  239. selectPlayer: card.Owner,
  240. cardEffect: activateClass);
  241. selectCardEffect.SetUpCustomMessage_ShowCard("Digivolution Cards");
  242. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  243. IEnumerator AfterSelectCardCoroutine1(List<CardSource> cardSources)
  244. {
  245. digivolutionCards_fixed = cardSources.Clone();
  246. yield return null;
  247. }
  248. }
  249. if (digivolutionCards_fixed.Count >= 1)
  250. {
  251. if (CardEffectCommons.IsExistOnBattleArea(card))
  252. {
  253. digivolutionCards_fixed.Reverse();
  254. yield return ContinuousController.instance.StartCoroutine(card.PermanentOfThisCard().AddDigivolutionCardsTop(digivolutionCards_fixed, activateClass));
  255. }
  256. }
  257. }
  258. }
  259. }
  260. }
  261. }
  262. if (timing == EffectTiming.WhenPermanentWouldBeDeleted)
  263. {
  264. ActivateClass activateClass = new ActivateClass();
  265. activateClass.SetUpICardEffect("Play [SkullKnightmon] and [DeadlyAxemon] from digivolution cards", CanUseCondition, card);
  266. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  267. activateClass.SetHashString("PlayDigivolutionCards_BT7_063");
  268. cardEffects.Add(activateClass);
  269. string EffectDiscription()
  270. {
  271. return "[All Turns] When this Digimon would be deleted, you may play 1 [SkullKnightmon] and 1 [DeadlyAxemon] from this Digimon's digivolution cards suspended without paying their memory costs.";
  272. }
  273. bool CanSelectCardCondition(CardSource cardSource)
  274. {
  275. if (cardSource.IsDigimon)
  276. {
  277. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  278. {
  279. if (cardSource.CardNames.Contains("SkullKnightmon"))
  280. {
  281. return true;
  282. }
  283. }
  284. }
  285. return false;
  286. }
  287. bool CanSelectCardCondition1(CardSource cardSource)
  288. {
  289. if (cardSource.IsDigimon)
  290. {
  291. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  292. {
  293. if (cardSource.CardNames.Contains("DeadlyAxemon"))
  294. {
  295. return true;
  296. }
  297. }
  298. }
  299. return false;
  300. }
  301. bool CanUseCondition(Hashtable hashtable)
  302. {
  303. if (CardEffectCommons.IsExistOnBattleArea(card))
  304. {
  305. if (CardEffectCommons.CanTriggerWhenRemoveField(hashtable, card))
  306. {
  307. return true;
  308. }
  309. }
  310. return false;
  311. }
  312. bool CanActivateCondition(Hashtable hashtable)
  313. {
  314. if (CardEffectCommons.IsExistOnBattleArea(card))
  315. {
  316. if (card.PermanentOfThisCard().DigivolutionCards.Count((cardSource) => CanSelectCardCondition(cardSource) || CanSelectCardCondition1(cardSource)) >= 1)
  317. {
  318. return true;
  319. }
  320. }
  321. return false;
  322. }
  323. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  324. {
  325. if (CardEffectCommons.IsExistOnBattleArea(card))
  326. {
  327. Permanent selectedPermanent = card.PermanentOfThisCard();
  328. if (card.PermanentOfThisCard().DigivolutionCards.Count((cardSource) => CanSelectCardCondition(cardSource) || CanSelectCardCondition1(cardSource)) >= 1)
  329. {
  330. List<CardSource> selectedCards = new List<CardSource>();
  331. int maxCount = 2;
  332. #region max count
  333. List<CardSource[]> cardsList = ParameterComparer.Enumerate(card.PermanentOfThisCard().DigivolutionCards, maxCount).ToList();
  334. List<int> maxCounts = new List<int>() { 0 };
  335. foreach (CardSource[] cardSources in cardsList)
  336. {
  337. List<int> _maxCounts = new List<int>();
  338. if (cardSources.Length >= 2)
  339. {
  340. if (CanSelectCardCondition(cardSources[0]))
  341. {
  342. if (CanSelectCardCondition1(cardSources[1]))
  343. {
  344. _maxCounts.Add(2);
  345. }
  346. else
  347. {
  348. _maxCounts.Add(1);
  349. }
  350. }
  351. if (CanSelectCardCondition1(cardSources[0]))
  352. {
  353. if (CanSelectCardCondition(cardSources[1]))
  354. {
  355. _maxCounts.Add(2);
  356. }
  357. else
  358. {
  359. _maxCounts.Add(1);
  360. }
  361. }
  362. if (!CanSelectCardCondition(cardSources[0]) && !CanSelectCardCondition1(cardSources[0]))
  363. {
  364. if (CanSelectCardCondition(cardSources[1]))
  365. {
  366. _maxCounts.Add(1);
  367. }
  368. if (CanSelectCardCondition1(cardSources[1]))
  369. {
  370. _maxCounts.Add(1);
  371. }
  372. }
  373. }
  374. else if (cardSources.Length == 1)
  375. {
  376. if (CanSelectCardCondition(cardSources[0]))
  377. {
  378. _maxCounts.Add(1);
  379. }
  380. else if (CanSelectCardCondition1(cardSources[0]))
  381. {
  382. _maxCounts.Add(1);
  383. }
  384. }
  385. if (_maxCounts.Count >= 1)
  386. {
  387. maxCounts.Add(_maxCounts.Max());
  388. }
  389. }
  390. if (maxCounts.Count >= 1)
  391. {
  392. maxCount = maxCounts.Max();
  393. }
  394. #endregion
  395. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  396. selectCardEffect.SetUp(
  397. canTargetCondition: (cardSource) => CanSelectCardCondition(cardSource) || CanSelectCardCondition1(cardSource),
  398. canTargetCondition_ByPreSelecetedList: CanTargetCondition_ByPreSelecetedList,
  399. canEndSelectCondition: CanEndSelectCondition,
  400. canNoSelect: () => true,
  401. selectCardCoroutine: SelectCardCoroutine,
  402. afterSelectCardCoroutine: null,
  403. message: "Select cards to play.",
  404. maxCount: maxCount,
  405. canEndNotMax: false,
  406. isShowOpponent: true,
  407. mode: SelectCardEffect.Mode.Custom,
  408. root: SelectCardEffect.Root.Custom,
  409. customRootCardList: selectedPermanent.DigivolutionCards,
  410. canLookReverseCard: true,
  411. selectPlayer: card.Owner,
  412. cardEffect: activateClass);
  413. selectCardEffect.SetUpCustomMessage("Select digivolution cards to play.", "The opponent is selecting digivolution cards to play.");
  414. selectCardEffect.SetUpCustomMessage_ShowCard("Played Cards");
  415. yield return StartCoroutine(selectCardEffect.Activate());
  416. #region CanTargetCondition_ByPreSelecetedList
  417. bool CanTargetCondition_ByPreSelecetedList(List<CardSource> cardSources, CardSource cardSource)
  418. {
  419. List<CardSource> _cardSources = new List<CardSource>();
  420. foreach (CardSource cardSource1 in cardSources)
  421. {
  422. _cardSources.Add(cardSource1);
  423. }
  424. _cardSources.Add(cardSource);
  425. List<CardSource[]> cardsList = ParameterComparer.Enumerate(_cardSources, _cardSources.Count).ToList();
  426. bool match = false;
  427. if (cardsList.Count >= 2)
  428. {
  429. foreach (CardSource[] cardSources1 in cardsList)
  430. {
  431. if (CanSelectCardCondition(cardSources1[0]))
  432. {
  433. if (CanSelectCardCondition1(cardSources1[1]))
  434. {
  435. match = true;
  436. }
  437. }
  438. if (CanSelectCardCondition1(cardSources1[0]))
  439. {
  440. if (CanSelectCardCondition(cardSources1[1]))
  441. {
  442. match = true;
  443. }
  444. }
  445. }
  446. }
  447. else
  448. {
  449. match = true;
  450. }
  451. if (!match)
  452. {
  453. return false;
  454. }
  455. return true;
  456. }
  457. #endregion
  458. #region CanEndSelectCondition
  459. bool CanEndSelectCondition(List<CardSource> cardSources)
  460. {
  461. List<CardSource[]> cardsList = ParameterComparer.Enumerate(cardSources, cardSources.Count).ToList();
  462. bool match = false;
  463. if (cardsList.Count >= 2)
  464. {
  465. foreach (CardSource[] cardSources1 in cardsList)
  466. {
  467. if (CanSelectCardCondition(cardSources1[0]))
  468. {
  469. if (CanSelectCardCondition1(cardSources1[1]))
  470. {
  471. match = true;
  472. }
  473. }
  474. if (CanSelectCardCondition1(cardSources1[0]))
  475. {
  476. if (CanSelectCardCondition(cardSources1[1]))
  477. {
  478. match = true;
  479. }
  480. }
  481. }
  482. }
  483. else
  484. {
  485. match = true;
  486. }
  487. if (!match)
  488. {
  489. return false;
  490. }
  491. return true;
  492. }
  493. #endregion
  494. IEnumerator SelectCardCoroutine(CardSource cardSource)
  495. {
  496. selectedCards.Add(cardSource);
  497. yield return null;
  498. }
  499. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  500. cardSources: selectedCards,
  501. activateClass: activateClass,
  502. payCost: false,
  503. isTapped: true,
  504. root: SelectCardEffect.Root.DigivolutionCards,
  505. activateETB: true));
  506. }
  507. }
  508. }
  509. }
  510. return cardEffects;
  511. }
  512. }