EX2_048.cs 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630
  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. if (card.Owner.isYou)
  105. {
  106. GManager.instance.commandText.OpenCommandText("From which area do you select a card?");
  107. List<Command_SelectCommand> command_SelectCommands = new List<Command_SelectCommand>()
  108. {
  109. new Command_SelectCommand($"From Field", () => photonView.RPC("SetFromHand", RpcTarget.All, false), 0),
  110. new Command_SelectCommand($"From hand", () => photonView.RPC("SetFromHand", RpcTarget.All, true), 1),
  111. };
  112. GManager.instance.selectCommandPanel.SetUpCommandButton(command_SelectCommands);
  113. }
  114. else
  115. {
  116. GManager.instance.commandText.OpenCommandText("The opponent is choosing from which area to select a card.");
  117. #region AIƒ‚�[ƒh
  118. if (GManager.instance.IsAI)
  119. {
  120. SetFromHand(RandomUtility.IsSucceedProbability(0.5f));
  121. }
  122. #endregion
  123. }
  124. }
  125. else if (!CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition) && card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  126. {
  127. SetFromHand(true);
  128. }
  129. else if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition) && card.Owner.HandCards.Count(CanSelectCardCondition) == 0)
  130. {
  131. SetFromHand(false);
  132. }
  133. yield return new WaitWhile(() => !endSelect);
  134. endSelect = false;
  135. GManager.instance.commandText.CloseCommandText();
  136. yield return new WaitWhile(() => GManager.instance.commandText.gameObject.activeSelf);
  137. List<CardSource> selectedCards = new List<CardSource>();
  138. Permanent selectedPermanent = null;
  139. if (fromHand)
  140. {
  141. if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  142. {
  143. int maxCount = 1;
  144. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  145. selectHandEffect.SetUp(
  146. selectPlayer: card.Owner,
  147. canTargetCondition: CanSelectCardCondition,
  148. canTargetCondition_ByPreSelecetedList: null,
  149. canEndSelectCondition: null,
  150. maxCount: maxCount,
  151. canNoSelect: true,
  152. canEndNotMax: false,
  153. isShowOpponent: true,
  154. selectCardCoroutine: SelectCardCoroutine,
  155. afterSelectCardCoroutine: null,
  156. mode: SelectHandEffect.Mode.Custom,
  157. cardEffect: activateClass);
  158. 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.");
  159. //selectHandEffect.SetUpCustomMessage_ShowCard("Digivolution Card");
  160. yield return StartCoroutine(selectHandEffect.Activate());
  161. IEnumerator SelectCardCoroutine(CardSource cardSource)
  162. {
  163. selectedCards.Add(cardSource);
  164. yield return null;
  165. }
  166. }
  167. }
  168. else
  169. {
  170. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  171. {
  172. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  173. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  174. selectPermanentEffect.SetUp(
  175. selectPlayer: card.Owner,
  176. canTargetCondition: CanSelectPermanentCondition,
  177. canTargetCondition_ByPreSelecetedList: null,
  178. canEndSelectCondition: null,
  179. maxCount: maxCount,
  180. canNoSelect: false,
  181. canEndNotMax: false,
  182. selectPermanentCoroutine: SelectPermanentCoroutine,
  183. afterSelectPermanentCoroutine: null,
  184. mode: SelectPermanentEffect.Mode.Custom,
  185. cardEffect: activateClass);
  186. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to place in digivolution cards.", "The opponent is selecting 1 Digimon to place in digivolution cards.");
  187. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  188. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  189. {
  190. selectedPermanent = permanent;
  191. yield return null;
  192. }
  193. }
  194. }
  195. Permanent getDigivolutiuonDigimon = null;
  196. if ((fromHand && selectedCards.Count >= 1) || (!fromHand && selectedPermanent != null))
  197. {
  198. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition1))
  199. {
  200. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition1));
  201. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  202. selectPermanentEffect.SetUp(
  203. selectPlayer: card.Owner,
  204. canTargetCondition: CanSelectPermanentCondition1,
  205. canTargetCondition_ByPreSelecetedList: null,
  206. canEndSelectCondition: null,
  207. maxCount: maxCount,
  208. canNoSelect: true,
  209. canEndNotMax: false,
  210. selectPermanentCoroutine: SelectPermanentCoroutine,
  211. afterSelectPermanentCoroutine: null,
  212. mode: SelectPermanentEffect.Mode.Custom,
  213. cardEffect: activateClass);
  214. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will get a digivolution card.", "The opponent is selecting 1 Digimon that will get a digivolution card.");
  215. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  216. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  217. {
  218. getDigivolutiuonDigimon = permanent;
  219. yield return null;
  220. }
  221. }
  222. }
  223. if (getDigivolutiuonDigimon != null)
  224. {
  225. if (!getDigivolutiuonDigimon.IsToken)
  226. {
  227. if (fromHand)
  228. {
  229. if (selectedCards.Count >= 1)
  230. {
  231. yield return ContinuousController.instance.StartCoroutine(getDigivolutiuonDigimon.AddDigivolutionCardsBottom(selectedCards, activateClass));
  232. }
  233. }
  234. else
  235. {
  236. if (selectedPermanent != null)
  237. {
  238. yield return ContinuousController.instance.StartCoroutine(new IPlacePermanentToDigivolutionCards(new List<Permanent[]>() { new Permanent[] { selectedPermanent, getDigivolutiuonDigimon } }, false, activateClass).PlacePermanentToDigivolutionCards());
  239. }
  240. }
  241. }
  242. }
  243. }
  244. }
  245. }
  246. }
  247. if (timing == EffectTiming.OnEnterFieldAnyone)
  248. {
  249. ActivateClass activateClass = new ActivateClass();
  250. activateClass.SetUpICardEffect("Place 1 [ADR-02 Searcher] under your [Mother D-Reaper]'s digivolution cards", CanUseCondition, card);
  251. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  252. cardEffects.Add(activateClass);
  253. string EffectDiscription()
  254. {
  255. 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.";
  256. }
  257. bool CanSelectPermanentCondition(Permanent permanent)
  258. {
  259. if (permanent != null)
  260. {
  261. if (permanent.TopCard != null)
  262. {
  263. if (permanent.IsDigimon)
  264. {
  265. if (permanent.TopCard.Owner == card.Owner)
  266. {
  267. if (permanent.TopCard.Owner.GetBattleAreaPermanents().Contains(permanent))
  268. {
  269. if (!permanent.IsToken)
  270. {
  271. if (permanent.TopCard.CardNames.Contains("ADR-02 Searcher"))
  272. {
  273. return true;
  274. }
  275. if (permanent.TopCard.CardNames.Contains("ADR-02Searcher"))
  276. {
  277. return true;
  278. }
  279. }
  280. }
  281. }
  282. }
  283. }
  284. }
  285. return false;
  286. }
  287. bool CanSelectCardCondition(CardSource cardSource)
  288. {
  289. if (cardSource != null)
  290. {
  291. if (cardSource.Owner == card.Owner)
  292. {
  293. if (!cardSource.IsToken)
  294. {
  295. if (cardSource.CardNames.Contains("ADR-02 Searcher"))
  296. {
  297. return true;
  298. }
  299. if (cardSource.CardNames.Contains("ADR-02Searcher"))
  300. {
  301. return true;
  302. }
  303. }
  304. }
  305. }
  306. return false;
  307. }
  308. bool CanSelectPermanentCondition1(Permanent permanent)
  309. {
  310. if (permanent != null)
  311. {
  312. if (permanent.TopCard != null)
  313. {
  314. if (permanent.IsDigimon)
  315. {
  316. if (permanent.TopCard.Owner == card.Owner)
  317. {
  318. if (permanent.TopCard.Owner.GetBattleAreaPermanents().Contains(permanent))
  319. {
  320. if (!permanent.IsToken)
  321. {
  322. if (permanent.TopCard.CardNames.Contains("Mother D-Reaper"))
  323. {
  324. return true;
  325. }
  326. if (permanent.TopCard.CardNames.Contains("MotherD-Reaper"))
  327. {
  328. return true;
  329. }
  330. }
  331. }
  332. }
  333. }
  334. }
  335. }
  336. return false;
  337. }
  338. bool CanUseCondition(Hashtable hashtable)
  339. {
  340. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  341. }
  342. bool CanActivateCondition(Hashtable hashtable)
  343. {
  344. if (CardEffectCommons.IsExistOnBattleArea(card))
  345. {
  346. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition1))
  347. {
  348. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition) || card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  349. {
  350. return true;
  351. }
  352. }
  353. }
  354. return false;
  355. }
  356. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  357. {
  358. if (isExistOnField(card))
  359. {
  360. if (card.Owner.GetBattleAreaDigimons().Contains(card.PermanentOfThisCard()))
  361. {
  362. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition1))
  363. {
  364. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition) || card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  365. {
  366. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition) && card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  367. {
  368. if (card.Owner.isYou)
  369. {
  370. GManager.instance.commandText.OpenCommandText("From which area do you select a card?");
  371. List<Command_SelectCommand> command_SelectCommands = new List<Command_SelectCommand>()
  372. {
  373. new Command_SelectCommand($"From Field", () => photonView.RPC("SetFromHand", RpcTarget.All, false), 0),
  374. new Command_SelectCommand($"From hand", () => photonView.RPC("SetFromHand", RpcTarget.All, true), 1),
  375. };
  376. GManager.instance.selectCommandPanel.SetUpCommandButton(command_SelectCommands);
  377. }
  378. else
  379. {
  380. GManager.instance.commandText.OpenCommandText("The opponent is choosing from which area to select a card.");
  381. #region AIƒ‚�[ƒh
  382. if (GManager.instance.IsAI)
  383. {
  384. SetFromHand(RandomUtility.IsSucceedProbability(0.5f));
  385. }
  386. #endregion
  387. }
  388. }
  389. else if (!CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition) && card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  390. {
  391. SetFromHand(true);
  392. }
  393. else if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition) && card.Owner.HandCards.Count(CanSelectCardCondition) == 0)
  394. {
  395. SetFromHand(false);
  396. }
  397. yield return new WaitWhile(() => !endSelect);
  398. endSelect = false;
  399. GManager.instance.commandText.CloseCommandText();
  400. yield return new WaitWhile(() => GManager.instance.commandText.gameObject.activeSelf);
  401. List<CardSource> selectedCards = new List<CardSource>();
  402. Permanent selectedPermanent = null;
  403. if (fromHand)
  404. {
  405. if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  406. {
  407. int maxCount = 1;
  408. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  409. selectHandEffect.SetUp(
  410. selectPlayer: card.Owner,
  411. canTargetCondition: CanSelectCardCondition,
  412. canTargetCondition_ByPreSelecetedList: null,
  413. canEndSelectCondition: null,
  414. maxCount: maxCount,
  415. canNoSelect: true,
  416. canEndNotMax: false,
  417. isShowOpponent: true,
  418. selectCardCoroutine: SelectCardCoroutine,
  419. afterSelectCardCoroutine: null,
  420. mode: SelectHandEffect.Mode.Custom,
  421. cardEffect: activateClass);
  422. 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.");
  423. //selectHandEffect.SetUpCustomMessage_ShowCard("Digivolution Card");
  424. yield return StartCoroutine(selectHandEffect.Activate());
  425. IEnumerator SelectCardCoroutine(CardSource cardSource)
  426. {
  427. selectedCards.Add(cardSource);
  428. yield return null;
  429. }
  430. }
  431. }
  432. else
  433. {
  434. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  435. {
  436. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  437. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  438. selectPermanentEffect.SetUp(
  439. selectPlayer: card.Owner,
  440. canTargetCondition: CanSelectPermanentCondition,
  441. canTargetCondition_ByPreSelecetedList: null,
  442. canEndSelectCondition: null,
  443. maxCount: maxCount,
  444. canNoSelect: false,
  445. canEndNotMax: false,
  446. selectPermanentCoroutine: SelectPermanentCoroutine,
  447. afterSelectPermanentCoroutine: null,
  448. mode: SelectPermanentEffect.Mode.Custom,
  449. cardEffect: activateClass);
  450. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to place in digivolution cards.", "The opponent is selecting 1 Digimon to place in digivolution cards.");
  451. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  452. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  453. {
  454. selectedPermanent = permanent;
  455. yield return null;
  456. }
  457. }
  458. }
  459. Permanent getDigivolutiuonDigimon = null;
  460. if ((fromHand && selectedCards.Count >= 1) || (!fromHand && selectedPermanent != null))
  461. {
  462. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition1))
  463. {
  464. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition1));
  465. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  466. selectPermanentEffect.SetUp(
  467. selectPlayer: card.Owner,
  468. canTargetCondition: CanSelectPermanentCondition1,
  469. canTargetCondition_ByPreSelecetedList: null,
  470. canEndSelectCondition: null,
  471. maxCount: maxCount,
  472. canNoSelect: true,
  473. canEndNotMax: false,
  474. selectPermanentCoroutine: SelectPermanentCoroutine,
  475. afterSelectPermanentCoroutine: null,
  476. mode: SelectPermanentEffect.Mode.Custom,
  477. cardEffect: activateClass);
  478. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will get a digivolution card.", "The opponent is selecting 1 Digimon that will get a digivolution card.");
  479. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  480. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  481. {
  482. getDigivolutiuonDigimon = permanent;
  483. yield return null;
  484. }
  485. }
  486. }
  487. if (getDigivolutiuonDigimon != null)
  488. {
  489. if (!getDigivolutiuonDigimon.IsToken)
  490. {
  491. if (fromHand)
  492. {
  493. if (selectedCards.Count >= 1)
  494. {
  495. yield return ContinuousController.instance.StartCoroutine(getDigivolutiuonDigimon.AddDigivolutionCardsBottom(selectedCards, activateClass));
  496. }
  497. }
  498. else
  499. {
  500. if (selectedPermanent != null)
  501. {
  502. yield return ContinuousController.instance.StartCoroutine(new IPlacePermanentToDigivolutionCards(new List<Permanent[]>() { new Permanent[] { selectedPermanent, getDigivolutiuonDigimon } }, false, activateClass).PlacePermanentToDigivolutionCards());
  503. }
  504. }
  505. }
  506. }
  507. }
  508. }
  509. }
  510. }
  511. }
  512. }
  513. return cardEffects;
  514. }
  515. bool endSelect = false;
  516. bool fromHand = false;
  517. [PunRPC]
  518. public void SetFromHand(bool fromHand)
  519. {
  520. this.fromHand = fromHand;
  521. endSelect = true;
  522. }
  523. }
  524. }