EX2_007.cs 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519
  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_007 : 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.None)
  15. {
  16. bool Condition()
  17. {
  18. return CardEffectCommons.IsExistOnBattleArea(card);
  19. }
  20. cardEffects.Add(CardEffectFactory.CanNotAttackSelfStaticEffect(
  21. defenderCondition: null,
  22. isInheritedEffect: false,
  23. card: card,
  24. condition: Condition,
  25. effectName: "Can't Attack"));
  26. }
  27. if (timing == EffectTiming.None)
  28. {
  29. CanNotAffectedClass canNotAffectedClass = new CanNotAffectedClass();
  30. canNotAffectedClass.SetUpICardEffect("Isn't affected by opponent's effects", CanUseCondition, card);
  31. canNotAffectedClass.SetUpCanNotAffectedClass(CardCondition: CardCondition1, SkillCondition: SkillCondition);
  32. cardEffects.Add(canNotAffectedClass);
  33. bool CanUseCondition(Hashtable hashtable)
  34. {
  35. if (CardEffectCommons.IsExistOnBattleArea(card))
  36. {
  37. return true;
  38. }
  39. return false;
  40. }
  41. bool CardCondition1(CardSource cardSource)
  42. {
  43. if (CardEffectCommons.IsExistOnBattleArea(card))
  44. {
  45. if (card == card.PermanentOfThisCard().TopCard)
  46. {
  47. if (cardSource == card.PermanentOfThisCard().TopCard)
  48. {
  49. return true;
  50. }
  51. }
  52. }
  53. return false;
  54. }
  55. bool SkillCondition(ICardEffect cardEffect)
  56. {
  57. return CardEffectCommons.IsOpponentEffect(cardEffect, card);
  58. }
  59. }
  60. if (timing == EffectTiming.OnDeclaration)
  61. {
  62. ActivateClass activateClass = new ActivateClass();
  63. activateClass.SetUpICardEffect("Place 1 card under this Digimon's digivolution cards", CanUseCondition, card);
  64. activateClass.SetUpActivateClass(null, ActivateCoroutine, 1, false, EffectDiscription());
  65. cardEffects.Add(activateClass);
  66. string EffectDiscription()
  67. {
  68. return "[Main][Once Per Turn] If you don't have another [Mother D-Reaper] in play, place 1 of your [ADR-02 Searcher] from in play or from your hand under this Digimon as its bottom digivolution card.";
  69. }
  70. bool CanSelectPermanentCondition(Permanent permanent)
  71. {
  72. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card))
  73. {
  74. if (!permanent.IsToken)
  75. {
  76. if (permanent.TopCard.CardNames.Contains("ADR-02 Searcher"))
  77. {
  78. return true;
  79. }
  80. if (permanent.TopCard.CardNames.Contains("ADR-02Searcher"))
  81. {
  82. return true;
  83. }
  84. }
  85. }
  86. return false;
  87. }
  88. bool CanSelectCardCondition(CardSource cardSource)
  89. {
  90. if (!cardSource.IsToken)
  91. {
  92. if (cardSource.CardNames.Contains("ADR-02 Searcher"))
  93. {
  94. return true;
  95. }
  96. if (cardSource.CardNames.Contains("ADR-02Searcher"))
  97. {
  98. return true;
  99. }
  100. }
  101. return false;
  102. }
  103. bool CanUseCondition(Hashtable hashtable)
  104. {
  105. if (CardEffectCommons.IsExistOnBattleArea(card))
  106. {
  107. if (!card.PermanentOfThisCard().IsToken)
  108. {
  109. if (card.Owner.GetBattleAreaDigimons().Count((permanent) => (permanent.TopCard.CardNames.Contains("Mother D-Reaper") || permanent.TopCard.CardNames.Contains("MotherD-Reaper")) && permanent != card.PermanentOfThisCard()) == 0)
  110. {
  111. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  112. {
  113. return true;
  114. }
  115. if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  116. {
  117. return true;
  118. }
  119. }
  120. }
  121. }
  122. return false;
  123. }
  124. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  125. {
  126. if (isExistOnField(card))
  127. {
  128. if (card.Owner.GetBattleAreaDigimons().Contains(card.PermanentOfThisCard()))
  129. {
  130. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition) || card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  131. {
  132. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition) && card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  133. {
  134. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  135. {
  136. new SelectionElement<bool>(message: $"From Field", value : false, spriteIndex: 0),
  137. new SelectionElement<bool>(message: $"From hand", value : true, spriteIndex: 1),
  138. };
  139. string selectPlayerMessage = "From which area do you play a card?";
  140. string notSelectPlayerMessage = "The opponent is choosing from which area to play a card.";
  141. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  142. }
  143. else if (!CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition) && card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  144. {
  145. GManager.instance.userSelectionManager.SetBool(true);
  146. }
  147. else if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition) && card.Owner.HandCards.Count(CanSelectCardCondition) == 0)
  148. {
  149. GManager.instance.userSelectionManager.SetBool(false);
  150. }
  151. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  152. bool fromHand = GManager.instance.userSelectionManager.SelectedBoolValue;
  153. if (fromHand)
  154. {
  155. if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  156. {
  157. List<CardSource> selectedCards = new List<CardSource>();
  158. int maxCount = 1;
  159. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  160. selectHandEffect.SetUp(
  161. selectPlayer: card.Owner,
  162. canTargetCondition: CanSelectCardCondition,
  163. canTargetCondition_ByPreSelecetedList: null,
  164. canEndSelectCondition: null,
  165. maxCount: maxCount,
  166. canNoSelect: true,
  167. canEndNotMax: false,
  168. isShowOpponent: true,
  169. selectCardCoroutine: SelectCardCoroutine,
  170. afterSelectCardCoroutine: null,
  171. mode: SelectHandEffect.Mode.Custom,
  172. cardEffect: activateClass);
  173. 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.");
  174. selectHandEffect.SetUpCustomMessage_ShowCard("Digivolution Card");
  175. yield return StartCoroutine(selectHandEffect.Activate());
  176. IEnumerator SelectCardCoroutine(CardSource cardSource)
  177. {
  178. selectedCards.Add(cardSource);
  179. yield return null;
  180. }
  181. if (selectedCards.Count >= 1)
  182. {
  183. yield return ContinuousController.instance.StartCoroutine(card.PermanentOfThisCard().AddDigivolutionCardsBottom(selectedCards, activateClass));
  184. }
  185. }
  186. }
  187. else
  188. {
  189. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  190. {
  191. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  192. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  193. selectPermanentEffect.SetUp(
  194. selectPlayer: card.Owner,
  195. canTargetCondition: CanSelectPermanentCondition,
  196. canTargetCondition_ByPreSelecetedList: null,
  197. canEndSelectCondition: null,
  198. maxCount: maxCount,
  199. canNoSelect: false,
  200. canEndNotMax: false,
  201. selectPermanentCoroutine: SelectPermanentCoroutine,
  202. afterSelectPermanentCoroutine: null,
  203. mode: SelectPermanentEffect.Mode.Custom,
  204. cardEffect: activateClass);
  205. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to place in digivolution cards.", "The opponent is selecting 1 Digimon to place in digivolution cards.");
  206. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  207. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  208. {
  209. Permanent selectedPermanent = permanent;
  210. yield return ContinuousController.instance.StartCoroutine(new IPlacePermanentToDigivolutionCards(new List<Permanent[]>() { new Permanent[] { selectedPermanent, card.PermanentOfThisCard() } }, false, activateClass).PlacePermanentToDigivolutionCards());
  211. }
  212. }
  213. }
  214. }
  215. }
  216. }
  217. }
  218. }
  219. ActivateClass activateClass2 = new ActivateClass();
  220. activateClass2.SetUpICardEffect("Reduce play cost", CanUseCondition2, card);
  221. activateClass2.SetUpActivateClass(CanActivateCondition2, ActivateCoroutine2, 1, true, EffectDiscription2());
  222. activateClass2.SetHashString("Reduce_EX2_007");
  223. string EffectDiscription2()
  224. {
  225. return "[Your Turn][Once Per Turn] When you would play a card with [D-Reaper] in its traits from your hand, you may reduce its play cost by 1 for each of this Digimon's digivolution cards.";
  226. }
  227. bool CardCondition(CardSource cardSource)
  228. {
  229. if (cardSource.Owner == card.Owner)
  230. {
  231. if (CardEffectCommons.IsExistOnHand(cardSource))
  232. {
  233. if (cardSource.CardTraits.Contains("D-Reaper"))
  234. {
  235. if(!cardSource.IsOption)
  236. return true;
  237. }
  238. }
  239. }
  240. return false;
  241. }
  242. bool CanUseCondition2(Hashtable hashtable)
  243. {
  244. if (CardEffectCommons.IsExistOnBattleArea(card))
  245. {
  246. if (CardEffectCommons.IsOwnerTurn(card))
  247. {
  248. if (CardEffectCommons.CanTriggerWhenPermanentWouldPlay(hashtable, CardCondition))
  249. {
  250. return true;
  251. }
  252. }
  253. }
  254. return false;
  255. }
  256. bool CanActivateCondition2(Hashtable hashtable)
  257. {
  258. if (CardEffectCommons.IsExistOnBattleArea(card))
  259. {
  260. if (card.PermanentOfThisCard().DigivolutionCards.Count >= 1)
  261. {
  262. PlayCardClass playCard = CardEffectCommons.GetPlayCardClassFromHashtable(hashtable);
  263. if (playCard != null)
  264. {
  265. if (playCard.PayCost)
  266. {
  267. return true;
  268. }
  269. }
  270. }
  271. }
  272. return false;
  273. }
  274. IEnumerator ActivateCoroutine2(Hashtable _hashtable)
  275. {
  276. if (CardEffectCommons.IsExistOnBattleArea(card))
  277. {
  278. if (card.PermanentOfThisCard().DigivolutionCards.Count >= 1)
  279. {
  280. int reduceCount = card.PermanentOfThisCard().DigivolutionCards.Count;
  281. ContinuousController.instance.PlaySE(GManager.instance.GetComponent<Effects>().BuffSE);
  282. ChangeCostClass changeCostClass = new ChangeCostClass();
  283. changeCostClass.SetUpICardEffect($"Play Cost -{reduceCount}", CanUseCondition1, card);
  284. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => false, isChangePayingCost: () => true);
  285. card.Owner.UntilCalculateFixedCostEffect.Add((_timing) => changeCostClass);
  286. yield return new WaitForSeconds(0.2f);
  287. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ShowReducedCost(_hashtable));
  288. bool CanUseCondition1(Hashtable hashtable)
  289. {
  290. return true;
  291. }
  292. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  293. {
  294. if (CardSourceCondition(cardSource))
  295. {
  296. if (RootCondition(root))
  297. {
  298. if (PermanentsCondition(targetPermanents))
  299. {
  300. Cost -= reduceCount;
  301. }
  302. }
  303. }
  304. return Cost;
  305. }
  306. bool PermanentsCondition(List<Permanent> targetPermanents)
  307. {
  308. if (targetPermanents == null)
  309. {
  310. return true;
  311. }
  312. else
  313. {
  314. if (targetPermanents.Count((targetPermanent) => targetPermanent != null) == 0)
  315. {
  316. return true;
  317. }
  318. }
  319. return false;
  320. }
  321. bool CardSourceCondition(CardSource cardSource)
  322. {
  323. if (cardSource != null)
  324. {
  325. if (cardSource.Owner == card.Owner)
  326. {
  327. return true;
  328. }
  329. }
  330. return false;
  331. }
  332. bool RootCondition(SelectCardEffect.Root root)
  333. {
  334. return true;
  335. }
  336. bool isUpDown()
  337. {
  338. return true;
  339. }
  340. }
  341. }
  342. }
  343. if (timing == EffectTiming.BeforePayCost)
  344. {
  345. cardEffects.Add(activateClass2);
  346. }
  347. if (timing == EffectTiming.None)
  348. {
  349. ChangeCostClass changeCostClass = new ChangeCostClass();
  350. changeCostClass.SetUpICardEffect("Play Cost -", CanUseCondition, card);
  351. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => true, isChangePayingCost: () => true);
  352. changeCostClass.SetNotShowUI(true);
  353. cardEffects.Add(changeCostClass);
  354. bool CanUseCondition(Hashtable hashtable)
  355. {
  356. if (!card.Owner.isYou && GManager.instance.IsAI)
  357. {
  358. return false;
  359. }
  360. if (CardEffectCommons.IsExistOnBattleArea(card))
  361. {
  362. if (CardEffectCommons.IsOwnerTurn(card))
  363. {
  364. if (card.PermanentOfThisCard().DigivolutionCards.Count >= 1)
  365. {
  366. if (activateClass2 != null)
  367. {
  368. if (!card.cEntity_EffectController.isOverMaxCountPerTurn(activateClass2, activateClass2.MaxCountPerTurn))
  369. {
  370. return true;
  371. }
  372. }
  373. }
  374. }
  375. }
  376. return false;
  377. }
  378. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  379. {
  380. if (CardSourceCondition(cardSource))
  381. {
  382. if (RootCondition(root))
  383. {
  384. if (PermanentsCondition(targetPermanents))
  385. {
  386. Cost -= card.PermanentOfThisCard().DigivolutionCards.Count;
  387. }
  388. }
  389. }
  390. return Cost;
  391. }
  392. bool PermanentsCondition(List<Permanent> targetPermanents)
  393. {
  394. if (targetPermanents == null)
  395. {
  396. return true;
  397. }
  398. else
  399. {
  400. if (targetPermanents.Count((targetPermanent) => targetPermanent != null) == 0)
  401. {
  402. return true;
  403. }
  404. }
  405. return false;
  406. }
  407. bool CardSourceCondition(CardSource cardSource)
  408. {
  409. if (cardSource != null)
  410. {
  411. if (cardSource.Owner == card.Owner)
  412. {
  413. if (cardSource.Owner.HandCards.Contains(cardSource))
  414. {
  415. if (cardSource.CardTraits.Contains("D-Reaper"))
  416. {
  417. return true;
  418. }
  419. }
  420. }
  421. }
  422. return false;
  423. }
  424. bool RootCondition(SelectCardEffect.Root root)
  425. {
  426. return true;
  427. }
  428. bool isUpDown()
  429. {
  430. return true;
  431. }
  432. }
  433. return cardEffects;
  434. }
  435. }
  436. }