BT24_075.cs 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System;
  4. // SkullBaluchimon
  5. namespace DCGO.CardEffects.BT24
  6. {
  7. public class BT24_075 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Alt Digivolution Condition
  13. if (timing == EffectTiming.None)
  14. {
  15. static bool PermanentCondition(Permanent targetPermanent)
  16. {
  17. return targetPermanent.TopCard.IsLevel4
  18. && (targetPermanent.TopCard.EqualsTraits("Demon")
  19. || targetPermanent.TopCard.HasTSTraits);
  20. }
  21. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 3, ignoreDigivolutionRequirement: false, card: card, condition: null));
  22. }
  23. #endregion
  24. #region Shared OP/WD
  25. string SharedEffectName() => "By trashing 1, delete 1 each of opponent's lvl 3 and 4";
  26. string SharedEffectDescription(string tag) => $"[{tag}] By trashing 1 card in your hand, delete 1 each of your opponent's level 3 and level 4 Digimon.";
  27. bool SharedCanActivateCondition(Hashtable hashtable)
  28. {
  29. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  30. && card.Owner.HandCards.Count >= 1;
  31. }
  32. bool CanSelectLevel3Condition(Permanent permanent)
  33. {
  34. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card)
  35. && permanent.TopCard.IsLevel3;
  36. }
  37. bool CanSelectLevel4Condition(Permanent permanent)
  38. {
  39. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card)
  40. && permanent.TopCard.IsLevel4;
  41. }
  42. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  43. {
  44. bool discarded = false;
  45. int discardCount = 1;
  46. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  47. selectHandEffect.SetUp(
  48. selectPlayer: card.Owner,
  49. canTargetCondition: (cardSource) => true,
  50. canTargetCondition_ByPreSelecetedList: null,
  51. canEndSelectCondition: null,
  52. maxCount: discardCount,
  53. canNoSelect: true,
  54. canEndNotMax: false,
  55. isShowOpponent: true,
  56. selectCardCoroutine: null,
  57. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  58. mode: SelectHandEffect.Mode.Discard,
  59. cardEffect: activateClass);
  60. selectHandEffect.SetUpCustomMessage("Select 1 Card to trash.", "The opponent is selecting 1 card to trash from their hand.");
  61. yield return StartCoroutine(selectHandEffect.Activate());
  62. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  63. {
  64. if (cardSources.Count >= 1)
  65. {
  66. discarded = true;
  67. yield return null;
  68. }
  69. }
  70. if (discarded)
  71. {
  72. List<Permanent> selectedPermanents = new List<Permanent>();
  73. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectLevel3Condition))
  74. {
  75. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectLevel3Condition));
  76. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  77. selectPermanentEffect.SetUp(
  78. selectPlayer: card.Owner,
  79. canTargetCondition: CanSelectLevel3Condition,
  80. canTargetCondition_ByPreSelecetedList: null,
  81. canEndSelectCondition: null,
  82. maxCount: maxCount,
  83. canNoSelect: false,
  84. canEndNotMax: false,
  85. selectPermanentCoroutine: SelectDeletionCoroutine,
  86. afterSelectPermanentCoroutine: null,
  87. mode: SelectPermanentEffect.Mode.Custom,
  88. cardEffect: activateClass);
  89. selectPermanentEffect.SetUpCustomMessage("Select 1 level 3 Digimon to delete.", "The opponent is selecting 1 level 3 Digimon to delete.");
  90. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  91. }
  92. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectLevel4Condition))
  93. {
  94. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectLevel4Condition));
  95. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  96. selectPermanentEffect.SetUp(
  97. selectPlayer: card.Owner,
  98. canTargetCondition: CanSelectLevel4Condition,
  99. canTargetCondition_ByPreSelecetedList: null,
  100. canEndSelectCondition: null,
  101. maxCount: maxCount,
  102. canNoSelect: false,
  103. canEndNotMax: false,
  104. selectPermanentCoroutine: SelectDeletionCoroutine,
  105. afterSelectPermanentCoroutine: null,
  106. mode: SelectPermanentEffect.Mode.Custom,
  107. cardEffect: activateClass);
  108. selectPermanentEffect.SetUpCustomMessage("Select 1 level 4 Digimon to delete.", "The opponent is selecting 1 level 4 Digimon to delete.");
  109. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  110. }
  111. IEnumerator SelectDeletionCoroutine(Permanent permanent)
  112. {
  113. selectedPermanents.Add(permanent);
  114. yield return null;
  115. }
  116. yield return ContinuousController.instance.StartCoroutine(new DestroyPermanentsClass(
  117. selectedPermanents,
  118. CardEffectCommons.CardEffectHashtable(activateClass)).Destroy());
  119. }
  120. }
  121. #endregion
  122. #region On Play
  123. if (timing == EffectTiming.OnEnterFieldAnyone)
  124. {
  125. ActivateClass activateClass = new ActivateClass();
  126. activateClass.SetUpICardEffect(SharedEffectName(), CanUseCondition, card);
  127. activateClass.SetUpActivateClass(SharedCanActivateCondition, hash => SharedActivateCoroutine(hash, activateClass), -1, true, SharedEffectDescription("On Play"));
  128. cardEffects.Add(activateClass);
  129. bool CanUseCondition(Hashtable hashtable)
  130. {
  131. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  132. && CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  133. }
  134. }
  135. #endregion
  136. #region When Digivolving
  137. if (timing == EffectTiming.OnEnterFieldAnyone)
  138. {
  139. ActivateClass activateClass = new ActivateClass();
  140. activateClass.SetUpICardEffect(SharedEffectName(), CanUseCondition, card);
  141. activateClass.SetUpActivateClass(SharedCanActivateCondition, hash => SharedActivateCoroutine(hash, activateClass), -1, true, SharedEffectDescription("When Digivolving"));
  142. cardEffects.Add(activateClass);
  143. bool CanUseCondition(Hashtable hashtable)
  144. {
  145. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  146. && CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  147. }
  148. }
  149. #endregion
  150. #region Inherited
  151. if (timing == EffectTiming.None)
  152. {
  153. bool Condition()
  154. {
  155. return CardEffectCommons.IsExistOnBattleArea(card)
  156. && CardEffectCommons.IsOwnerTurn(card)
  157. && (card.PermanentOfThisCard().TopCard.EqualsCardName("Titamon")
  158. || card.PermanentOfThisCard().TopCard.EqualsTraits("Titan"));
  159. }
  160. cardEffects.Add(CardEffectFactory.ChangeSelfSAttackStaticEffect(changeValue: 1, isInheritedEffect: true, card: card, condition: Condition));
  161. }
  162. #endregion
  163. return cardEffects;
  164. }
  165. }
  166. }