BT23_013.cs 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. // Jesmon
  5. namespace DCGO.CardEffects.BT23
  6. {
  7. public class BT23_013 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Static Effects
  13. #region Alternative Digivolution Condition
  14. if (timing == EffectTiming.None)
  15. {
  16. bool PermanentCondition(Permanent targetPermanent)
  17. {
  18. return targetPermanent.TopCard.EqualsCardName("SaviorHuckmon")
  19. || (targetPermanent.TopCard.HasCSTraits && targetPermanent.TopCard.HasLevel && targetPermanent.TopCard.IsLevel5);
  20. }
  21. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  22. permanentCondition: PermanentCondition,
  23. digivolutionCost: 3,
  24. ignoreDigivolutionRequirement: false,
  25. card: card,
  26. condition: null)
  27. );
  28. }
  29. #endregion
  30. #region Alternative Digivolution Condition
  31. if (timing == EffectTiming.None)
  32. {
  33. bool PermanentCondition(Permanent targetPermanent)
  34. {
  35. return targetPermanent.TopCard.EqualsCardName("Huckmon");
  36. }
  37. bool Condition()
  38. {
  39. return card.Owner.Enemy.GetBattleAreaDigimons().Filter(x => x.DP >= 10000).Count >= 1;
  40. }
  41. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  42. permanentCondition: PermanentCondition,
  43. digivolutionCost: 5,
  44. ignoreDigivolutionRequirement: false,
  45. card: card,
  46. condition: Condition)
  47. );
  48. }
  49. #endregion
  50. #region Rush
  51. if (timing == EffectTiming.None)
  52. {
  53. cardEffects.Add(CardEffectFactory.RushSelfStaticEffect(isInheritedEffect: false, card: card, condition: null));
  54. }
  55. #endregion
  56. #region Alliance
  57. if (timing == EffectTiming.OnAllyAttack)
  58. {
  59. cardEffects.Add(CardEffectFactory.AllianceSelfEffect(isInheritedEffect: false, card: card, condition: null));
  60. }
  61. #endregion
  62. #endregion
  63. #region WD/WA Shared
  64. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  65. {
  66. bool IsValidSistermon(CardSource cardSource)
  67. {
  68. var digimonOnField = card.Owner.GetBattleAreaDigimons().Select(x => x.TopCard);
  69. var fieldNames = digimonOnField
  70. .SelectMany(x => x.CardNames)
  71. .Select(n => n.ToLowerInvariant())
  72. .ToHashSet();
  73. var sourceNames = (cardSource.CardNames)
  74. .Select(n => n.ToLowerInvariant());
  75. return cardSource.IsDigimon
  76. && cardSource.ContainsCardName("Sistermon")
  77. && !sourceNames.Any(n => fieldNames.Contains(n))
  78. && CardEffectCommons.CanPlayAsNewPermanent(cardSource, false, activateClass);
  79. }
  80. bool HasTokenInPlay(Permanent permanent)
  81. {
  82. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card) &&
  83. permanent.TopCard.EqualsCardName("Atho, René & Por");
  84. }
  85. bool playToken = false;
  86. bool playSistermon = false;
  87. bool playFromHand = false;
  88. bool playFromTrash = false;
  89. bool canPlayToken = !CardEffectCommons.HasMatchConditionPermanent(HasTokenInPlay);
  90. bool canSelectHand = CardEffectCommons.HasMatchConditionOwnersHand(card, IsValidSistermon);
  91. bool canSelectTrash = CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, IsValidSistermon);
  92. #region User Selection - Play Token or Select Card Location
  93. var playOptions = new List<SelectionElement<bool>>();
  94. if (canPlayToken) playOptions.Add(new SelectionElement<bool>(message: $"Play [Atho, René & Por] Token", value: true, spriteIndex: 0));
  95. if (canSelectHand || canSelectTrash) playOptions.Add(new SelectionElement<bool>(message: $"Player [Sistermon] in name digimon from hand or trash", value: false, spriteIndex: 1));
  96. if (playOptions.Count == 1)
  97. {
  98. if (playOptions[0].Message.Contains("Token")) playToken = true;
  99. else playSistermon = true;
  100. }
  101. if (playOptions.Count == 2)
  102. {
  103. string selectPlayerMessage = "Which effect will you use";
  104. string notSelectPlayerMessage = "The opponent is which effect to use.";
  105. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: playOptions, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  106. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  107. var selectedOption = GManager.instance.userSelectionManager.SelectedBoolValue;
  108. if (selectedOption) playToken = true;
  109. else playSistermon = true;
  110. }
  111. if (playSistermon)
  112. {
  113. if (canSelectHand && canSelectTrash)
  114. {
  115. List<SelectionElement<bool>> selectionElements1 = new List<SelectionElement<bool>>()
  116. {
  117. new SelectionElement<bool>(message: $"From hand", value : true, spriteIndex: 0),
  118. new SelectionElement<bool>(message: $"From trash", value : false, spriteIndex: 1),
  119. };
  120. string selectPlayerMessage1 = "From which area do you select a card?";
  121. string notSelectPlayerMessage1 = "The opponent is choosing from which area to select a card.";
  122. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements1, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage1, notSelectPlayerMessage: notSelectPlayerMessage1);
  123. }
  124. else
  125. {
  126. GManager.instance.userSelectionManager.SetBool(canSelectHand);
  127. }
  128. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  129. var handOrTrashSelection = GManager.instance.userSelectionManager.SelectedBoolValue;
  130. if (handOrTrashSelection) playFromHand = true;
  131. else playFromTrash = true;
  132. }
  133. #endregion
  134. CardSource selectedCard = null;
  135. IEnumerator SelectCardCoroutine(CardSource cardSource)
  136. {
  137. selectedCard = cardSource;
  138. yield return null;
  139. }
  140. if (playToken) yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayAthoRenePorToken(activateClass: activateClass));
  141. if (playFromHand)
  142. {
  143. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  144. selectHandEffect.SetUp(
  145. selectPlayer: card.Owner,
  146. canTargetCondition: IsValidSistermon,
  147. canTargetCondition_ByPreSelecetedList: null,
  148. canEndSelectCondition: null,
  149. maxCount: 1,
  150. canNoSelect: true,
  151. canEndNotMax: false,
  152. isShowOpponent: true,
  153. selectCardCoroutine: SelectCardCoroutine,
  154. afterSelectCardCoroutine: null,
  155. mode: SelectHandEffect.Mode.Custom,
  156. cardEffect: activateClass);
  157. selectHandEffect.SetUpCustomMessage("Select 1 digimon to play", "The opponent is selecting 1 digimon to play");
  158. yield return ContinuousController.instance.StartCoroutine(selectHandEffect.Activate());
  159. if (selectedCard != null) yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  160. new List<CardSource>() { selectedCard },
  161. activateClass: activateClass,
  162. payCost: false,
  163. isTapped: false,
  164. root: SelectCardEffect.Root.Hand,
  165. activateETB: true));
  166. }
  167. if (playFromTrash)
  168. {
  169. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  170. selectCardEffect.SetUp(
  171. canTargetCondition: IsValidSistermon,
  172. canTargetCondition_ByPreSelecetedList: null,
  173. canEndSelectCondition: null,
  174. canNoSelect: () => true,
  175. selectCardCoroutine: SelectCardCoroutine,
  176. afterSelectCardCoroutine: null,
  177. message: "Select 1 digimon to play",
  178. maxCount: 1,
  179. canEndNotMax: false,
  180. isShowOpponent: true,
  181. mode: SelectCardEffect.Mode.Custom,
  182. root: SelectCardEffect.Root.Trash,
  183. customRootCardList: null,
  184. canLookReverseCard: true,
  185. selectPlayer: card.Owner,
  186. cardEffect: activateClass);
  187. selectCardEffect.SetUpCustomMessage("Select 1 digimon to play", "The opponent is selecting 1 digimon to play");
  188. selectCardEffect.SetUpCustomMessage_ShowCard("Selected Digimon");
  189. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  190. if (selectedCard != null) yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  191. new List<CardSource>() { selectedCard },
  192. activateClass: activateClass,
  193. payCost: false,
  194. isTapped: false,
  195. root: SelectCardEffect.Root.Trash,
  196. activateETB: true));
  197. }
  198. }
  199. #endregion
  200. #region When Digivolving
  201. if (timing == EffectTiming.OnEnterFieldAnyone)
  202. {
  203. ActivateClass activateClass = new ActivateClass();
  204. activateClass.SetUpICardEffect("Play 1 [Atho, René & Por] token or 1 [Sistermon] in name digimon from hand or trash", CanUseCondition, card);
  205. activateClass.SetUpActivateClass(CanActivateCondition, hash => SharedActivateCoroutine(hash, activateClass), -1, true, EffectDiscription());
  206. cardEffects.Add(activateClass);
  207. string EffectDiscription()
  208. {
  209. return "[When Digivolving] You may play 1 [Atho, René & Por] Token or, from your hand or trash, 1 Digimon card with [Sistermon] in its name without paying the cost. This effect can't play cards with the same names as any of your Digimon.";
  210. }
  211. bool CanUseCondition(Hashtable hashtable)
  212. {
  213. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  214. && CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  215. }
  216. bool CanActivateCondition(Hashtable hashtable)
  217. {
  218. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  219. }
  220. }
  221. #endregion
  222. #region When Attacking
  223. if (timing == EffectTiming.OnAllyAttack)
  224. {
  225. ActivateClass activateClass = new ActivateClass();
  226. activateClass.SetUpICardEffect("Play 1 [Atho, René & Por] token or 1 [Sistermon] in name digimon from hand or trash", CanUseCondition, card);
  227. activateClass.SetUpActivateClass(CanActivateCondition, hash => SharedActivateCoroutine(hash, activateClass), -1, true, EffectDiscription());
  228. cardEffects.Add(activateClass);
  229. string EffectDiscription()
  230. {
  231. return "[When Attacking] You may play 1 [Atho, René & Por] Token or, from your hand or trash, 1 Digimon card with [Sistermon] in its name without paying the cost. This effect can't play cards with the same names as any of your Digimon.";
  232. }
  233. bool CanUseCondition(Hashtable hashtable)
  234. {
  235. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  236. && CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  237. }
  238. bool CanActivateCondition(Hashtable hashtable)
  239. {
  240. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  241. }
  242. }
  243. #endregion
  244. #region Your Turn - OPT
  245. if (timing == EffectTiming.OnEnterFieldAnyone)
  246. {
  247. ActivateClass activateClass = new ActivateClass();
  248. activateClass.SetUpICardEffect("This digimon may attack", CanUseCondition, card);
  249. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  250. activateClass.SetHashString("BT23_013_YT");
  251. cardEffects.Add(activateClass);
  252. string EffectDiscription()
  253. {
  254. return "[Your Turn] [Once Per Turn] When any of your other Digimon are played, this Digimon may attack.";
  255. }
  256. bool CanUseCondition(Hashtable hashtable)
  257. {
  258. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  259. && CardEffectCommons.CanTriggerOnPermanentPlay(hashtable, PermanentCondition, null);
  260. }
  261. bool CanActivateCondition(Hashtable hashtable)
  262. {
  263. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  264. && CardEffectCommons.IsOwnerTurn(card);
  265. }
  266. bool PermanentCondition(Permanent permanent)
  267. {
  268. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card)
  269. && permanent != card.PermanentOfThisCard();
  270. }
  271. IEnumerator ActivateCoroutine(Hashtable hashtable)
  272. {
  273. if (card.PermanentOfThisCard().CanAttack(activateClass))
  274. {
  275. SelectAttackEffect selectAttackEffect = GManager.instance.GetComponent<SelectAttackEffect>();
  276. selectAttackEffect.SetUp(
  277. attacker: card.PermanentOfThisCard(),
  278. canAttackPlayerCondition: () => true,
  279. defenderCondition: _ => true,
  280. cardEffect: activateClass);
  281. yield return ContinuousController.instance.StartCoroutine(selectAttackEffect.Activate());
  282. }
  283. }
  284. }
  285. #endregion
  286. return cardEffects;
  287. }
  288. }
  289. }