EX2_048.cs 31 KB

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