P_224.cs 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. // Kotone Amano
  6. namespace DCGO.CardEffects.P
  7. {
  8. public class P_224 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region SoYMP/OP Shared
  14. string EffectNameShared()
  15. => "Place digimon under tamer to draw 1";
  16. string EffectDiscriptionShared(string tag)
  17. {
  18. return $"[{tag}] By placing 1 [Xros Heart] or [Twilight] trait Digimon card from your hand or trash under this Tamer, if you have 7 or fewer cards in your hand, <Draw 1>.";
  19. }
  20. bool CanSelectSharedCardCondition(CardSource card)
  21. {
  22. return card.IsDigimon
  23. && (card.EqualsTraits("Xros Heart") || card.EqualsTraits("Twilight"));
  24. }
  25. bool CanActivateConditionShared(Hashtable hashtable)
  26. {
  27. return CardEffectCommons.IsExistOnBattleArea(card)
  28. && (CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectSharedCardCondition)
  29. || CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectSharedCardCondition));
  30. }
  31. IEnumerator ActivateCoroutineShared(Hashtable hashtable, ActivateClass activateClass)
  32. {
  33. bool canSelectHand = card.Owner.HandCards.Count(CanSelectSharedCardCondition) >= 1;
  34. bool canSelectTrash = CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectSharedCardCondition);
  35. if (canSelectHand || canSelectTrash)
  36. {
  37. if (canSelectHand && canSelectTrash)
  38. {
  39. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  40. {
  41. new SelectionElement<bool>(message: $"From hand", value : true, spriteIndex: 0),
  42. new SelectionElement<bool>(message: $"From trash", value : false, spriteIndex: 1),
  43. };
  44. string selectPlayerMessage = "From which area do you select a card?";
  45. string notSelectPlayerMessage = "The opponent is choosing from which area to select a card.";
  46. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  47. }
  48. else
  49. {
  50. GManager.instance.userSelectionManager.SetBool(canSelectHand);
  51. }
  52. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  53. bool fromHand = GManager.instance.userSelectionManager.SelectedBoolValue;
  54. List<CardSource> selectedCards = new List<CardSource>();
  55. IEnumerator SelectCardCoroutine(CardSource cardSource)
  56. {
  57. selectedCards.Add(cardSource);
  58. yield return null;
  59. }
  60. if (fromHand)
  61. {
  62. int maxCount = 1;
  63. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  64. selectHandEffect.SetUp(
  65. selectPlayer: card.Owner,
  66. canTargetCondition: CanSelectSharedCardCondition,
  67. canTargetCondition_ByPreSelecetedList: null,
  68. canEndSelectCondition: null,
  69. maxCount: maxCount,
  70. canNoSelect: true,
  71. canEndNotMax: false,
  72. isShowOpponent: true,
  73. selectCardCoroutine: SelectCardCoroutine,
  74. afterSelectCardCoroutine: null,
  75. mode: SelectHandEffect.Mode.Custom,
  76. cardEffect: activateClass);
  77. 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.");
  78. selectHandEffect.SetUpCustomMessage_ShowCard("Digivolution Card");
  79. yield return StartCoroutine(selectHandEffect.Activate());
  80. }
  81. else
  82. {
  83. int maxCount = 1;
  84. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  85. selectCardEffect.SetUp(
  86. canTargetCondition: CanSelectSharedCardCondition,
  87. canTargetCondition_ByPreSelecetedList: null,
  88. canEndSelectCondition: null,
  89. canNoSelect: () => true,
  90. selectCardCoroutine: SelectCardCoroutine,
  91. afterSelectCardCoroutine: null,
  92. message: "Select 1 card to place on bottom of digivolution cards.",
  93. maxCount: maxCount,
  94. canEndNotMax: false,
  95. isShowOpponent: true,
  96. mode: SelectCardEffect.Mode.Custom,
  97. root: SelectCardEffect.Root.Trash,
  98. customRootCardList: null,
  99. canLookReverseCard: true,
  100. selectPlayer: card.Owner,
  101. cardEffect: activateClass);
  102. selectCardEffect.SetUpCustomMessage_ShowCard("Digivolution Card");
  103. selectCardEffect.SetUpCustomMessage("Select 1 card to place on bottom of digivolution cards.", "The opponent is selecting 1 card to place on bottom of digivolution cards.");
  104. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  105. }
  106. if (selectedCards.Count >= 1)
  107. {
  108. Permanent selectedPermanent = card.PermanentOfThisCard();
  109. if (selectedPermanent != null)
  110. {
  111. yield return ContinuousController.instance.StartCoroutine(selectedPermanent.AddDigivolutionCardsBottom(new List<CardSource>() { selectedCards[0] }, activateClass));
  112. if (card.Owner.HandCards.Count <= 7)
  113. {
  114. yield return ContinuousController.instance.StartCoroutine(new DrawClass(card.Owner, 1, activateClass).Draw());
  115. }
  116. }
  117. }
  118. }
  119. }
  120. #endregion
  121. #region Start of Your Main Phase
  122. if (timing == EffectTiming.OnStartMainPhase)
  123. {
  124. ActivateClass activateClass = new ActivateClass();
  125. activateClass.SetUpICardEffect(EffectNameShared(), CanUseCondition, card);
  126. activateClass.SetUpActivateClass(CanActivateConditionShared, hash => ActivateCoroutineShared(hash, activateClass), -1, true, EffectDiscriptionShared("Start of Your Main Phase"));
  127. cardEffects.Add(activateClass);
  128. bool CanUseCondition(Hashtable hashtable)
  129. {
  130. return CardEffectCommons.IsExistOnBattleArea(card)
  131. && CardEffectCommons.IsOwnerTurn(card);
  132. }
  133. }
  134. #endregion
  135. #region On Play
  136. if (timing == EffectTiming.OnEnterFieldAnyone)
  137. {
  138. ActivateClass activateClass = new ActivateClass();
  139. activateClass.SetUpICardEffect(EffectNameShared(), CanUseCondition, card);
  140. activateClass.SetUpActivateClass(CanActivateConditionShared, hash => ActivateCoroutineShared(hash, activateClass), -1, true, EffectDiscriptionShared("On Play"));
  141. cardEffects.Add(activateClass);
  142. bool CanUseCondition(Hashtable hashtable)
  143. {
  144. return CardEffectCommons.IsExistOnBattleArea(card)
  145. && CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  146. }
  147. }
  148. #endregion
  149. #region Main
  150. if (timing == EffectTiming.OnDeclaration)
  151. {
  152. ActivateClass activateClass = new ActivateClass();
  153. activateClass.SetUpICardEffect("Suspend to Play a Digimon from tamer", CanUseCondition, card);
  154. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  155. cardEffects.Add(activateClass);
  156. string EffectDiscription()
  157. {
  158. return "[Main] By suspending this Tamer, you may play 1 level 5 or higher [Xros Heart] trait Digimon card from under any of your Tamers with the play cost reduced by 1.";
  159. }
  160. bool CanSelectCardCondition(CardSource cardSource)
  161. {
  162. return !cardSource.willBeRemoveSources
  163. && cardSource.IsDigimon
  164. && cardSource.HasLevel && cardSource.Level >= 5
  165. && cardSource.EqualsTraits("Xros Heart")
  166. && CardEffectCommons.CanPlayAsNewPermanent(cardSource, false, activateClass);
  167. }
  168. bool CanSelectPermanentCondition(Permanent permanent)
  169. {
  170. return CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card)
  171. && permanent.IsTamer
  172. && permanent.DigivolutionCards.Count(CanSelectCardCondition) >= 1;
  173. }
  174. bool CanUseCondition(Hashtable hashtable)
  175. {
  176. return CardEffectCommons.IsExistOnBattleArea(card)
  177. && card.PermanentOfThisCard().CanSuspend;
  178. }
  179. bool CanActivateCondition(Hashtable hashtable)
  180. {
  181. return CardEffectCommons.IsExistOnBattleArea(card)
  182. && CardEffectCommons.CanActivateSuspendCostEffect(card)
  183. && card.Owner.GetBattleAreaPermanents().Count(CanSelectPermanentCondition) >= 1;
  184. }
  185. IEnumerator ActivateCoroutine(Hashtable hashtable)
  186. {
  187. yield return ContinuousController.instance.StartCoroutine(new SuspendPermanentsClass(new List<Permanent>() { card.PermanentOfThisCard() }, CardEffectCommons.CardEffectHashtable(activateClass)).Tap());
  188. Permanent selectedPermanent = null;
  189. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  190. selectPermanentEffect.SetUp(
  191. selectPlayer: card.Owner,
  192. canTargetCondition: CanSelectPermanentCondition,
  193. canTargetCondition_ByPreSelecetedList: null,
  194. canEndSelectCondition: null,
  195. maxCount: 1,
  196. canNoSelect: true,
  197. canEndNotMax: false,
  198. selectPermanentCoroutine: SelectPermanentCoroutine,
  199. afterSelectPermanentCoroutine: null,
  200. mode: SelectPermanentEffect.Mode.Custom,
  201. cardEffect: activateClass);
  202. selectPermanentEffect.SetUpCustomMessage("Select a Tamer.", "The opponent is selecting a Tamer.");
  203. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  204. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  205. {
  206. selectedPermanent = permanent;
  207. yield return null;
  208. }
  209. if (selectedPermanent != null)
  210. {
  211. #region reduce play cost
  212. ChangeCostClass changeCostClass = new ChangeCostClass();
  213. changeCostClass.SetUpICardEffect($"Play Cost -1", CanUseCondition1, card);
  214. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CanSelectCardCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => false, isChangePayingCost: () => true);
  215. Func<EffectTiming, ICardEffect> getCardEffect = GetCardEffect;
  216. card.Owner.UntilCalculateFixedCostEffect.Add(getCardEffect);
  217. ICardEffect GetCardEffect(EffectTiming _timing)
  218. {
  219. if (_timing == EffectTiming.None)
  220. {
  221. return changeCostClass;
  222. }
  223. return null;
  224. }
  225. bool CanUseCondition1(Hashtable hashtable)
  226. {
  227. return true;
  228. }
  229. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  230. {
  231. if (CanSelectCardCondition(cardSource))
  232. {
  233. if (RootCondition(root))
  234. {
  235. if (PermanentsCondition(targetPermanents))
  236. {
  237. Cost -= 1;
  238. }
  239. }
  240. }
  241. return Cost;
  242. }
  243. bool PermanentsCondition(List<Permanent> targetPermanents)
  244. {
  245. if (targetPermanents == null)
  246. {
  247. return true;
  248. }
  249. else
  250. {
  251. if (targetPermanents.Count((targetPermanent) => targetPermanent != null) == 0)
  252. {
  253. return true;
  254. }
  255. }
  256. return false;
  257. }
  258. bool RootCondition(SelectCardEffect.Root root)
  259. {
  260. return true;
  261. }
  262. bool isUpDown()
  263. {
  264. return true;
  265. }
  266. #endregion
  267. List<CardSource> selectedCards = new List<CardSource>();
  268. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  269. selectCardEffect.SetUp(
  270. canTargetCondition: CanSelectCardCondition,
  271. canTargetCondition_ByPreSelecetedList: null,
  272. canEndSelectCondition: null,
  273. canNoSelect: () => true,
  274. selectCardCoroutine: SelectCardCoroutine,
  275. afterSelectCardCoroutine: null,
  276. message: "Select 1 Digimon card to play.",
  277. maxCount: 1,
  278. canEndNotMax: false,
  279. isShowOpponent: true,
  280. mode: SelectCardEffect.Mode.Custom,
  281. root: SelectCardEffect.Root.Custom,
  282. customRootCardList: selectedPermanent.DigivolutionCards,
  283. canLookReverseCard: false,
  284. selectPlayer: card.Owner,
  285. cardEffect: activateClass);
  286. selectCardEffect.SetUpCustomMessage("Select 1 Digimon card to play.", "The opponent is selecting 1 Digimon card to play.");
  287. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  288. yield return StartCoroutine(selectCardEffect.Activate());
  289. IEnumerator SelectCardCoroutine(CardSource cardSource)
  290. {
  291. selectedCards.Add(cardSource);
  292. yield return null;
  293. }
  294. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  295. cardSources: selectedCards,
  296. activateClass: activateClass,
  297. payCost: true,
  298. isTapped: false,
  299. root: SelectCardEffect.Root.Custom,
  300. activateETB: true));
  301. #region release effect reducing play cost
  302. card.Owner.UntilCalculateFixedCostEffect.Remove(getCardEffect);
  303. #endregion
  304. }
  305. }
  306. }
  307. #endregion
  308. #region Security
  309. if (timing == EffectTiming.SecuritySkill)
  310. {
  311. cardEffects.Add(CardEffectFactory.PlaySelfTamerSecurityEffect(card));
  312. }
  313. #endregion
  314. return cardEffects;
  315. }
  316. }
  317. }