ST16_11.cs 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using System.Linq;
  5. using Photon;
  6. using System;
  7. using Photon.Pun;
  8. public class ST16_11 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. if (timing == EffectTiming.None)
  14. {
  15. bool PermanentCondition(Permanent targetPermanent)
  16. {
  17. if (targetPermanent.TopCard.HasGarurumonName)
  18. {
  19. if (targetPermanent.TopCard.HasLevel)
  20. {
  21. if (targetPermanent.Level == 4)
  22. {
  23. return true;
  24. }
  25. }
  26. }
  27. return false;
  28. }
  29. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 3, ignoreDigivolutionRequirement: false, card: card, condition: null));
  30. }
  31. if (timing == EffectTiming.OnAllyAttack)
  32. {
  33. ActivateClass activateClass = new ActivateClass();
  34. activateClass.SetUpICardEffect("Trash 1 card from hand to unsuspend this Digimon", CanUseCondition, card);
  35. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  36. activateClass.SetHashString("Unsuspend_ST16_11");
  37. cardEffects.Add(activateClass);
  38. string EffectDiscription()
  39. {
  40. return "[When Attacking][Once Per Turn] By trashing 1 card in your hand, unsuspend this Digimon.";
  41. }
  42. bool CanUseCondition(Hashtable hashtable)
  43. {
  44. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  45. }
  46. bool CanActivateCondition(Hashtable hashtable)
  47. {
  48. if (CardEffectCommons.IsExistOnBattleArea(card))
  49. {
  50. if (card.Owner.HandCards.Count >= 1)
  51. {
  52. return true;
  53. }
  54. }
  55. return false;
  56. }
  57. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  58. {
  59. if (card.Owner.HandCards.Count >= 1)
  60. {
  61. bool discarded = false;
  62. int discardCount = 1;
  63. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  64. selectHandEffect.SetUp(
  65. selectPlayer: card.Owner,
  66. canTargetCondition: (cardSource) => true,
  67. canTargetCondition_ByPreSelecetedList: null,
  68. canEndSelectCondition: null,
  69. maxCount: discardCount,
  70. canNoSelect: true,
  71. canEndNotMax: false,
  72. isShowOpponent: true,
  73. selectCardCoroutine: null,
  74. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  75. mode: SelectHandEffect.Mode.Discard,
  76. cardEffect: activateClass);
  77. yield return StartCoroutine(selectHandEffect.Activate());
  78. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  79. {
  80. if (cardSources.Count >= 1)
  81. {
  82. discarded = true;
  83. yield return null;
  84. }
  85. }
  86. if (discarded)
  87. {
  88. Permanent selectedPermanent = card.PermanentOfThisCard();
  89. yield return ContinuousController.instance.StartCoroutine(new IUnsuspendPermanents(new List<Permanent>() { selectedPermanent }, activateClass).Unsuspend());
  90. }
  91. }
  92. }
  93. }
  94. if (timing == EffectTiming.OnAllyAttack)
  95. {
  96. ActivateClass activateClass = new ActivateClass();
  97. activateClass.SetUpICardEffect("Trash 1 card from hand to delete 1 level 4 or lower Digimon", CanUseCondition, card);
  98. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  99. activateClass.SetIsInheritedEffect(true);
  100. activateClass.SetHashString("Delete_ST16_11");
  101. cardEffects.Add(activateClass);
  102. string EffectDiscription()
  103. {
  104. return "[When Attacking][Once Per Turn] By trashing 1 card in your hand, delete 1 of your opponent's level 4 or lower Digimon.";
  105. }
  106. bool CanSelectPermanentCondition(Permanent permanent)
  107. {
  108. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  109. {
  110. if (permanent.Level <= 4)
  111. {
  112. if (permanent.TopCard.HasLevel)
  113. {
  114. return true;
  115. }
  116. }
  117. }
  118. return false;
  119. }
  120. bool CanUseCondition(Hashtable hashtable)
  121. {
  122. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  123. }
  124. bool CanActivateCondition(Hashtable hashtable)
  125. {
  126. if (CardEffectCommons.IsExistOnBattleArea(card))
  127. {
  128. if (card.Owner.HandCards.Count >= 1)
  129. {
  130. return true;
  131. }
  132. }
  133. return false;
  134. }
  135. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  136. {
  137. if (card.Owner.HandCards.Count >= 1)
  138. {
  139. bool discarded = false;
  140. int discardCount = 1;
  141. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  142. selectHandEffect.SetUp(
  143. selectPlayer: card.Owner,
  144. canTargetCondition: (cardSource) => true,
  145. canTargetCondition_ByPreSelecetedList: null,
  146. canEndSelectCondition: null,
  147. maxCount: discardCount,
  148. canNoSelect: true,
  149. canEndNotMax: false,
  150. isShowOpponent: true,
  151. selectCardCoroutine: null,
  152. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  153. mode: SelectHandEffect.Mode.Discard,
  154. cardEffect: activateClass);
  155. yield return StartCoroutine(selectHandEffect.Activate());
  156. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  157. {
  158. if (cardSources.Count >= 1)
  159. {
  160. discarded = true;
  161. yield return null;
  162. }
  163. }
  164. if (discarded)
  165. {
  166. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  167. {
  168. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  169. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  170. selectPermanentEffect.SetUp(
  171. selectPlayer: card.Owner,
  172. canTargetCondition: CanSelectPermanentCondition,
  173. canTargetCondition_ByPreSelecetedList: null,
  174. canEndSelectCondition: null,
  175. maxCount: maxCount,
  176. canNoSelect: false,
  177. canEndNotMax: false,
  178. selectPermanentCoroutine: null,
  179. afterSelectPermanentCoroutine: null,
  180. mode: SelectPermanentEffect.Mode.Destroy,
  181. cardEffect: activateClass);
  182. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  183. }
  184. }
  185. }
  186. }
  187. }
  188. return cardEffects;
  189. }
  190. }