BT20_066.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_066 : 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 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 level 3 Digimon. 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.Level == 3)
  31. {
  32. if (permanent.TopCard.HasLevel)
  33. {
  34. if (permanent.CanSelectBySkill(activateClass))
  35. {
  36. return true;
  37. }
  38. }
  39. }
  40. }
  41. return false;
  42. }
  43. bool CanUseCondition(Hashtable hashtable)
  44. {
  45. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  46. }
  47. bool CanActivateCondition(Hashtable hashtable)
  48. {
  49. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  50. {
  51. return true;
  52. }
  53. return false;
  54. }
  55. bool CanSelectCardCondition(CardSource cardSource)
  56. {
  57. if (cardSource != null)
  58. {
  59. if (cardSource.IsDigimon)
  60. {
  61. if (cardSource.Owner == card.Owner)
  62. {
  63. if(cardSource.CardTraits.Contains("Free") || cardSource.ContainsCardName("Imperialdramon"))
  64. {
  65. if (cardSource.CanPlayJogress(true))
  66. {
  67. return true;
  68. }
  69. }
  70. }
  71. }
  72. }
  73. return false;
  74. }
  75. IEnumerator ActivateCoroutine(Hashtable hashtable)
  76. {
  77. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  78. {
  79. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  80. int maxCount = 1;
  81. selectPermanentEffect.SetUp(
  82. selectPlayer: card.Owner,
  83. canTargetCondition: CanSelectPermanentCondition,
  84. canTargetCondition_ByPreSelecetedList: null,
  85. canEndSelectCondition: null,
  86. maxCount: maxCount,
  87. canNoSelect: false,
  88. canEndNotMax: false,
  89. selectPermanentCoroutine: null,
  90. afterSelectPermanentCoroutine: null,
  91. mode: SelectPermanentEffect.Mode.Destroy,
  92. cardEffect: activateClass);
  93. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  94. }
  95. if (CardEffectCommons.IsOwnerTurn(card))
  96. {
  97. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(card.PermanentOfThisCard(), card))
  98. {
  99. yield return ContinuousController.instance.StartCoroutine(
  100. CardEffectCommons.DNADigivolvePermanentsIntoHandOrTrashCard(
  101. CanSelectCardCondition,
  102. payCost: true,
  103. isHand: true,
  104. activateClass
  105. ));
  106. }
  107. }
  108. }
  109. }
  110. #endregion
  111. #region When Digivolving
  112. if (timing == EffectTiming.OnEnterFieldAnyone)
  113. {
  114. ActivateClass activateClass = new ActivateClass();
  115. activateClass.SetUpICardEffect("Delete digimon and digivolve into ImperialDramon", CanUseCondition, card);
  116. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  117. cardEffects.Add(activateClass);
  118. string EffectDiscription()
  119. {
  120. return "[When Digivolving] Delete 1 of your opponent's level 3 Digimon. 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.";
  121. }
  122. bool CanSelectPermanentCondition(Permanent permanent)
  123. {
  124. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  125. {
  126. if (permanent.Level == 3)
  127. {
  128. if (permanent.TopCard.HasLevel)
  129. {
  130. if (permanent.CanSelectBySkill(activateClass))
  131. {
  132. return true;
  133. }
  134. }
  135. }
  136. }
  137. return false;
  138. }
  139. bool CanUseCondition(Hashtable hashtable)
  140. {
  141. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  142. }
  143. bool CanActivateCondition(Hashtable hashtable)
  144. {
  145. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  146. {
  147. return true;
  148. }
  149. return false;
  150. }
  151. bool CanSelectCardCondition(CardSource cardSource)
  152. {
  153. if (cardSource != null)
  154. {
  155. if (cardSource.IsDigimon)
  156. {
  157. if (cardSource.Owner == card.Owner)
  158. {
  159. if(cardSource.CardTraits.Contains("Free") || cardSource.ContainsCardName("Imperialdramon"))
  160. {
  161. if (cardSource.CanPlayJogress(true))
  162. {
  163. return true;
  164. }
  165. }
  166. }
  167. }
  168. }
  169. return false;
  170. }
  171. IEnumerator ActivateCoroutine(Hashtable hashtable)
  172. {
  173. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  174. {
  175. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  176. int maxCount = 1;
  177. selectPermanentEffect.SetUp(
  178. selectPlayer: card.Owner,
  179. canTargetCondition: CanSelectPermanentCondition,
  180. canTargetCondition_ByPreSelecetedList: null,
  181. canEndSelectCondition: null,
  182. maxCount: maxCount,
  183. canNoSelect: false,
  184. canEndNotMax: false,
  185. selectPermanentCoroutine: null,
  186. afterSelectPermanentCoroutine: null,
  187. mode: SelectPermanentEffect.Mode.Destroy,
  188. cardEffect: activateClass);
  189. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  190. }
  191. if (CardEffectCommons.IsOwnerTurn(card))
  192. {
  193. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(card.PermanentOfThisCard(), card))
  194. {
  195. yield return ContinuousController.instance.StartCoroutine(
  196. CardEffectCommons.DNADigivolvePermanentsIntoHandOrTrashCard(
  197. CanSelectCardCondition,
  198. payCost: true,
  199. isHand: true,
  200. activateClass
  201. ));
  202. }
  203. }
  204. }
  205. }
  206. #endregion
  207. #region InheritedEffects
  208. if (timing == EffectTiming.OnDestroyedAnyone)
  209. {
  210. cardEffects.Add(CardEffectFactory.RetaliationSelfEffect(isInheritedEffect: true, card: card, condition: null));
  211. }
  212. #endregion
  213. return cardEffects;
  214. }
  215. }
  216. }