BT18_096.cs 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.BT18
  6. {
  7. public class BT18_096 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Ignore color requirements
  13. if (timing == EffectTiming.None)
  14. {
  15. IgnoreColorConditionClass ignoreColorConditionClass = new IgnoreColorConditionClass();
  16. ignoreColorConditionClass.SetUpICardEffect("Ignore color requirements", CanUseCondition, card);
  17. ignoreColorConditionClass.SetUpIgnoreColorConditionClass(cardCondition: CardCondition);
  18. cardEffects.Add(ignoreColorConditionClass);
  19. bool CanUseCondition(Hashtable hashtable)
  20. {
  21. return CardEffectCommons.HasMatchConditionOwnersPermanent(card,
  22. permanent =>
  23. permanent.IsDigimon &&
  24. permanent.TopCard.HasHybridTenWarriorsTraits);
  25. }
  26. bool CardCondition(CardSource cardSource)
  27. {
  28. return cardSource == card;
  29. }
  30. }
  31. #endregion
  32. #region Main Effect
  33. if (timing == EffectTiming.OptionSkill)
  34. {
  35. ActivateClass activateClass = new ActivateClass();
  36. activateClass.SetUpICardEffect(card.BaseENGCardNameFromEntity, CanUseCondition, card);
  37. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDescription());
  38. cardEffects.Add(activateClass);
  39. string EffectDescription()
  40. {
  41. return
  42. "[Main] 1 of your Digimon or Tamers may digivolve into [Susanoomon] in the hand or trash without paying the cost. Then, by placing up to 4 of your Tamers with different colors under 1 of your [Susanoomon] as its bottom digivolution cards, gain 1 memory for each placed card.";
  43. }
  44. bool CanUseCondition(Hashtable hashtable)
  45. {
  46. return CardEffectCommons.CanTriggerOptionMainEffect(hashtable, card);
  47. }
  48. bool DigivolveFromPermanentCondition(Permanent permanent)
  49. {
  50. return CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card) &&
  51. (permanent.IsDigimon || permanent.IsTamer) &&
  52. (card.Owner.HandCards.Where(DigivolveToCardCondition).Any(cardSource =>
  53. cardSource.CanPlayCardTargetFrame(permanent.PermanentFrame, false, activateClass)) ||
  54. card.Owner.TrashCards.Where(DigivolveToCardCondition).Any(cardSource =>
  55. cardSource.CanPlayCardTargetFrame(permanent.PermanentFrame, false, activateClass)));
  56. }
  57. bool DigivolveToCardCondition(CardSource cardSource)
  58. {
  59. return cardSource.EqualsCardName("Susanoomon");
  60. }
  61. bool CanSelectOwnTamerPermanentCondition(Permanent permanent)
  62. {
  63. return CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card) && permanent.IsTamer;
  64. }
  65. bool CanSelectSusanoomonPermanentCondition(Permanent permanent)
  66. {
  67. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card) &&
  68. permanent.TopCard.EqualsCardName("Susanoomon");
  69. }
  70. IEnumerator ActivateCoroutine(Hashtable hashtable)
  71. {
  72. // Digivolve into Susanoomon
  73. if (CardEffectCommons.HasMatchConditionPermanent(DigivolveFromPermanentCondition))
  74. {
  75. Permanent selectedPermanent = null;
  76. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  77. selectPermanentEffect.SetUp(
  78. selectPlayer: card.Owner,
  79. canTargetCondition: DigivolveFromPermanentCondition,
  80. canTargetCondition_ByPreSelecetedList: null,
  81. canEndSelectCondition: null,
  82. maxCount: 1,
  83. canNoSelect: false,
  84. canEndNotMax: false,
  85. selectPermanentCoroutine: SelectPermanentCoroutine,
  86. afterSelectPermanentCoroutine: null,
  87. mode: SelectPermanentEffect.Mode.Custom,
  88. cardEffect: activateClass);
  89. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will digivolve.",
  90. "The opponent is selecting 1 Digimon that will digivolve.");
  91. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  92. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  93. {
  94. selectedPermanent = permanent;
  95. yield return null;
  96. }
  97. if (selectedPermanent != null)
  98. {
  99. bool canSelectHand = CardEffectCommons.HasMatchConditionOwnersHand(card, DigivolveToCardCondition);
  100. bool canSelectTrash = CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, DigivolveToCardCondition);
  101. if (canSelectHand || canSelectTrash)
  102. {
  103. if (canSelectHand && canSelectTrash)
  104. {
  105. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>
  106. {
  107. new(message: "From hand", value: true, spriteIndex: 0),
  108. new(message: "From trash", value: false, spriteIndex: 1),
  109. };
  110. string selectPlayerMessage = "From which area do you digivolve?";
  111. string notSelectPlayerMessage = "The opponent is choosing from which area to digivolve.";
  112. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements,
  113. selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage,
  114. notSelectPlayerMessage: notSelectPlayerMessage);
  115. }
  116. else
  117. {
  118. GManager.instance.userSelectionManager.SetBool(canSelectHand);
  119. }
  120. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager
  121. .WaitForEndSelect());
  122. bool fromHand = GManager.instance.userSelectionManager.SelectedBoolValue;
  123. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DigivolveIntoHandOrTrashCard(
  124. targetPermanent: selectedPermanent,
  125. cardCondition: DigivolveToCardCondition,
  126. payCost: false,
  127. reduceCostTuple: null,
  128. fixedCostTuple: null,
  129. ignoreDigivolutionRequirementFixedCost: -1,
  130. isHand: fromHand,
  131. activateClass: activateClass,
  132. successProcess: null));
  133. }
  134. }
  135. }
  136. // Place Tamers
  137. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectSusanoomonPermanentCondition) &&
  138. CardEffectCommons.HasMatchConditionPermanent(CanSelectOwnTamerPermanentCondition))
  139. {
  140. Permanent susanoomonPermanent = null;
  141. SelectPermanentEffect selectPermanentEffect =
  142. GManager.instance.GetComponent<SelectPermanentEffect>();
  143. selectPermanentEffect.SetUp(
  144. selectPlayer: card.Owner,
  145. canTargetCondition: CanSelectSusanoomonPermanentCondition,
  146. canTargetCondition_ByPreSelecetedList: null,
  147. canEndSelectCondition: null,
  148. maxCount: 1,
  149. canNoSelect: true,
  150. canEndNotMax: false,
  151. selectPermanentCoroutine: SelectPermanentCoroutine1,
  152. afterSelectPermanentCoroutine: null,
  153. mode: SelectPermanentEffect.Mode.Custom,
  154. cardEffect: activateClass);
  155. selectPermanentEffect.SetUpCustomMessage(
  156. "Select 1 of your Susanoomon.",
  157. "The opponent is selecting 1 of their Susanoomon.");
  158. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  159. IEnumerator SelectPermanentCoroutine1(Permanent selectedPermanent)
  160. {
  161. susanoomonPermanent = selectedPermanent;
  162. yield return null;
  163. }
  164. if (susanoomonPermanent != null)
  165. {
  166. selectPermanentEffect.SetUp(
  167. selectPlayer: card.Owner,
  168. canTargetCondition: CanSelectOwnTamerPermanentCondition,
  169. canTargetCondition_ByPreSelecetedList: CanTargetConditionByPreSelectedList,
  170. canEndSelectCondition: CanEndSelectCondition,
  171. maxCount: Math.Min(4, CardEffectCommons.MatchConditionPermanentCount(CanSelectOwnTamerPermanentCondition)),
  172. canNoSelect: true,
  173. canEndNotMax: true,
  174. selectPermanentCoroutine: SelectPermanentCoroutine2,
  175. afterSelectPermanentCoroutine: AfterSelectPermanentCoroutine,
  176. mode: SelectPermanentEffect.Mode.Custom,
  177. cardEffect: activateClass);
  178. selectPermanentEffect.SetUpCustomMessage(
  179. "Select up to 4 of your Tamers with different colors to place on bottom of digivolution cards of your Susanoomon.",
  180. "The opponent is selecting up to 4 of your Tamers with different colors to place on bottom of digivolution cards of your Susanoomon.");
  181. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  182. bool CanTargetConditionByPreSelectedList(List<Permanent> permanents, Permanent permanent)
  183. {
  184. List<Permanent> concat = permanents.Concat(new List<Permanent>() { permanent }).ToList();
  185. return Combinations.GetDifferenetColorCardCount(concat.Map(permanent1 => permanent1.TopCard)) >=
  186. concat.Count;
  187. }
  188. bool CanEndSelectCondition(List<Permanent> permanents)
  189. {
  190. return permanents.Count > 0 && Combinations.GetDifferenetColorCardCount(
  191. permanents.Map(permanent1 => permanent1.TopCard)) >= permanents.Count;
  192. }
  193. IEnumerator SelectPermanentCoroutine2(Permanent selectedPermanent)
  194. {
  195. yield return ContinuousController.instance.StartCoroutine(new IPlacePermanentToDigivolutionCards(
  196. new List<Permanent[]> { new[] { selectedPermanent, susanoomonPermanent } }, false,
  197. activateClass).PlacePermanentToDigivolutionCards());
  198. }
  199. IEnumerator AfterSelectPermanentCoroutine(List<Permanent> permanents)
  200. {
  201. yield return ContinuousController.instance.StartCoroutine(
  202. card.Owner.AddMemory(permanents.Count, activateClass));
  203. }
  204. }
  205. }
  206. }
  207. }
  208. #endregion
  209. #region Security Effect
  210. if (timing == EffectTiming.SecuritySkill)
  211. {
  212. ActivateClass activateClass = new ActivateClass();
  213. activateClass.SetUpICardEffect($"Play 1 Tamer card with an inherited effect from hand or trash and add this card to hand",
  214. CanUseCondition, card);
  215. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDescription());
  216. activateClass.SetIsSecurityEffect(true);
  217. cardEffects.Add(activateClass);
  218. string EffectDescription()
  219. {
  220. return
  221. "[Security] You may play 1 Tamer card with an inherited effect from your hand or trash without paying the cost. Then, add this card to the hand.";
  222. }
  223. bool CanUseCondition(Hashtable hashtable)
  224. {
  225. return CardEffectCommons.CanTriggerSecurityEffect(hashtable, card);
  226. }
  227. bool CanSelectCardCondition(CardSource cardSource)
  228. {
  229. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  230. {
  231. return cardSource.IsTamer && cardSource.HasInheritedEffect;
  232. }
  233. return false;
  234. }
  235. IEnumerator ActivateCoroutine(Hashtable hashtable)
  236. {
  237. bool canSelectHand = CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectCardCondition);
  238. bool canSelectTrash = CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition);
  239. if (canSelectHand || canSelectTrash)
  240. {
  241. if (canSelectHand && canSelectTrash)
  242. {
  243. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>
  244. {
  245. new(message: "From hand", value: true, spriteIndex: 0),
  246. new(message: "From trash", value: false, spriteIndex: 1),
  247. };
  248. string selectPlayerMessage = "From which area do you play a card?";
  249. string notSelectPlayerMessage = "The opponent is choosing from which area to play a card.";
  250. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements,
  251. selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage,
  252. notSelectPlayerMessage: notSelectPlayerMessage);
  253. }
  254. else
  255. {
  256. GManager.instance.userSelectionManager.SetBool(canSelectHand);
  257. }
  258. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager
  259. .WaitForEndSelect());
  260. bool fromHand = GManager.instance.userSelectionManager.SelectedBoolValue;
  261. List<CardSource> selectedCards = new List<CardSource>();
  262. IEnumerator SelectCardCoroutine(CardSource cardSource)
  263. {
  264. selectedCards.Add(cardSource);
  265. yield return null;
  266. }
  267. if (fromHand)
  268. {
  269. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  270. selectHandEffect.SetUp(
  271. selectPlayer: card.Owner,
  272. canTargetCondition: CanSelectCardCondition,
  273. canTargetCondition_ByPreSelecetedList: null,
  274. canEndSelectCondition: null,
  275. maxCount: 1,
  276. canNoSelect: true,
  277. canEndNotMax: false,
  278. isShowOpponent: true,
  279. selectCardCoroutine: SelectCardCoroutine,
  280. afterSelectCardCoroutine: null,
  281. mode: SelectHandEffect.Mode.Custom,
  282. cardEffect: activateClass);
  283. selectHandEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  284. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  285. yield return StartCoroutine(selectHandEffect.Activate());
  286. }
  287. else
  288. {
  289. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  290. selectCardEffect.SetUp(
  291. canTargetCondition: CanSelectCardCondition,
  292. canTargetCondition_ByPreSelecetedList: null,
  293. canEndSelectCondition: null,
  294. canNoSelect: () => true,
  295. selectCardCoroutine: SelectCardCoroutine,
  296. afterSelectCardCoroutine: null,
  297. message: "Select 1 card to play.",
  298. maxCount: 1,
  299. canEndNotMax: false,
  300. isShowOpponent: true,
  301. mode: SelectCardEffect.Mode.Custom,
  302. root: SelectCardEffect.Root.Trash,
  303. customRootCardList: null,
  304. canLookReverseCard: true,
  305. selectPlayer: card.Owner,
  306. cardEffect: activateClass);
  307. selectCardEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  308. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  309. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  310. }
  311. SelectCardEffect.Root root = SelectCardEffect.Root.Hand;
  312. if (!fromHand)
  313. {
  314. root = SelectCardEffect.Root.Trash;
  315. }
  316. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  317. cardSources: selectedCards, activateClass: activateClass, payCost: false, isTapped: false, root: root,
  318. activateETB: true));
  319. }
  320. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.AddThisCardToHand(card, activateClass));
  321. }
  322. }
  323. #endregion
  324. return cardEffects;
  325. }
  326. }
  327. }