BT9_078.cs 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  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 BT9_078 : 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.CardNames.Contains("DoruGreymon");
  18. }
  19. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 1, ignoreDigivolutionRequirement: false, card: card, condition: null));
  20. }
  21. if (timing == EffectTiming.OnEnterFieldAnyone)
  22. {
  23. ActivateClass activateClass = new ActivateClass();
  24. activateClass.SetUpICardEffect("Trash 1 card from hand to gain Memory +1", CanUseCondition, card);
  25. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  26. cardEffects.Add(activateClass);
  27. string EffectDiscription()
  28. {
  29. return "[When Digivolving] You may trash 1 card with [Dex] or [DeathX] in its name or [X Antibody] in its traits in your hand to gain 1 memory.";
  30. }
  31. bool CanSelectCardCondition(CardSource cardSource)
  32. {
  33. if (cardSource != null)
  34. {
  35. if (cardSource.Owner == card.Owner)
  36. {
  37. if (cardSource.ContainsCardName("Dex"))
  38. {
  39. return true;
  40. }
  41. if (cardSource.ContainsCardName("DeathX"))
  42. {
  43. return true;
  44. }
  45. if (cardSource.HasXAntibodyTraits)
  46. {
  47. return true;
  48. }
  49. }
  50. }
  51. return false;
  52. }
  53. bool CanUseCondition(Hashtable hashtable)
  54. {
  55. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  56. }
  57. bool CanActivateCondition(Hashtable hashtable)
  58. {
  59. if (CardEffectCommons.IsExistOnBattleArea(card))
  60. {
  61. if (card.Owner.HandCards.Count >= 1)
  62. {
  63. return true;
  64. }
  65. }
  66. return false;
  67. }
  68. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  69. {
  70. if (isExistOnField(card))
  71. {
  72. if (card.Owner.GetBattleAreaDigimons().Contains(card.PermanentOfThisCard()))
  73. {
  74. if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  75. {
  76. bool discarded = false;
  77. int discardCount = 1;
  78. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  79. selectHandEffect.SetUp(
  80. selectPlayer: card.Owner,
  81. canTargetCondition: CanSelectCardCondition,
  82. canTargetCondition_ByPreSelecetedList: null,
  83. canEndSelectCondition: null,
  84. maxCount: discardCount,
  85. canNoSelect: true,
  86. canEndNotMax: false,
  87. isShowOpponent: true,
  88. selectCardCoroutine: null,
  89. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  90. mode: SelectHandEffect.Mode.Discard,
  91. cardEffect: activateClass);
  92. yield return StartCoroutine(selectHandEffect.Activate());
  93. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  94. {
  95. if (cardSources.Count >= 1)
  96. {
  97. discarded = true;
  98. yield return null;
  99. }
  100. }
  101. if (discarded)
  102. {
  103. yield return ContinuousController.instance.StartCoroutine(card.Owner.AddMemory(1, activateClass));
  104. }
  105. }
  106. }
  107. }
  108. }
  109. }
  110. if (timing == EffectTiming.OnEnterFieldAnyone)
  111. {
  112. ActivateClass activateClass = new ActivateClass();
  113. activateClass.SetUpICardEffect("Delete 1 level 4 or lower Digimon", CanUseCondition, card);
  114. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  115. cardEffects.Add(activateClass);
  116. string EffectDiscription()
  117. {
  118. return "[When Digivolving] If this Digimon has [DoruGreymon] in its digivolution cards or is digivolving from the trash, delete 1 of your opponent's level 4 or lower Digimon.";
  119. }
  120. bool CanSelectPermanentCondition(Permanent permanent)
  121. {
  122. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  123. {
  124. if (permanent.Level <= 4)
  125. {
  126. if (permanent.TopCard.HasLevel)
  127. {
  128. return true;
  129. }
  130. }
  131. }
  132. return false;
  133. }
  134. bool RootCondition(SelectCardEffect.Root root)
  135. {
  136. return root == SelectCardEffect.Root.Trash;
  137. }
  138. bool CanUseCondition(Hashtable hashtable)
  139. {
  140. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  141. }
  142. bool CanActivateCondition(Hashtable hashtable)
  143. {
  144. if (CardEffectCommons.IsExistOnBattleArea(card))
  145. {
  146. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  147. {
  148. if (card.PermanentOfThisCard().DigivolutionCards.Count((cardSource) => cardSource.CardNames.Contains("DoruGreymon")) >= 1)
  149. {
  150. return true;
  151. }
  152. if (CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card, RootCondition))
  153. {
  154. return true;
  155. }
  156. }
  157. }
  158. return false;
  159. }
  160. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  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. return cardEffects;
  183. }
  184. }