BT7_078.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  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 BT7_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.OnEnterFieldAnyone)
  14. {
  15. ActivateClass activateClass = new ActivateClass();
  16. activateClass.SetUpICardEffect("Delete Digimon", CanUseCondition, card);
  17. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  18. cardEffects.Add(activateClass);
  19. string EffectDiscription()
  20. {
  21. return "[When Digivolving] You may delete 1 of your Digimon with [Ten Warriors] or [Hybrid] in its traits to delete 1 of your opponent's Digimon whose level is less than or equal to the deleted Digimon's level.";
  22. }
  23. bool CanSelectPermanentCondition(Permanent permanent)
  24. {
  25. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  26. {
  27. if (permanent.TopCard.CardTraits.Contains("Ten Warriors"))
  28. {
  29. return true;
  30. }
  31. if (permanent.TopCard.CardTraits.Contains("TenWarriors"))
  32. {
  33. return true;
  34. }
  35. if (permanent.TopCard.CardTraits.Contains("Hybrid"))
  36. {
  37. return true;
  38. }
  39. }
  40. return false;
  41. }
  42. bool CanUseCondition(Hashtable hashtable)
  43. {
  44. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  45. }
  46. bool CanActivateCondition(Hashtable hashtable)
  47. {
  48. if (CardEffectCommons.IsExistOnBattleArea(card))
  49. {
  50. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  51. {
  52. return true;
  53. }
  54. }
  55. return false;
  56. }
  57. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  58. {
  59. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  60. {
  61. Permanent deleteTargetPermanent = null;
  62. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  63. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  64. selectPermanentEffect.SetUp(
  65. selectPlayer: card.Owner,
  66. canTargetCondition: CanSelectPermanentCondition,
  67. canTargetCondition_ByPreSelecetedList: null,
  68. canEndSelectCondition: null,
  69. maxCount: maxCount,
  70. canNoSelect: true,
  71. canEndNotMax: false,
  72. selectPermanentCoroutine: SelectPermanentCoroutine,
  73. afterSelectPermanentCoroutine: null,
  74. mode: SelectPermanentEffect.Mode.Custom,
  75. cardEffect: activateClass);
  76. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to delete.", "The opponent is selecting 1 Digimon to delete.");
  77. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  78. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  79. {
  80. deleteTargetPermanent = permanent;
  81. yield return null;
  82. }
  83. if (deleteTargetPermanent != null)
  84. {
  85. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DeletePeremanentAndProcessAccordingToResult(
  86. targetPermanents: new List<Permanent>() { deleteTargetPermanent },
  87. activateClass: activateClass,
  88. successProcess: permanents => SuccessProcess(),
  89. failureProcess: null));
  90. IEnumerator SuccessProcess()
  91. {
  92. bool CanSelectPermanentCondition1(Permanent permanent)
  93. {
  94. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  95. {
  96. if (deleteTargetPermanent.LevelJustBeforeRemoveField > 0)
  97. {
  98. if (permanent.Level <= deleteTargetPermanent.LevelJustBeforeRemoveField)
  99. {
  100. if (permanent.TopCard.HasLevel)
  101. {
  102. return true;
  103. }
  104. }
  105. }
  106. }
  107. return false;
  108. }
  109. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition1))
  110. {
  111. maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition1));
  112. selectPermanentEffect.SetUp(
  113. selectPlayer: card.Owner,
  114. canTargetCondition: CanSelectPermanentCondition1,
  115. canTargetCondition_ByPreSelecetedList: null,
  116. canEndSelectCondition: null,
  117. maxCount: maxCount,
  118. canNoSelect: false,
  119. canEndNotMax: false,
  120. selectPermanentCoroutine: null,
  121. afterSelectPermanentCoroutine: null,
  122. mode: SelectPermanentEffect.Mode.Destroy,
  123. cardEffect: activateClass);
  124. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  125. }
  126. }
  127. }
  128. }
  129. }
  130. }
  131. if (timing == EffectTiming.OnDestroyedAnyone)
  132. {
  133. ActivateClass activateClass = new ActivateClass();
  134. activateClass.SetUpICardEffect("Play 1 Digimon from hand", CanUseCondition, card);
  135. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  136. cardEffects.Add(activateClass);
  137. string EffectDiscription()
  138. {
  139. return "[On Deletion] You may play 1 purple level 4 or lower Digimon card with [Hybrid] in its form from your hand without paying its memory cost.";
  140. }
  141. bool CanSelectCardCondition(CardSource cardSource)
  142. {
  143. if (cardSource.IsDigimon)
  144. {
  145. if (cardSource.HasCardColor(CardColor.Purple))
  146. {
  147. if (cardSource.Level <= 4)
  148. {
  149. if (cardSource.CardTraits.Contains("Hybrid"))
  150. {
  151. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  152. {
  153. if (cardSource.HasLevel)
  154. {
  155. return true;
  156. }
  157. }
  158. }
  159. }
  160. }
  161. }
  162. return false;
  163. }
  164. bool CanUseCondition(Hashtable hashtable)
  165. {
  166. return CardEffectCommons.CanTriggerOnDeletion(hashtable, card, activateClass);
  167. }
  168. bool CanActivateCondition(Hashtable hashtable)
  169. {
  170. if (CardEffectCommons.CanActivateOnDeletion(card, activateClass))
  171. {
  172. if (card.Owner.HandCards.Count >= 1)
  173. {
  174. return true;
  175. }
  176. }
  177. return false;
  178. }
  179. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  180. {
  181. if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  182. {
  183. List<CardSource> selectedCards = new List<CardSource>();
  184. int maxCount = 1;
  185. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  186. selectHandEffect.SetUp(
  187. selectPlayer: card.Owner,
  188. canTargetCondition: CanSelectCardCondition,
  189. canTargetCondition_ByPreSelecetedList: null,
  190. canEndSelectCondition: null,
  191. maxCount: maxCount,
  192. canNoSelect: true,
  193. canEndNotMax: false,
  194. isShowOpponent: true,
  195. selectCardCoroutine: SelectCardCoroutine,
  196. afterSelectCardCoroutine: null,
  197. mode: SelectHandEffect.Mode.Custom,
  198. cardEffect: activateClass);
  199. selectHandEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  200. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  201. yield return StartCoroutine(selectHandEffect.Activate());
  202. IEnumerator SelectCardCoroutine(CardSource cardSource)
  203. {
  204. selectedCards.Add(cardSource);
  205. yield return null;
  206. }
  207. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(cardSources: selectedCards, activateClass: activateClass, payCost: false, isTapped: false, root: SelectCardEffect.Root.Hand, activateETB: true));
  208. }
  209. }
  210. }
  211. return cardEffects;
  212. }
  213. }