P_192.cs 9.2 KB

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