P_223.cs 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.P
  6. {
  7. // Kuzuhamon
  8. public class P_223 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region Alt Digivolution Condition
  14. if (timing == EffectTiming.None)
  15. {
  16. bool PermanentCondition(Permanent targetPermanent)
  17. {
  18. return targetPermanent.TopCard.ContainsCardName("Maid Mode") && targetPermanent.TopCard.HasLevel && targetPermanent.TopCard.Level == 6;
  19. }
  20. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 1, ignoreDigivolutionRequirement: false, card: card, condition: null));
  21. }
  22. #endregion
  23. #region Reduced play cost
  24. #region Before Pay Cost - Condition Effect
  25. if (timing == EffectTiming.BeforePayCost)
  26. {
  27. ActivateClass activateClass = new ActivateClass();
  28. activateClass.SetUpICardEffect("Play cost reduction -4", CanUseCondition, card);
  29. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  30. activateClass.SetHashString("P_223_ReducePlayCost");
  31. cardEffects.Add(activateClass);
  32. string EffectDiscription()
  33. {
  34. return "When this card would be played from the hand, if you have 3 or fewer security, reduce the play cost by 4.";
  35. }
  36. bool CanUseCondition(Hashtable hashtable)
  37. {
  38. return CardEffectCommons.CanTriggerWhenPermanentWouldPlay(hashtable, CardCondition);
  39. }
  40. bool CanActivateCondition(Hashtable hashtable)
  41. {
  42. return CardEffectCommons.IsExistOnHand(card)
  43. && CardEffectCommons.HasMatchConditionPermanent(x => card.Owner.SecurityCards.Count <= 3);
  44. }
  45. bool CardCondition(CardSource cardSource)
  46. {
  47. return CardEffectCommons.IsExistOnHand(cardSource)
  48. && cardSource == card;
  49. }
  50. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  51. {
  52. ChangeCostClass changeCostClass = new ChangeCostClass();
  53. changeCostClass.SetUpICardEffect("Play Cost -4", CanUseCondition1, card);
  54. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => false, isChangePayingCost: () => true);
  55. card.Owner.UntilCalculateFixedCostEffect.Add((_timing) => changeCostClass);
  56. bool CanUseCondition1(Hashtable hashtable)
  57. {
  58. return true;
  59. }
  60. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  61. {
  62. if (CardSourceCondition(cardSource))
  63. {
  64. if (RootCondition(root))
  65. {
  66. if (PermanentsCondition(targetPermanents))
  67. {
  68. if (cardSource.Owner.SecurityCards.Count <= 3)
  69. {
  70. Cost -= 4;
  71. }
  72. }
  73. }
  74. }
  75. return Cost;
  76. }
  77. bool PermanentsCondition(List<Permanent> targetPermanents)
  78. {
  79. if (targetPermanents == null)
  80. {
  81. return true;
  82. }
  83. else
  84. {
  85. if (targetPermanents.Count((targetPermanent) => targetPermanent != null) == 0)
  86. {
  87. return true;
  88. }
  89. }
  90. return false;
  91. }
  92. bool CardSourceCondition(CardSource cardSource)
  93. {
  94. return cardSource == card;
  95. }
  96. bool RootCondition(SelectCardEffect.Root root)
  97. {
  98. return root == SelectCardEffect.Root.Hand;
  99. }
  100. bool isUpDown()
  101. {
  102. return true;
  103. }
  104. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ShowReducedCost(_hashtable));
  105. }
  106. }
  107. #endregion
  108. #region Reduce Play Cost - Not Shown
  109. if (timing == EffectTiming.None)
  110. {
  111. ChangeCostClass changeCostClass = new ChangeCostClass();
  112. changeCostClass.SetUpICardEffect("Play Cost -4", CanUseCondition, card);
  113. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => true, isChangePayingCost: () => true);
  114. changeCostClass.SetNotShowUI(true);
  115. cardEffects.Add(changeCostClass);
  116. bool CanUseCondition(Hashtable hashtable)
  117. {
  118. if (card.Owner.HandCards.Contains(card))
  119. {
  120. ICardEffect activateClass = card.EffectList(EffectTiming.BeforePayCost).Find(cardEffect => cardEffect.EffectName == "Play cost reduction -4");
  121. if (activateClass != null)
  122. {
  123. if (card.Owner.SecurityCards.Count <= 3)
  124. {
  125. return true;
  126. }
  127. }
  128. }
  129. return false;
  130. }
  131. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  132. {
  133. if (CardSourceCondition(cardSource))
  134. {
  135. if (RootCondition(root))
  136. {
  137. if (PermanentsCondition(targetPermanents))
  138. {
  139. if (cardSource.Owner.SecurityCards.Count <= 3)
  140. {
  141. Cost -= 4;
  142. }
  143. }
  144. }
  145. }
  146. return Cost;
  147. }
  148. bool PermanentsCondition(List<Permanent> targetPermanents)
  149. {
  150. if (targetPermanents == null)
  151. {
  152. return true;
  153. }
  154. else
  155. {
  156. if (targetPermanents.Count((targetPermanent) => targetPermanent != null) == 0)
  157. {
  158. return true;
  159. }
  160. }
  161. return false;
  162. }
  163. bool CardSourceCondition(CardSource cardSource)
  164. {
  165. if (cardSource != null)
  166. {
  167. if (cardSource == card)
  168. {
  169. return true;
  170. }
  171. }
  172. return false;
  173. }
  174. bool RootCondition(SelectCardEffect.Root root)
  175. {
  176. return root == SelectCardEffect.Root.Hand;
  177. }
  178. bool isUpDown()
  179. {
  180. return true;
  181. }
  182. }
  183. #endregion
  184. #endregion
  185. #region Name Rule
  186. if (timing == EffectTiming.None)
  187. {
  188. ChangeCardNamesClass changeCardNamesClass = new ChangeCardNamesClass();
  189. changeCardNamesClass.SetUpICardEffect("Also treated as [Sakuyamon]", CanUseCondition, card);
  190. changeCardNamesClass.SetUpChangeCardNamesClass(changeCardNames: changeCardNames);
  191. cardEffects.Add(changeCardNamesClass);
  192. bool CanUseCondition(Hashtable hashtable)
  193. {
  194. return true;
  195. }
  196. List<string> changeCardNames(CardSource cardSource, List<string> CardNames)
  197. {
  198. if (cardSource == card)
  199. {
  200. CardNames.Add("Sakuyamon");
  201. }
  202. return CardNames;
  203. }
  204. }
  205. #endregion
  206. #region On Play / When Digivolving Shared
  207. string SharedEffectDiscription(string tag)
  208. {
  209. return $"[{tag}] You may use 1 [Onmyōjutsu] or [Plug-In] trait Option card from your hand or trash without paying the cost.";
  210. }
  211. bool SharedCanActivateCondition(Hashtable hashtable)
  212. {
  213. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  214. }
  215. bool CanSelectOptionCard(CardSource cardSource)
  216. {
  217. if (cardSource.IsOption)
  218. {
  219. if (cardSource.HasOnmyoOrPluginTraits)
  220. {
  221. if (!cardSource.CanNotPlayThisOption)
  222. {
  223. return true;
  224. }
  225. }
  226. }
  227. return false;
  228. }
  229. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  230. {
  231. bool canSelectHand = CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectOptionCard);
  232. bool canSelectTrash = CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectOptionCard);
  233. bool playFromHand = false;
  234. bool playFromTrash = false;
  235. if (canSelectHand || canSelectTrash)
  236. {
  237. List<CardSource> selectedCards = new List<CardSource>();
  238. #region #region User Selection - Select Card Location
  239. if (canSelectHand && canSelectTrash)
  240. {
  241. List<SelectionElement<bool>> selectionElements1 = new List<SelectionElement<bool>>()
  242. {
  243. new SelectionElement<bool>(message: $"From hand", value : true, spriteIndex: 0),
  244. new SelectionElement<bool>(message: $"From trash", value : false, spriteIndex: 1),
  245. };
  246. string selectPlayerMessage1 = "From which area do you select a card?";
  247. string notSelectPlayerMessage1 = "The opponent is choosing from which area to select a card.";
  248. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements1, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage1, notSelectPlayerMessage: notSelectPlayerMessage1);
  249. }
  250. else
  251. {
  252. GManager.instance.userSelectionManager.SetBool(canSelectHand);
  253. }
  254. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  255. var handOrTrashSelection = GManager.instance.userSelectionManager.SelectedBoolValue;
  256. if (handOrTrashSelection) playFromHand = true;
  257. else playFromTrash = true;
  258. #endregion
  259. IEnumerator SelectCardCoroutine(CardSource cardSource)
  260. {
  261. selectedCards.Add(cardSource);
  262. yield return null;
  263. }
  264. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  265. if (playFromHand)
  266. {
  267. selectHandEffect.SetUp(
  268. selectPlayer: card.Owner,
  269. canTargetCondition: CanSelectOptionCard,
  270. canTargetCondition_ByPreSelecetedList: null,
  271. canEndSelectCondition: null,
  272. maxCount: 1,
  273. canNoSelect: true,
  274. canEndNotMax: false,
  275. isShowOpponent: true,
  276. selectCardCoroutine: SelectCardCoroutine,
  277. afterSelectCardCoroutine: null,
  278. mode: SelectHandEffect.Mode.Custom,
  279. cardEffect: activateClass);
  280. selectHandEffect.SetUpCustomMessage("Select 1 option to use", "The opponent is selecting 1 option to use");
  281. yield return ContinuousController.instance.StartCoroutine(selectHandEffect.Activate());
  282. yield return ContinuousController.instance.StartCoroutine(
  283. CardEffectCommons.PlayOptionCards(
  284. cardSources: selectedCards,
  285. activateClass: activateClass,
  286. payCost: false,
  287. root: SelectCardEffect.Root.Hand));
  288. }
  289. if (playFromTrash)
  290. {
  291. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  292. selectCardEffect.SetUp(
  293. canTargetCondition: CanSelectOptionCard,
  294. canTargetCondition_ByPreSelecetedList: null,
  295. canEndSelectCondition: null,
  296. canNoSelect: () => true,
  297. selectCardCoroutine: SelectCardCoroutine,
  298. afterSelectCardCoroutine: null,
  299. message: "Select 1 Option to use",
  300. maxCount: 1,
  301. canEndNotMax: false,
  302. isShowOpponent: true,
  303. mode: SelectCardEffect.Mode.Custom,
  304. root: SelectCardEffect.Root.Trash,
  305. customRootCardList: null,
  306. canLookReverseCard: true,
  307. selectPlayer: card.Owner,
  308. cardEffect: activateClass);
  309. selectCardEffect.SetUpCustomMessage("Select 1 option to use", "The opponent is selecting 1 option to use");
  310. selectCardEffect.SetUpCustomMessage_ShowCard("Used Card");
  311. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  312. yield return ContinuousController.instance.StartCoroutine(
  313. CardEffectCommons.PlayOptionCards(
  314. cardSources: selectedCards,
  315. activateClass: activateClass,
  316. payCost: false,
  317. root: SelectCardEffect.Root.Trash));
  318. }
  319. }
  320. }
  321. #endregion
  322. #region On Play
  323. if (timing == EffectTiming.OnEnterFieldAnyone)
  324. {
  325. ActivateClass activateClass = new ActivateClass();
  326. activateClass.SetUpICardEffect("You may use an [Onmyōjutsu] or [Plug-In] Option from hand or trash", CanUseCondition, card);
  327. activateClass.SetUpActivateClass(SharedCanActivateCondition, hash => SharedActivateCoroutine(hash, activateClass), -1, true, SharedEffectDiscription("On Play"));
  328. cardEffects.Add(activateClass);
  329. bool CanUseCondition(Hashtable hashtable)
  330. {
  331. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  332. }
  333. }
  334. #endregion
  335. #region When Digivolving
  336. if (timing == EffectTiming.OnEnterFieldAnyone)
  337. {
  338. ActivateClass activateClass = new ActivateClass();
  339. activateClass.SetUpICardEffect("You may use an [Onmyōjutsu] or [Plug-In] Option from hand or trash", CanUseCondition, card);
  340. activateClass.SetUpActivateClass(SharedCanActivateCondition, hash => SharedActivateCoroutine(hash, activateClass), -1, true, SharedEffectDiscription("When Digivolving"));
  341. cardEffects.Add(activateClass);
  342. bool CanUseCondition(Hashtable hashtable)
  343. {
  344. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card) && CardEffectCommons.IsExistOnBattleArea(card);
  345. }
  346. }
  347. #endregion
  348. #region All Turns
  349. if (timing == EffectTiming.OnUseOption)
  350. {
  351. ActivateClass activateClass = new ActivateClass();
  352. activateClass.SetUpICardEffect("Play a [Pipe Fox] Token", CanUseCondition, card);
  353. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  354. activateClass.SetHashString("PlayToken_P_223");
  355. cardEffects.Add(activateClass);
  356. string EffectDiscription()
  357. {
  358. return "[All Turns][Once Per Turn] When you use Option cards, you may play 1 [Pipe Fox] Token (Digimon/Yellow/6000 DP/<Blocker>).";
  359. }
  360. bool CanUseCondition(Hashtable hashtable)
  361. {
  362. return CardEffectCommons.IsExistOnBattleArea(card)
  363. && CardEffectCommons.CanTriggerWhenOwnerUseOption(hashtable, null, null, card);
  364. }
  365. bool CanActivateCondition(Hashtable hashtable)
  366. {
  367. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  368. }
  369. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  370. {
  371. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPipeFox(activateClass));
  372. }
  373. }
  374. #endregion
  375. return cardEffects;
  376. }
  377. }
  378. }