EX6_031.cs 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604
  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. namespace DCGO.CardEffects.EX6
  9. {
  10. public class EX6_031 : CEntity_Effect
  11. {
  12. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  13. {
  14. List<ICardEffect> cardEffects = new List<ICardEffect>();
  15. #region Alternate Digivolution
  16. if (timing == EffectTiming.None)
  17. {
  18. bool PermanentCondition(Permanent targetPermanent)
  19. {
  20. return targetPermanent.TopCard.ContainsCardName("Sanzomon") ||
  21. targetPermanent.TopCard.ContainsCardName("Gokuumon") ||
  22. targetPermanent.TopCard.ContainsCardName("Sagomon") ||
  23. targetPermanent.TopCard.ContainsCardName("Cho-Hakkaimon");
  24. }
  25. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  26. permanentCondition: PermanentCondition,
  27. digivolutionCost: 6,
  28. ignoreDigivolutionRequirement: false,
  29. card: card,
  30. condition: null)
  31. );
  32. }
  33. #endregion
  34. #region DigiXros
  35. if (timing == EffectTiming.None)
  36. {
  37. AddDigiXrosConditionClass addDigiXrosConditionClass = new AddDigiXrosConditionClass();
  38. addDigiXrosConditionClass.SetUpICardEffect($"DigiXros -2", CanUseCondition, card);
  39. addDigiXrosConditionClass.SetUpAddDigiXrosConditionClass(getDigiXrosCondition: GetDigiXros);
  40. addDigiXrosConditionClass.SetNotShowUI(true);
  41. cardEffects.Add(addDigiXrosConditionClass);
  42. bool CanUseCondition(Hashtable hashtable)
  43. {
  44. return true;
  45. }
  46. DigiXrosCondition GetDigiXros(CardSource cardSource)
  47. {
  48. if (cardSource == card)
  49. {
  50. DigiXrosConditionElement elementSanzomon =
  51. new DigiXrosConditionElement(CanSelectCardConditionSanzomon, "Sanzomon");
  52. bool CanSelectCardConditionSanzomon(CardSource conditionCardSource)
  53. {
  54. if (conditionCardSource != null)
  55. {
  56. if (conditionCardSource.Owner == card.Owner)
  57. {
  58. if (conditionCardSource.IsDigimon)
  59. {
  60. if (conditionCardSource.CardNames_DigiXros.Contains("Sanzomon"))
  61. {
  62. return true;
  63. }
  64. }
  65. }
  66. }
  67. return false;
  68. }
  69. DigiXrosConditionElement elementGokuumon =
  70. new DigiXrosConditionElement(CanSelectCardConditionGokuumon, "Gokuumon");
  71. bool CanSelectCardConditionGokuumon(CardSource conditionCardSource)
  72. {
  73. if (conditionCardSource != null)
  74. {
  75. if (conditionCardSource.Owner == card.Owner)
  76. {
  77. if (conditionCardSource.IsDigimon)
  78. {
  79. if (conditionCardSource.CardNames_DigiXros.Contains("Gokuumon"))
  80. {
  81. return true;
  82. }
  83. }
  84. }
  85. }
  86. return false;
  87. }
  88. DigiXrosConditionElement elementSagomon =
  89. new DigiXrosConditionElement(CanSelectCardConditionSagomon, "Sagomon");
  90. bool CanSelectCardConditionSagomon(CardSource conditionCardSource)
  91. {
  92. if (conditionCardSource != null)
  93. {
  94. if (conditionCardSource.Owner == card.Owner)
  95. {
  96. if (conditionCardSource.IsDigimon)
  97. {
  98. if (conditionCardSource.CardNames_DigiXros.Contains("Sagomon"))
  99. {
  100. return true;
  101. }
  102. }
  103. }
  104. }
  105. return false;
  106. }
  107. DigiXrosConditionElement elementChoHakkaimon =
  108. new DigiXrosConditionElement(CanSelectCardConditionChoHakkaimon, "Cho-Hakkaimon");
  109. bool CanSelectCardConditionChoHakkaimon(CardSource conditionCardSource)
  110. {
  111. if (conditionCardSource != null)
  112. {
  113. if (conditionCardSource.Owner == card.Owner)
  114. {
  115. if (conditionCardSource.IsDigimon)
  116. {
  117. if (conditionCardSource.CardNames_DigiXros.Contains("Cho-Hakkaimon"))
  118. {
  119. return true;
  120. }
  121. }
  122. }
  123. }
  124. return false;
  125. }
  126. List<DigiXrosConditionElement> elements = new List<DigiXrosConditionElement>()
  127. { elementSanzomon, elementGokuumon, elementSagomon, elementChoHakkaimon };
  128. DigiXrosCondition digiXrosCondition = new DigiXrosCondition(elements, null, 2);
  129. return digiXrosCondition;
  130. }
  131. return null;
  132. }
  133. }
  134. #endregion
  135. #region On Play/ When Digivolving Shared
  136. bool CanActivateSharedCondition(Hashtable hashtable)
  137. {
  138. return CardEffectCommons.IsExistOnBattleArea(card);
  139. }
  140. #endregion
  141. #region On Play
  142. if (timing == EffectTiming.OnEnterFieldAnyone)
  143. {
  144. ActivateClass activateClass = new ActivateClass();
  145. activateClass.SetUpICardEffect("Security Attack -1", CanUseCondition, card);
  146. activateClass.SetUpActivateClass(CanActivateSharedCondition, ActivateCoroutine, -1, false,
  147. EffectDescription());
  148. cardEffects.Add(activateClass);
  149. string EffectDescription()
  150. {
  151. return "[On Play] All Digimon gain <Security Attack -1> until the end of your opponent's turn.";
  152. }
  153. bool CanUseCondition(Hashtable hashtable)
  154. {
  155. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  156. }
  157. IEnumerator ActivateCoroutine(Hashtable hashtable)
  158. {
  159. bool PermanentCondition(Permanent permanent)
  160. {
  161. if (CardEffectCommons.IsPermanentExistsOnBattleArea(permanent))
  162. {
  163. if (permanent.IsDigimon)
  164. {
  165. return true;
  166. }
  167. }
  168. return false;
  169. }
  170. yield return ContinuousController.instance.StartCoroutine(
  171. CardEffectCommons.ChangeDigimonSAttackPlayerEffect(
  172. permanentCondition: PermanentCondition,
  173. changeValue: -1,
  174. effectDuration: EffectDuration.UntilOpponentTurnEnd,
  175. activateClass: activateClass));
  176. }
  177. }
  178. #endregion
  179. #region When Digivolving
  180. if (timing == EffectTiming.OnEnterFieldAnyone)
  181. {
  182. ActivateClass activateClass = new ActivateClass();
  183. activateClass.SetUpICardEffect("Security Attack -1", CanUseCondition, card);
  184. activateClass.SetUpActivateClass(CanActivateSharedCondition, ActivateCoroutine, -1, false,
  185. EffectDescription());
  186. cardEffects.Add(activateClass);
  187. string EffectDescription()
  188. {
  189. return "[When Digivolving] All Digimon gain <Security Attack -1> until the end of your opponent's turn.";
  190. }
  191. bool CanUseCondition(Hashtable hashtable)
  192. {
  193. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  194. }
  195. IEnumerator ActivateCoroutine(Hashtable hashtable)
  196. {
  197. bool PermanentCondition(Permanent permanent)
  198. {
  199. if (CardEffectCommons.IsPermanentExistsOnBattleArea(permanent))
  200. {
  201. if (permanent.IsDigimon)
  202. {
  203. return true;
  204. }
  205. }
  206. return false;
  207. }
  208. yield return ContinuousController.instance.StartCoroutine(
  209. CardEffectCommons.ChangeDigimonSAttackPlayerEffect(
  210. permanentCondition: PermanentCondition,
  211. changeValue: -1,
  212. effectDuration: EffectDuration.UntilOpponentTurnEnd,
  213. activateClass: activateClass));
  214. }
  215. }
  216. #endregion
  217. #region All Turns
  218. if (timing == EffectTiming.WhenPermanentWouldBeDeleted || timing == EffectTiming.WhenReturntoHandAnyone || timing == EffectTiming.WhenReturntoLibraryAnyone)
  219. {
  220. ActivateClass activateClass = new ActivateClass();
  221. activateClass.SetUpICardEffect(
  222. "Play 1 [Sanzomon] and 1 [Gokuumon]/[Sagomon]/[Cho-Hakkaimon] from its digivolution cards without paying the cost.",
  223. CanUseCondition, card);
  224. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true,
  225. EffectDescription());
  226. activateClass.SetHashString("PlaySourceCard_EX6_031");
  227. cardEffects.Add(activateClass);
  228. string EffectDescription()
  229. {
  230. return
  231. "[All Turns] When this Digimon would be deleted or returned to the hand or deck, you may play 1 [Sanzomon] and 1 [Gokuumon]/[Sagomon]/[Cho-Hakkaimon] from its digivolution cards without paying the cost.";
  232. }
  233. bool CanSelectDigimonSanzomonCardCondition(CardSource cardSource)
  234. {
  235. if (cardSource.IsDigimon)
  236. {
  237. if (cardSource.ContainsCardName("Sanzomon"))
  238. {
  239. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false,
  240. cardEffect: activateClass))
  241. {
  242. return true;
  243. }
  244. }
  245. }
  246. return false;
  247. }
  248. bool CanSelectDigimonJourneyCardCondition(CardSource cardSource)
  249. {
  250. if (cardSource.IsDigimon)
  251. {
  252. if (cardSource.ContainsCardName("Gokuumon") ||
  253. cardSource.ContainsCardName("Sagomon") ||
  254. cardSource.ContainsCardName("Cho-Hakkaimon"))
  255. {
  256. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false,
  257. cardEffect: activateClass))
  258. {
  259. return true;
  260. }
  261. }
  262. }
  263. return false;
  264. }
  265. bool CanUseCondition(Hashtable hashtable)
  266. {
  267. if (CardEffectCommons.IsExistOnBattleArea(card))
  268. {
  269. if (CardEffectCommons.CanTriggerWhenRemoveField(hashtable, card))
  270. {
  271. return true;
  272. }
  273. }
  274. return false;
  275. }
  276. bool CanActivateCondition(Hashtable hashtable)
  277. {
  278. if (CardEffectCommons.IsExistOnBattleArea(card))
  279. {
  280. if (card.PermanentOfThisCard().DigivolutionCards.Count >= 1)
  281. {
  282. if (card.PermanentOfThisCard().DigivolutionCards
  283. .Count(CanSelectDigimonSanzomonCardCondition) >= 1)
  284. {
  285. return true;
  286. }
  287. if (card.PermanentOfThisCard().DigivolutionCards
  288. .Count(CanSelectDigimonJourneyCardCondition) >= 1)
  289. {
  290. return true;
  291. }
  292. }
  293. }
  294. return false;
  295. }
  296. IEnumerator ActivateCoroutine(Hashtable hashtable)
  297. {
  298. if (CardEffectCommons.IsExistOnBattleArea(card))
  299. {
  300. Permanent cardPermanent = card.PermanentOfThisCard();
  301. List<CardSource> selectedCards = new List<CardSource>();
  302. if (cardPermanent.DigivolutionCards.Count(CanSelectDigimonSanzomonCardCondition) >= 1)
  303. {
  304. int maxCount = Math.Min(1,
  305. cardPermanent.DigivolutionCards.Count(CanSelectDigimonSanzomonCardCondition));
  306. SelectCardEffect selectCardEffect =
  307. GManager.instance.GetComponent<SelectCardEffect>();
  308. selectCardEffect.SetUp(
  309. canTargetCondition: CanSelectDigimonSanzomonCardCondition,
  310. canTargetCondition_ByPreSelecetedList: null,
  311. canEndSelectCondition: null,
  312. canNoSelect: () => true,
  313. selectCardCoroutine: SelectCardCoroutine,
  314. afterSelectCardCoroutine: null,
  315. message: "Select 1 digivolution card to play.",
  316. maxCount: maxCount,
  317. canEndNotMax: false,
  318. isShowOpponent: true,
  319. mode: SelectCardEffect.Mode.Custom,
  320. root: SelectCardEffect.Root.Custom,
  321. customRootCardList: cardPermanent.DigivolutionCards,
  322. canLookReverseCard: true,
  323. selectPlayer: card.Owner,
  324. cardEffect: activateClass);
  325. selectCardEffect.SetUpCustomMessage(
  326. "Select 1 digivolution card to play.",
  327. "The opponent is selecting 1 digivolution card to play.");
  328. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  329. yield return StartCoroutine(selectCardEffect.Activate());
  330. IEnumerator SelectCardCoroutine(CardSource cardSource)
  331. {
  332. selectedCards.Add(cardSource);
  333. yield return null;
  334. }
  335. }
  336. if (cardPermanent.DigivolutionCards.Count(CanSelectDigimonJourneyCardCondition) >= 1)
  337. {
  338. int maxCount = Math.Min(1,
  339. cardPermanent.DigivolutionCards.Count(CanSelectDigimonJourneyCardCondition));
  340. SelectCardEffect selectCardEffect =
  341. GManager.instance.GetComponent<SelectCardEffect>();
  342. selectCardEffect.SetUp(
  343. canTargetCondition: CanSelectDigimonJourneyCardCondition,
  344. canTargetCondition_ByPreSelecetedList: null,
  345. canEndSelectCondition: null,
  346. canNoSelect: () => true,
  347. selectCardCoroutine: SelectCardCoroutine,
  348. afterSelectCardCoroutine: null,
  349. message: "Select 1 digivolution card to play.",
  350. maxCount: maxCount,
  351. canEndNotMax: false,
  352. isShowOpponent: true,
  353. mode: SelectCardEffect.Mode.Custom,
  354. root: SelectCardEffect.Root.Custom,
  355. customRootCardList: cardPermanent.DigivolutionCards,
  356. canLookReverseCard: true,
  357. selectPlayer: card.Owner,
  358. cardEffect: activateClass);
  359. selectCardEffect.SetUpCustomMessage(
  360. "Select 1 digivolution card to play.",
  361. "The opponent is selecting 1 digivolution card to play.");
  362. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  363. yield return StartCoroutine(selectCardEffect.Activate());
  364. IEnumerator SelectCardCoroutine(CardSource cardSource)
  365. {
  366. selectedCards.Add(cardSource);
  367. yield return null;
  368. }
  369. }
  370. // Play the selected Digivolution card
  371. yield return ContinuousController.instance.StartCoroutine(
  372. CardEffectCommons.PlayPermanentCards(
  373. cardSources: selectedCards,
  374. activateClass: activateClass,
  375. payCost: false,
  376. isTapped: false,
  377. root: SelectCardEffect.Root.DigivolutionCards,
  378. activateETB: true));
  379. }
  380. }
  381. }
  382. #endregion
  383. #region Your Turn
  384. if (timing == EffectTiming.None)
  385. {
  386. bool Condition()
  387. {
  388. if (CardEffectCommons.IsExistOnBattleArea(card))
  389. {
  390. if (CardEffectCommons.IsOwnerTurn(card))
  391. {
  392. return true;
  393. }
  394. }
  395. return false;
  396. }
  397. bool PermanentCondition(Permanent permanent)
  398. {
  399. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  400. {
  401. if (permanent.HasSecurityAttackChanges)
  402. {
  403. return true;
  404. }
  405. }
  406. return false;
  407. }
  408. cardEffects.Add(CardEffectFactory.InvertSAttackStaticEffect(
  409. permanentCondition: PermanentCondition,
  410. changeValue: -1,
  411. isInheritedEffect: false,
  412. card: card,
  413. condition: Condition));
  414. }
  415. #endregion
  416. #region End of Opponent's Turn
  417. if (timing == EffectTiming.OnEndTurn)
  418. {
  419. ActivateClass activateClass = new ActivateClass();
  420. activateClass.SetUpICardEffect(
  421. "Place 1 Digimon with [Security Attack] on top of its owner's security stack",
  422. CanUseCondition, card);
  423. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDescription());
  424. activateClass.SetHashString("EOT_EX6-031");
  425. cardEffects.Add(activateClass);
  426. string EffectDescription()
  427. {
  428. return
  429. "[End of Your Turn] [Once Per Turn] You may place 1 Digimon with [Security Attack] on top of its owner's security stack.";
  430. }
  431. bool IsPermanentWithSecurityAttackCondition(Permanent permanent)
  432. {
  433. if (CardEffectCommons.IsPermanentExistsOnBattleArea(permanent))
  434. {
  435. if (permanent.HasSecurityAttackChanges)
  436. {
  437. return true;
  438. }
  439. }
  440. return false;
  441. }
  442. bool CanUseCondition(Hashtable hashtable)
  443. {
  444. if (CardEffectCommons.IsExistOnBattleArea(card))
  445. {
  446. if (CardEffectCommons.IsOpponentTurn(card))
  447. {
  448. return true;
  449. }
  450. }
  451. return false;
  452. }
  453. bool CanActivateCondition(Hashtable hashtable)
  454. {
  455. if (CardEffectCommons.IsExistOnBattleArea(card))
  456. {
  457. if (CardEffectCommons.HasMatchConditionPermanent(IsPermanentWithSecurityAttackCondition))
  458. {
  459. return true;
  460. }
  461. }
  462. return false;
  463. }
  464. IEnumerator ActivateCoroutine(Hashtable hashtable)
  465. {
  466. if (CardEffectCommons.HasMatchConditionPermanent(IsPermanentWithSecurityAttackCondition))
  467. {
  468. int maxCount = Math.Min(1,
  469. CardEffectCommons.MatchConditionPermanentCount(IsPermanentWithSecurityAttackCondition));
  470. SelectPermanentEffect selectPermanentEffect =
  471. GManager.instance.GetComponent<SelectPermanentEffect>();
  472. selectPermanentEffect.SetUp(
  473. selectPlayer: card.Owner,
  474. canTargetCondition: IsPermanentWithSecurityAttackCondition,
  475. canTargetCondition_ByPreSelecetedList: null,
  476. canEndSelectCondition: null,
  477. maxCount: maxCount,
  478. canNoSelect: true,
  479. canEndNotMax: false,
  480. selectPermanentCoroutine: SelectPermanentCoroutine,
  481. afterSelectPermanentCoroutine: null,
  482. mode: SelectPermanentEffect.Mode.Custom,
  483. cardEffect: activateClass);
  484. selectPermanentEffect.SetUpCustomMessage(
  485. "Select 1 Digimon to place on top of your security stack.",
  486. "The opponent is selecting 1 Digimon to place on top of their security stack.");
  487. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  488. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  489. {
  490. if (permanent.TopCard != null)
  491. {
  492. if (!permanent.TopCard.CanNotBeAffected(activateClass))
  493. {
  494. yield return ContinuousController.instance.StartCoroutine(
  495. new IPutSecurityPermanent(permanent,
  496. CardEffectCommons.CardEffectHashtable(activateClass),
  497. toTop: true).PutSecurity());
  498. }
  499. }
  500. }
  501. }
  502. }
  503. }
  504. #endregion
  505. return cardEffects;
  506. }
  507. }
  508. }