BT22_042.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. // Nyabootmon
  5. namespace DCGO.CardEffects.BT22
  6. {
  7. public class BT22_042 : 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.EqualsCardName("Chaperomon");
  18. }
  19. bool Condition()
  20. {
  21. return CardEffectCommons.HasMatchConditionOwnersPermanent(card, perm => perm.IsTamer && perm.TopCard.EqualsCardName("Arisa Kinosaki"));
  22. }
  23. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 6, ignoreDigivolutionRequirement: false, card: card, condition: Condition));
  24. }
  25. #endregion
  26. #region Overclock
  27. if (timing == EffectTiming.OnEndTurn)
  28. {
  29. cardEffects.Add(CardEffectFactory.OverclockSelfEffect(trait: "Puppet", isInheritedEffect: false, card: card, condition: null));
  30. }
  31. #endregion
  32. #region When Digivolving
  33. if (timing == EffectTiming.OnEnterFieldAnyone)
  34. {
  35. ActivateClass activateClass = new ActivateClass();
  36. activateClass.SetUpICardEffect($"Play 1 level 4 or lower [Puppet] digimon, then -3K DP for each digimon to 1 digimon", CanUseCondition, card);
  37. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  38. cardEffects.Add(activateClass);
  39. string EffectDiscription()
  40. {
  41. return "[When Digivolving] You may play 1 level 4 or lower [Puppet] trait Digimon card from your hand without paying the cost. Then, to 1 of your opponent's Digimon, give -3000 DP until their turn ends for each of your Digimon.";
  42. }
  43. bool CanUseCondition(Hashtable hashtable)
  44. {
  45. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  46. && CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  47. }
  48. bool CanActivateCondition(Hashtable hashtable)
  49. {
  50. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  51. }
  52. bool IsPuppetDigimon(CardSource cardSource)
  53. {
  54. return cardSource.IsDigimon
  55. && cardSource.HasLevel && cardSource.Level <= 4
  56. && cardSource.HasPuppetTraits
  57. && CardEffectCommons.CanPlayAsNewPermanent(cardSource, false, activateClass);
  58. }
  59. bool IsOpponentDigimon(Permanent permanent)
  60. {
  61. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  62. }
  63. IEnumerator ActivateCoroutine(Hashtable hashtable)
  64. {
  65. if (CardEffectCommons.HasMatchConditionOwnersHand(card, IsPuppetDigimon))
  66. {
  67. CardSource selectedCard = null;
  68. #region Select Hand Card
  69. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionOwnersCardCountInHand(card, IsPuppetDigimon));
  70. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  71. selectHandEffect.SetUp(
  72. selectPlayer: card.Owner,
  73. canTargetCondition: IsPuppetDigimon,
  74. canTargetCondition_ByPreSelecetedList: null,
  75. canEndSelectCondition: null,
  76. maxCount: maxCount,
  77. canNoSelect: true,
  78. canEndNotMax: false,
  79. isShowOpponent: true,
  80. selectCardCoroutine: SelectCardCoroutine,
  81. afterSelectCardCoroutine: null,
  82. mode: SelectHandEffect.Mode.Custom,
  83. cardEffect: activateClass);
  84. IEnumerator SelectCardCoroutine(CardSource cardSource)
  85. {
  86. selectedCard = cardSource;
  87. yield return null;
  88. }
  89. selectHandEffect.SetUpCustomMessage("Select 1 digimon to play.", "The opponent is selecting 1 digimon to play.");
  90. selectHandEffect.SetUpCustomMessage_ShowCard("Selected Card");
  91. yield return ContinuousController.instance.StartCoroutine(selectHandEffect.Activate());
  92. #endregion
  93. if (selectedCard != null) yield return ContinuousController.instance.StartCoroutine(
  94. CardEffectCommons.PlayPermanentCards(
  95. cardSources: new List<CardSource>() { selectedCard },
  96. activateClass: activateClass,
  97. payCost: false,
  98. isTapped: false,
  99. root: SelectCardEffect.Root.Hand,
  100. activateETB: true));
  101. }
  102. if (CardEffectCommons.HasMatchConditionOpponentsPermanent(card, IsOpponentDigimon))
  103. {
  104. int dpMinus = card.Owner.GetBattleAreaDigimons().Count * 3000;
  105. Permanent selectedPermament = null;
  106. #region Select Permanent
  107. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionOpponentsPermanentCount(card, IsOpponentDigimon));
  108. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  109. selectPermanentEffect.SetUp(
  110. selectPlayer: card.Owner,
  111. canTargetCondition: IsOpponentDigimon,
  112. canTargetCondition_ByPreSelecetedList: null,
  113. canEndSelectCondition: null,
  114. maxCount: maxCount,
  115. canNoSelect: false,
  116. canEndNotMax: false,
  117. selectPermanentCoroutine: SelectPermanentCoroutine,
  118. afterSelectPermanentCoroutine: null,
  119. mode: SelectPermanentEffect.Mode.Custom,
  120. cardEffect: activateClass);
  121. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  122. {
  123. selectedPermament = permanent;
  124. yield return null;
  125. }
  126. selectPermanentEffect.SetUpCustomMessage($"Select 1 Digimon to -{dpMinus} DP", $"The opponent is selecting 1 Digimon to -{dpMinus} DP");
  127. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  128. #endregion
  129. if (selectedPermament != null) yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDP(
  130. targetPermanent: selectedPermament,
  131. changeValue: -dpMinus,
  132. effectDuration: EffectDuration.UntilOpponentTurnEnd,
  133. activateClass: activateClass
  134. ));
  135. }
  136. }
  137. }
  138. #endregion
  139. #region All Turns - OPT
  140. if (timing == EffectTiming.OnDestroyedAnyone)
  141. {
  142. ActivateClass activateClass = new ActivateClass();
  143. activateClass.SetUpICardEffect("Activate a [When Digivolving] effect", CanUseCondition, card);
  144. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  145. activateClass.SetHashString("BT22_042_UseWD");
  146. activateClass.SetIsDigimonEffect(true);
  147. cardEffects.Add(activateClass);
  148. string EffectDiscription()
  149. {
  150. return "[All Turns] [Once Per Turn] When any of your other Digimon are deleted, you may activate 1 of this Digimon's [When Digivolving] effects.";
  151. }
  152. bool CanUseCondition(Hashtable hashtable)
  153. {
  154. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  155. && CardEffectCommons.CanTriggerOnPermanentDeleted(hashtable, IsOwnerDigimon, activateClass);
  156. }
  157. bool CanActivateCondition(Hashtable hashtable)
  158. {
  159. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  160. }
  161. bool IsOwnerDigimon(Permanent permanent)
  162. {
  163. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card) &&
  164. permanent != card.PermanentOfThisCard();
  165. }
  166. IEnumerator ActivateCoroutine(Hashtable hashtable)
  167. {
  168. List<ICardEffect> candidateEffects = card.PermanentOfThisCard().EffectList(EffectTiming.OnEnterFieldAnyone)
  169. .Clone()
  170. .Filter(cardEffect => cardEffect != null && cardEffect is ActivateICardEffect && !cardEffect.IsSecurityEffect && cardEffect.IsWhenDigivolving);
  171. if (candidateEffects.Count >= 1)
  172. {
  173. ICardEffect selectedEffect = null;
  174. if (candidateEffects.Count == 1)
  175. {
  176. selectedEffect = candidateEffects[0];
  177. }
  178. else
  179. {
  180. List<SkillInfo> skillInfos = candidateEffects
  181. .Map(cardEffect => new SkillInfo(cardEffect, null, EffectTiming.None));
  182. List<CardSource> cardSources = candidateEffects
  183. .Map(cardEffect => cardEffect.EffectSourceCard);
  184. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  185. selectCardEffect.SetUp(
  186. canTargetCondition: (cardSource) => true,
  187. canTargetCondition_ByPreSelecetedList: null,
  188. canEndSelectCondition: null,
  189. canNoSelect: () => false,
  190. selectCardCoroutine: null,
  191. afterSelectCardCoroutine: null,
  192. message: "Select 1 effect to activate.",
  193. maxCount: 1,
  194. canEndNotMax: false,
  195. isShowOpponent: false,
  196. mode: SelectCardEffect.Mode.Custom,
  197. root: SelectCardEffect.Root.Custom,
  198. customRootCardList: cardSources,
  199. canLookReverseCard: true,
  200. selectPlayer: card.Owner,
  201. cardEffect: activateClass);
  202. selectCardEffect.SetNotShowCard();
  203. selectCardEffect.SetUpSkillInfos(skillInfos);
  204. selectCardEffect.SetUpAfterSelectIndexCoroutine(AfterSelectIndexCoroutine);
  205. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  206. IEnumerator AfterSelectIndexCoroutine(List<int> selectedIndexes)
  207. {
  208. if (selectedIndexes.Count == 1)
  209. {
  210. selectedEffect = candidateEffects[selectedIndexes[0]];
  211. yield return null;
  212. }
  213. }
  214. }
  215. if (selectedEffect != null)
  216. {
  217. Hashtable effectHashtable = CardEffectCommons.WhenDigivolvingCheckHashtableOfCard(selectedEffect.EffectSourceCard);
  218. if (!selectedEffect.IsDisabled)
  219. {
  220. yield return ContinuousController.instance.StartCoroutine(
  221. ((ActivateICardEffect)selectedEffect).Activate_Optional_Effect_Execute(effectHashtable));
  222. }
  223. }
  224. }
  225. }
  226. }
  227. #endregion
  228. return cardEffects;
  229. }
  230. }
  231. }