ST16_12.cs 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  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_12 : 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. return targetPermanent.TopCard.HasGarurumonName && targetPermanent.TopCard.HasLevel && targetPermanent.TopCard.Level == 5;
  18. }
  19. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 3, ignoreDigivolutionRequirement: false, card: card, condition: null));
  20. }
  21. if (timing == EffectTiming.OnCounterTiming)
  22. {
  23. cardEffects.Add(CardEffectFactory.BlastDigivolveEffect(card: card, condition: null));
  24. }
  25. if (timing == EffectTiming.OnEnterFieldAnyone)
  26. {
  27. ActivateClass activateClass = new ActivateClass();
  28. activateClass.SetUpICardEffect("Trash cards from hand to gain Memory", CanUseCondition, card);
  29. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  30. cardEffects.Add(activateClass);
  31. string EffectDiscription()
  32. {
  33. return "[When Digivolving] By trashing up to 3 cards in your hand, gain 1 memory for each card trashed.";
  34. }
  35. bool CanUseCondition(Hashtable hashtable)
  36. {
  37. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  38. }
  39. bool CanActivateCondition(Hashtable hashtable)
  40. {
  41. if (CardEffectCommons.IsExistOnBattleArea(card))
  42. {
  43. if (card.Owner.HandCards.Count >= 1)
  44. {
  45. return true;
  46. }
  47. }
  48. return false;
  49. }
  50. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  51. {
  52. if (card.Owner.HandCards.Count >= 1)
  53. {
  54. int discardedCount = 0;
  55. int discardCount = Math.Min(3, card.Owner.HandCards.Count);
  56. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  57. selectHandEffect.SetUp(
  58. selectPlayer: card.Owner,
  59. canTargetCondition: (cardSource) => true,
  60. canTargetCondition_ByPreSelecetedList: null,
  61. canEndSelectCondition: CanEndSelectCondition,
  62. maxCount: discardCount,
  63. canNoSelect: true,
  64. canEndNotMax: true,
  65. isShowOpponent: true,
  66. selectCardCoroutine: null,
  67. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  68. mode: SelectHandEffect.Mode.Discard,
  69. cardEffect: activateClass);
  70. yield return StartCoroutine(selectHandEffect.Activate());
  71. bool CanEndSelectCondition(List<CardSource> cardSources)
  72. {
  73. if (CardEffectCommons.HasNoElement(cardSources))
  74. {
  75. return false;
  76. }
  77. return true;
  78. }
  79. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  80. {
  81. if (cardSources.Count >= 1)
  82. {
  83. discardedCount = cardSources.Count;
  84. yield return null;
  85. }
  86. }
  87. if (discardedCount >= 1)
  88. {
  89. yield return ContinuousController.instance.StartCoroutine(card.Owner.AddMemory(discardedCount, activateClass));
  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 Digimon with the lowest level", CanUseCondition, card);
  98. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  99. activateClass.SetHashString("Delete_ST16_12");
  100. cardEffects.Add(activateClass);
  101. string EffectDiscription()
  102. {
  103. return "[When Attacking][Once Per Turn] By trashing 1 card in your hand, delete 1 of your opponent's Digimon with the lowest level.";
  104. }
  105. bool CanSelectPermanentCondition(Permanent permanent)
  106. {
  107. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  108. {
  109. if (CardEffectCommons.IsMinLevel(permanent, card.Owner.Enemy))
  110. {
  111. return true;
  112. }
  113. }
  114. return false;
  115. }
  116. bool CanUseCondition(Hashtable hashtable)
  117. {
  118. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  119. }
  120. bool CanActivateCondition(Hashtable hashtable)
  121. {
  122. if (CardEffectCommons.IsExistOnBattleArea(card))
  123. {
  124. if (card.Owner.HandCards.Count >= 1)
  125. {
  126. return true;
  127. }
  128. }
  129. return false;
  130. }
  131. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  132. {
  133. if (card.Owner.HandCards.Count >= 1)
  134. {
  135. bool discarded = false;
  136. int discardCount = 1;
  137. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  138. selectHandEffect.SetUp(
  139. selectPlayer: card.Owner,
  140. canTargetCondition: (cardSource) => true,
  141. canTargetCondition_ByPreSelecetedList: null,
  142. canEndSelectCondition: null,
  143. maxCount: discardCount,
  144. canNoSelect: true,
  145. canEndNotMax: false,
  146. isShowOpponent: true,
  147. selectCardCoroutine: null,
  148. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  149. mode: SelectHandEffect.Mode.Discard,
  150. cardEffect: activateClass);
  151. yield return StartCoroutine(selectHandEffect.Activate());
  152. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  153. {
  154. if (cardSources.Count >= 1)
  155. {
  156. discarded = true;
  157. yield return null;
  158. }
  159. }
  160. if (discarded)
  161. {
  162. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  163. {
  164. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  165. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  166. selectPermanentEffect.SetUp(
  167. selectPlayer: card.Owner,
  168. canTargetCondition: CanSelectPermanentCondition,
  169. canTargetCondition_ByPreSelecetedList: null,
  170. canEndSelectCondition: null,
  171. maxCount: maxCount,
  172. canNoSelect: false,
  173. canEndNotMax: false,
  174. selectPermanentCoroutine: null,
  175. afterSelectPermanentCoroutine: null,
  176. mode: SelectPermanentEffect.Mode.Destroy,
  177. cardEffect: activateClass);
  178. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  179. }
  180. }
  181. }
  182. }
  183. }
  184. return cardEffects;
  185. }
  186. }