BT23_101.cs 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. // Hudiemon
  5. namespace DCGO.CardEffects.BT23
  6. {
  7. public class BT23_101 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Alternative Digivolution Condition
  13. if (timing == EffectTiming.None)
  14. {
  15. bool PermanentCondition(Permanent targetPermanent)
  16. {
  17. return targetPermanent.TopCard.HasLevel && targetPermanent.TopCard.IsLevel3
  18. && targetPermanent.TopCard.HasCSTraits;
  19. }
  20. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  21. permanentCondition: PermanentCondition,
  22. digivolutionCost: 4,
  23. ignoreDigivolutionRequirement: false,
  24. card: card,
  25. condition: null)
  26. );
  27. }
  28. if (timing == EffectTiming.None)
  29. {
  30. bool PermanentCondition(Permanent targetPermanent)
  31. {
  32. return targetPermanent.TopCard.EqualsCardName("Erika Mishima");
  33. }
  34. bool Condition()
  35. {
  36. return card.Owner.GetBattleAreaPermanents()
  37. .Filter(x => x.IsTamer && x.TopCard.HasHudieTraits)
  38. .Count >= 4;
  39. }
  40. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  41. permanentCondition: PermanentCondition,
  42. digivolutionCost: 3,
  43. ignoreDigivolutionRequirement: true,
  44. card: card,
  45. condition: Condition)
  46. );
  47. }
  48. #endregion
  49. #region Alliance
  50. if (timing == EffectTiming.OnAllyAttack)
  51. {
  52. cardEffects.Add(CardEffectFactory.AllianceSelfEffect(
  53. isInheritedEffect: false,
  54. card: card,
  55. condition: null));
  56. }
  57. #endregion
  58. #region OP/WD Shared
  59. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  60. {
  61. bool CanSelectHandCardCondition(CardSource cardSource)
  62. {
  63. return cardSource.HasPlayCost && cardSource.BasePlayCostFromEntity <= 5
  64. && cardSource.HasCSTraits;
  65. }
  66. bool IsOpponentDigimon(Permanent permanent)
  67. {
  68. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  69. }
  70. int HudieDigimonAmount()
  71. {
  72. return card.Owner.GetBattleAreaPermanents()
  73. .Filter(x => CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(x, card)
  74. && x.TopCard.HasHudieTraits)
  75. .Count;
  76. }
  77. if (CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectHandCardCondition))
  78. {
  79. CardSource selectedHandCard = null;
  80. #region Select Hand card
  81. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionOwnersCardCountInHand(card, CanSelectHandCardCondition));
  82. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  83. selectHandEffect.SetUp(
  84. selectPlayer: card.Owner,
  85. canTargetCondition: CanSelectHandCardCondition,
  86. canTargetCondition_ByPreSelecetedList: null,
  87. canEndSelectCondition: null,
  88. maxCount: maxCount,
  89. canNoSelect: true,
  90. canEndNotMax: false,
  91. isShowOpponent: true,
  92. selectCardCoroutine: SelectCardCoroutine,
  93. afterSelectCardCoroutine: null,
  94. mode: SelectHandEffect.Mode.Custom,
  95. cardEffect: activateClass);
  96. IEnumerator SelectCardCoroutine(CardSource cardSource)
  97. {
  98. selectedHandCard = cardSource;
  99. yield return null;
  100. }
  101. selectHandEffect.SetUpCustomMessage("Select 1 card to play", "The opponent is selecting 1 card to play");
  102. selectHandEffect.SetUpCustomMessage_ShowCard("Selected card");
  103. yield return ContinuousController.instance.StartCoroutine(selectHandEffect.Activate());
  104. #endregion
  105. if (selectedHandCard != null) yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  106. cardSources: new List<CardSource>() { selectedHandCard },
  107. activateClass: activateClass,
  108. payCost: false,
  109. isTapped: false,
  110. root: SelectCardEffect.Root.Hand,
  111. activateETB: true));
  112. }
  113. if (CardEffectCommons.HasMatchConditionPermanent(IsOpponentDigimon))
  114. {
  115. Permanent selectedOpponentDigimon = null;
  116. #region Select Opponent Digimon
  117. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(IsOpponentDigimon));
  118. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  119. selectPermanentEffect.SetUp(
  120. selectPlayer: card.Owner,
  121. canTargetCondition: IsOpponentDigimon,
  122. canTargetCondition_ByPreSelecetedList: null,
  123. canEndSelectCondition: null,
  124. maxCount: maxCount,
  125. canNoSelect: false,
  126. canEndNotMax: false,
  127. selectPermanentCoroutine: SelectPermanentCoroutine,
  128. afterSelectPermanentCoroutine: null,
  129. mode: SelectPermanentEffect.Mode.Custom,
  130. cardEffect: activateClass);
  131. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  132. {
  133. selectedOpponentDigimon = permanent;
  134. yield return null;
  135. }
  136. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  137. #endregion
  138. if (selectedOpponentDigimon != null)
  139. {
  140. int dpReduction = HudieDigimonAmount() * 3000;
  141. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDP(
  142. targetPermanent: selectedOpponentDigimon,
  143. changeValue: -dpReduction,
  144. effectDuration: EffectDuration.UntilEachTurnEnd,
  145. activateClass: activateClass));
  146. }
  147. }
  148. }
  149. #endregion
  150. #region On Play
  151. if (timing == EffectTiming.OnEnterFieldAnyone)
  152. {
  153. ActivateClass activateClass = new ActivateClass();
  154. activateClass.SetUpICardEffect("Play 1 5 cost or lower [CS] card from hand, then 1 digimon gains -3000 for each of your [Hudie] digimon", CanUseCondition, card);
  155. activateClass.SetUpActivateClass(CanActivateCondition, hash => SharedActivateCoroutine(hash, activateClass), -1, false, EffectDiscription());
  156. cardEffects.Add(activateClass);
  157. string EffectDiscription()
  158. {
  159. return "[On Play] You may play 1 play cost 5 or lower [CS] trait card from your hand without paying the cost. Then, to 1 of your opponent's Digimon, give -3000 DP for the turn for each of your [Hudie] trait Digimon.";
  160. }
  161. bool CanUseCondition(Hashtable hashtable)
  162. {
  163. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  164. && CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  165. }
  166. bool CanActivateCondition(Hashtable hashtable)
  167. {
  168. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  169. }
  170. }
  171. #endregion
  172. #region When Digivolving
  173. if (timing == EffectTiming.OnEnterFieldAnyone)
  174. {
  175. ActivateClass activateClass = new ActivateClass();
  176. activateClass.SetUpICardEffect("Play 1 5 cost or lower [CS] card from hand, then 1 digimon gains -3000 for each of your [Hudie] digimon", CanUseCondition, card);
  177. activateClass.SetUpActivateClass(CanActivateCondition, hash => SharedActivateCoroutine(hash, activateClass), -1, false, EffectDiscription());
  178. cardEffects.Add(activateClass);
  179. string EffectDiscription()
  180. {
  181. return "[When Digivolving] You may play 1 play cost 5 or lower [CS] trait card from your hand without paying the cost. Then, to 1 of your opponent's Digimon, give -3000 DP for the turn for each of your [Hudie] trait Digimon.";
  182. }
  183. bool CanUseCondition(Hashtable hashtable)
  184. {
  185. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  186. && CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  187. }
  188. bool CanActivateCondition(Hashtable hashtable)
  189. {
  190. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  191. }
  192. }
  193. #endregion
  194. #region When Attacking - OPT
  195. if (timing == EffectTiming.OnAllyAttack)
  196. {
  197. ActivateClass activateClass = new ActivateClass();
  198. activateClass.SetUpICardEffect("By bounce 1 [CS] tamer to hand, Activate 1 [On Play]", CanUseCondition, card);
  199. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  200. activateClass.SetHashString("BT23_101_WA");
  201. cardEffects.Add(activateClass);
  202. string EffectDiscription()
  203. {
  204. return "[When Attacking] [Once Per Turn] By returning 1 of your [CS] trait Tamers to the hand, activate 1 of this Digimon's [On Play] effects.";
  205. }
  206. bool CanUseCondition(Hashtable hashtable)
  207. {
  208. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  209. && CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  210. }
  211. bool CanActivateCondition(Hashtable hashtable)
  212. {
  213. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  214. && CardEffectCommons.HasMatchConditionOwnersPermanent(card, IsCSTamer);
  215. }
  216. bool IsCSTamer(Permanent permanent)
  217. {
  218. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaTamer(permanent, card)
  219. && permanent.TopCard.HasCSTraits;
  220. }
  221. IEnumerator ActivateCoroutine(Hashtable hashtable)
  222. {
  223. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, IsCSTamer))
  224. {
  225. Permanent selectedPermament = null;
  226. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(IsCSTamer));
  227. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  228. selectPermanentEffect.SetUp(
  229. selectPlayer: card.Owner,
  230. canTargetCondition: IsCSTamer,
  231. canTargetCondition_ByPreSelecetedList: null,
  232. canEndSelectCondition: null,
  233. maxCount: maxCount,
  234. canNoSelect: false,
  235. canEndNotMax: false,
  236. selectPermanentCoroutine: SelectPermanentCoroutine,
  237. afterSelectPermanentCoroutine: null,
  238. mode: SelectPermanentEffect.Mode.Custom,
  239. cardEffect: activateClass);
  240. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  241. {
  242. selectedPermament = permanent;
  243. yield return null;
  244. }
  245. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  246. if (selectedPermament != null)
  247. {
  248. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.BouncePeremanentAndProcessAccordingToResult(
  249. targetPermanents: new List<Permanent>() { selectedPermament },
  250. activateClass: activateClass,
  251. successProcess: SuccessProcess(),
  252. failureProcess: null));
  253. IEnumerator SuccessProcess()
  254. {
  255. List<ICardEffect> candidateEffects = card.PermanentOfThisCard().EffectList(EffectTiming.OnEnterFieldAnyone)
  256. .Clone()
  257. .Filter(cardEffect => cardEffect != null && cardEffect is ActivateICardEffect && !cardEffect.IsSecurityEffect && cardEffect.IsOnPlay);
  258. if (candidateEffects.Count >= 1)
  259. {
  260. ICardEffect selectedEffect = null;
  261. if (candidateEffects.Count == 1)
  262. {
  263. selectedEffect = candidateEffects[0];
  264. }
  265. else
  266. {
  267. List<SkillInfo> skillInfos = candidateEffects
  268. .Map(cardEffect => new SkillInfo(cardEffect, null, EffectTiming.None));
  269. List<CardSource> cardSources = candidateEffects
  270. .Map(cardEffect => cardEffect.EffectSourceCard);
  271. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  272. selectCardEffect.SetUp(
  273. canTargetCondition: (cardSource) => true,
  274. canTargetCondition_ByPreSelecetedList: null,
  275. canEndSelectCondition: null,
  276. canNoSelect: () => false,
  277. selectCardCoroutine: null,
  278. afterSelectCardCoroutine: null,
  279. message: "Select 1 effect to activate.",
  280. maxCount: 1,
  281. canEndNotMax: false,
  282. isShowOpponent: false,
  283. mode: SelectCardEffect.Mode.Custom,
  284. root: SelectCardEffect.Root.Custom,
  285. customRootCardList: cardSources,
  286. canLookReverseCard: true,
  287. selectPlayer: card.Owner,
  288. cardEffect: activateClass);
  289. selectCardEffect.SetNotShowCard();
  290. selectCardEffect.SetUpSkillInfos(skillInfos);
  291. selectCardEffect.SetUpAfterSelectIndexCoroutine(AfterSelectIndexCoroutine);
  292. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  293. IEnumerator AfterSelectIndexCoroutine(List<int> selectedIndexes)
  294. {
  295. if (selectedIndexes.Count == 1)
  296. {
  297. selectedEffect = candidateEffects[selectedIndexes[0]];
  298. yield return null;
  299. }
  300. }
  301. }
  302. if (selectedEffect != null)
  303. {
  304. selectedEffect.SetIsDigimonEffect(true);
  305. Hashtable effectHashtable = CardEffectCommons.OnPlayCheckHashtableOfCard(selectedEffect.EffectSourceCard);
  306. if (!selectedEffect.IsDisabled)
  307. {
  308. yield return ContinuousController.instance.StartCoroutine(
  309. ((ActivateICardEffect)selectedEffect).Activate_Optional_Effect_Execute(effectHashtable));
  310. }
  311. }
  312. }
  313. }
  314. }
  315. }
  316. }
  317. }
  318. #endregion
  319. return cardEffects;
  320. }
  321. }
  322. }