BT7_112.cs 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398
  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. public class BT7_112 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. if (timing == EffectTiming.None)
  14. {
  15. bool CanSelectCardCondition(CardSource cardSource)
  16. {
  17. if (cardSource.CardTraits.Contains("Hybrid"))
  18. {
  19. return true;
  20. }
  21. if (cardSource.IsTamer)
  22. {
  23. return true;
  24. }
  25. return false;
  26. }
  27. bool Condition()
  28. {
  29. return card.Owner.HandCards.Contains(card) && (card.Owner.HandCards.Count(CanSelectCardCondition) + card.Owner.TrashCards.Count(CanSelectCardCondition) >= 10);
  30. }
  31. bool PermanentCondition(Permanent targetPermanent)
  32. {
  33. return targetPermanent.IsTamer;
  34. }
  35. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  36. permanentCondition: PermanentCondition,
  37. digivolutionCost: 7,
  38. ignoreDigivolutionRequirement: false,
  39. card: card,
  40. condition: Condition));
  41. }
  42. if (timing == EffectTiming.BeforePayCost)
  43. {
  44. ActivateClass activateClass = new ActivateClass();
  45. activateClass.SetUpICardEffect("Return cards to deck", CanUseCondition, card);
  46. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  47. activateClass.SetHashString("ReturnCardsToDeck_BT7_112");
  48. cardEffects.Add(activateClass);
  49. string EffectDiscription()
  50. {
  51. return "You may digivolve this card from your hand onto one of your Tamers as if the Tamer is a level 6 Digimon by placing 10 Tamer cards and/or cards with [Hybrid] in their traits from your hand and/or trash at the bottom of your deck in any order.";
  52. }
  53. bool PermanentCondition(Permanent targetPermanent)
  54. {
  55. return CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(targetPermanent, card)
  56. && (targetPermanent.IsDigimon || targetPermanent.IsTamer);//Latest ruling is can return cards even when digivolving over level 6
  57. }
  58. bool CanSelectCardCondition(CardSource cardSource)
  59. {
  60. if (cardSource.CardTraits.Contains("Hybrid"))
  61. {
  62. return true;
  63. }
  64. if (cardSource.IsTamer)
  65. {
  66. return true;
  67. }
  68. return false;
  69. }
  70. bool CanUseCondition(Hashtable hashtable)
  71. {
  72. if (CardEffectCommons.CanTriggerWhenPermanentWouldDigivolve(hashtable, PermanentCondition, cardSource => cardSource == card))
  73. {
  74. return true;
  75. }
  76. return false;
  77. }
  78. bool CanActivateCondition(Hashtable hashtable)
  79. {
  80. if (card.Owner.HandCards.Count(CanSelectCardCondition) + card.Owner.TrashCards.Count(CanSelectCardCondition) >= 10)
  81. {
  82. return true;
  83. }
  84. return false;
  85. }
  86. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  87. {
  88. List<Permanent> permanents = CardEffectCommons.GetPermanentsFromHashtable(_hashtable);
  89. if (permanents != null)
  90. {
  91. if (!permanents
  92. .Filter(permanent => permanent != null && permanent.TopCard != null)
  93. .Any(permanent => permanent.IsTamer))//If digivolution is not over a tamer, trashing is optional but allowed
  94. {
  95. string selectPlayerMessage = "Will you place 10 Tamer or Hybrid cards to bottom of deck?";
  96. string notSelectPlayerMessage = "The opponent is choosing if they will return cards to deck.";
  97. List<SelectionElement<bool>> command_SelectCommands = new List<SelectionElement<bool>>()
  98. {
  99. new SelectionElement<bool>(message: $"Yes", value: true, spriteIndex: 0),
  100. new SelectionElement<bool>(message: $"No", value: false, spriteIndex: 1),
  101. };
  102. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: command_SelectCommands, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  103. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  104. if (!GManager.instance.userSelectionManager.SelectedBoolValue)
  105. yield break;
  106. }
  107. }
  108. if (card.Owner.HandCards.Count(CanSelectCardCondition) + card.Owner.TrashCards.Count(CanSelectCardCondition) >= 10)
  109. {
  110. List<CardSource> libraryCards = new List<CardSource>();
  111. if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  112. {
  113. List<CardSource> selectedCards = new List<CardSource>();
  114. int maxCount = Math.Min(10, card.Owner.HandCards.Count(CanSelectCardCondition));
  115. int minCount = 10 - card.Owner.TrashCards.Count(CanSelectCardCondition);
  116. bool CanNoSelect = minCount <= 0;
  117. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  118. selectHandEffect.SetUp(
  119. selectPlayer: card.Owner,
  120. canTargetCondition: CanSelectCardCondition,
  121. canTargetCondition_ByPreSelecetedList: null,
  122. canEndSelectCondition: CanEndSelectCondition,
  123. maxCount: maxCount,
  124. canNoSelect: CanNoSelect,
  125. canEndNotMax: true,
  126. isShowOpponent: true,
  127. selectCardCoroutine: SelectCardCoroutine,
  128. afterSelectCardCoroutine: null,
  129. mode: SelectHandEffect.Mode.Custom,
  130. cardEffect: activateClass);
  131. selectHandEffect.SetUpCustomMessage("Select cards to place to the bottom of the deck.", "The opponent is selecting cards.");
  132. yield return StartCoroutine(selectHandEffect.Activate());
  133. bool CanEndSelectCondition(List<CardSource> cardSources)
  134. {
  135. if (cardSources.Count < minCount)
  136. {
  137. return false;
  138. }
  139. return true;
  140. }
  141. IEnumerator SelectCardCoroutine(CardSource cardSource)
  142. {
  143. selectedCards.Add(cardSource);
  144. libraryCards.Add(cardSource);
  145. yield return null;
  146. }
  147. foreach (CardSource selectedCard in selectedCards)
  148. {
  149. yield return ContinuousController.instance.StartCoroutine(CardObjectController.RemoveFromAllArea(selectedCard));
  150. }
  151. }
  152. if (card.Owner.TrashCards.Count(CanSelectCardCondition) >= 1)
  153. {
  154. List<CardSource> selectedCards = new List<CardSource>();
  155. int maxCount = Math.Min(10 - libraryCards.Count, card.Owner.TrashCards.Count(CanSelectCardCondition));
  156. if (maxCount >= 1)
  157. {
  158. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  159. selectCardEffect.SetUp(
  160. canTargetCondition: CanSelectCardCondition,
  161. canTargetCondition_ByPreSelecetedList: null,
  162. canEndSelectCondition: null,
  163. canNoSelect: () => false,
  164. selectCardCoroutine: SelectCardCoroutine,
  165. afterSelectCardCoroutine: null,
  166. message: "Select cards to place to the bottom of the deck.",
  167. maxCount: maxCount,
  168. canEndNotMax: false,
  169. isShowOpponent: true,
  170. mode: SelectCardEffect.Mode.Custom,
  171. root: SelectCardEffect.Root.Trash,
  172. customRootCardList: null,
  173. canLookReverseCard: true,
  174. selectPlayer: card.Owner,
  175. cardEffect: activateClass);
  176. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  177. IEnumerator SelectCardCoroutine(CardSource cardSource)
  178. {
  179. selectedCards.Add(cardSource);
  180. libraryCards.Add(cardSource);
  181. yield return null;
  182. }
  183. foreach (CardSource selectedCard in selectedCards)
  184. {
  185. yield return ContinuousController.instance.StartCoroutine(CardObjectController.RemoveFromAllArea(selectedCard));
  186. }
  187. }
  188. }
  189. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ReturnRevealedCardsToLibraryBottom(libraryCards, activateClass));
  190. if (libraryCards.Count == 10)
  191. {
  192. ContinuousController.instance.PlaySE(GManager.instance.GetComponent<Effects>().BuffSE);
  193. AddDigivolutionRequirementClass addEvolutionConditionClass = new AddDigivolutionRequirementClass();
  194. addEvolutionConditionClass.SetUpICardEffect($"Can digivolve to this card", CanUseCondition1, card);
  195. addEvolutionConditionClass.SetUpAddDigivolutionRequirementClass(getEvoCost: GetEvoCost);
  196. card.Owner.UntilCalculateFixedCostEffect.Add((_timing) => addEvolutionConditionClass);
  197. #region show cost
  198. if (_hashtable != null)
  199. {
  200. if (_hashtable.ContainsKey("Permanents"))
  201. {
  202. if (_hashtable["Permanents"] is List<Permanent>)
  203. {
  204. List<Permanent> Permanents = (List<Permanent>)_hashtable["Permanents"];
  205. if (Permanents != null)
  206. {
  207. if (Permanents.Count >= 1)
  208. {
  209. if (_hashtable.ContainsKey("IPlayCard"))
  210. {
  211. if (_hashtable["IPlayCard"] is PlayCardClass)
  212. {
  213. PlayCardClass playCard = (PlayCardClass)_hashtable["IPlayCard"];
  214. if (playCard != null)
  215. {
  216. if (!playCard.isJogress && playCard.PayCost)
  217. {
  218. Permanent Permanent = Permanents[0];
  219. if (Permanent != null)
  220. {
  221. if (Permanent.TopCard != null)
  222. {
  223. if (_hashtable.ContainsKey("Card"))
  224. {
  225. CardSource Card = (CardSource)_hashtable["Card"];
  226. if (Card != null)
  227. {
  228. GManager.instance.memoryObject.ShowMemoryPredictionLine(Card.Owner.ExpectedMemory(Card.PayingCost(playCard.Root, Permanents, checkAvailability: false)));
  229. }
  230. }
  231. }
  232. }
  233. }
  234. }
  235. }
  236. }
  237. }
  238. }
  239. }
  240. }
  241. }
  242. #endregion
  243. bool CanUseCondition1(Hashtable hashtable)
  244. {
  245. return true;
  246. }
  247. int GetEvoCost(Permanent permanent, CardSource cardSource, CardEffectCommons.IgnoreRequirement ignore, bool ignoreDigivolutionCondition)
  248. {
  249. if ((CardSourceCondition(cardSource) && PermanentCondition(permanent)))
  250. {
  251. return 7;
  252. }
  253. return -1;
  254. }
  255. bool PermanentCondition(Permanent targetPermanent)
  256. {
  257. if (targetPermanent != null)
  258. {
  259. if (targetPermanent.IsTamer)
  260. {
  261. return true;
  262. }
  263. }
  264. return false;
  265. }
  266. bool CardSourceCondition(CardSource cardSource)
  267. {
  268. return cardSource == card;
  269. }
  270. }
  271. }
  272. }
  273. }
  274. if (timing == EffectTiming.None)
  275. {
  276. cardEffects.Add(CardEffectFactory.ChangeSelfSAttackStaticEffect(changeValue: 2, isInheritedEffect: false, card: card, condition: null));
  277. }
  278. if (timing == EffectTiming.OnEnterFieldAnyone)
  279. {
  280. ActivateClass activateClass = new ActivateClass();
  281. activateClass.SetUpICardEffect("Delete 1 Digimon", CanUseCondition, card);
  282. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  283. cardEffects.Add(activateClass);
  284. string EffectDiscription()
  285. {
  286. return "[When Digivolving] Delete 1 of your opponent's Digimon.";
  287. }
  288. bool CanSelectPermanentCondition(Permanent permanent)
  289. {
  290. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  291. }
  292. bool CanUseCondition(Hashtable hashtable)
  293. {
  294. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  295. }
  296. bool CanActivateCondition(Hashtable hashtable)
  297. {
  298. if (CardEffectCommons.IsExistOnBattleArea(card))
  299. {
  300. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  301. {
  302. return true;
  303. }
  304. }
  305. return false;
  306. }
  307. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  308. {
  309. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  310. {
  311. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  312. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  313. selectPermanentEffect.SetUp(
  314. selectPlayer: card.Owner,
  315. canTargetCondition: CanSelectPermanentCondition,
  316. canTargetCondition_ByPreSelecetedList: null,
  317. canEndSelectCondition: null,
  318. maxCount: maxCount,
  319. canNoSelect: false,
  320. canEndNotMax: false,
  321. selectPermanentCoroutine: null,
  322. afterSelectPermanentCoroutine: null,
  323. mode: SelectPermanentEffect.Mode.Destroy,
  324. cardEffect: activateClass);
  325. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  326. }
  327. }
  328. }
  329. return cardEffects;
  330. }
  331. }