BT20_011.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  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. namespace DCGO.CardEffects.BT20
  9. {
  10. public class BT20_011 : CEntity_Effect
  11. {
  12. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  13. {
  14. List<ICardEffect> cardEffects = new List<ICardEffect>();
  15. #region On Play
  16. if (timing == EffectTiming.OnEnterFieldAnyone)
  17. {
  18. ActivateClass activateClass = new ActivateClass();
  19. activateClass.SetUpICardEffect("Delete digimon with 3000DP or less, and digivolve into ImperialDramon", CanUseCondition, card);
  20. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  21. cardEffects.Add(activateClass);
  22. string EffectDiscription()
  23. {
  24. return "[On Play] Delete 1 of your opponent's Digimon with 3000 DP or less. Then, if it's your turn, 2 of your Digimon may DNA digivolve into a Digimon card with [Imperialdramon] in its name or the [Free] trait in the hand.";
  25. }
  26. bool CanSelectPermanentCondition(Permanent permanent)
  27. {
  28. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  29. {
  30. if (permanent.DP <= card.Owner.MaxDP_DeleteEffect(3000, activateClass))
  31. {
  32. return true;
  33. }
  34. }
  35. return false;
  36. }
  37. bool CanUseCondition(Hashtable hashtable)
  38. {
  39. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  40. }
  41. bool CanActivateCondition(Hashtable hashtable)
  42. {
  43. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  44. {
  45. return true;
  46. }
  47. return false;
  48. }
  49. bool CanSelectCardCondition(CardSource cardSource)
  50. {
  51. if (cardSource != null)
  52. {
  53. if (cardSource.IsDigimon)
  54. {
  55. if (cardSource.Owner == card.Owner)
  56. {
  57. if (cardSource.CardTraits.Contains("Free") || cardSource.ContainsCardName("Imperialdramon"))
  58. {
  59. if (cardSource.CanPlayJogress(true))
  60. {
  61. return true;
  62. }
  63. }
  64. }
  65. }
  66. }
  67. return false;
  68. }
  69. IEnumerator ActivateCoroutine(Hashtable hashtable)
  70. {
  71. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  72. {
  73. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  74. int maxCount = 1;
  75. selectPermanentEffect.SetUp(
  76. selectPlayer: card.Owner,
  77. canTargetCondition: CanSelectPermanentCondition,
  78. canTargetCondition_ByPreSelecetedList: null,
  79. canEndSelectCondition: null,
  80. maxCount: maxCount,
  81. canNoSelect: false,
  82. canEndNotMax: false,
  83. selectPermanentCoroutine: null,
  84. afterSelectPermanentCoroutine: null,
  85. mode: SelectPermanentEffect.Mode.Destroy,
  86. cardEffect: activateClass);
  87. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  88. }
  89. if (CardEffectCommons.IsOwnerTurn(card))
  90. {
  91. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(card.PermanentOfThisCard(), card))
  92. {
  93. yield return ContinuousController.instance.StartCoroutine(
  94. CardEffectCommons.DNADigivolvePermanentsIntoHandOrTrashCard(
  95. CanSelectCardCondition,
  96. payCost: true,
  97. isHand: true,
  98. activateClass
  99. ));
  100. }
  101. }
  102. }
  103. }
  104. #endregion
  105. #region When Digivolving
  106. if (timing == EffectTiming.OnEnterFieldAnyone)
  107. {
  108. ActivateClass activateClass = new ActivateClass();
  109. activateClass.SetUpICardEffect("Delete digimon with 3000DP or less, and digivolve into ImperialDramon", CanUseCondition, card);
  110. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  111. cardEffects.Add(activateClass);
  112. string EffectDiscription()
  113. {
  114. return "[When Digivolving] Delete 1 of your opponent's Digimon with 3000 DP or less. Then, if it's your turn, 2 of your Digimon may DNA digivolve into a Digimon card with [Imperialdramon] in its name or the [Free] trait in the hand.";
  115. }
  116. bool CanSelectPermanentCondition(Permanent permanent)
  117. {
  118. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  119. {
  120. if (permanent.DP <= card.Owner.MaxDP_DeleteEffect(3000, activateClass))
  121. {
  122. return true;
  123. }
  124. }
  125. return false;
  126. }
  127. bool CanUseCondition(Hashtable hashtable)
  128. {
  129. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  130. CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  131. }
  132. bool CanActivateCondition(Hashtable hashtable)
  133. {
  134. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  135. }
  136. bool CanSelectCardCondition(CardSource cardSource)
  137. {
  138. if (cardSource != null)
  139. {
  140. if (cardSource.IsDigimon)
  141. {
  142. if (cardSource.Owner == card.Owner)
  143. {
  144. if(cardSource.CardTraits.Contains("Free") || cardSource.ContainsCardName("Imperialdramon"))
  145. {
  146. if (cardSource.CanPlayJogress(true))
  147. {
  148. if (isExistOnField(card))
  149. {
  150. if (cardSource.CanJogressFromTargetPermanent(card.PermanentOfThisCard(), true))
  151. {
  152. return true;
  153. }
  154. }
  155. }
  156. }
  157. }
  158. }
  159. }
  160. return false;
  161. }
  162. IEnumerator ActivateCoroutine(Hashtable hashtable)
  163. {
  164. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  165. {
  166. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  167. int maxCount = 1;
  168. selectPermanentEffect.SetUp(
  169. selectPlayer: card.Owner,
  170. canTargetCondition: CanSelectPermanentCondition,
  171. canTargetCondition_ByPreSelecetedList: null,
  172. canEndSelectCondition: null,
  173. maxCount: maxCount,
  174. canNoSelect: false,
  175. canEndNotMax: false,
  176. selectPermanentCoroutine: null,
  177. afterSelectPermanentCoroutine: null,
  178. mode: SelectPermanentEffect.Mode.Destroy,
  179. cardEffect: activateClass);
  180. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  181. }
  182. if (CardEffectCommons.IsOwnerTurn(card))
  183. {
  184. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(card.PermanentOfThisCard(), card))
  185. {
  186. yield return ContinuousController.instance.StartCoroutine(
  187. CardEffectCommons.DNADigivolvePermanentsIntoHandOrTrashCard(
  188. CanSelectCardCondition,
  189. payCost: true,
  190. isHand: true,
  191. activateClass
  192. ));
  193. }
  194. }
  195. }
  196. }
  197. #endregion
  198. #region Inherited Effect
  199. if (timing == EffectTiming.None)
  200. {
  201. bool InheritedEffectCondition()
  202. {
  203. return CardEffectCommons.IsOwnerTurn(card);
  204. }
  205. cardEffects.Add(CardEffectFactory.ChangeSelfDPStaticEffect(
  206. changeValue: 2000,
  207. isInheritedEffect: true,
  208. card: card,
  209. condition: InheritedEffectCondition));
  210. }
  211. #endregion
  212. return cardEffects;
  213. }
  214. }
  215. }